davidavdav / NamedArrays.jl

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

name an 1-dim array #53

Closed HenryLeongStat closed 7 years ago

HenryLeongStat commented 7 years ago

Hello! Thank you for this useful package! I try to name the 1-dim array in the constructor like the following: NamedArray([1,3,2,4],(["a","b","c","d"])) However, an error Dimension mismatch appears. Is there any method that can name a 1-dim array in the constructor? Doesn't quite understand the example indexing in the documentation.

Thanks! 😄

davidavdav commented 7 years ago

Hi,

The 2nd argument in your call, (["a","b","c","d"]) isn't parsed as a 1-tuple, but as a parenthesized expression. You need to add a comma, as in (["a","b","c","d"], ) or give an array-of-arrays: [["a","b","c","d"]].

Perhaps I should add a special constructor for 1-dim arrays. That might make sense for typing, but might also be a bit confusing.

Cheers

HenryLeongStat commented 7 years ago

It works! Thanks a lot! :D