QuantumBFS / YaoExtensions.jl

Useful extensions for Yao
Apache License 2.0
9 stars 3 forks source link

Test fails on upcoming 1.3 #5

Closed KristofferC closed 5 years ago

KristofferC commented 5 years ago

After https://github.com/JuliaLang/julia/pull/32122 the following behavior is different from 1.3 and 1.2

1.2:

julia> a = fill(1 + im)
0-dimensional Array{Complex{Int64},0}:
1 + 1im

julia> -a
-1 - 1im

1.3:

julia> a = fill(1 + im)
0-dimensional Array{Complex{Int64},0}:
1 + 1im

julia> -a
0-dimensional Array{Complex{Int64},0}:
-1 - 1im

This causes one of the tests here to fail with:

random diff circuit: Error During Test at /root/.julia/packages/YaoExtensions/VAbtx/test/CircuitBuild.jl:43
  Got exception outside of a @test
  MethodError: Cannot `convert` an object of type Array{Float64,0} to an object of type Float64
  Closest candidates are:
    convert(::Type{Float64}, !Matched::SymEngine.BasicType{Val{:RealDouble}}) at /root/.julia/packages/SymEngine/zSUGO/src/numerics.jl:35
    convert(::Type{Float64}, !Matched::SymEngine.Basic) at /root/.julia/packages/SymEngine/zSUGO/src/numerics.jl:179
    convert(::Type{T}, !Matched::SymEngine.Basic) where T<:Real at /root/.julia/packages/SymEngine/zSUGO/src/numerics.jl:184
    ...

The difference is that here:

https://github.com/QuantumBFS/YaoExtensions.jl/blob/2545ea2161d5820be0faa9871c16ce0b2e030e9a/src/Diff.jl#L201

g is a 0-dimensional array. In 1.2 this would get downgraded to a scalar while in 1.3 it keeps being a 0-d Array.