Skip to content

Commit 95072cd

Browse files
committed
Deprecate array-reducing isreal.
1 parent 11bc347 commit 95072cd

10 files changed

+11
-15
lines changed

base/abstractarraymath.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22

33
## Basic functions ##
44

5-
isreal(x::AbstractArray) = all(isreal,x)
65
iszero(x::AbstractArray) = all(iszero,x)
7-
isreal{T<:Real,n}(x::AbstractArray{T,n}) = true
86
ctranspose(a::AbstractArray) = error("ctranspose not implemented for $(typeof(a)). Consider adding parentheses, e.g. A*(B*C') instead of A*B*C' to avoid explicit calculation of the transposed matrix.")
97
transpose(a::AbstractArray) = error("transpose not implemented for $(typeof(a)). Consider adding parentheses, e.g. A*(B*C.') instead of A*B*C' to avoid explicit calculation of the transposed matrix.")
108

base/complex.jl

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,11 @@ real{T<:Real}(::Type{Complex{T}}) = T
7878
"""
7979
isreal(x) -> Bool
8080
81-
Test whether `x` or all its elements are numerically equal to some real number.
81+
Test whether `x` is numerically equal to some real number.
8282
8383
```jldoctest
8484
julia> isreal(5.)
8585
true
86-
87-
julia> isreal([4.; complex(0,1)])
88-
false
8986
```
9087
"""
9188
isreal(x::Real) = true

base/deprecated.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1496,8 +1496,9 @@ function frexp{T<:AbstractFloat}(A::Array{T})
14961496
return (F, E)
14971497
end
14981498

1499-
# Deprecate reducing isinteger over arrays
1499+
# Deprecate array-reducing isinteger and isreal
15001500
@deprecate isinteger(A::AbstractArray) all(isinteger, A)
1501+
@deprecate isreal(A::AbstractArray) all(isreal, A)
15011502

15021503
# Calling promote_op is likely a bad idea, so deprecate its convenience wrapper promote_eltype_op
15031504
@deprecate promote_eltype_op(op, As...) promote_op(op, map(eltype, As)...)

base/linalg/dense.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ function logm(A::StridedMatrix)
509509
end
510510
end
511511

512-
if isreal(A) && ~np_real_eigs
512+
if all(isreal, A) && ~np_real_eigs
513513
return real(retmat)
514514
else
515515
return retmat

base/linalg/diagonal.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ end
101101
parent(D::Diagonal) = D.diag
102102

103103
ishermitian{T<:Real}(D::Diagonal{T}) = true
104-
ishermitian(D::Diagonal) = isreal(D.diag)
104+
ishermitian(D::Diagonal) = all(isreal, D.diag)
105105
issymmetric(D::Diagonal) = true
106106
isposdef(D::Diagonal) = all(x -> x > 0, D.diag)
107107

base/linalg/eigen.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function getindex(A::Union{Eigen,GeneralizedEigen}, d::Symbol)
2323
throw(KeyError(d))
2424
end
2525

26-
isposdef(A::Union{Eigen,GeneralizedEigen}) = isreal(A.values) && all(x -> x > 0, A.values)
26+
isposdef(A::Union{Eigen,GeneralizedEigen}) = all(isreal, A.values) && all(x -> x > 0, A.values)
2727

2828
"""
2929
eigfact!(A, [B])

base/linalg/symmetric.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,9 @@ end
169169

170170
ishermitian(A::Hermitian) = true
171171
ishermitian{T<:Real,S}(A::Symmetric{T,S}) = true
172-
ishermitian{T<:Complex,S}(A::Symmetric{T,S}) = isreal(A.data)
172+
ishermitian{T<:Complex,S}(A::Symmetric{T,S}) = all(isreal, A.data)
173173
issymmetric{T<:Real,S}(A::Hermitian{T,S}) = true
174-
issymmetric{T<:Complex,S}(A::Hermitian{T,S}) = isreal(A.data)
174+
issymmetric{T<:Complex,S}(A::Hermitian{T,S}) = all(isreal, A.data)
175175
issymmetric(A::Symmetric) = true
176176
transpose(A::Symmetric) = A
177177
ctranspose{T<:Real}(A::Symmetric{T}) = A

base/linalg/triangular.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1828,7 +1828,7 @@ logm(A::LowerTriangular) = logm(A.').'
18281828
function sqrtm{T}(A::UpperTriangular{T})
18291829
n = checksquare(A)
18301830
realmatrix = false
1831-
if isreal(A)
1831+
if all(isreal, A)
18321832
realmatrix = true
18331833
for i = 1:n
18341834
if real(A[i,i]) < 0

test/abstractarray.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -748,7 +748,7 @@ end
748748

749749
# isinteger and isreal
750750
@test all(isinteger, Diagonal(rand(1:5, 5))) # reducing isinteger(...) deprecated
751-
@test isreal(Diagonal(rand(5)))
751+
@test all(isreal, Diagonal(rand(5))) # reducing isreal(...) deprecated
752752

753753
# unary ops
754754
let A = Diagonal(rand(1:5,5))

test/linalg/cholesky.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ for eltya in (Float32, Float64, Complex64, Complex128, BigFloat, Int)
129129
cpapd = cholfact(apd, :U, Val{true})
130130
@test rank(cpapd) == n
131131
@test all(diff(diag(real(cpapd.factors))).<=0.) # diagonal should be non-increasing
132-
if isreal(apd)
132+
if all(isreal, apd)
133133
@test apd*inv(cpapd) eye(n)
134134
end
135135
@test full(cpapd) apd

0 commit comments

Comments
 (0)