You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
will trigger TracerBoolConversionError due to the if/else clause in qutip.core.qobj.tr() (same goes for qutip.core.qobj.dag()).
See qutip.core.qobj:
def tr(self):
"""Trace of a quantum object.
Returns
-------
trace : float
Returns the trace of the quantum object.
"""
out = _data.trace(self._data)
# This ensures that trace can return something that is not a number such
# as a `tensorflow.Tensor` in qutip-tensorflow.
return out.real if (self.isherm
and hasattr(out, "real")
) else out
I understand that the subtraction operation diff = evo.final_state - qt.destroy(2, dtype="jax") might result in a non-Hermitian operator, so the value is not defined before runtime -> raising the error.
However, to me it seems that the if-else clause is not strictly necessary (I guess the reason for it, is performance of the tr() and dag() method).
Is there a way to prevent this within the jax-package or does that require changes in qutip.core.qobj?
The text was updated successfully, but these errors were encountered:
Thank you Eric, I guess it does not hurt to set diff._isherm = False for my problem (even if in some cases it might be Hermitian). Another workaround is to directly call diff.data.trace().
The issue raised the question, if it would be more sensible to put the if else clause into the datalayer implementation of tr (and e.g. dag).
The following code:
will trigger
TracerBoolConversionError
due to the if/else clause inqutip.core.qobj.tr()
(same goes forqutip.core.qobj.dag()
).See
qutip.core.qobj
:I understand that the subtraction operation
diff = evo.final_state - qt.destroy(2, dtype="jax")
might result in a non-Hermitian operator, so the value is not defined before runtime -> raising the error.However, to me it seems that the if-else clause is not strictly necessary (I guess the reason for it, is performance of the
tr()
anddag()
method).Is there a way to prevent this within the jax-package or does that require changes in
qutip.core.qobj
?The text was updated successfully, but these errors were encountered: