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

Change in element type of setdiff output from Julia 1.7 to 1.8 #46657

Open
mtfishman opened this issue Sep 6, 2022 · 4 comments
Open

Change in element type of setdiff output from Julia 1.7 to 1.8 #46657

mtfishman opened this issue Sep 6, 2022 · 4 comments

Comments

@mtfishman
Copy link
Contributor

In Julia 1.7 I see:

julia> setdiff([1, 2, 3], [1.0, 2.0])
1-element Vector{Int64}:
 3

julia> versioninfo()
Julia Version 1.7.3
Commit 742b9abb4d (2022-05-06 12:58 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Xeon(R) E-2176M  CPU @ 2.70GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-12.0.1 (ORCJIT, skylake)
Environment:
  JULIA_EDITOR = vim

while in Julia 1.8 I see:

julia> setdiff([1, 2, 3], [1.0, 2.0])
1-element Vector{Float64}:
 3.0

julia> versioninfo()
Julia Version 1.8.0
Commit 5544a0fab76 (2022-08-17 13:38 UTC)
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 6 × Intel(R) Xeon(R) E-2176M  CPU @ 2.70GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-13.0.1 (ORCJIT, skylake)
  Threads: 1 on 6 virtual cores
Environment:
  LD_PRELOAD = libgtk3-nocsd.so.0
  LD_LIBRARY_PATH = /usr/lib/x86_64-linux-gnu/libcutensor/11.1/:/opt/intel/compilers_and_libraries_2020.0.166/linux/tbb/lib/intel64_lin/gcc4.7:/opt/intel/compilers_and_libraries_2020.0.166/linux/compiler/lib/intel64_lin:/opt/intel/compilers_and_libraries_2020.0.166/linux/mkl/lib/intel64_lin::/home/mfishman/software/itensor/lib
  JULIA_EDITOR = vim

This broke some code in ITensors.jl which implicitly assumed the previous behavior. It's not hard to work around this and I'm not sure if there was an implied guarantee that this wouldn't change from version to version, I'm curious to hear if this was intended/what led to this change.

The behavior of 1.7 makes more sense to me since setdiff outputs the elements unique to the first input, so it seems like it should have the same element type as the first input.

@mtfishman mtfishman changed the title Change in output of element type of setdiff from Julia 1.7 to 1.8 Change in element type of setdiff output from Julia 1.7 to 1.8 Sep 6, 2022
@KristofferC
Copy link
Member

#45511

@Seelengrab
Copy link
Contributor

I don't have 1.7 installed, but I'm curious what you get for this:

julia> setdiff([1,2,3], Float64[1,2,3.1], ['a', 'b', 'c'])
1-element Vector{Any}:
 3

@mtfishman
Copy link
Contributor Author

On Julia 1.7 I get:

julia> setdiff([1,2,3], Float64[1,2,3.1], ['a', 'b', 'c'])
1-element Vector{Int64}:
 3

and on Julia 1.8 I get:

julia> setdiff([1,2,3], Float64[1,2,3.1], ['a', 'b', 'c'])
1-element Vector{Any}:
 3

@rfourquet
Copy link
Member

rfourquet commented Sep 7, 2022

This was changed in #41769. Fwiw, I think changing the eltype of the result was a mistake (#41769 (comment)).
You also now get things like

julia> intersect(BitSet(1:4), (x for x in 1:1))
Set{Any} with 1 element:
  1

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

No branches or pull requests

4 participants