Skip to content

Commit 41669cd

Browse files
authored
Stop using LinearAlgebra.copy_oftype (#626)
This undocumented function does not actually ensure that the result is mutable. Use the same approach as `Base.copymutable`, which relies only on public API.
1 parent 11d91ab commit 41669cd

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/scalarstats.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ function mad(x; center=nothing, normalize::Union{Bool, Nothing}=nothing, constan
317317
# Knowing the eltype allows allocating a single array able to hold both original values
318318
# and differences from the center, instead of two arrays
319319
S = isconcretetype(T) ? promote_type(T, typeof(middle(zero(T)))) : T
320-
x2 = x isa AbstractArray ? LinearAlgebra.copy_oftype(x, S) : collect(S, x)
320+
x2 = x isa AbstractArray ? copyto!(similar(x, S), x) : collect(S, x)
321321
c = center === nothing ? median!(x2) : center
322322
if isconcretetype(T)
323323
x2 .= abs.(x2 .- c)

0 commit comments

Comments
 (0)