Closed sethaxen closed 1 year ago
Looks like there is a bug in zero dimensional broadcast.
Base.Broadcast.materialise
unwraps the zero dim array and just returns a scalar.
We have no special casing like that for zero dims here so we try to rebuild with that unwrapped scalar and hit this error.
Line 43 of broadcast.jl needs to add a check that ndims(A) == 0
then just return data
as is.
Okay, would you like me to open a PR with the proposed fix?
Always good to get PRs, I guess your example can be the test.
broadcast_dims
similarly fails for 0-dimensional DimArray
s, which I'll fix in the same PR:
julia> x = DimArray(fill(3), ())
0-dimensional DimArray{Int64,0}:
3
julia> broadcast_dims(+, x, x)
ERROR: MethodError: no method matching broadcast_dims!(::typeof(+), ::Array{Int64, 0}, ::DimArray{Int64, 0, Tuple{}, Tuple{}, Array{Int64, 0}, DimensionalData.NoName, DimensionalData.Dimensions.LookupArrays.NoMetadata}, ::DimArray{Int64, 0, Tuple{}, Tuple{}, Array{Int64, 0}, DimensionalData.NoName, DimensionalData.Dimensions.LookupArrays.NoMetadata})
Closest candidates are:
broadcast_dims!(::Any, ::AbstractDimArray{<:Any, N}, ::AbstractDimArray...) where N at ~/.julia/packages/DimensionalData/K9D4P/src/utils.jl:113
Stacktrace:
[1] broadcast_dims(::Function, ::DimArray{Int64, 0, Tuple{}, Tuple{}, Array{Int64, 0}, DimensionalData.NoName, DimensionalData.Dimensions.LookupArrays.NoMetadata}, ::Vararg{DimArray{Int64, 0, Tuple{}, Tuple{}, Array{Int64, 0}, DimensionalData.NoName, DimensionalData.Dimensions.LookupArrays.NoMetadata}})
@ DimensionalData ~/.julia/packages/DimensionalData/K9D4P/src/utils.jl:96
[2] top-level scope
@ REPL[4]:1
isapprox
for 0-dimensionalDimArray
seems to try to use a method ofrebuild
that is not defined: