Skip to content

Commit 77cd9f1

Browse files
authored
Use values in iszero (#635)
* Use values in iszero * Special case empty coeff vectors * Check for zero coefficients first * Fix typo
1 parent 9e06124 commit 77cd9f1

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/Fun.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,7 @@ isapprox(g::Number, f::Fun; kw...) = isapprox(g*ones(space(f)), f; kw...)
773773
isreal(f::Fun{<:RealSpace,<:Real}) = true
774774
isreal(f::Fun) = false
775775

776-
iszero(f::Fun) = all(iszero,f.coefficients)
776+
iszero(f::Fun) = all(iszero, coefficients(f)) || all(iszero, values(f))
777777

778778
# Deliberately not named isconst or isconstant to avoid conflicts with Base or DomainSets
779779
isconstantfun(f::Fun) = iszero(f - first(f))

test/SpacesTest.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,11 @@ using Test
208208
F = Fun{typeof(PointSpace(1:3)), Float32}
209209
@test ApproxFunBase.cfstype(F) == Float32
210210
end
211+
212+
@testset "isconstantfun" begin
213+
f = Fun(PointSpace(1:4), ones(4))
214+
@test ApproxFunBase.isconstantfun(f)
215+
end
211216
end
212217

213218
@testset "DiracSpace" begin

0 commit comments

Comments
 (0)