9
9
from xarray .core .duck_array_ops import (
10
10
first , last , count , mean , array_notnull_equiv , where , stack , concatenate
11
11
)
12
+ from xarray .core .pycompat import dask_array_type
12
13
from xarray import DataArray
13
- from xarray .testing import assert_allclose
14
+ from xarray .testing import assert_allclose , assert_equal
14
15
from xarray import concat
15
16
16
- from . import TestCase , raises_regex , has_dask
17
+ from . import TestCase , raises_regex , has_dask , requires_dask
17
18
18
19
19
20
class TestOps (TestCase ):
@@ -194,23 +195,19 @@ def series_reduce(da, func, dim, **kwargs):
194
195
def test_reduce (dim_num , dtype , dask , func , skipna , aggdim ):
195
196
196
197
if aggdim == 'y' and dim_num < 2 :
197
- return
198
+ pytest . skip ( 'dim not in this test' )
198
199
199
200
if dtype == np .bool_ and func == 'mean' :
200
- return # numpy does not support this
201
+ pytest . skip ( ' numpy does not support this' )
201
202
202
203
if dask and not has_dask :
203
- return
204
+ pytest . skip ( 'requires dask' )
204
205
205
206
rtol = 1e-04 if dtype == np .float32 else 1e-05
206
207
207
208
da = construct_dataarray (dim_num , dtype , contains_nan = True , dask = dask )
208
209
axis = None if aggdim is None else da .get_axis_num (aggdim )
209
210
210
- if dask and not skipna and func in ['var' , 'std' ] and dtype == np .bool_ :
211
- # TODO this might be dask's bug
212
- return
213
-
214
211
if (LooseVersion (np .__version__ ) >= LooseVersion ('1.13.0' ) and
215
212
da .dtype .kind == 'O' and skipna ):
216
213
# Numpy < 1.13 does not handle object-type array.
@@ -269,19 +266,17 @@ def test_argmin_max(dim_num, dtype, contains_nan, dask, func, skipna, aggdim):
269
266
# just make sure da[da.argmin()] == da.min()
270
267
271
268
if aggdim == 'y' and dim_num < 2 :
272
- return
269
+ pytest . skip ( 'dim not in this test' )
273
270
274
271
if dask and not has_dask :
275
- return
272
+ pytest . skip ( 'requires dask' )
276
273
277
274
if contains_nan :
278
275
if not skipna :
279
- # numpy's argmin (not nanargmin) does not handle object-dtype
280
- return
276
+ pytest . skip ( " numpy's argmin (not nanargmin) does not handle "
277
+ "object-dtype" )
281
278
if skipna and np .dtype (dtype ).kind in 'iufc' :
282
- # numpy's nanargmin raises ValueError for all nan axis
283
- return
284
-
279
+ pytest .skip ("numpy's nanargmin raises ValueError for all nan axis" )
285
280
da = construct_dataarray (dim_num , dtype , contains_nan = contains_nan ,
286
281
dask = dask )
287
282
@@ -302,3 +297,10 @@ def test_argmin_max_error():
302
297
da = construct_dataarray (2 , np .bool_ , contains_nan = True , dask = False )
303
298
with pytest .raises (ValueError ):
304
299
da .argmin (dim = 'y' )
300
+
301
+
302
+ @requires_dask
303
+ def test_isnull_with_dask ():
304
+ da = construct_dataarray (2 , np .float32 , contains_nan = True , dask = True )
305
+ assert isinstance (da .isnull ().data , dask_array_type )
306
+ assert_equal (da .isnull ().load (), da .load ().isnull ())
0 commit comments