Skip to content

Commit

Permalink
use try-except for npfloat128 import (#1037)
Browse files Browse the repository at this point in the history
  • Loading branch information
alphasentaurii authored Apr 30, 2024
1 parent acc8fe0 commit 4d50b95
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ ROMAN

- Added support for pars- reference files [#1036]

General
-------

- Use try/except for np.float128 import [#1037]


11.17.20 (2024-04-18)
=====================
Expand Down
7 changes: 6 additions & 1 deletion crds/certify/certify.py
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,12 @@ def table_mode_dictionary(generic_name, tab, mode_keys):

def handle_nan(var):
"""Map nan values to 'nan' so that 'nan' == 'nan'."""
if isinstance(var, (np.float32, np.float64, np.float128)) and np.isnan(var):
try:
from numpy import float128
floats = (np.float32, np.float64, np.float128)
except ImportError:
floats = (np.float32, np.float64)
if isinstance(var, floats) and np.isnan(var):
return 'nan'
elif isinstance(var, np.ndarray) and var.shape == () and np.any(np.isnan(var)):
return 'nan'
Expand Down

0 comments on commit 4d50b95

Please sign in to comment.