Skip to content

Commit 6a513e2

Browse files
committed
Deprecate array-reducing isreal.
1 parent 7f74903 commit 6a513e2

10 files changed

+12
-15
lines changed

base/abstractarraymath.jl

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
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
6+
all{T<:Real}(::typeof(isreal), ::AbstractArray{T}) = true
87
all{T<:Integer}(::typeof(isinteger), ::AbstractArray{T}) = true
98
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.")
109
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.")

base/complex.jl

+1-4
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

+2-1
Original file line numberDiff line numberDiff line change
@@ -1504,8 +1504,9 @@ function frexp{T<:AbstractFloat}(A::Array{T})
15041504
return (F, E)
15051505
end
15061506

1507-
# Deprecate reducing isinteger over arrays
1507+
# Deprecate array-reducing isinteger and isreal
15081508
@deprecate isinteger(A::AbstractArray) all(isinteger, A)
1509+
@deprecate isreal(A::AbstractArray) all(isreal, A)
15091510

15101511
# Deprecate promote_eltype_op (#19814, #19937)
15111512
_promote_eltype_op(::Any) = Any

base/linalg/dense.jl

+1-1
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

+1-1
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

+1-1
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

+2-2
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

+1-1
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

+1-1
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

+1-1
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)