From b28d6d8f718c64e8be119267242a1aadc1122934 Mon Sep 17 00:00:00 2001
From: Paul McCarthy <pauldmccarthy@gmail.com>
Date: Wed, 18 Apr 2018 15:41:35 +0100
Subject: [PATCH] suppress all-nan warning when calculating nanmin/max

---
 fsl/utils/naninfrange.py | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/fsl/utils/naninfrange.py b/fsl/utils/naninfrange.py
index 523f4080c..c8437c8d9 100644
--- a/fsl/utils/naninfrange.py
+++ b/fsl/utils/naninfrange.py
@@ -9,6 +9,8 @@ the range of a numpy array, ignoring infinite and nan values.
 """
 
 
+import warnings
+
 import numpy as np
 
 
@@ -27,8 +29,10 @@ def naninfrange(data):
     # But np.nanmin/nanmax are substantially
     # faster than the alternate, so we try it
     # first.
-    dmin = np.nanmin(data)
-    dmax = np.nanmax(data)
+    with warnings.catch_warnings():
+        warnings.filterwarnings('ignore')
+        dmin = np.nanmin(data)
+        dmax = np.nanmax(data)
 
     # If there are no nans/infs in the data,
     # we can just use nanmin/nanmax
-- 
GitLab