Skip to content

Commit 04b3569

Browse files
committed
move SparseArrays to stdlib
1 parent daf1235 commit 04b3569

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+697
-652
lines changed

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -881,6 +881,8 @@ Deprecated or removed
881881
* The functions `eigs` and `svds` have been moved to the `IterativeEigensolvers` standard
882882
library module ([#24714]).
883883

884+
* Sparse array functionality has moved to the `SparseArrays` standard library module ([#25249]).
885+
884886
* `@printf` and `@sprintf` have been moved to the `Printf` standard library ([#23929],[#25056]).
885887

886888
* `isnumber` has been deprecated in favor of `isnumeric`, `is_assigned_char`

base/asyncmap.jl

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -260,13 +260,6 @@ function asyncmap(f, b::BitArray; kwargs...)
260260
return b2
261261
end
262262

263-
# TODO: Optimize for sparse arrays
264-
# For now process as regular arrays and convert back
265-
function asyncmap(f, s::AbstractSparseArray...; kwargs...)
266-
sa = map(Array, s)
267-
return sparse(asyncmap(f, sa...; kwargs...))
268-
end
269-
270263
mutable struct AsyncCollector
271264
f
272265
results

base/deprecated.jl

Lines changed: 30 additions & 217 deletions
Large diffs are not rendered by default.

base/exports.jl

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -433,15 +433,13 @@ export
433433
minimum,
434434
minmax,
435435
ndims,
436-
nonzeros,
437436
ones,
438437
parent,
439438
parentindices,
440439
partialsort,
441440
partialsort!,
442441
partialsortperm,
443442
partialsortperm!,
444-
permute,
445443
permute!,
446444
permutedims,
447445
permutedims!,
@@ -512,7 +510,6 @@ export
512510
# linear algebra
513511
bkfact!,
514512
bkfact,
515-
blkdiag,
516513
chol,
517514
cholfact!,
518515
cholfact,
@@ -593,10 +590,6 @@ export
593590
,
594591
×,
595592

596-
# sparse
597-
dropzeros,
598-
dropzeros!,
599-
600593
# bitarrays
601594
falses,
602595
flipbits!,
@@ -1183,22 +1176,4 @@ export
11831176
@goto,
11841177
@view,
11851178
@views,
1186-
@static,
1187-
1188-
# SparseArrays module re-exports
1189-
SparseArrays,
1190-
AbstractSparseArray,
1191-
AbstractSparseMatrix,
1192-
AbstractSparseVector,
1193-
SparseMatrixCSC,
1194-
SparseVector,
1195-
issparse,
1196-
sparse,
1197-
sparsevec,
1198-
spdiagm,
1199-
sprand,
1200-
sprandn,
1201-
spzeros,
1202-
rowvals,
1203-
nzrange,
1204-
nnz
1179+
@static

base/linalg/bidiag.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,8 @@ broadcast(::typeof(big), B::Bidiagonal) = Bidiagonal(big.(B.dv), big.(B.ev), B.u
178178
# On the other hand, similar(B, [neweltype,] shape...) should yield a sparse matrix.
179179
# The first method below effects the former, and the second the latter.
180180
similar(B::Bidiagonal, ::Type{T}) where {T} = Bidiagonal(similar(B.dv, T), similar(B.ev, T), B.uplo)
181-
similar(B::Bidiagonal, ::Type{T}, dims::Union{Dims{1},Dims{2}}) where {T} = spzeros(T, dims...)
181+
# The method below is moved to SparseArrays for now
182+
# similar(B::Bidiagonal, ::Type{T}, dims::Union{Dims{1},Dims{2}}) where {T} = spzeros(T, dims...)
182183

183184

184185
###################

base/linalg/dense.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,8 +303,6 @@ Vector `kv.second` will be placed on the `kv.first` diagonal.
303303
versions with fast arithmetic, see [`Diagonal`](@ref), [`Bidiagonal`](@ref)
304304
[`Tridiagonal`](@ref) and [`SymTridiagonal`](@ref).
305305
306-
See also: [`spdiagm`](@ref)
307-
308306
# Examples
309307
```jldoctest
310308
julia> diagm(1 => [1,2,3])

base/linalg/diagonal.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ Array(D::Diagonal) = Matrix(D)
5959
# On the other hand, similar(D, [neweltype,] shape...) should yield a sparse matrix.
6060
# The first method below effects the former, and the second the latter.
6161
similar(D::Diagonal, ::Type{T}) where {T} = Diagonal(similar(D.diag, T))
62-
similar(D::Diagonal, ::Type{T}, dims::Union{Dims{1},Dims{2}}) where {T} = spzeros(T, dims...)
62+
# The method below is moved to SparseArrays for now
63+
# similar(D::Diagonal, ::Type{T}, dims::Union{Dims{1},Dims{2}}) where {T} = spzeros(T, dims...)
6364

6465
copyto!(D1::Diagonal, D2::Diagonal) = (copyto!(D1.diag, D2.diag); D1)
6566

base/linalg/lapack.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3759,7 +3759,7 @@ for (stev, stebz, stegr, stein, elty) in
37593759
chklapackerror(info[])
37603760
if any(ifail .!= 0)
37613761
# TODO: better error message / type
3762-
error("failed to converge eigenvectors:\n$(nonzeros(ifail))")
3762+
error("failed to converge eigenvectors:\n$(find(!iszero, ifail))")
37633763
end
37643764
z
37653765
end

base/linalg/tridiag.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ end
111111
# On the other hand, similar(S, [neweltype,] shape...) should yield a sparse matrix.
112112
# The first method below effects the former, and the second the latter.
113113
similar(S::SymTridiagonal, ::Type{T}) where {T} = SymTridiagonal(similar(S.dv, T), similar(S.ev, T))
114-
similar(S::SymTridiagonal, ::Type{T}, dims::Union{Dims{1},Dims{2}}) where {T} = spzeros(T, dims...)
114+
# The method below is moved to SparseArrays for now
115+
# similar(S::SymTridiagonal, ::Type{T}, dims::Union{Dims{1},Dims{2}}) where {T} = spzeros(T, dims...)
115116

116117
#Elementary operations
117118
broadcast(::typeof(abs), M::SymTridiagonal) = SymTridiagonal(abs.(M.dv), abs.(M.ev))
@@ -497,7 +498,8 @@ Array(M::Tridiagonal) = Matrix(M)
497498
# On the other hand, similar(M, [neweltype,] shape...) should yield a sparse matrix.
498499
# The first method below effects the former, and the second the latter.
499500
similar(M::Tridiagonal, ::Type{T}) where {T} = Tridiagonal(similar(M.dl, T), similar(M.d, T), similar(M.du, T))
500-
similar(M::Tridiagonal, ::Type{T}, dims::Union{Dims{1},Dims{2}}) where {T} = spzeros(T, dims...)
501+
# The method below is moved to SparseArrays for now
502+
# similar(M::Tridiagonal, ::Type{T}, dims::Union{Dims{1},Dims{2}}) where {T} = spzeros(T, dims...)
501503

502504
# Operations on Tridiagonal matrices
503505
copyto!(dest::Tridiagonal, src::Tridiagonal) = (copyto!(dest.dl, src.dl); copyto!(dest.d, src.d); copyto!(dest.du, src.du); dest)

base/sysimg.jl

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -447,10 +447,6 @@ using .LinAlg
447447
const = dot
448448
const × = cross
449449

450-
# sparse matrices, vectors, and sparse linear algebra
451-
include("sparse/sparse.jl")
452-
using .SparseArrays
453-
454450
include("asyncmap.jl")
455451

456452
include("multimedia.jl")
@@ -504,6 +500,7 @@ Base.require(:IterativeEigensolvers)
504500
Base.require(:Mmap)
505501
Base.require(:Profile)
506502
Base.require(:SharedArrays)
503+
Base.require(:SparseArrays)
507504
Base.require(:SuiteSparse)
508505
Base.require(:Test)
509506
Base.require(:Unicode)
@@ -518,6 +515,19 @@ Base.require(:Libdl)
518515
@deprecate_binding Profile root_module(:Profile) true ", run `using Profile` instead"
519516
@deprecate_binding Dates root_module(:Dates) true ", run `using Dates` instead"
520517
@deprecate_binding Distributed root_module(:Distributed) true ", run `using Distributed` instead"
518+
519+
# PR #25249
520+
@deprecate_binding SparseArrays root_module(:SparseArrays) true ", run `using SparseArrays` instead"
521+
@deprecate_binding(AbstractSparseArray, root_module(:SparseArrays).AbstractSparseArray, true,
522+
", run `using SparseArrays` to load sparse array functionality")
523+
@deprecate_binding(AbstractSparseMatrix, root_module(:SparseArrays).AbstractSparseMatrix, true,
524+
", run `using SparseArrays` to load sparse array functionality")
525+
@deprecate_binding(AbstractSparseVector, root_module(:SparseArrays).AbstractSparseVector, true,
526+
", run `using SparseArrays` to load sparse array functionality")
527+
@deprecate_binding(SparseMatrixCSC, root_module(:SparseArrays).SparseMatrixCSC, true,
528+
", run `using SparseArrays` to load sparse array functionality")
529+
@deprecate_binding(SparseVector, root_module(:SparseArrays).SparseVector, true,
530+
", run `using SparseArrays` to load sparse array functionality")
521531
end
522532

523533
empty!(LOAD_PATH)

0 commit comments

Comments
 (0)