qutip / QuantumToolbox.jl

Quantum Toolbox in Julia
https://qutip.org/QuantumToolbox.jl/
BSD 3-Clause "New" or "Revised" License
46 stars 16 forks source link

Handle `tidyup` separately for real and imaginary values #183

Closed ytdHuang closed 4 months ago

ytdHuang commented 4 months ago

This PR calls tidyup! inside tidyup, namely

tidyup(A, tol) = tidyup!(copy(A), tol)

Also, use multiple dispatch for different element types T<:Real or T<:Complex for function tidyup!:

If T<:Real, then use the origin method:

@. A = T(abs(A) > tol) * A

If T<:Complex, then use the following method:

@. A = T(abs(real(A)) > tol) * real(A) + 1im * T(abs(imag(A)) > tol) * imag(A)
codecov[bot] commented 4 months ago

Codecov Report

Attention: Patch coverage is 85.71429% with 1 line in your changes missing coverage. Please review.

Project coverage is 93.33%. Comparing base (731e26f) to head (f307cd6).

Files Patch % Lines
src/qobj/arithmetic_and_attributes.jl 85.71% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #183 +/- ## ========================================== - Coverage 93.37% 93.33% -0.04% ========================================== Files 28 28 Lines 2098 2101 +3 ========================================== + Hits 1959 1961 +2 - Misses 139 140 +1 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.