Skip to content

Commit c32cf7b

Browse files
committed
Deprecate isimag.
1 parent 7c34d69 commit c32cf7b

File tree

3 files changed

+6
-9
lines changed

3 files changed

+6
-9
lines changed

base/complex.jl

-6
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,6 @@ false
9090
"""
9191
isreal(x::Real) = true
9292
isreal(z::Complex) = iszero(imag(z))
93-
"""
94-
isimag(z) -> Bool
95-
96-
Test whether `z` is purely imaginary, i.e. has a real part equal to 0.
97-
"""
98-
isimag(z::Number) = iszero(real(z))
9993
isinteger(z::Complex) = isreal(z) & isinteger(real(z))
10094
isfinite(z::Complex) = isfinite(real(z)) & isfinite(imag(z))
10195
isnan(z::Complex) = isnan(real(z)) | isnan(imag(z))

base/deprecated.jl

+3
Original file line numberDiff line numberDiff line change
@@ -1276,6 +1276,9 @@ eval(SparseArrays, :(broadcast_zpreserving!(f, C::SparseMatrixCSC, A::Union{Arra
12761276
@deprecate getindex(t::Tuple, r::AbstractArray) getindex(t, vec(r))
12771277
@deprecate getindex(t::Tuple, b::AbstractArray{Bool}) getindex(t, vec(b))
12781278

1279+
# Deprecate isimag (#19947).
1280+
@deprecate isimag(z::Number) Base.iszero(real(z))
1281+
12791282
@deprecate airy(z::Number) airyai(z)
12801283
@deprecate airyx(z::Number) airyaix(z)
12811284
@deprecate airyprime(z::Number) airyaiprime(z)

test/complex.jl

+3-3
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,9 @@ end
147147
end
148148
end
149149

150-
@testset "isimag and isinf" begin
151-
@test isimag(complex(0.0,1.0))
152-
@test !isimag(complex(1.0,1.0))
150+
@testset "isinf" begin
151+
@test Base.iszero(real(complex(0.0,1.0))) # isimag deprecated
152+
@test !Base.iszero(real(complex(1.0,1.0))) # isimag deprecated
153153
@test isinf(complex(Inf,0))
154154
@test isinf(complex(-Inf,0))
155155
@test isinf(complex(0,Inf))

0 commit comments

Comments
 (0)