Skip to content

Commit

Permalink
polish warning message
Browse files Browse the repository at this point in the history
  • Loading branch information
GiggleLiu committed May 13, 2024
1 parent c92e55e commit 15f2866
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/YaoBlocks/src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ Base.vec(et::EntryTable) = Vector(et)
function safe_real(x::Complex{T}) where T
img = imag(x)
if !iszero(img) && !(hasmethod(eps, Tuple{Type{T}}) && isapprox(x - im*img, x; rtol=10*eps(T), atol=10*eps(T)))
@warn "Convert number $x to real is unsafe due to the nonzero imaginary part: $img. Maybe you want to use `sandwich` function?"
@warn "Convert number $x to real is unsafe due to the nonzero imaginary part: $img. Maybe you want to use the `sandwich` function?"
end
return real(x)
end
Expand Down

0 comments on commit 15f2866

Please sign in to comment.