Skip to content
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

Usage of _iszero, _isnotzero #609

Open
OlivierHnt opened this issue Mar 16, 2025 · 3 comments · May be fixed by #610
Open

Usage of _iszero, _isnotzero #609

OlivierHnt opened this issue Mar 16, 2025 · 3 comments · May be fixed by #610

Comments

@OlivierHnt
Copy link

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, iszero(x::Interval) throws if x contains zero but is not thin, like $[-1, 1]$.

I 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?

@ViralBShah
Copy link
Member

Should be ok in principle. Are you able to put a PR?

@SobhanMP
Copy link
Member

I think it's probably worth reading the comments in #296, in short beware that -0 is a bit weird.

@OlivierHnt
Copy link
Author

Thx for the heads up 🙂. I'll make a PR, we can discuss the backporting procedure then.

@OlivierHnt OlivierHnt linked a pull request Mar 17, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants