Skip to content

Commit

Permalink
Use CSR as default for expand_operator
Browse files Browse the repository at this point in the history
Transform the qobj to CSR only if it is Dense, incase more data types are introduced in the future.
  • Loading branch information
BoxiLi committed Dec 18, 2023
1 parent 0a7cf78 commit 56d2766
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/qutip_qip/operations/gates.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import numbers
from packaging.version import parse as parse_version
from collections.abc import Iterable
from itertools import product
from functools import partial, reduce
Expand Down Expand Up @@ -1276,6 +1277,9 @@ def expand_operator(
[0. 0. 0. 0. 0. 0. 1. 0.]
[0. 0. 0. 1. 0. 0. 0. 0.]]
"""
if parse_version(qutip.__version__) >= parse_version("5.dev"):
if isinstance(oper.data, qutip.data.Dense):
oper = oper.to("csr")
if N is not None:
warnings.warn(
"The function expand_operator has been generalized to "
Expand Down

0 comments on commit 56d2766

Please sign in to comment.