Open dingraha opened 4 months ago
I can actually fix this by commenting out this line, which creates a FlatAxis
when constructing a ShapedAxis
for a 1D array. That appears to preserve the necessary shape information that's needed by maybe_reshape
. But that change breaks other things, unfortunately. For example, indexing a matrix with nested component axis like here no longer works, since the presence of the ShapedAxis
triggers calling maybe_reshape
, which can't figure out the necessary size of the nested component axis.
OK, I attempted to fix this issue by introducing a Shaped1DAxis
type in this PR: https://github.com/jonniedie/ComponentArrays.jl/pull/249. It fixes the issue described here, but breaks some relatively minor things (IMHO). The most serious issue appears to be indexing a ComponentIndex
with multiple symbols: https://github.com/dingraha/ComponentArrays.jl/blob/0db92aec69fac664524cc95a8f5fa1d3a605ce93/test/runtests.jl#L362, but that already didn't work with multi-dimensional ShapedAxis
.
Now almost everything works with https://github.com/jonniedie/ComponentArrays.jl/pull/249. The things that are broken:
ComponentArray
with an empty NamedTuple
is not identical to creating one with an empty Array
, like this, as seen here: ComponentArray(a = T[], b = (;)) == ComponentVector{T}(a = T[], b = T[])
ComponentIndex
with multiple symbols doesn't work when one of the indices refers to a ShapedAxis
, as seen here. IIUC that used to work when the index was one-dimensional (and was thus converted into a FlatAxis
, but did not work for multi-dimensional ShapedAxis
, and still doesn't.Managed to fix the test for indexing a ComponentIndex
with multiple symbols. Now the only broken test in https://github.com/jonniedie/ComponentArrays.jl/pull/249 is the "empty NamedTuple
vs empty Array
one, which is relatively minor IMHO.
When i try the following code:
I see this error:
It looks like
maybe_reshape
is ignoring the length of theb
component inJ
, I guess because it's aFlatAxis
, not aShapedAxis
. If I makeb
have asize
of, say(1, nk)
it works as expected.Any ideas?