Skip to content

Commit ba3a926

Browse files
committed
Fix macro hygiene issue with broadcast methods specialized for unary operations over SparseMatrixCSCs.
1 parent 182f4b3 commit ba3a926

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

base/sparse/sparsematrix.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1397,7 +1397,7 @@ such that `broadcast(::typeof(fc), A::SparseMatrixCSC) = fp(fc, A)`.
13971397
macro _enumerate_childmethods(fp, fcs...)
13981398
fcexps = Expr(:block)
13991399
for fc in fcs
1400-
push!(fcexps.args, :( broadcast(::typeof($(esc(fc))), A::SparseMatrixCSC) = $(esc(fp))($(esc(fc)), A) ) )
1400+
push!(fcexps.args, :( $(esc(:broadcast))(::typeof($(esc(fc))), A::SparseMatrixCSC) = $(esc(fp))($(esc(fc)), A) ) )
14011401
end
14021402
return fcexps
14031403
end

test/sparsedir/sparse.jl

+9
Original file line numberDiff line numberDiff line change
@@ -1612,3 +1612,12 @@ end
16121612
let A = sparse(UInt32[1,2,3], UInt32[1,2,3], [1.0,2.0,3.0])
16131613
@test A[1,1:3] == A[1,:] == [1,0,0]
16141614
end
1615+
1616+
# Check that `broadcast` methods specialized for unary operations over
1617+
# `SparseMatrixCSC`s are called. (Issue # .)
1618+
let
1619+
A = spdiagm(1.0:5.0)
1620+
@test isa(sin.(A), SparseMatrixCSC) # representative for _unary_nz2z_z2z class
1621+
@test isa(abs.(A), SparseMatrixCSC) # representative for _unary_nz2nz_z2z class
1622+
@test isa(exp.(A), Array) # representative for _unary_nz2nz_z2nz class
1623+
end

0 commit comments

Comments
 (0)