Skip to content

Commit

Permalink
Fix all/any for empty fill arrays (#158)
Browse files Browse the repository at this point in the history
* Fix all/any for empty fill arrays

* v0.12.4
  • Loading branch information
dlfivefifty authored Sep 10, 2021
1 parent 5e9019d commit 38898d4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
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 = "0.12.3"
version = "0.12.4"

[deps]
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Expand Down
8 changes: 4 additions & 4 deletions src/FillArrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

2 comments on commit 38898d4

@dlfivefifty
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/44648

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.12.4 -m "<description of version>" 38898d4a70737a7609b87dcef82e7b77656f4197
git push origin v0.12.4

Please sign in to comment.