Skip to content
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

n[1:end] doesn't work for matrices with Symbol names #129

Open
knuesel opened this issue Jun 22, 2023 · 1 comment
Open

n[1:end] doesn't work for matrices with Symbol names #129

knuesel opened this issue Jun 22, 2023 · 1 comment

Comments

@knuesel
Copy link

knuesel commented Jun 22, 2023

Here's an example:

julia> a = [1 3; 2 4];

julia> a[1:end]
4-element Vector{Int64}:
 1
 2
 3
 4

julia> n = NamedArray(a, ([:a, :b], [:c, :d]));

julia> n[1:end]
ERROR: MethodError: Cannot `convert` an object of type String to an object of type Symbol
Stacktrace
Stacktrace:
 [1] convert
   @ ~/.julia/packages/OrderedCollections/vTcqn/src/ordered_dict.jl:106 [inlined]
 [2] setindex!
   @ ./array.jl:969 [inlined]
 [3] similar(n::NamedMatrix{Int64, Matrix{Int64}, Tuple{OrderedCollections.OrderedDict{Symbol, Int64}, OrderedCollections.OrderedDict{Symbol, Int64}}}, t::Type, dims::Tuple{Int64})
   @ NamedArrays ~/.julia/packages/NamedArrays/spYk1/src/base.jl:45
 [4] similar
   @ ./abstractarray.jl:836 [inlined]
 [5] _unsafe_getindex
   @ ./multidimensional.jl:873 [inlined]
 [6] _getindex
   @ ./multidimensional.jl:861 [inlined]
 [7] getindex(A::NamedMatrix{Int64, Matrix{Int64}, Tuple{OrderedCollections.OrderedDict{Symbol, Int64}, OrderedCollections.OrderedDict{Symbol, Int64}}}, I::UnitRange{Int64})
   @ Base ./abstractarray.jl:1294
 [8] top-level scope
   @ REPL[5]:1
@davidavdav
Copy link
Owner

Thanks for finding this bug, for some reason it has to do with the type of the names being Symbol, which seems to be an edge case of some sort.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants