Skip to content

Commit

Permalink
fix in(x, ::RectDiagonal) (#137)
Browse files Browse the repository at this point in the history
Co-authored-by: Sheehan Olver <solver@mac.com>
  • Loading branch information
jishnub and dlfivefifty authored Feb 16, 2021
1 parent b941f64 commit 708b830
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 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.11.2"
version = "0.11.3"

[deps]
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Expand Down
6 changes: 5 additions & 1 deletion src/FillArrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,11 @@ count(f, x::AbstractFill) = f(getindex_value(x)) ? length(x) : 0
# in
#########
in(x, A::AbstractFill) = x == getindex_value(A)
in(x, A::RectDiagonal) = iszero(x) || x in A.diag
function in(x, A::RectDiagonal{<:Number})
any(iszero, size(A)) && return false # Empty matrix
all(isone, size(A)) && return x == A.diag[1] # A 1x1 matrix has only one element
x == zero(eltype(A)) || x in A.diag
end

include("fillalgebra.jl")
include("fillbroadcast.jl")
Expand Down
13 changes: 13 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,20 @@ import FillArrays: AbstractFill, RectDiagonal, SquareEye
end
A = FillArrays.RectDiagonal([1, 2, 3])
@test 3 in A
@test 0 in A
@test !(4 in A)
A = FillArrays.RectDiagonal([1])
@test 1 in A
@test !(0 in A)
A = FillArrays.RectDiagonal([2], (1:1, 1:4))
@test 2 in A
@test 0 in A
@test !(1 in A)
@test !(Zeros(1,1) in A)
A = FillArrays.RectDiagonal(Int[])
@test !(0 in A)
A = FillArrays.RectDiagonal(Int[], (1:0, 1:4))
@test !(0 in A)
end
end

Expand Down

2 comments on commit 708b830

@dlfivefifty
Copy link
Member

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/30159

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.11.3 -m "<description of version>" 708b830498df63b9d005bc0906abee559545f9ac
git push origin v0.11.3

Please sign in to comment.