@@ -487,16 +487,21 @@ def test_mixed_grouping(chunk):
487
487
assert (r .sel (v1 = [3 , 4 , 5 ]) == 0 ).all ().data
488
488
489
489
490
+ @pytest .mark .parametrize ("add_nan" , [True , False ])
490
491
@pytest .mark .parametrize ("dtype_out" , [np .float64 , "float64" , np .dtype ("float64" )])
491
492
@pytest .mark .parametrize ("dtype" , [np .float32 , np .float64 ])
492
493
@pytest .mark .parametrize ("chunk" , (True , False ))
493
- def test_dtype (chunk , dtype , dtype_out , engine ):
494
+ def test_dtype (add_nan , chunk , dtype , dtype_out , engine ):
494
495
if chunk and not has_dask :
495
496
pytest .skip ()
496
497
497
498
xp = dask .array if chunk else np
498
499
data = xp .linspace (0 , 1 , 48 , dtype = dtype ).reshape ((4 , 12 ))
499
500
501
+ if add_nan :
502
+ data [1 , ...] = np .nan
503
+ data [0 , [0 , 2 ]] = np .nan
504
+
500
505
arr = xr .DataArray (
501
506
data ,
502
507
dims = ("x" , "t" ),
@@ -511,11 +516,11 @@ def test_dtype(chunk, dtype, dtype_out, engine):
511
516
512
517
assert actual .dtype == np .dtype ("float64" )
513
518
assert actual .compute ().dtype == np .dtype ("float64" )
514
- assert_equal (expected , actual )
519
+ xr . testing . assert_allclose (expected , actual )
515
520
516
521
actual = xarray_reduce (arr .to_dataset (), "labels" , ** kwargs )
517
522
expected = arr .to_dataset ().groupby ("labels" ).mean (dtype = "float64" )
518
523
519
524
assert actual .arr .dtype == np .dtype ("float64" )
520
525
assert actual .compute ().arr .dtype == np .dtype ("float64" )
521
- assert_equal (expected , actual .transpose ("labels" , ...))
526
+ xr . testing . assert_allclose (expected , actual .transpose ("labels" , ...))
0 commit comments