diff --git a/Project.toml b/Project.toml index 97090f04..5e6514fd 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "FillArrays" uuid = "1a297f60-69ca-5386-bcde-b61e274b549b" -version = "0.12.3" +version = "0.12.4" [deps] LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" diff --git a/src/FillArrays.jl b/src/FillArrays.jl index 56f580e6..412ce7c0 100644 --- a/src/FillArrays.jl +++ b/src/FillArrays.jl @@ -574,10 +574,10 @@ end # In particular, these make iszero(Eye(n)) efficient. # use any/all on scalar to get Boolean error message -any(f::Function, x::AbstractFill) = any(f(getindex_value(x))) -all(f::Function, x::AbstractFill) = all(f(getindex_value(x))) -any(x::AbstractFill) = any(getindex_value(x)) -all(x::AbstractFill) = all(getindex_value(x)) +any(f::Function, x::AbstractFill) = isempty(x) || any(f(getindex_value(x))) +all(f::Function, x::AbstractFill) = isempty(x) || all(f(getindex_value(x))) +any(x::AbstractFill) = isempty(x) || any(getindex_value(x)) +all(x::AbstractFill) = isempty(x) || all(getindex_value(x)) count(x::Ones{Bool}) = length(x) count(x::Zeros{Bool}) = 0 diff --git a/test/runtests.jl b/test/runtests.jl index 424c6672..d506c4c0 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -966,6 +966,9 @@ end @test any(Zeros{Bool}(10)) === all(Zeros{Bool}(10)) === any(Fill(false,10)) === all(Fill(false,10)) === false @test all(b -> ndims(b) == 1, Fill([1,2],10)) @test any(b -> ndims(b) == 1, Fill([1,2],10)) + + @test all(Fill(2,0)) + @test any(Fill(2,0)) end @testset "Error" begin