From a7a37409db8d861b6ed1ff906aa61193736bf0d8 Mon Sep 17 00:00:00 2001 From: Sacha Verweij Date: Sat, 7 Jan 2017 15:29:25 -0800 Subject: [PATCH] Deprecate array-reducing isinteger. --- base/abstractarraymath.jl | 3 +-- base/deprecated.jl | 3 +++ base/number.jl | 5 +---- test/abstractarray.jl | 2 +- test/arrayops.jl | 2 +- 5 files changed, 7 insertions(+), 8 deletions(-) diff --git a/base/abstractarraymath.jl b/base/abstractarraymath.jl index 93135aed45faa..72eba80cfa3b1 100644 --- a/base/abstractarraymath.jl +++ b/base/abstractarraymath.jl @@ -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 ## diff --git a/base/deprecated.jl b/base/deprecated.jl index 07de11d104777..13d19d2601697 100644 --- a/base/deprecated.jl +++ b/base/deprecated.jl @@ -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))) diff --git a/base/number.jl b/base/number.jl index 303ab5cb460c5..5648ed651a944 100644 --- a/base/number.jl +++ b/base/number.jl @@ -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 diff --git a/test/abstractarray.jl b/test/abstractarray.jl index 2beb33da6895b..9e4de03aa0351 100644 --- a/test/abstractarray.jl +++ b/test/abstractarray.jl @@ -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 diff --git a/test/arrayops.jl b/test/arrayops.jl index a46d640b26a5a..b28fd3180a913 100644 --- a/test/arrayops.jl +++ b/test/arrayops.jl @@ -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)