Skip to content

Commit 6546a1a

Browse files
committed
ComponentArrays with names in a center dimension
1 parent 2c2c032 commit 6546a1a

File tree

1 file changed

+36
-11
lines changed

1 file changed

+36
-11
lines changed

src/ComponentArrayInterpreter.jl

Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,10 @@ get_concrete(cai::ComponentArrayInterpreter) = StaticComponentArrayInterpreter{c
108108
"""
109109
ComponentArrayInterpreter(; kwargs...)
110110
ComponentArrayInterpreter(::AbstractComponentArray)
111+
111112
ComponentArrayInterpreter(::AbstractComponentArray, n_dims::NTuple{N,<:Integer})
112113
ComponentArrayInterpreter(n_dims::NTuple{N,<:Integer}, ::AbstractComponentArray)
114+
ComponentArrayInterpreter(n_dims::NTuple{N,<:Integer}, ::AbstractComponentArray, m_dims::NTuple{M,<:Integer})
113115
114116
Construct a `ComponentArrayInterpreter <: AbstractComponentArrayInterpreter`
115117
with components being vectors of given length or given model of a `AbstractComponentArray`.
@@ -156,17 +158,17 @@ end
156158
# with ComponentArrays in the first dimensions (e.g. rownames of a matrix or array)
157159
function ComponentArrayInterpreter(
158160
ca::CA.AbstractComponentArray, n_dims::NTuple{N,<:Integer}) where {N}
159-
ComponentArrayInterpreter(CA.getaxes(ca), n_dims)
161+
ComponentArrayInterpreter((), CA.getaxes(ca), n_dims)
160162
end
161163
function ComponentArrayInterpreter(
162164
cai::AbstractComponentArrayInterpreter, n_dims::NTuple{N,<:Integer}) where {N}
163-
ComponentArrayInterpreter(CA.getaxes(cai), n_dims)
164-
end
165-
function ComponentArrayInterpreter(
166-
axes::NTuple{M,<:CA.AbstractAxis}, n_dims::NTuple{N,<:Integer}) where {M,N}
167-
axes_ext = (axes..., map(n_dim -> CA.Axis(i=1:n_dim), n_dims)...)
168-
ComponentArrayInterpreter(axes_ext)
165+
ComponentArrayInterpreter((), CA.getaxes(cai), n_dims)
169166
end
167+
# function ComponentArrayInterpreter(
168+
# axes::NTuple{M,<:CA.AbstractAxis}, n_dims::NTuple{N,<:Integer}) where {M,N}
169+
# axes_ext = (axes..., map(n_dim -> CA.Axis(i=1:n_dim), n_dims)...)
170+
# ComponentArrayInterpreter(axes_ext)
171+
# end
170172

171173
# support also for other AbstractComponentArrayInterpreter types
172174
# in a type-stable way by providing the Tuple of dimensions as a value type
@@ -190,18 +192,41 @@ end
190192
# with ComponentArrays in the last dimensions (e.g. columnnames of a matrix)
191193
function ComponentArrayInterpreter(
192194
n_dims::NTuple{N,<:Integer}, ca::CA.AbstractComponentArray) where {N}
193-
ComponentArrayInterpreter(n_dims, CA.getaxes(ca))
195+
ComponentArrayInterpreter(n_dims, CA.getaxes(ca), ())
194196
end
195197
function ComponentArrayInterpreter(
196198
n_dims::NTuple{N,<:Integer}, cai::AbstractComponentArrayInterpreter) where {N}
197-
ComponentArrayInterpreter(n_dims, CA.getaxes(cai))
199+
ComponentArrayInterpreter(n_dims, CA.getaxes(cai), ())
200+
end
201+
# function ComponentArrayInterpreter(
202+
# n_dims::NTuple{N,<:Integer}, axes::NTuple{M,<:CA.AbstractAxis}) where {N,M}
203+
# axes_ext = (map(n_dim -> CA.Axis(i=1:n_dim), n_dims)..., axes...)
204+
# ComponentArrayInterpreter(axes_ext)
205+
# end
206+
207+
# with ComponentArrays in the center dimensions (e.g. columnnames of a 3D-array)
208+
function ComponentArrayInterpreter(
209+
n_dims::NTuple{N,<:Integer}, ca::CA.AbstractComponentArray,
210+
m_dims::NTuple{M,<:Integer}) where {N,M}
211+
ComponentArrayInterpreter(n_dims, CA.getaxes(ca), m_dims)
198212
end
199213
function ComponentArrayInterpreter(
200-
n_dims::NTuple{N,<:Integer}, axes::NTuple{M,<:CA.AbstractAxis}) where {N,M}
201-
axes_ext = (map(n_dim -> CA.Axis(i=1:n_dim), n_dims)..., axes...)
214+
n_dims::NTuple{N,<:Integer}, cai::AbstractComponentArrayInterpreter,
215+
m_dims::NTuple{M,<:Integer}) where {N,M}
216+
ComponentArrayInterpreter(n_dims, CA.getaxes(cai), m_dims)
217+
end
218+
219+
function ComponentArrayInterpreter(
220+
n_dims::NTuple{N,<:Integer}, axes::NTuple{A,<:CA.AbstractAxis},
221+
m_dims::NTuple{M,<:Integer}) where {N,A,M}
222+
axes_ext = (
223+
map(n_dim -> CA.Axis(i=1:n_dim), n_dims)...,
224+
axes...,
225+
map(n_dim -> CA.Axis(i=1:n_dim), m_dims)...)
202226
ComponentArrayInterpreter(axes_ext)
203227
end
204228

229+
205230
function stack_ca_int(
206231
::Val{n_dims}, cai::IT) where {IT<:AbstractComponentArrayInterpreter,n_dims}
207232
@assert n_dims isa NTuple{N,<:Integer} where {N}

0 commit comments

Comments
 (0)