Skip to content

Declare that an AbstractDimStack is an AbstractArray with namedtuple eltype? #870

@tiemvanderdeure

Description

@tiemvanderdeure

After #811 merged, any DimStack now behaves a lot like an AbstractArray that iterates NamedTuples. Should we declare it as such?

It could even be an AbstractBasicDimArray, but that would require some changes as a AbstractDimStack does not have its dimension in its type, currently.

It would allow us to remove a whole list of array-like methods, and make additional things work, e.g.:

A = [1.0 2.0 3.0; 4.0 5.0 6.0]
dimz = (X([:a, :b]), Y(10.0:10.0:30.0))
da1 = DimArray(A, dimz; name=:one)
da2 = DimArray(Float32.(2A), dimz; name=:two)
da3 = DimArray(Int.(3A), dimz; name=:three)

s = DimStack((da1, da2, da3))

broadcast!(s, s) do x
    (one = 1, two = 2, three = 3)
end

This now fails because ndims is not implemented for DimStack (an oversight, I assume), but if I just add
abstract type AbstractDimStack{K,T,N,L} <: AbstractArray{T,N} end
then it just works.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions