in these methods
|
Base.sum(a::AbstractArray{<:Measurement}) = result(sum(value.(a)), ones(length(a)), a) |
|
function Base.prod(a::AbstractArray{<:Measurement}) |
|
x = value.(a) |
|
return result(prod(x), |
|
[prod(deleteat!(copy(x), i)) for i in eachindex(x)], |
|
a) |
|
end |
I see this was done as an optimization, but it feels like it might be more appropriate as its own function rather than Base.sum to avoid all the known issues with piracy (particularly method invalidations contributing to load times & recompilation). this design also means there is a discrepancy between e.g. Base.sum(x) and Base.sum(x; dims=:)
in these methods
Measurements.jl/src/math.jl
Line 779 in 86adc26
Measurements.jl/src/math.jl
Lines 785 to 790 in 86adc26
I see this was done as an optimization, but it feels like it might be more appropriate as its own function rather than
Base.sumto avoid all the known issues with piracy (particularly method invalidations contributing to load times & recompilation). this design also means there is a discrepancy between e.g.Base.sum(x)andBase.sum(x; dims=:)