JuliaArrays/FillArrays.jl

getindex of Ones with Trues

JeffFessler opened this issue · 0 comments

I managed to hit a simple looking case that probably needs another getindex variation:

using FillArrays

x = Ones{Float32}(4,5) # 2D
b = Trues(length(x))
x[b] # works fine

y = Ones{Float32}(3) # 1D
c = Trues(length(y))
y[c] # fails


ERROR: LoadError: MethodError: getindex(::Ones{Float32, 1, Tuple{Base.OneTo{Int64}}}, ::Trues{1, Tuple{Base.OneTo{Int64}}}) is ambiguous. Candidates:
  getindex(x::AbstractArray{T, N}, mask::Ones{Bool, N, Tuple{Vararg{Base.OneTo{Int64}, N}}}) where {T, N} in FillArrays at /Users/fessler/.julia/packages/FillArrays/cVkp8/src/trues.jl:39
  getindex(A::FillArrays.AbstractFill, kr::AbstractVector{Bool}) in FillArrays at /Users/fessler/.julia/packages/FillArrays/cVkp8/src/FillArrays.jl:183
  getindex(A::FillArrays.AbstractFill, kr::AbstractArray{Bool, N} where N) in FillArrays at /Users/fessler/.julia/packages/FillArrays/cVkp8/src/FillArrays.jl:184
Possible fix, define
  getindex(::FillArrays.AbstractFill{T, 1, Axes} where Axes, ::Trues{1, Tuple{Base.OneTo{Int64}}}) where T

Closest related issue or PR I could find was this one: #33