Skip to content

Commit

Permalink
Merge branch 'qutip:master' into steadystate_floque_checks
Browse files Browse the repository at this point in the history
  • Loading branch information
nwlambert authored Apr 13, 2024
2 parents d601702 + 601da4a commit 87e7ba5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions doc/changes/2371.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
The import statement was added to import the partial_transpose function directly from the qutip module. This was done to fix the TypeError: 'module' object is not callable error.

Added a condition that check if the input rho is a ket (a type of quantum state) and it also ensures that the negativity function can handle both kets and density operators as input.
6 changes: 5 additions & 1 deletion qutip/entropy.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

from numpy import conj, e, inf, imag, inner, real, sort, sqrt
from numpy.lib.scimath import log, log2
from . import (ptrace, ket2dm, tensor, sigmay, partial_transpose,
from .partial_transpose import partial_transpose
from . import (ptrace, tensor, sigmay, ket2dm,
expand_operator)
from .core import data as _data

Expand Down Expand Up @@ -129,6 +130,8 @@ def negativity(rho, subsys, method='tracenorm', logarithmic=False):
Experimental.
"""
if rho.isket or rho.isbra:
rho = ket2dm(rho)
mask = [idx == subsys for idx, n in enumerate(rho.dims[0])]
rho_pt = partial_transpose(rho, mask)

Expand All @@ -140,6 +143,7 @@ def negativity(rho, subsys, method='tracenorm', logarithmic=False):
else:
raise ValueError("Unknown method %s" % method)

# Return the negativity value (or its logarithm if specified)
if logarithmic:
return log2(2 * N + 1)
else:
Expand Down

0 comments on commit 87e7ba5

Please sign in to comment.