Permutedims not working correctly with NamedArray where names are symbols

I’m trying to permute the dimensions of a NamedArray where the names are symbols. However, I’m getting “Method Error: Cannot convert an object of type String to an object of type Symbol”

Here is an example of the code I’m using

using NamedArrays

A = NamedArray([1 2 3;4 5 6],([:a,:b],[:c,:d,:e]))
permutedims(A,(2,1))

This error does not arise if the names are strings or if the size of each dimension matches, e.g. the following work:

using NamedArrays

A = NamedArray([1 2 3;4 5 6],(["a","b"],["c","d","e"]))
permutedims(A,(2,1))


B = NamedArray([1 2;4 5],([:a,:b],[:c,:d]))
permutedims(B,(2,1))

Any advice on how to solve this issue?

*edit: transpose does work in this case, but in general my structures are >2 dimensional

To future generations searching and finding this topic, I’ve solved the issue.

using NamedArrays

A = NamedArray([1 2 3;4 5 6],([:a,:b],[:c,:d,:e]))
permutedims(A, [2,1] ) #Permutation should be a vector

I’m going to raise an issue on the NamedArrays github to add support for tuples.

1 Like