Skip to content

Commit

Permalink
Merge pull request qutip#2507 from rochisha0/fix-entr
Browse files Browse the repository at this point in the history
Change `clip` to `where`
  • Loading branch information
Ericgig authored Aug 9, 2024
2 parents 234f26b + 6743fc1 commit 682a3c1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions doc/changes/2507.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
`clip` gives deprecation warning, that might be a problem in the future. Hence switch to `where`
3 changes: 2 additions & 1 deletion qutip/entropy.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ def entropy_vn(rho, base=np.e, sparse=False):
if rho.type == 'ket' or rho.type == 'bra':
rho = ket2dm(rho)
vals = rho.eigenenergies(sparse=sparse)
nzvals = np.clip(vals, 1e-17, None)
threshold = 1e-17
nzvals = np.where(vals < threshold, threshold, vals)
if base == 2:
logvals = np.log2(nzvals)
elif base == np.e:
Expand Down

0 comments on commit 682a3c1

Please sign in to comment.