Skip to content

Approximate comparison between Vector{ComplexF64} and Vector{Number} fails on Julia 1.9 nightly #46650

@jagot

Description

@jagot

Discovered when running unit tests on nightly: https://github.com/jagot/MatrixPolynomials.jl/runs/8208663752?check_suite_focus=true#step:6:123

Works fine on e.g. Julia 1.8.

MWE:

julia> versioninfo()
Julia Version 1.9.0-DEV.1297
Commit cad4bc58b93 (2022-09-06 09:09 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin21.4.0)
  CPU: 8 × Intel(R) Core(TM) i7-7920HQ CPU @ 3.10GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-14.0.5 (ORCJIT, skylake)
  Threads: 1 on 8 virtual cores
Environment:
  JULIA_NIGHTLY = /Applications/Julia-0.7.app/Contents/Resources/julia/bin/julia

julia> using Test

julia> a = rand(ComplexF64, 10)
10-element Vector{ComplexF64}:
  0.5455316396314835 + 0.5871568741825269im
  0.1711560834205118 + 0.559313023279538im
 0.08048160770332391 + 0.02144583972400227im
 0.35451948668119837 + 0.38953512553886116im
  0.5988634140053631 + 0.9915552588562572im
  0.8140146155177268 + 0.03465175324289793im
  0.4024593106930263 + 0.9365910083425163im
  0.9779762769506364 + 0.21666079958127393im
  0.8915574012031455 + 0.5310056545199755im
  0.8216676230864705 + 0.4066094732379455im

julia> b = Vector{Number}(a)
10-element Vector{Number}:
  0.5455316396314835 + 0.5871568741825269im
  0.1711560834205118 + 0.559313023279538im
 0.08048160770332391 + 0.02144583972400227im
 0.35451948668119837 + 0.38953512553886116im
  0.5988634140053631 + 0.9915552588562572im
  0.8140146155177268 + 0.03465175324289793im
  0.4024593106930263 + 0.9365910083425163im
  0.9779762769506364 + 0.21666079958127393im
  0.8915574012031455 + 0.5310056545199755im
  0.8216676230864705 + 0.4066094732379455im

julia> @test a  b atol=1e-14
Error During Test at REPL[21]:1
  Test threw exception
  Expression: (a, b, atol = 1.0e-14)
  - not defined for ComplexF64
  Stacktrace:
    [1] error(::String, ::String, ::Type)
      @ Base ./error.jl:44
    [2] no_op_err(name::String, T::Type)
      @ Base ./promotion.jl:484
    [3] -(x::ComplexF64, y::ComplexF64)
      @ Base ./promotion.jl:487
    [4] _broadcast_getindex_evalf
      @ ./broadcast.jl:683 [inlined]
    [5] _broadcast_getindex
      @ ./broadcast.jl:656 [inlined]
    [6] getindex
      @ ./broadcast.jl:610 [inlined]
    [7] copy
      @ ./broadcast.jl:912 [inlined]
    [8] materialize
      @ ./broadcast.jl:873 [inlined]
    [9] broadcast_preserving_zero_d
      @ ./broadcast.jl:862 [inlined]
   [10] -(A::Vector{ComplexF64}, B::Vector{Number})
      @ Base ./arraymath.jl:8
   [11] isapprox(x::Vector{ComplexF64}, y::Vector{Number}; atol::Float64, rtol::Float64, nans::Bool, norm::typeof(LinearAlgebra.norm))
      @ LinearAlgebra /Applications/Julia-1.9.app/Contents/Resources/julia/share/julia/stdlib/v1.9/LinearAlgebra/src/generic.jl:1772
   [12] eval_test(evaluated::Expr, quoted::Expr, source::LineNumberNode, negate::Bool)
      @ Test /Applications/Julia-1.9.app/Contents/Resources/julia/share/julia/stdlib/v1.9/Test/src/Test.jl:332
   [13] top-level scope
      @ /Applications/Julia-1.9.app/Contents/Resources/julia/share/julia/stdlib/v1.9/Test/src/Test.jl:477
   [14] eval
      @ ./boot.jl:370 [inlined]
   [15] eval_user_input(ast::Any, backend::REPL.REPLBackend, mod::Module)
      @ REPL /Applications/Julia-1.9.app/Contents/Resources/julia/share/julia/stdlib/v1.9/REPL/src/REPL.jl:152
   [16] repl_backend_loop(backend::REPL.REPLBackend, get_module::Function)
      @ REPL /Applications/Julia-1.9.app/Contents/Resources/julia/share/julia/stdlib/v1.9/REPL/src/REPL.jl:248
   [17] start_repl_backend(backend::REPL.REPLBackend, consumer::Any; get_module::Function)
      @ REPL /Applications/Julia-1.9.app/Contents/Resources/julia/share/julia/stdlib/v1.9/REPL/src/REPL.jl:233
   [18] run_repl(repl::REPL.AbstractREPL, consumer::Any; backend_on_current_task::Bool)
      @ REPL /Applications/Julia-1.9.app/Contents/Resources/julia/share/julia/stdlib/v1.9/REPL/src/REPL.jl:372
   [19] run_repl(repl::REPL.AbstractREPL, consumer::Any)
      @ REPL /Applications/Julia-1.9.app/Contents/Resources/julia/share/julia/stdlib/v1.9/REPL/src/REPL.jl:357
   [20] (::Base.var"#1013#1015"{Bool, Bool, Bool})(REPL::Module)
      @ Base ./client.jl:421
   [21] #invokelatest#2
      @ ./essentials.jl:805 [inlined]
   [22] invokelatest
      @ ./essentials.jl:802 [inlined]
   [23] run_main_repl(interactive::Bool, quiet::Bool, banner::Bool, history_file::Bool, color_set::Bool)
      @ Base ./client.jl:405
   [24] exec_options(opts::Base.JLOptions)
      @ Base ./client.jl:322
   [25] _start()
      @ Base ./client.jl:522
ERROR: There was an error during testing

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions