jonniedie / ComponentArrays.jl

Arrays with arbitrarily nested named components.
MIT License
287 stars 34 forks source link

Cannot create zero-length ComponentArray #173

Open nrontsis opened 1 year ago

nrontsis commented 1 year ago

I cannot manage to create a zero length ComponentArray. Instead I get an Array back:

julia> ComponentArray(zeros(0), Axis(()))
Float64[]

This seems to be due to this line, that if deleted several things stop working in the package. I wonder what was the rationale behind that line?

I found this to affect type stability.

jonniedie commented 1 year ago

Hm. Yeah, it seems that we should make FlatAxis be a real type instead of a type alias. I don’t remember the rationale for making it a type alias. I won’t be able to get to this for the next few days, unfortunately, but I’d be happy to review a PR.

nrontsis commented 1 year ago

Somewhat related: https://github.com/jonniedie/ComponentArrays.jl/issues/116#issuecomment-1016069072

nrontsis commented 1 year ago

Thanks for the reply, I am happy to give a go at opening a PR for this, but I would prefer that the open PRs get reviewed first, to minimise potentially duplicated work.

nrontsis commented 1 year ago

Not a solution, but it seems possible to create a zero-length array via:

ComponentVector(Vector{Float64}(), (Axis(),))