Skip to content
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

Fix in(x, ::RectDiagonal) #137

Merged
merged 1 commit into from
Feb 16, 2021
Merged
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 = "0.11.2"
version = "0.11.3"

[deps]
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Expand Down
43 changes: 0 additions & 43 deletions appveyor.yml

This file was deleted.

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