Skip to content

Commit

Permalink
Deprecate remaining not-zero-preserving vectorized methods over Spars…
Browse files Browse the repository at this point in the history
…eVectors.
  • Loading branch information
Sacha0 committed Jul 25, 2017
1 parent f94f8eb commit 85c46b1
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 24 deletions.
8 changes: 8 additions & 0 deletions base/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1577,6 +1577,14 @@ for op in (:floor, :ceil, :trunc, :round,
:sinh, :tanh, :asinh, :atanh)
@eval @deprecate ($op)(x::AbstractSparseVector{<:Number,<:Integer}) ($op).(x)
end
# deprecate remaining vectorized methods over SparseVectors (not-zero-preserving)
for op in (:exp, :exp2, :exp10, :log, :log2, :log10,
:cos, :cosd, :acos, :cosh, :cospi,
:csc, :cscd, :acot, :csch, :acsch,
:cot, :cotd, :acosd, :coth,
:sec, :secd, :acotd, :sech, :asech)
@eval @deprecate ($op)(x::AbstractSparseVector{<:Number,<:Integer}) ($op).(x)
end

# PR #22182
@deprecate is_apple Sys.isapple
Expand Down
10 changes: 0 additions & 10 deletions base/sparse/sparsevector.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1083,16 +1083,6 @@ macro unarymap_z2nz(op, TF)
end)
end

for op in [:exp, :exp2, :exp10, :log, :log2, :log10,
:cos, :csc, :cot, :sec, :cospi,
:cosd, :cscd, :cotd, :secd,
:acos, :acot, :acosd, :acotd,
:cosh, :csch, :coth, :sech,
:acsch, :asech]
@eval @unarymap_z2nz $(op) Number
end


### Binary Map

# mode:
Expand Down
26 changes: 12 additions & 14 deletions test/sparse/sparsevector.jl
Original file line number Diff line number Diff line change
Expand Up @@ -677,20 +677,18 @@ end

### Non-zero-preserving math functions: sparse -> dense

function check_z2nz(f::Function, x::SparseVector{T}, xf::Vector{T}) where T
R = typeof(f(zero(T)))
r = f(x)
isa(r, Vector) || error("$f(x) is not a dense vector.")
eltype(r) == R || error("$f(x) results in eltype = $(eltype(r)), expect $R")
r == f.(xf) || error("Incorrect results found in $f(x).")
end

for f in [exp, exp2, exp10, log, log2, log10,
cos, csc, cot, sec, cospi,
cosd, cscd, cotd, secd,
acos, acot, acosd, acotd,
cosh, csch, coth, sech, acsch, asech]
check_z2nz(f, rnd_x0, rnd_x0f)
for op in (exp, exp2, exp10, log, log2, log10,
cos, cosd, acos, cosh, cospi,
csc, cscd, acot, csch, acsch,
cot, cotd, acosd, coth,
sec, secd, acotd, sech, asech)
spvec = rnd_x0
densevec = rnd_x0f
spresvec = op.(spvec)
@test spresvec == op.(densevec)
resvaltype = typeof(op(zero(eltype(spvec))))
resindtype = Base.SparseArrays.indtype(spvec)
@test isa(spresvec, SparseVector{resvaltype,resindtype})
end


Expand Down

0 comments on commit 85c46b1

Please sign in to comment.