davidavdav / NamedArrays.jl

Julia type that implements a drop-in replacement of Array with named dimensions
Other
118 stars 20 forks source link

Naming single dimension vector #86

Closed toktay closed 4 years ago

toktay commented 4 years ago

I am complete newbie, my complain may be not just. I have difficulty figuring out naming a single dimension vector indices. I asked the julia forum someone gave me this tip.

a = NamedArray([0.6, 0.25, 0.15], ([:s,:t,:u],))

What I want to do, to access the array like a[:s], a[:t] etc.

The comma just after symbol array in the tuple, the second parameter to the constructor, seems mandatory!

I have not been able to understand the compiler messages, they seemed very cryptic for me which forced me to ask to the forum.

I believe there should be an additional constructor to handle one dimensional arrays more user friendly.

Sincerely

davidavdav commented 4 years ago

Hi, I see the confusion—it is of course a Julia thing that the minimum number of commas in a tuple does not vary linearly with the number of elements, one element being the odd one out.

I'll see if it is possible to have a constructor for abstracvectors without too much ambiguity