-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NamedArrays with AbstractString names #140
Comments
Yes, this is a problem. I see that the regular I don't know how they have solved it for Dict, I've tried to interpret the sources, traced it down to One solution for now is to use The strange thing is that it does work for |
Sure, I can (and do) work around it by making a copy of the names array, which is a pity when this is a memory-mapped file I just split on a line break. I have ~40K names in there. It isn't a major performance issue but it isn't nice. Instead of fixing it in |
FYI I just ran into the same problem when using fixed-width string types from InlineStrings.jl. |
If one creates a
named_array = NamedArray(values_vector; names = (names_vector,))
then thekeytype(named_array.dicts[1]) == eltype(names_vector)
. This seems reasonable on its face, except when theeltype(names_vector) <: AbstractString
.Consider for example
names_vector = split(one_name_per_line, "\n")
. In this case thekeytype
isSubstring
. Trying to index into the named array with a regularString
will fail because aString
isn't aSubstring
. This also fails the other way around: ifeltype(names_vector) == String
, you can't index into the named array with aSubstring
.A better behavior would be to test whether the
eltype
of the names vector is<: AbstractString
, and if so, force thekeytype
to beAbstractString
.The text was updated successfully, but these errors were encountered: