Skip to content

Commit

Permalink
move SparseArrays to stdlib [ci skip] [bsd skip]
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrikekre committed Jan 9, 2018
1 parent 9b5eed2 commit 11e778b
Show file tree
Hide file tree
Showing 54 changed files with 707 additions and 649 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -872,6 +872,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 ([#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...)
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 @@ -434,15 +434,13 @@ export
minimum,
minmax,
ndims,
nonzeros,
ones,
parent,
parentindices,
partialsort,
partialsort!,
partialsortperm,
partialsortperm!,
permute,
permute!,
permutedims,
permutedims!,
Expand Down Expand Up @@ -513,7 +511,6 @@ export
# linear algebra
bkfact!,
bkfact,
blkdiag,
chol,
cholfact!,
cholfact,
Expand Down Expand Up @@ -594,10 +591,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(x->x != 0, 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 @@ -427,10 +427,6 @@ include("libgit2/libgit2.jl")
# package manager
include("pkg/pkg.jl")

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

include("asyncmap.jl")

# worker threads
Expand Down Expand Up @@ -499,6 +495,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 @@ -512,6 +509,19 @@ Base.require(:Future)
@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
8 changes: 6 additions & 2 deletions doc/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ if Sys.iswindows()
cp_q("../stdlib/FileWatching/docs/src/index.md", "src/stdlib/filewatching.md")
cp_q("../stdlib/CRC32c/docs/src/index.md", "src/stdlib/crc32c.md")
cp_q("../stdlib/Dates/docs/src/index.md", "src/stdlib/dates.md")
cp_q("../stdlib/SparseArrays/docs/src/index.md", "src/stdlib/sparsearrays.md")
cp_q("../stdlib/IterativeEigensolvers/docs/src/index.md", "src/stdlib/iterativeeigensolvers.md")
cp_q("../stdlib/Unicode/docs/src/index.md", "src/stdlib/unicode.md")
cp_q("../stdlib/Distributed/docs/src/index.md", "src/stdlib/distributed.md")
Expand All @@ -44,6 +45,7 @@ else
symlink_q("../../../stdlib/FileWatching/docs/src/index.md", "src/stdlib/filewatching.md")
symlink_q("../../../stdlib/CRC32c/docs/src/index.md", "src/stdlib/crc32c.md")
symlink_q("../../../stdlib/Dates/docs/src/index.md", "src/stdlib/dates.md")
symlink_q("../../../stdlib/SparseArrays/docs/src/index.md", "src/stdlib/sparsearrays.md")
symlink_q("../../../stdlib/IterativeEigensolvers/docs/src/index.md", "src/stdlib/iterativeeigensolvers.md")
symlink_q("../../../stdlib/Unicode/docs/src/index.md", "src/stdlib/unicode.md")
symlink_q("../../../stdlib/Distributed/docs/src/index.md", "src/stdlib/distributed.md")
Expand Down Expand Up @@ -125,6 +127,7 @@ const PAGES = [
"stdlib/sharedarrays.md",
"stdlib/filewatching.md",
"stdlib/crc32c.md",
"stdlib/sparsearrays.md",
"stdlib/iterativeeigensolvers.md",
"stdlib/unicode.md",
"stdlib/printf.md",
Expand Down Expand Up @@ -163,12 +166,13 @@ const PAGES = [
]

using DelimitedFiles, Test, Mmap, SharedArrays, Profile, Base64, FileWatching, CRC32c,
Dates, IterativeEigensolvers, Unicode, Distributed, Printf
Dates, SparseArrays, IterativeEigensolvers, Unicode, Distributed, Printf

makedocs(
build = joinpath(pwd(), "_build/html/en"),
modules = [Base, Core, BuildSysImg, DelimitedFiles, Test, Mmap, SharedArrays, Profile,
Base64, FileWatching, Dates, IterativeEigensolvers, Unicode, Distributed, Printf],
Base64, FileWatching, Dates, SparseArrays, IterativeEigensolvers, Unicode,
Distributed, Printf],
clean = false,
doctest = "doctest" in ARGS,
linkcheck = "linkcheck" in ARGS,
Expand Down
1 change: 1 addition & 0 deletions doc/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
* [Memory-mapped I/O](@ref)
* [Base64](@ref)
* [File Events](@ref lib-filewatching)
* [Sparse Arrays](@ref)
* [Iterative Eigensolvers](@ref lib-itereigen)
* [Unicode](@ref)
* [Printf](@ref)
Expand Down
Loading

0 comments on commit 11e778b

Please sign in to comment.