Skip to content
Snippets Groups Projects
Commit b28d6d8f authored by Paul McCarthy's avatar Paul McCarthy :mountain_bicyclist:
Browse files

suppress all-nan warning when calculating nanmin/max

parent dd104d78
No related branches found
No related tags found
No related merge requests found
...@@ -9,6 +9,8 @@ the range of a numpy array, ignoring infinite and nan values. ...@@ -9,6 +9,8 @@ the range of a numpy array, ignoring infinite and nan values.
""" """
import warnings
import numpy as np import numpy as np
...@@ -27,8 +29,10 @@ def naninfrange(data): ...@@ -27,8 +29,10 @@ def naninfrange(data):
# But np.nanmin/nanmax are substantially # But np.nanmin/nanmax are substantially
# faster than the alternate, so we try it # faster than the alternate, so we try it
# first. # first.
dmin = np.nanmin(data) with warnings.catch_warnings():
dmax = np.nanmax(data) warnings.filterwarnings('ignore')
dmin = np.nanmin(data)
dmax = np.nanmax(data)
# If there are no nans/infs in the data, # If there are no nans/infs in the data,
# we can just use nanmin/nanmax # we can just use nanmin/nanmax
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment