-
-
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
1 < missing < 3
fails
#31171
Comments
The syntax has short-circuiting semantics [1] (i.e. the upper bound doesn't get evaluated if the first condition fails. Of course there could be some special exception for [1] i.e. |
It explains this: julia> missing < 1 < 3
ERROR: TypeError: non-boolean (Missing) used in boolean context
Stacktrace:
[1] top-level scope at none:0
julia> 3 > 1 > missing
missing |
I agree it would be nice if this worked. For example a typical pattern would be But we probably don't want to special-case missing, so we would have to use |
FWIW this already works: julia> 2 .< missing .< 3
missing |
Triage discussed this for quite a while, and none of the options for implementing this are that appealing. We did not come to a conclusion in this discussion. Some of the options discussed were:
Speaking on behalf of myself (not of triage), I think I'm beginning to favor doing nothing here. This may be one of the cases where users should be wary of missing values and use explicit |
I had proposed the following lowering of
|
I didn't quite catch it on the call; why is the last |
It at least requires the thing you return to support |
I get that, but it feels strange to me since we don't call
That said, I'm not wholly convinced we actually need to do something here. @nalimilan's filtering example would be compelling, except that |
Not sure what you mean, could you elaborate? |
Why? We force the LHS to return a boolean now, but not the RHS |
There are two ways of using the result from
It just gets back to my "what's the point" question. If it's to emulate |
For the sake of concreteness: IntervalSets.jl didn't support in(v, I::TypedEndpointsInterval{:closed,:closed}) = leftendpoint(I) ≤ v ≤ rightendpoint(I)
in(v, I::TypedEndpointsInterval{:open,:open}) = leftendpoint(I) < v < rightendpoint(I)
in(v, I::TypedEndpointsInterval{:closed,:open}) = leftendpoint(I) ≤ v < rightendpoint(I)
in(v, I::TypedEndpointsInterval{:open,:closed}) = leftendpoint(I) < v ≤ rightendpoint(I) would have worked fine already if this issue was fixed, but I had to add other methods to make it work: in(::Missing, I::TypedEndpointsInterval{:closed,:closed}) = !isempty(I) && missing
in(::Missing, I::TypedEndpointsInterval{:open,:open}) = !isempty(I) && missing
in(::Missing, I::TypedEndpointsInterval{:closed,:open}) = !isempty(I) && missing
in(::Missing, I::TypedEndpointsInterval{:open,:closed}) = !isempty(I) && missing It's not the end of the world of course. It does raise the issue of whether |
Sorry, my example with |
This is a really good point. If we're going to go out of our way to handle |
I can't imagine returning anything other than |
Nope, he elected to return |
Ah, my bad, I hadn't realized the order of |
If we give up on the short-circuiting behaviour, couldn't |
|
Should be
missing
, no?The text was updated successfully, but these errors were encountered: