rafaqz / DimensionalData.jl

Named dimensions and indexing for julia arrays and other data
https://rafaqz.github.io/DimensionalData.jl/stable/
MIT License
282 stars 42 forks source link

`@d` with `mydimstack.field` does not work #829

Closed haakon-e closed 2 weeks ago

haakon-e commented 2 weeks ago

Just updated to DD v0.28.3, testing @d and I notice the following:

xs = 1.0:10.0
v1 = DimVector(xs, X(xs), name=:x)
v2 = DimVector(xs, X(xs), name=:x)
ds = DimStack(v1)
x = ds.x
@d ds.x .* v2  # does not work
@d x .* v2     # works
stacktrace ```julia ERROR: LoadError: MethodError: no method matching iterate(::Nothing) The function `iterate` exists, but no method is defined for this combination of argument types. Closest candidates are: iterate(::Base.MethodSpecializations) @ Base reflection.jl:1299 iterate(::Base.MethodSpecializations, ::Nothing) @ Base reflection.jl:1305 iterate(::Base.MethodSpecializations, ::Int64) @ Base reflection.jl:1306 ... Stacktrace: [1] indexed_iterate(I::Nothing, i::Int64) @ Base ./tuple.jl:162 [2] (::DimensionalData.var"#242#244"{Vector{Pair{Symbol, Any}}, Expr})(arg::Expr) @ DimensionalData ~/.julia/packages/DimensionalData/hhCBb/src/array/broadcast.jl:259 [3] iterate(::Base.Generator{Vector{Any}, DimensionalData.var"#242#244"{Vector{Pair{Symbol, Any}}, Expr}}) @ Base ./generator.jl:48 [4] _collect(c::Vector{…}, itr::Base.Generator{…}, ::Base.EltypeUnknown, isz::Base.HasShape{…}) @ Base ./array.jl:800 [5] collect_similar(cont::Vector{Any}, itr::Base.Generator{Vector{Any}, DimensionalData.var"#242#244"{Vector{…}, Expr}}) @ Base ./array.jl:709 [6] map(f::Function, A::Vector{Any}) @ Base ./abstractarray.jl:3371 [7] _find_broadcast_vars(expr::Expr) @ DimensionalData ~/.julia/packages/DimensionalData/hhCBb/src/array/broadcast.jl:256 [8] var"@d"(__source__::LineNumberNode, __module__::Module, expr::Expr, options::Union{Nothing, Expr}) @ DimensionalData ~/.julia/packages/DimensionalData/hhCBb/src/array/broadcast.jl:160 [9] var"@d"(__source__::LineNumberNode, __module__::Module, expr::Expr) @ DimensionalData ~/.julia/packages/DimensionalData/hhCBb/src/array/broadcast.jl:159 in expression starting at REPL[10]:1 Some type information was truncated. Use `show(err)` to see complete types. ```

is this expected?

asinghvi17 commented 2 weeks ago

It's expected, since the name of the array is not a dimension, but it may he convenient to allow this. See discussion in my AoG PR that was just merged, I think it was #823?

rafaqz commented 2 weeks ago

No this should work

Looks like a bug in the macro

(Basically everything that works with a normal broadcast should work or it's a bug)