Skip to content

Commit

Permalink
Merge pull request qutip#2557 from eendebakpt/numpy_version_check
Browse files Browse the repository at this point in the history
Improve performance of qt.Qobj by static version check
  • Loading branch information
Ericgig authored Nov 19, 2024
2 parents b44b697 + 13ef614 commit edac7d9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions doc/changes/2557.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Improve performance of qt.Qobj by using static numpy version check
3 changes: 2 additions & 1 deletion qutip/core/data/dense.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,11 @@ __all__ = [
class OrderEfficiencyWarning(EfficiencyWarning):
pass

is_numpy1 = np.lib.NumpyVersion(np.__version__) < '2.0.0b1'

cdef class Dense(base.Data):
def __init__(self, data, shape=None, copy=True):
if np.lib.NumpyVersion(np.__version__) < '2.0.0b1':
if is_numpy1:
# np2 accept None which act as np1's False
copy = builtins.bool(copy)
base = np.array(data, dtype=np.complex128, order='K', copy=copy)
Expand Down

0 comments on commit edac7d9

Please sign in to comment.