File tree Expand file tree Collapse file tree 2 files changed +36
-0
lines changed
Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Original file line number Diff line number Diff line change 1414try :
1515 from scipy .ndimage import convolve1d
1616
17+ # In some cases we don't need SciPy directly, since it is required by code
18+ # here which uses 'convolve1d' under-the-hood. Without it installed, get:
19+ #
20+ # NameError: name 'convolve1d' is not defined. Did you
21+ # mean: 'cf_convolve1d'?
22+
1723 SCIPY_AVAILABLE = True
1824# not 'except ImportError' as that can hide nested errors, catch anything:
1925except Exception :
@@ -2330,6 +2336,9 @@ def test_Field_percentile(self):
23302336 # TODO: add loop to check get same shape and close enough data
23312337 # for every possible axis combo (see also test_Data_percentile).
23322338
2339+ @unittest .skipIf (
2340+ not SCIPY_AVAILABLE , "scipy must be installed for this test."
2341+ )
23332342 def test_Field_grad_xy (self ):
23342343 f = cf .example_field (0 )
23352344
@@ -2415,6 +2424,9 @@ def test_Field_grad_xy(self):
24152424 y .dimension_coordinate ("X" ).standard_name , "longitude"
24162425 )
24172426
2427+ @unittest .skipIf (
2428+ not SCIPY_AVAILABLE , "scipy must be installed for this test."
2429+ )
24182430 def test_Field_laplacian_xy (self ):
24192431 f = cf .example_field (0 )
24202432
Original file line number Diff line number Diff line change 22import faulthandler
33import unittest
44
5+
6+ SCIPY_AVAILABLE = False
7+ try :
8+ # We don't need SciPy directly in this test, it is only required by code
9+ # here which uses 'convolve1d' under-the-hood. Without it installed, get:
10+ #
11+ # NameError: name 'convolve1d' is not defined. Did you
12+ # mean: 'cf_convolve1d'?
13+ import scipy
14+
15+ SCIPY_AVAILABLE = True
16+ # not 'except ImportError' as that can hide nested errors, catch anything:
17+ except Exception :
18+ pass # test with this dependency will then be skipped by unittest
19+
520faulthandler .enable () # to debug seg faults and timeouts
621
722import cf
823
924
1025class MathTest (unittest .TestCase ):
26+ @unittest .skipIf (
27+ not SCIPY_AVAILABLE , "scipy must be installed for this test."
28+ )
1129 def test_curl_xy (self ):
1230 f = cf .example_field (0 )
1331
@@ -97,6 +115,9 @@ def test_curl_xy(self):
97115 c .dimension_coordinate ("X" ).standard_name , "longitude"
98116 )
99117
118+ @unittest .skipIf (
119+ not SCIPY_AVAILABLE , "scipy must be installed for this test."
120+ )
100121 def test_div_xy (self ):
101122 f = cf .example_field (0 )
102123
@@ -185,6 +206,9 @@ def test_div_xy(self):
185206 d .dimension_coordinate ("X" ).standard_name , "longitude"
186207 )
187208
209+ @unittest .skipIf (
210+ not SCIPY_AVAILABLE , "scipy must be installed for this test."
211+ )
188212 def test_differential_operators (self ):
189213 f = cf .example_field (0 )
190214
You can’t perform that action at this time.
0 commit comments