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

Conversation

fredrikekre
Copy link
Member

@fredrikekre fredrikekre commented Dec 22, 2017

Work in progress, but at least I got this locally:

Test Summary:           |     Pass  Fail  Error  Broken     Total
  Overall               | 26574757     2      2  328326  26903087

so its not too bad!

TODOs:

  • Chase down the 2 last test failures
  • Activate deprecated sparse methods that are moved from base/deprecated.jl to stdlib/SparseArrays/src/deprecated.jl
  • Add deprecations for all the moved methods
  • Make doc building work.

@fredrikekre fredrikekre added excision Removal of code from Base or the repository sparse Sparse arrays stdlib Julia's standard library labels Dec 22, 2017
@fredrikekre fredrikekre force-pushed the fe/stdlib-sparsearrays branch 2 times, most recently from 67dc16a to 17f8a9a Compare December 29, 2017 02:00
@fredrikekre fredrikekre force-pushed the fe/stdlib-sparsearrays branch 2 times, most recently from 6c63ce9 to d4fa4c5 Compare January 5, 2018 22:09
@Sacha0
Copy link
Member

Sacha0 commented Jan 6, 2018

Resurrect once #25364 clears, and then on to LinAlg? :)

@fredrikekre fredrikekre force-pushed the fe/stdlib-sparsearrays branch from d4fa4c5 to b32e398 Compare January 8, 2018 00:16
@fredrikekre
Copy link
Member Author

Down to one:

Test Summary:           |     Pass  Error  Broken     Total
  Overall               | 26597574      1  328323  26925898

@fredrikekre fredrikekre force-pushed the fe/stdlib-sparsearrays branch from b32e398 to 77edba7 Compare January 8, 2018 07:32
@fredrikekre fredrikekre mentioned this pull request Jan 8, 2018
5 tasks
@fredrikekre fredrikekre force-pushed the fe/stdlib-sparsearrays branch 2 times, most recently from 10763d5 to 6acf733 Compare January 9, 2018 09:36
@fredrikekre
Copy link
Member Author

Test Summary: |     Pass  Broken     Total
  Overall     | 26598707  328325  26927032
    SUCCESS

@fredrikekre fredrikekre force-pushed the fe/stdlib-sparsearrays branch 2 times, most recently from 11e778b to 7d3e87c Compare January 9, 2018 13:06
@fredrikekre fredrikekre changed the title [WIP] SparseArrays to stdlib move SparseArrays to stdlib Jan 9, 2018
@@ -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.

@deprecate_moved droptol! "SparseArrays" false true
## deprecated functions that are moved to stdlib/SparseArrays/src/deprecated.jl
@deprecate_moved spones "SparseArrays" true true
@deprecate_moved speye "SparseArrays" true true
Copy link
Member Author

Choose a reason for hiding this comment

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

Calling spones and speye now will result in users first getting redirected to SparseArrays, and then get a message that those methods are deprecated. But perhaps no big deal.

@@ -505,6 +503,7 @@ function OverflowError()
end

# PR #22703
import .LinAlg: Bidiagonal
Copy link
Member Author

Choose a reason for hiding this comment

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

Had to add this (and similarly below) to be able to build the sysimg, otherwise I get

LoadError("sysimg.jl", 461, LoadError("deprecated.jl", 507, TypeError(:Union, "parameter", Type, Bidiagonal)))

I wonder why those are not needed to compile master?

Copy link
Member

Choose a reason for hiding this comment

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

Curious :).

@@ -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))")
Copy link
Member Author

Choose a reason for hiding this comment

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

There is no nonzeros method for Vector on master, but with this excision we get

WARNING: importing deprecated binding Base.nonzeros into LAPACK.

here, so updated.

Copy link
Member

Choose a reason for hiding this comment

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

Perhaps !iszero? :)

@@ -896,7 +896,7 @@ vec(x::AbstractSparseVector) = x
copy(x::AbstractSparseVector) =
SparseVector(length(x), copy(nonzeroinds(x)), copy(nonzeros(x)))

function reinterpret(::Type{T}, x::AbstractSparseVector{Tv}) where {T,Tv}
function Base.reinterpret(::Type{T}, x::AbstractSparseVector{Tv}) where {T,Tv}
Copy link
Member Author

@fredrikekre fredrikekre Jan 9, 2018

Choose a reason for hiding this comment

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

I assume this is meant to extend Base.reinterpret? The import Base: reinterpret was removed in #23750. Or should this method have been removed as part of the last commit in that PR @Keno ?

Copy link
Member

Choose a reason for hiding this comment

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

I think this can be deleted.

@@ -1048,110 +1048,112 @@ end
@test iA === iS === nothing
end

# findmin/findmax/minumum/maximum
@testset "findmin/findmax/minumum/maximum" begin
Copy link
Member Author

Choose a reason for hiding this comment

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

This just adds a testset to fix:

Deprecated syntax `implicit assignment to global variable `A``

see https://github.com/JuliaLang/julia/pull/25249/files?w=1#diff-6b5c2f417a1aa03f6bfdfb283f4bd01c

Copy link
Member

Choose a reason for hiding this comment

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

Good catch!

