Allow pointwise equality #604
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I gained a better feeling of all the changes we made in v0.22 after updating a bunch of code I have.
One recurrent and painful item was dealing with
iszero
andisone
, which both @lbenet and @timholy raised concerns about. For instance, in PR #586, the removal ofiszero
broke ForwardDiff compatibility. At the time, I felt that this was not so bad since there was a potential hook.Yet, I also realised that this also breaks SparseArrays which is presumably much more difficult to fix (it does not seem realistic to ask the entire ecosystem to provide us for a hook...). E.g
Additionally, because
iszero
andisone
are pointwise by nature, they can not yield ambiguous answers: the interval is, or not, a zero/one singleton.This is in stark contrast with other boolean operations which are rightfully disallowed; to illustrate:
<
also implies some ordering, which may lead to ambiguous answersisfinite
may be ambiguous depending on the flavour (but could be brought back by using @Kolaru's flavour mechanism...)isnan
conflicts withisnai
Therefore, I am proposing to bring back
iszero
andisone
. Moreover, our functionisthin(::Interval, ::Number)
is by definition just a generalisation ofisthinzero
andisthinone
for anyNumber
. Thus,==(::Interval, ::Number)
is safe ifiszero
andisone
are considered safe.Lastly, I think that
isinteger
is also safe since integers are necessarily finite.Note
I think this is not a breaking PR as
isthinzero
/isthinone
/isthin
/isthininteger
would still be defined and exported.However, if we do end up liking these changes by the end of 0.22; I think we ought to remove
isthinzero
/isthinone
/isthin
/isthininteger
for the 1.0 release as we should not have distinct functions do the same operation.