Open schlichtanders opened 4 years ago
perhaps we can keep the AxisArray
wrapper on the outside, like we do with adjoint
and transpose
?
e.g. define
Base.permutedims(A::AxisArray{T,1}) where {T} = AxisArray(permutedims(A.data), Axis{:permutedim}(Base.OneTo(1)), A.axes[1])
then we'd be able to do e.g.
julia> permutedims(AxisArray(1:3, ["A", "B", "C"]))[Axis{:row}("A")]
1-dimensional AxisArray{Int64,1,...} with axes:
:permutedim, Base.OneTo(1)
And data, a 1-element Vector{Int64}:
1
one common thing is to using broadcasting on named vectors, for which one is put into another dimension.
permutedims(a)
as well asreshape(a, 1, :)
can be used to bring a column vectora
to row format.reshape(a, 1, 1, :)
would create a 3rd-dim vector.It would be great if these operations preserve the indexing.
gives an error
The ultimate goal would be that the following works and preserves indexes as would be intuitive:
and similar for using reshape instead of permutedims