Skip to content

Commit

Permalink
Deprecate array-reducing isinteger.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sacha0 committed Jan 14, 2017
1 parent 4186749 commit a7a3740
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 8 deletions.
3 changes: 1 addition & 2 deletions base/abstractarraymath.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@

## Basic functions ##

isinteger(x::AbstractArray) = all(isinteger,x)
isinteger{T<:Integer,n}(x::AbstractArray{T,n}) = true
isreal(x::AbstractArray) = all(isreal,x)
iszero(x::AbstractArray) = all(iszero,x)
isreal{T<:Real,n}(x::AbstractArray{T,n}) = true
all{T<:Integer}(::typeof(isinteger), ::AbstractArray{T}) = true

## Constructors ##

Expand Down
3 changes: 3 additions & 0 deletions base/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1541,6 +1541,9 @@ function frexp{T<:AbstractFloat}(A::Array{T})
return (F, E)
end

# Deprecate reducing isinteger over arrays
@deprecate isinteger(A::AbstractArray) all(isinteger, A)

# Deprecate promote_eltype_op (#19814, #19937)
_promote_eltype_op(::Any) = Any
_promote_eltype_op(op, A) = (@_inline_meta; promote_op(op, eltype(A)))
Expand Down
5 changes: 1 addition & 4 deletions base/number.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@
"""
isinteger(x) -> Bool
Test whether `x` or all its elements are numerically equal to some integer.
Test whether `x` is numerically equal to some integer.
```jldoctest
julia> isinteger(4.0)
true
julia> isinteger([1; 2; 5.5])
false
```
"""
isinteger(x::Integer) = true
Expand Down
2 changes: 1 addition & 1 deletion test/abstractarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,7 @@ let
end

# isinteger and isreal
@test isinteger(Diagonal(rand(1:5,5)))
@test all(isinteger, Diagonal(rand(1:5, 5))) # reducing isinteger(...) deprecated
@test isreal(Diagonal(rand(5)))

# unary ops
Expand Down
2 changes: 1 addition & 1 deletion test/arrayops.jl
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ end
X = get(A, -5:5, NaN32)
@test eltype(X) == Float32
@test Base.elsize(X) == sizeof(Float32)
@test !isinteger(X)
@test !all(isinteger, X)
@test isnan.(X) == [trues(6);falses(5)]
@test X[7:11] == [1:5;]
X = get(A, (2:4, 9:-2:-13), 0)
Expand Down

0 comments on commit a7a3740

Please sign in to comment.