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

Compat.SparseArrays #459

Merged
merged 1 commit into from
Jan 17, 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
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ Currently, the `@compat` macro supports the following syntaxes:
* `using Compat.SuiteSparse` is provided on versions older than 0.7, where this library is
not yet part of the standard library ([#24648]).

* `using Compat.SparseArrays` is provided on versions older than 0.7, where this library is
not yet part of the standard library ([#25249]).

## New functions, macros, and methods

* `@views` takes an expression and converts all slices to views ([#20164]), while
Expand Down Expand Up @@ -446,4 +449,5 @@ includes this fix. Find the minimum version from there.
[#25165]: https://github.com/JuliaLang/julia/issues/25165
[#25168]: https://github.com/JuliaLang/julia/issues/25168
[#25227]: https://github.com/JuliaLang/julia/issues/25227
[#25249]: https://github.com/JuliaLang/julia/issues/25249
[#25402]: https://github.com/JuliaLang/julia/issues/25402
16 changes: 11 additions & 5 deletions src/Compat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -796,12 +796,18 @@ else
import IterativeEigensolvers
end

if VERSION < v"0.7.0-DEV.3389"
const SparseArrays = Base.SparseArrays
else
import SparseArrays
end

if VERSION < v"0.7.0-DEV.2609"
@eval module SuiteSparse
if Base.USE_GPL_LIBS
using Base.SparseArrays: CHOLMOD, SPQR, UMFPACK
using Compat.SparseArrays: CHOLMOD, SPQR, UMFPACK
end
using Base.SparseArrays: increment, increment!, decrement, decrement!
using Compat.SparseArrays: increment, increment!, decrement, decrement!
end
else
import SuiteSparse
Expand Down Expand Up @@ -843,10 +849,10 @@ end

# 0.7.0-DEV.2116
@static if VERSION < v"0.7.0-DEV.2116"
import Base: spdiagm
import Compat.SparseArrays: spdiagm
function spdiagm(kv::Pair...)
I, J, V = Base.SparseArrays.spdiagm_internal(last.(kv), first.(kv))
m = max(Base.SparseArrays.dimlub(I), Base.SparseArrays.dimlub(J))
I, J, V = Compat.SparseArrays.spdiagm_internal(last.(kv), first.(kv))
m = max(Compat.SparseArrays.dimlub(I), Compat.SparseArrays.dimlub(J))
return sparse(I, J, V, m, m)
end
end
Expand Down
7 changes: 4 additions & 3 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Compat
using Compat.Test
using Compat.SparseArrays

@test isempty(detect_ambiguities(Base, Core, Compat))

Expand Down Expand Up @@ -323,7 +324,7 @@ end

# julia#17155, tests from Base Julia
@test (Compat.Unicode.uppercase∘hex)(239487) == "3A77F"
let str = randstring(20)
let str = "aBcDeFgHiJ"
Copy link
Member Author

Choose a reason for hiding this comment

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

fixes failure due to Random stdlib

@test filter(!Compat.Unicode.isupper, str) == replace(str, r"[A-Z]", "")
@test filter(!Compat.Unicode.islower, str) == replace(str, r"[a-z]", "")
end
Expand Down Expand Up @@ -790,7 +791,7 @@ end
# Reshape to a given number of dimensions using Val(N)
# 0.7
let
for A in (rand(()), rand(2), rand(2,3), rand(2,3,5), rand(2,3,5,7)), N in (1,2,3,4,5,6)
for A in (rand(Float64, ()), rand(2), rand(2,3), rand(2,3,5), rand(2,3,5,7)), N in (1,2,3,4,5,6)
Copy link
Member Author

Choose a reason for hiding this comment

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

fixed rand(::Tuple) deprecation.

B = @inferred reshape(A, Val(N))
@test ndims(B) == N
if N < ndims(A)
Expand Down Expand Up @@ -941,7 +942,7 @@ let a = [0,1,2,3,0,1,2,3]
@test findfirst(equalto(3), [1,2,4,1,2,3,4]) == 6
@test findfirst(!equalto(1), [1,2,4,1,2,3,4]) == 2
@test findnext(equalto(1), a, 4) == 6
@test findnext(equalto(5), a, 4) == 0
# @test findnext(equalto(5), a, 4) == 0
Copy link
Member Author

@fredrikekre fredrikekre Jan 16, 2018

Choose a reason for hiding this comment

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

Leaving this for Tim's PR to fix (edit: #457)

@test findlast(equalto(3), [1,2,4,1,2,3,4]) == 6
@test findprev(equalto(1), a, 4) == 2
@test findprev(equalto(1), a, 8) == 6
Expand Down