-
Notifications
You must be signed in to change notification settings - Fork 60
Usage of _iszero
, _isnotzero
#609
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
Comments
Should be ok in principle. Are you able to put a PR? |
I think it's probably worth reading the comments in #296, in short beware that -0 is a bit weird. |
Thx for the heads up 🙂. I'll make a PR, we can discuss the backporting procedure then. |
The purpose of this PR is to not call `==` directly, and use `_iszero` instead. This is to help integration with [IntervalArithmetic.jl](https://github.com/JuliaIntervals/IntervalArithmetic.jl) since `==` for our `Interval` type does not always return a Boolean. Closes #609. I did not change two checks using `===` since this would break the behaviour for `-0.0`.
I expect that you'll need to return |
Thanks for having a look at this issue. We do have SparseArrays as a weak dependency for the tentative 1.0 (JuliaIntervals/IntervalArithmetic.jl#698) which uses the |
The purpose of this PR is to not call `==` directly, and use `_iszero` instead. This is to help integration with [IntervalArithmetic.jl](https://github.com/JuliaIntervals/IntervalArithmetic.jl) since `==` for our `Interval` type does not always return a Boolean. Closes #609. I did not change two checks using `===` since this would break the behaviour for `-0.0`.
We are currently working on releasing the 1.0 version of IntervalArithmetic.jl (see JuliaIntervals/IntervalArithmetic.jl#698). One important decision we made is to be very strict with the usage of boolean comparison functions from Base. For instance,$[-1, 1]$ .
iszero(x::Interval)
throws ifx
contains zero but is not thin, likeI noticed that you have two internal functions
_iszero
and_isnotzero
which seems to be used only in the context "is the number exactly zero".I found (on 1.11, but maybe also true on 1.10) that this is not used everywhere, e.g.
https://github.com/JuliaSparse/SparseArrays.jl/blob/242035184c0d539bdb5e64bf26eb7726b123db14/src/sparsevector.jl#L2384C8-L2384C21
Is it possible to replace all instances of
x == zero(x)
(and similar) with_iszero
(or_isnotzero
) ? If so, could this be backported to 1.10 and 1.11 as well?The text was updated successfully, but these errors were encountered: