Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eachslice errors when dims=() on v1.9 #481

Closed
sethaxen opened this issue Apr 13, 2023 · 1 comment · Fixed by #601
Closed

eachslice errors when dims=() on v1.9 #481

sethaxen opened this issue Apr 13, 2023 · 1 comment · Fixed by #601

Comments

@sethaxen
Copy link
Collaborator

on v1.9.0-rc2:

julia> x = randn(10);

julia> da = DimArray(x, X);

julia> eachslice(x; dims=())
0-dimensional Slices{Vector{Float64}, Tuple{Colon}, Tuple{}, SubArray{Float64, 1, Vector{Float64}, Tuple{Base.Slice{Base.OneTo{Int64}}}, true}, 0}:
[0.7891813730345938, -1.3764708206873746, -0.5592354054654276, -1.399151200456184, 1.0245087542948947, 1.0028814175526604, 1.5265892145440452, -0.3877364838824226, 0.1777686084271991, 1.5604282747062839]

julia> eachslice(da; dims=())
ERROR: MethodError: no method matching hasdim(::DimArray{Float64, 1, Tuple{X{DimensionalData.Dimensions.LookupArrays.NoLookup{Base.OneTo{Int64}}}}, Tuple{}, Vector{Float64}, DimensionalData.NoName, DimensionalData.Dimensions.LookupArrays.NoMetadata})

Closest candidates are:
  hasdim(::Any, ::Any, ::Any...)
   @ DimensionalData ~/.julia/packages/DimensionalData/7iYMt/src/Dimensions/primitives.jl:248

Stacktrace:
 [1] #eachslice#92
   @ ~/.julia/packages/DimensionalData/7iYMt/src/array/methods.jl:124 [inlined]
 [2] top-level scope
   @ REPL[7]:1
@rafaqz
Copy link
Owner

rafaqz commented Jul 27, 2023

This is easy to fix for DimArray because it uses Slices, but hits problems with DimStack because we cant index DimIndices with [].

So this leads to a larger question: should indexing with [] be the same as [:, :, ...] for all AbstractDimArray? It would be consistent with how colons are filled in for missing dimensions, but maybe a bit weird for people that unlike base arrays da[] is not an error, but returns a new copy of da - especially when zero dimensional dim arrays will return the value.

@sethaxen I recall you also mentioned this indexing problem in the past. Any thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants