Skip to content

Commit

Permalink
Merge pull request #5215 from prckent/nxnumpy2
Browse files Browse the repository at this point in the history
Nexus: Initial NumPy 2 support
  • Loading branch information
ye-luo authored Nov 26, 2024
2 parents 2f961ad + dc5a84a commit aa5614d
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions nexus/lib/testing.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
# Workaround numpy2 changes
def portable_numpy(np):
if np.lib.NumpyVersion(np.__version__) >= '2.0.0b1':
np.set_printoptions(legacy="1.25")
np.string_ = np.bytes_
np.float_ = np.float64
#end if
#end def portable_numpy


try:
import numpy as np
portable_numpy(np)
numpy_available = True
except:
numpy_available = False
Expand All @@ -10,6 +20,7 @@
def_atol = 0.0
def_rtol = 1e-6


# determine if two floats differ
def float_diff(v1,v2,atol=def_atol,rtol=def_rtol):
return np.abs(v1-v2)>atol+rtol*np.abs(v2)
Expand Down

0 comments on commit aa5614d

Please sign in to comment.