pop!(need_to_handle_undef_sparam, which(Base.SparseArrays._absspvec_vcat, (AbstractSparseArray{Tv, Ti, 1} where {Tv, Ti},)))
pop!(need_to_handle_undef_sparam, which(Base.SparseArrays._absspvec_hcat, (AbstractSparseArray{Tv, Ti, 1} where {Tv, Ti},)))
pop!(need_to_handle_undef_sparam, which(Base.cat, (Any, Base.SparseArrays._TypedDenseConcatGroup{T} where T)))
# pop!(need_to_handle_undef_sparam, which(SparseArrays._absspvec_vcat, (AbstractSparseArray{Tv, Ti, 1} where {Tv, Ti},)))
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 don't know what this test does, but it passes with those two lines removed :)

@fredrikekre
Copy link
Member Author

This is no longer WIP, all tests, and doc building, passed for me locally, so feel free to review!

"If preserving element type `T` is not necessary, consider the shorter ",
"`sparse(I, size(S)...)` or `SparseMatrixCSC(I, size(S))` (with default ",
"`eltype(I)` of `Bool`)."), :speye)
return SparseMatrixCSC{T}(I, m, n)
Copy link
Member Author

Choose a reason for hiding this comment

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

SparseMatrixCSC{T}(I, m, n) -> SparseMatrixCSC{T}(I, size(S)...)

Copy link
Member

Choose a reason for hiding this comment

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

Good catch!

@fredrikekre fredrikekre force-pushed the fe/stdlib-sparsearrays branch from 7d3e87c to b4ff1bf Compare January 9, 2018 14:33
@KristofferC
Copy link
Member

This looks good to me. Great work.

@fredrikekre fredrikekre force-pushed the fe/stdlib-sparsearrays branch 3 times, most recently from 492514d to 9c218a1 Compare January 10, 2018 23:36
NEWS.md Outdated
@@ -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 ([#25249]).
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps "has moved to the SparseArrays (package|module) in the standard library", "has moved to the SparseArrays standard library (package|module)", or "has moved to SparseArrays in the standard library"?

## functions that were re-exported from Base
@deprecate_moved nonzeros "SparseArrays" true true
@deprecate_moved permute "SparseArrays" true true
@deprecate_moved blkdiag "SparseArrays" true true
Copy link
Member

Choose a reason for hiding this comment

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

Tangentially, adding the oc to blockdiag might be nice...

@deprecate_moved rowvals "SparseArrays" true true
@deprecate_moved nzrange "SparseArrays" true true
@deprecate_moved nnz "SparseArrays" true true
## functions that where exported from Base.SparseArrays but not from Base
Copy link
Member

Choose a reason for hiding this comment

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

"that were exported"? :)

Copy link
Member

@Sacha0 Sacha0 left a comment

Choose a reason for hiding this comment

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

Absolutely superlative! Thanks so much for your persistence and patience in seeing this work through! :)

@fredrikekre fredrikekre force-pushed the fe/stdlib-sparsearrays branch from 9c218a1 to 04b3569 Compare January 11, 2018 23:33
@Sacha0
Copy link
Member

Sacha0 commented Jan 12, 2018

(The AV i686 failure seems unrelated. FreeBSD timed out without apparent issue prior.)

@Sacha0
Copy link
Member

Sacha0 commented Jan 12, 2018

Assuming CI continues to approve and absent objections or requests for time, I plan to merge these changes tomorrow midday PT or later. Best!

@Sacha0 Sacha0 merged commit f8bc37b into JuliaLang:master Jan 12, 2018
@Sacha0
Copy link
Member

Sacha0 commented Jan 12, 2018

Bravo!

@fredrikekre fredrikekre deleted the fe/stdlib-sparsearrays branch January 12, 2018 21:16
@ararslan
Copy link
Member

Thanks so much for taking this on @fredrikekre! You're a true hero!

@rfourquet
Copy link
Member

When running julia stdlib/SparseArrays/test/runtests.jl, I get a bunch of errors, with show methods (show removes the SparseArrays. module prefix). Is this issue tracked somewhere ?

@KristofferC
Copy link
Member

What happens when you run make test-SparseArrays?

@fredrikekre
Copy link
Member Author

show removes the prefix if the module is Main or something, I tried to modify those tests to incorporate that, but didn't bother in the end. It is rather annoying that the sparse show testset does not pass if copy-pasted into the REPL though.

@rfourquet
Copy link
Member

What happens when you run make test-SparseArrays?

This works! But indeed, running the runtest.jl file directly or copy-pasting a @testset into the REPL would be nice. I guess this problem will show-up also with other stdlib packages.

@KristofferC
Copy link
Member

Yeah, I think @fredrikekre identified the issue then. Not sure what the best way to solve it is. Probably change the show tests to look if the module is loaded in Main.

@Sacha0
Copy link
Member

Sacha0 commented Jan 14, 2018

Perhaps opening a dedicated issue would be worthwhile? Being able to copy-paste and/or include test files in REPL sessions is useful. Best! :)

@rfourquet
Copy link
Member

In the "test/offsetarray.jl", there is const OAs_name = join(fullname(OAs), ".") near to the top of the file, which seems to address the same problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
excision Removal of code from Base or the repository sparse Sparse arrays stdlib Julia's standard library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants