SparseArray package not available in Julia 1.1.0?

I am unable to install the SparseArray package in Julia 1.1.0 . I am getting the following error message. This is a very basic package needed in any application that deals with large data.

julia> import Pkg; Pkg.add(“SparseArray”)

Updating registry at ~/.julia/registries/General
Updating git-repo https://github.com/JuliaRegistries/General.git
ERROR: The following package names could not be resolved:

  • SparseArray (not found in project, manifest or registry)
    Please specify by known name=uuid.
    Stacktrace:
    [1] pkgerror(::String) at /sware/build/Building/julia/usr/share/julia/stdlib/v1.1/Pkg/src/Types.jl:120
    [2] #ensure_resolved#72(::Bool, ::Function, ::Pkg.Types.EnvCache, ::Array{Pkg.Types.PackageSpec,1}) at /sware/build/Building/julia/usr/share/julia/stdlib/v1.1/Pkg/src/Types.jl:1010
    [3] #ensure_resolved at ./none:0 [inlined]
    [4] #add_or_develop#15(::Symbol, ::Bool, ::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::Pkg.Types.Context, ::Array{Pkg.Types.PackageSpec,1}) at /sware/build/Building/julia/usr/share/julia/stdlib/v1.1/Pkg/src/API.jl:49
    [5] #add_or_develop at ./none:0 [inlined]
    [6] #add_or_develop#14 at /sware/build/Building/julia/usr/share/julia/stdlib/v1.1/Pkg/src/API.jl:31 [inlined]
    [7] #add_or_develop at ./none:0 [inlined]
    [8] #add_or_develop#13 at /sware/build/Building/julia/usr/share/julia/stdlib/v1.1/Pkg/src/API.jl:29 [inlined]
    [9] #add_or_develop at ./none:0 [inlined]
    [10] #add_or_develop#12(::Base.Iterators.Pairs{Symbol,Symbol,Tuple{Symbol},NamedTuple{(:mode,),Tuple{Symbol}}}, ::Function, ::String) at /sware/build/Building/julia/usr/share/julia/stdlib/v1.1/Pkg/src/API.jl:28
    [11] #add_or_develop at ./none:0 [inlined]
    [12] #add#20 at /sware/build/Building/julia/usr/share/julia/stdlib/v1.1/Pkg/src/API.jl:59 [inlined]
    [13] add(::String) at /sware/build/Building/julia/usr/share/julia/stdlib/v1.1/Pkg/src/API.jl:59
    [14] top-level scope at none:0

It is SparseArrays.

3 Likes

Thanks, noted

Thanks. I installed that package, but the command speye() does not seem to be working.

using SparseArrays; x = speye(4)

ERROR: UndefVarError: speye not defined
Stacktrace:
[1] top-level scope at none:0

Because it has been deprecated.

I assume that you are working from some outdated script/docs. At this point you may benefit from

  1. reading the fine manual,
  2. looking at the deprecations (or, optionally, using 0.7 for the transition)
3 Likes

Thanks again. For new users like me, it is really difficult to track depreciations in new versions. But I guess many features of Julia are still in development.

For the moment, spzeros(n,n) is working fine for me.

FWIW, Julia 1.0 was the first stable version, and allowing changes to the API was implicit in the 0.* versioning. Now in 1.x there should be very few breaking changes.

1 Like

Hi

using SparseArrays; x = speye(4)
ERROR: UndefVarError: speye not defined
Stacktrace:
[1] top-level scope at none:0

I am sure that I have installed SparseArrays in Julia 1.1.0

Please read the discussion above; speye was deprecated.

I highly recommend following @Tamas_Papp’s advice. Upgrading from pre-1.0 to 1.x is so much easier if you use version 0.7. That’s why we made it!

julia> VERSION
v"0.7.0-rc2.0"

julia> speye(10,10)
WARNING: Base.speye is deprecated: it has been moved to the standard library
package `SparseArrays`.
Add `using SparseArrays` to your imports.
 in module Main
┌ Warning: `speye(m::Integer, n::Integer)` has been deprecated in favor of `I`,
`sparse`, and `SparseMatrixCSC` constructor methods. For a direct replacement,
consider `sparse(1.0I, m, n)`, `SparseMatrixCSC(1.0I, m, n)`, or
`SparseMatrixCSC{Float64}(I, m, n)`. If `Float64` element type is not  necessary,
consider the shorter `sparse(I, m, n)` or `SparseMatrixCSC(I, m, n)` (with default `eltype(I)` of `Bool`).
│   caller = top-level scope at none:0
└ @ Core none:0
10×10 SparseArrays.SparseMatrixCSC{Float64,Int64} with 10 stored entries:
 ...
1 Like

I am USING JULIA 1.1.0

speye(10,10)
ERROR: UndefVarError: speye not defined
Stacktrace:
[1] top-level scope at none:0

Use julia 0.7 when upgrading not 1.1.0. Julia 0.7 gives you deprecation messages that tell you how to upgrade, just like @mbauman showed you.

For Julia 1.1.0, how can we call Sparse identity matrix function? I need a command in terminal.

Try use julia 0.7 and use speye, it will tell you how to do it because julia 0.7 has deprecation warnings. Julia 0.7 is good when upgrading code. It is better to use julia 0.7 first because it will tell you what the replacement is for upgrading code.

Thanks a lot for your suggestion, P.S. such methods like that I have to install / use Matlab 2008 now

is there a external package for Sparse identity matrix function in Julia?

See the deprecation message:

Note the For a direct replacement, consider `sparse(1.0I, m, n)`

1 Like
julia> A = sparse(1.0I, 3, 3)
ERROR: MethodError: no method matching sparse(::Array{Float64,1}, ::Int64, ::Array{Int64,1}, ::Int64, ::Int64, ::typeof(+))

???

Sorry, our responses have probably been cryptic for someone coming from Matlab or Numpy (and not upgrading from an old Julia version)!

You just need to use both LinearAlgebra and SparseArrays:

julia> using SparseArrays, LinearAlgebra

julia> sparse(1.0I, 3, 3)
3×3 SparseMatrixCSC{Float64,Int64} with 3 stored entries:
  [1, 1]  =  1.0
  [2, 2]  =  1.0
  [3, 3]  =  1.0

It looks like you already defined I to mean something different in your current Julia session. We’re referencing LinearAlgebra.I. This will do the same (and skirt around a shadowed binding for I):

julia> sparse(1.0*LinearAlgebra.I, 3, 3)
3×3 SparseMatrixCSC{Float64,Int64} with 3 stored entries:
  [1, 1]  =  1.0
  [2, 2]  =  1.0
  [3, 3]  =  1.0
4 Likes

Hey, no problem, some time it looks very like matlab coding!

Thanks a lot for your support!