-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
deprecate array-reducing isinteger #19925
Conversation
@@ -2,8 +2,6 @@ | |||
|
|||
## Basic functions ## | |||
|
|||
isinteger(x::AbstractArray) = all(isinteger,x) | |||
isinteger{T<:Integer,n}(x::AbstractArray{T,n}) = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With this change, we will lose this optimization. It seems to be blocked by the bounds check in all
; adding @inbounds
to all
allows the loop to be optimized away.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might want to add
all{T<:Integer}(::typeof(isinteger), ::AbstractArray{T}) = true
all{T<:Real}(::typeof(isreal), ::AbstractArray{T}) = true
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As opposed or in addition to decorating all
with @inbounds
as you suggest above? Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think adding @inbounds
to all
is not safe unless we add a specialization for Array
(where we know iteration never goes out of bounds).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Specializations added. Thanks!
Also |
Re. |
There seems to be a good argument to keep
|
Added one commit deprecating vectorized |
Should |
Per the docstring ( |
If |
It seems misleading to me to claim |
Saying "0 is an imaginary number" seems mildly crazy to me, but then again I'm not sure what this function is even for. There are no uses in Base. Are there example use cases that clarify which behavior would be desired? |
Also @Sacha0 you'll probably want to move the |
Sounds wise. Dropping the last commit and opening an issue re. |
Last commit dropped and issue #19947 opened. Are the vectorized |
Upon reflection, I don't think we should deprecate
|
I separated the array-reducing |
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 | ||
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.") | ||
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.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bump for rebase. I think these two fallbacks are gone on master? or just moved, not positive
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rebased. Thanks!
Thanks all! |
This pull request deprecates array-reducing
isinteger(A::AbstractArray)
in favor ofall(isinteger, A)
(edit: likewiseisreal
). Discussion: #19674 (comment), #19598 (comment), and #19598 (comment). (Edit: Also fixesisimag
for real numbers that are zero.) Best!