Skip to content
This repository has been archived by the owner on May 4, 2019. It is now read-only.

getindex broken when using multidimensional index of DataArray{Bool} #292

Open
omus opened this issue Oct 27, 2017 · 0 comments
Open

getindex broken when using multidimensional index of DataArray{Bool} #292

omus opened this issue Oct 27, 2017 · 0 comments

Comments

@omus
Copy link
Contributor

omus commented Oct 27, 2017

julia> using DataArrays

julia> da = @data [1 2; NA 4]
2×2 DataArrays.DataArray{Int64,2}:
 1    2
  NA  4

julia> mask = @data [true false; false true]
2×2 DataArrays.DataArray{Bool,2}:
  true  false
 false   true

julia> da[Array{Bool}(mask)]
2-element DataArrays.DataArray{Int64,1}:
 1
 4

julia> da[mask[:]]
2-element DataArrays.DataArray{Int64,1}:
 1
 4

julia> da[mask]
ERROR: MethodError: no method matching sub2ind(::Tuple{Int64,Int64}, ::CartesianIndex{2})
Closest candidates are:
  sub2ind(::AbstractArray, ::Any...) at abstractarray.jl:1537
  sub2ind(::Tuple{Vararg{Integer,N}} where N) at abstractarray.jl:1563
  sub2ind(::Tuple{Vararg{Integer,N}} where N, ::Integer...) at abstractarray.jl:1581
  ...
Stacktrace:
 [1] macro expansion at /Users/omus/.julia/v0.6/DataArrays/src/indexing.jl:140 [inlined]
 [2] macro expansion at ./cartesian.jl:64 [inlined]
 [3] macro expansion at /Users/omus/.julia/v0.6/DataArrays/src/indexing.jl:139 [inlined]
 [4] _unsafe_getindex! at /Users/omus/.julia/v0.6/DataArrays/src/indexing.jl:129 [inlined]
 [5] macro expansion at ./multidimensional.jl:460 [inlined]
 [6] _unsafe_getindex(::IndexLinear, ::DataArrays.DataArray{Int64,2}, ::Base.LogicalIndex{CartesianIndex{2},Array{Bool,2}}) at ./multidimensional.jl:453
 [7] macro expansion at ./multidimensional.jl:442 [inlined]
 [8] _getindex at ./multidimensional.jl:438 [inlined]
 [9] getindex(::DataArrays.DataArray{Int64,2}, ::DataArrays.DataArray{Bool,2}) at ./abstractarray.jl:882
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant