Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move SparseArrays to stdlib #25249

Merged
merged 1 commit into from
Jan 12, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -881,6 +881,8 @@ Deprecated or removed
* The functions `eigs` and `svds` have been moved to the `IterativeEigensolvers` standard
library module ([#24714]).

* Sparse array functionality has moved to the `SparseArrays` standard library module ([#25249]).

* `@printf` and `@sprintf` have been moved to the `Printf` standard library ([#23929],[#25056]).

* `isnumber` has been deprecated in favor of `isnumeric`, `is_assigned_char`
Expand Down
7 changes: 0 additions & 7 deletions base/asyncmap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -260,13 +260,6 @@ function asyncmap(f, b::BitArray; kwargs...)
return b2
end

# TODO: Optimize for sparse arrays
# For now process as regular arrays and convert back
function asyncmap(f, s::AbstractSparseArray...; kwargs...)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I deprecated this in stdlib/SparseArrays/src/deprecated.jl since it is better to be transparent to the user that we don't have an optimized method for this anyway.

sa = map(Array, s)
return sparse(asyncmap(f, sa...; kwargs...))
end

mutable struct AsyncCollector
f
results
Expand Down
247 changes: 30 additions & 217 deletions base/deprecated.jl

Large diffs are not rendered by default.

27 changes: 1 addition & 26 deletions base/exports.jl
Original file line number Diff line number Diff line change
Expand Up @@ -433,15 +433,13 @@ export
minimum,
minmax,
ndims,
nonzeros,
ones,
parent,
parentindices,
partialsort,
partialsort!,
partialsortperm,
partialsortperm!,
permute,
permute!,
permutedims,
permutedims!,
Expand Down Expand Up @@ -512,7 +510,6 @@ export
# linear algebra
bkfact!,
bkfact,
blkdiag,
chol,
cholfact!,
cholfact,
Expand Down Expand Up @@ -593,10 +590,6 @@ export
⋅,
×,

# sparse
dropzeros,
dropzeros!,

# bitarrays
falses,
flipbits!,
Expand Down Expand Up @@ -1183,22 +1176,4 @@ export
@goto,
@view,
@views,
@static,

# SparseArrays module re-exports
SparseArrays,
AbstractSparseArray,
AbstractSparseMatrix,
AbstractSparseVector,
SparseMatrixCSC,
SparseVector,
issparse,
sparse,
sparsevec,
spdiagm,
sprand,
sprandn,
spzeros,
rowvals,
nzrange,
nnz
@static
3 changes: 2 additions & 1 deletion base/linalg/bidiag.jl
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,8 @@ broadcast(::typeof(big), B::Bidiagonal) = Bidiagonal(big.(B.dv), big.(B.ev), B.u
# On the other hand, similar(B, [neweltype,] shape...) should yield a sparse matrix.
# The first method below effects the former, and the second the latter.
similar(B::Bidiagonal, ::Type{T}) where {T} = Bidiagonal(similar(B.dv, T), similar(B.ev, T), B.uplo)
similar(B::Bidiagonal, ::Type{T}, dims::Union{Dims{1},Dims{2}}) where {T} = spzeros(T, dims...)
# The method below is moved to SparseArrays for now
# similar(B::Bidiagonal, ::Type{T}, dims::Union{Dims{1},Dims{2}}) where {T} = spzeros(T, dims...)


###################
Expand Down
2 changes: 0 additions & 2 deletions base/linalg/dense.jl
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,6 @@ Vector `kv.second` will be placed on the `kv.first` diagonal.
versions with fast arithmetic, see [`Diagonal`](@ref), [`Bidiagonal`](@ref)
[`Tridiagonal`](@ref) and [`SymTridiagonal`](@ref).

See also: [`spdiagm`](@ref)

# Examples
```jldoctest
julia> diagm(1 => [1,2,3])
Expand Down
3 changes: 2 additions & 1 deletion base/linalg/diagonal.jl
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ Array(D::Diagonal) = Matrix(D)
# On the other hand, similar(D, [neweltype,] shape...) should yield a sparse matrix.
# The first method below effects the former, and the second the latter.
similar(D::Diagonal, ::Type{T}) where {T} = Diagonal(similar(D.diag, T))
similar(D::Diagonal, ::Type{T}, dims::Union{Dims{1},Dims{2}}) where {T} = spzeros(T, dims...)
# The method below is moved to SparseArrays for now
# similar(D::Diagonal, ::Type{T}, dims::Union{Dims{1},Dims{2}}) where {T} = spzeros(T, dims...)

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

Expand Down
2 changes: 1 addition & 1 deletion base/linalg/lapack.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3759,7 +3759,7 @@ for (stev, stebz, stegr, stein, elty) in
chklapackerror(info[])
if any(ifail .!= 0)
# TODO: better error message / type
error("failed to converge eigenvectors:\n$(nonzeros(ifail))")
error("failed to converge eigenvectors:\n$(find(!iszero, ifail))")
end
z
end
Expand Down
6 changes: 4 additions & 2 deletions base/linalg/tridiag.jl
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ end
# On the other hand, similar(S, [neweltype,] shape...) should yield a sparse matrix.
# The first method below effects the former, and the second the latter.
similar(S::SymTridiagonal, ::Type{T}) where {T} = SymTridiagonal(similar(S.dv, T), similar(S.ev, T))
similar(S::SymTridiagonal, ::Type{T}, dims::Union{Dims{1},Dims{2}}) where {T} = spzeros(T, dims...)
# The method below is moved to SparseArrays for now
# similar(S::SymTridiagonal, ::Type{T}, dims::Union{Dims{1},Dims{2}}) where {T} = spzeros(T, dims...)

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

# Operations on Tridiagonal matrices
copyto!(dest::Tridiagonal, src::Tridiagonal) = (copyto!(dest.dl, src.dl); copyto!(dest.d, src.d); copyto!(dest.du, src.du); dest)
Expand Down
18 changes: 14 additions & 4 deletions base/sysimg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -447,10 +447,6 @@ using .LinAlg
const ⋅ = dot
const × = cross

# sparse matrices, vectors, and sparse linear algebra
include("sparse/sparse.jl")
using .SparseArrays

include("asyncmap.jl")

include("multimedia.jl")
Expand Down Expand Up @@ -504,6 +500,7 @@ Base.require(:IterativeEigensolvers)
Base.require(:Mmap)
Base.require(:Profile)
Base.require(:SharedArrays)
Base.require(:SparseArrays)
Base.require(:SuiteSparse)
Base.require(:Test)
Base.require(:Unicode)
Expand All @@ -518,6 +515,19 @@ Base.require(:Libdl)
@deprecate_binding Profile root_module(:Profile) true ", run `using Profile` instead"
@deprecate_binding Dates root_module(:Dates) true ", run `using Dates` instead"
@deprecate_binding Distributed root_module(:Distributed) true ", run `using Distributed` instead"

# PR #25249
@deprecate_binding SparseArrays root_module(:SparseArrays) true ", run `using SparseArrays` instead"
@deprecate_binding(AbstractSparseArray, root_module(:SparseArrays).AbstractSparseArray, true,
", run `using SparseArrays` to load sparse array functionality")
@deprecate_binding(AbstractSparseMatrix, root_module(:SparseArrays).AbstractSparseMatrix, true,
", run `using SparseArrays` to load sparse array functionality")
@deprecate_binding(AbstractSparseVector, root_module(:SparseArrays).AbstractSparseVector, true,
", run `using SparseArrays` to load sparse array functionality")
@deprecate_binding(SparseMatrixCSC, root_module(:SparseArrays).SparseMatrixCSC, true,
", run `using SparseArrays` to load sparse array functionality")
@deprecate_binding(SparseVector, root_module(:SparseArrays).SparseVector, true,
", run `using SparseArrays` to load sparse array functionality")
end

empty!(LOAD_PATH)
Expand Down
27 changes: 0 additions & 27 deletions doc/src/base/arrays.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,30 +188,3 @@ and can be converted to/from the latter via `Array(bitarray)` and `BitArray(arra
```@docs
Base.flipbits!
```

## [Sparse Vectors and Matrices](@id stdlib-sparse-arrays)

Sparse vectors and matrices largely support the same set of operations as their dense counterparts.
The following functions are specific to sparse arrays.

```@docs
Base.SparseArrays.SparseVector
Base.SparseArrays.SparseMatrixCSC
Base.SparseArrays.sparse
Base.SparseArrays.sparsevec
Base.SparseArrays.issparse
Base.SparseArrays.nnz
Base.SparseArrays.spzeros
Base.SparseArrays.spdiagm
Base.SparseArrays.sprand
Base.SparseArrays.sprandn
Base.SparseArrays.nonzeros
Base.SparseArrays.rowvals
Base.SparseArrays.nzrange
Base.SparseArrays.dropzeros!(::SparseMatrixCSC, ::Bool)
Base.SparseArrays.dropzeros(::SparseMatrixCSC, ::Bool)
Base.SparseArrays.dropzeros!(::SparseVector, ::Bool)
Base.SparseArrays.dropzeros(::SparseVector, ::Bool)
Base.SparseArrays.permute
Base.permute!{Tv, Ti, Tp <: Integer, Tq <: Integer}(::SparseMatrixCSC{Tv,Ti}, ::SparseMatrixCSC{Tv,Ti}, ::AbstractArray{Tp,1}, ::AbstractArray{Tq,1})
```
1 change: 0 additions & 1 deletion doc/src/base/base.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ Base.Markdown
Base.Meta
Base.Pkg
Base.Serializer
Base.SparseArrays
Base.StackTraces
Base.Sys
Base.Threads
Expand Down
1 change: 1 addition & 0 deletions doc/src/base/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,6 @@
* [Memory-mapped I/O](@ref)
* [Base64](@ref)
* [File Events](@ref lib-filewatching)
* [Sparse Arrays](@ref)
* [Iterative Eigensolvers](@ref lib-itereigen)
* [Printf](@ref)
1 change: 0 additions & 1 deletion doc/src/base/linalg.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ Base.LinAlg.pinv
Base.LinAlg.nullspace
Base.repmat
Base.kron
Base.SparseArrays.blkdiag
Base.LinAlg.linreg
Base.LinAlg.exp(::StridedMatrix{<:Base.LinAlg.BlasFloat})
Base.LinAlg.log(::StridedMatrix)
Expand Down
1 change: 1 addition & 0 deletions doc/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
* [Delimited Files](@ref)
* [Distributed Computing](@ref)
* [File Events](@ref lib-filewatching)
* [Sparse Arrays](@ref)
* [Iterative Eigensolvers](@ref lib-itereigen)
* [Memory-mapped I/O](@ref)
* [Printf](@ref)
Expand Down
Loading