-
-
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
Preserve the input element type in unique #23208
Conversation
Uh, what happened to AppVeyor? |
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.
:) !
Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. cc @ararslan |
Looks good to me – @JeffBezanson do you remember why it worked like this originally? Do we still want that logic for iterators or something, i.e. the case where we don't know the element type? |
Bump @JeffBezanson |
test/sets.jl
Outdated
@test unique(x for x in Any[1,1.0])::Vector{Real} == [1] | ||
@test unique(x for x in Any[1,1.0])::Vector{Any} == [1] | ||
@test unique(x for x in Real[1,1.0])::Vector{Real} == [1] | ||
@test eltype(unique(Integer[1,1,2])) === Integer |
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.
@test unique(Integer[1,1,2])::Vector{Integer} == [1,2]
to test type and result? :)
4662687
to
c9ade2a
Compare
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.
lgtm for the touch ups! :)
This should call |
Will do, thanks Jeff. Should that check be in place of the |
The check can be |
c9ade2a
to
fe45a28
Compare
Timeouts and |
fe45a28
to
56e5fdc
Compare
Anyone have advice on the CI failures? |
Hmm, I can reproduce the stalling locally. |
56e5fdc
to
7b83a36
Compare
When running in LLDB, I'm getting a SIGINT in the core tests built from this branch. LLDB session here: https://gist.github.com/ararslan/da7e7e0cfc2adb9ca40777d17cf75b9e. |
Okay, I've figured out what's happening now. julia> U = Union{Int8, UInt8, Int16, UInt16, Int32, UInt32, Int64, UInt64, Int128, UInt128}
Union{Int128, Int16, Int32, Int64, Int8, UInt128, UInt16, UInt32, UInt64, UInt8}
julia> F = Base.uniontypes(U)[2]
Int16
julia> A = U[rand(F(1):F(10)) for i = 1:10]
10-element Array{Union{Int128, Int16, Int32, Int64, Int8, UInt128, UInt16, UInt32, UInt64, UInt8},1}:
6
5
7
5
1
1
9
1
2
1
julia> unique(A) # freezes It freezes because now it hits a different code path. In this PR, |
Luckily, we seem to already have a fix for this over on #23367 julia> U = Union{Int8, UInt8, Int16, UInt16, Int32, UInt32, Int64, UInt64, Int128, UInt128}
Union{Int128, Int16, Int32, Int64, Int8, UInt128, UInt16, UInt32, UInt64, UInt8}
julia> F = Base.uniontypes(U)[2]
Int16
julia> A = U[rand(F(1):F(10)) for i = 1:10]
10-element Array{Union{Int128, Int16, Int32, Int64, Int8, UInt128, UInt16, UInt32, UInt64, UInt8},1}:
3
10
2
7
10
5
9
9
2
1
julia> unique(A)
7-element Array{Int16,1}:
3
10
2
7
5
9
1 |
Thanks, Jacob! In your example, is |
I checked out your |
Previously the element type of the output was the smallest type that would fit the union of the input's individual element types. Now the output has an identical element type to the input. Fixes #22696.
Jacob has noted that the issue is likely #22688 |
7b83a36
to
2f966e0
Compare
Okay, I've worked around the issue causing the core test to choke. Is this okay now? |
Previously the element type of the output was the smallest type that would fit the union of the input's individual element types. Now the output has an identical element type to the input.
Fixes #22696.
@nanosoldier
runbenchmarks(ALL, vs=":master")