Skip to content

Commit f07dd9f

Browse files
mbaumanJeffBezanson
authored andcommitted
Deprecate similar(f, …) in favor of just dispatching directly on f(…) (#26733)
Remove AbstractArray constructors; just use dispatch on functions Make compiler test use a local function that has the known properties that we want to test. The important thing is not necessarily zeros -- it is a relatively complex function. The `Base.zeros` method tree temporarily breaks this test due to its numerous deprecations, but this will be resolved in the future.
1 parent f26f2ab commit f07dd9f

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/sparsematrix.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1607,9 +1607,9 @@ end
16071607
# and computing reductions along columns into SparseMatrixCSC is
16081608
# non-trivial, so use Arrays for output
16091609
Base.reducedim_initarray(A::SparseMatrixCSC, region, v0, ::Type{R}) where {R} =
1610-
fill!(similar(dims->Array{R}(undef, dims), Base.reduced_indices(A,region)), v0)
1610+
fill(v0, Base.reduced_indices(A,region))
16111611
Base.reducedim_initarray0(A::SparseMatrixCSC, region, v0, ::Type{R}) where {R} =
1612-
fill!(similar(dims->Array{R}(undef, dims), Base.reduced_indices0(A,region)), v0)
1612+
fill(v0, Base.reduced_indices0(A,region))
16131613

16141614
# General mapreduce
16151615
function _mapreducezeros(f, op, ::Type{T}, nzeros::Int, v0) where T
@@ -1823,7 +1823,7 @@ function _findr(op, A, region, Tv)
18231823
throw(ArgumentError("array slices must be non-empty"))
18241824
else
18251825
ri = Base.reduced_indices0(A, region)
1826-
return (similar(A, ri), similar(dims->zeros(Ti, dims), ri))
1826+
return (similar(A, ri), zeros(Ti, ri))
18271827
end
18281828
end
18291829

0 commit comments

Comments
 (0)