-
-
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
Define OrderStyle
for Union{}
#36810
Conversation
Removes ambiguity: ``` julia> Base.OrderStyle(Union{}) ERROR: MethodError: Base.OrderStyle(::Type{Union{}}) is ambiguous. Candidates: ``` This error is relevant as with current `unique!` definition that relies on `OrderStyle` one can have a problem in corner cases. E.g.: ``` julia> [i for i in ["1"] if i isa Int] 0-element Array{Union{},1} ``` I propose to make this case `Unordered()` as probably this was the intention of the original implementation, but probably it does not matter much which option is chosen.
Actually maybe |
@nalimilan - I cannot see your comment I got via e-mail, but I can answer it. Initially I thought to use |
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 guess Ordered()
is OK since issorted(Union{}[])
is true.
Also my question is - what is the exact meaning of this trait? Should it be related to |
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.
Thanks @bkamins!
I'd merge this as-is except that I see it's been marked for triage.
What's there to triage here @ararslan? |
Good question. There's no unique answer, but I'd take "whatever |
Good point. Maybe let's change this in another PR to avoid holding this one back? |
OK - I will open a separate PR for this when this is merged. |
Bump @ararslan, does this actually need triage? |
Thanks as always, @bkamins ! |
@nalimilan, so before opening a PR, maybe let us discuss if we want to add
This will not be used much probably (so we could ignore the fact that we do not have this trait for them), but for consistency it would be cleaner to have it. I am not sure what is best (I am leaning towards leaving things as is and that is why I am commenting here and not opening a PR) |
I agree that it seems the trait should be defined for all types that support |
@ararslan - is this going to be backported into Julia 1.5.1 release? |
This didn't have a backport label so it was not included in 1.5.1. |
I know, but the original discussion was to backport it it - and that is why I am asking. My question is if then the plan is to have it backported to 1.5 at some point or it will be in 1.6. |
Tentatively adding the backport label so that at least it's considered for 1.5.2. |
Removes ambiguity: ``` julia> Base.OrderStyle(Union{}) ERROR: MethodError: Base.OrderStyle(::Type{Union{}}) is ambiguous. Candidates: ``` This error is relevant as with current `unique!` definition that relies on `OrderStyle` one can have a problem in corner cases. E.g.: ``` julia> [i for i in ["1"] if i isa Int] 0-element Array{Union{},1} ``` Co-authored-by: Milan Bouchet-Valat <nalimilan@club.fr> (cherry picked from commit 03e1a89)
Removes ambiguity:
This error is relevant as with current
unique!
definition that relies onOrderStyle
one can have a problem in corner cases. E.g.:I propose to make this case
Unordered()
as probably this was the intention of the original implementation, but probably it does not matter much which option is chosen.