-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rewrite the compatibility helper function
- Loading branch information
Showing
4 changed files
with
20 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
""" | ||
For the compatibility between qutip-v5 and v4. | ||
""" | ||
from itertools import chain | ||
from functools import reduce | ||
from packaging.version import parse as parse_version | ||
import numpy as np | ||
import qutip | ||
|
||
|
||
def to_scalar(qobj_or_scalar): | ||
if isinstance(qobj_or_scalar, qutip.Qobj): | ||
if qobj_or_scalar.dims == [[1], [1]]: | ||
return qobj_or_scalar[0, 0] | ||
return qobj_or_scalar |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters