Skip to content

Specialize checkindex for an AbstractFill index #411

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "FillArrays"
uuid = "1a297f60-69ca-5386-bcde-b61e274b549b"
version = "1.14.0"
version = "1.15.0"

[deps]
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Expand Down
3 changes: 3 additions & 0 deletions src/FillArrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -885,6 +885,9 @@ function repeat(A::AbstractFill; inner=ntuple(x->1, ndims(A)), outer=ntuple(x->1
_repeat(A, inner=inner, outer=outer)
end

Base.checkindex(::Type{Bool}, inds::AbstractUnitRange, I::AbstractFill) = Base.checkindex(Bool, inds, getindex_value(I))
Base.checkindex(::Type{Bool}, inds::AbstractUnitRange, I::AbstractFill{Bool}) = axes(I,1) == inds

include("oneelement.jl")

end # module
7 changes: 7 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,13 @@ end
@test StepRangeLen(z) ≡ convert(StepRangeLen, z) ≡ convert(StepRangeLen{Int}, z) ≡ convert(typeof(s), z) ≡ convert(AbstractRange, z) ≡ s
end
end

@testset "checkindex with an AbstractFill index" begin
@test Base.checkindex(Bool, 1:5, Fill(2, 3))
@test !Base.checkindex(Bool, 1:5, Fill(0, 3))
@test Base.checkindex(Bool, 1:5, Fill(true, 5))
@test !Base.checkindex(Bool, 1:5, Fill(true, 2))
end
end

@testset "RectDiagonal" begin
Expand Down
Loading