Skip to content

Commit

Permalink
change function definition
Browse files Browse the repository at this point in the history
  • Loading branch information
rochisha0 committed Jul 17, 2024
1 parent e25e006 commit e4f8fbb
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions qutip/core/qobj.py
Original file line number Diff line number Diff line change
Expand Up @@ -798,17 +798,15 @@ def diag(self) -> np.ndarray:
out = np.real(out)
return out

def expm(self, dtype: LayerType = _data.Dense) -> Qobj:
def expm(self, dtype: LayerType = None) -> Qobj:
"""Matrix exponential of quantum operator.
Input operator must be square.
Parameters
----------
dtype : type
The data-layer type that should be output. As the matrix
exponential is almost dense, this defaults to outputting dense
matrices.
The data-layer type that should be output.
Returns
-------
Expand All @@ -822,8 +820,8 @@ def expm(self, dtype: LayerType = _data.Dense) -> Qobj:
"""
if not self._dims.issquare:
raise TypeError("expm is only valid for square operators")
if not isinstance(self.data, (_data.CSR, _data.Dia)):
dtype = None
if dtype is None and isinstance(self.data, (_data.CSR, _data.Dia)):
dtype = _data.Dense
return Qobj(_data.expm(self._data, dtype=dtype),
dims=self._dims,
isherm=self._isherm,
Expand Down

0 comments on commit e4f8fbb

Please sign in to comment.