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

Error when a NamedArray is indexed with a BitMatrix #41

Closed
diegozea opened this issue Oct 25, 2016 · 3 comments
Closed

Error when a NamedArray is indexed with a BitMatrix #41

diegozea opened this issue Oct 25, 2016 · 3 comments

Comments

@diegozea
Copy link
Contributor

Hi!
I found this error trying to index a bidimensional named array with a bidimensional bit array.

julia> mat = NamedArray(rand(1:10,2,3))
2×3 Named Array{Int64,2}
A ╲ B │  1   2   3
──────┼───────────
1     │  3   3   9
2     │ 10   1   4

julia> mask = mat .== 3
2×3 BitArray{2}:
  true   true  false
 false  false  false

julia> mat[mask]
ERROR: MethodError: no method matching NamedArrays.NamedArray{T,N,AT,DT}(::Array{Int64,1}, ::Tuple{Array{String,1},Array{String,1}}, ::Tuple{Symbol,Symbol})
Closest candidates are:
  NamedArrays.NamedArray{T,N,AT,DT}{T,N}(::AbstractArray{T,N}, ::Tuple{}, ::Tuple{Vararg{T,N}}) at /home/diego/.julia/v0.5/NamedArrays/src/constructors.jl:18
  NamedArrays.NamedArray{T,N,AT,DT}{T,N}(::AbstractArray{T,N}, ::Tuple{}) at /home/diego/.julia/v0.5/NamedArrays/src/constructors.jl:19
  NamedArrays.NamedArray{T,N,AT,DT}{T,N}(::AbstractArray{T,N}, ::Tuple{Vararg{DataStructures.OrderedDict,N}}) at /home/diego/.julia/v0.5/NamedArrays/src/constructors.jl:30
  ...
 in namedgetindex(::NamedArrays.NamedArray{Int64,2,Array{Int64,2},Tuple{DataStructures.OrderedDict{String,Int64},DataStructures.OrderedDict{String,Int64}}}, ::BitArray{2}) at /home/diego/.julia/v0.5/NamedArrays/src/index.jl:116
 in getindex(::NamedArrays.NamedArray{Int64,2,Array{Int64,2},Tuple{DataStructures.OrderedDict{String,Int64},DataStructures.OrderedDict{String,Int64}}}, ::BitArray{2}) at /home/diego/.julia/v0.5/NamedArrays/src/index.jl:11

julia> array(mat)[mask]
2-element Array{Int64,1}:
 3
 3

Best!

@davidavdav
Copy link
Owner

davidavdav commented Oct 26, 2016

For julia-0.5, this seems to be fixed with b6a3b1d for free. Could you check, please?

@davidavdav
Copy link
Owner

In fact, @timholy seems to have solved this for me in his clever PR #29, which has been merged now.

@davidavdav
Copy link
Owner

I suppose this can be closed now.

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