@@ -6078,11 +6078,6 @@ def test_query(self, backend, engine, parser):
6078
6078
# pytest tests — new tests should go here, rather than in the class.
6079
6079
6080
6080
6081
- @pytest .fixture (params = [None ])
6082
- def data_set (request ):
6083
- return create_test_data (request .param )
6084
-
6085
-
6086
6081
@pytest .mark .parametrize ("test_elements" , ([1 , 2 ], np .array ([1 , 2 ]), DataArray ([1 , 2 ])))
6087
6082
def test_isin (test_elements , backend ):
6088
6083
expected = Dataset (
@@ -6153,17 +6148,18 @@ def test_constructor_raises_with_invalid_coords(unaligned_coords):
6153
6148
xr .DataArray ([1 , 2 , 3 ], dims = ["x" ], coords = unaligned_coords )
6154
6149
6155
6150
6156
- def test_dir_expected_attrs (data_set ):
6151
+ @pytest .mark .parametrize ("ds" , [3 ], indirect = True )
6152
+ def test_dir_expected_attrs (ds ):
6157
6153
6158
6154
some_expected_attrs = {"pipe" , "mean" , "isnull" , "var1" , "dim2" , "numbers" }
6159
- result = dir (data_set )
6155
+ result = dir (ds )
6160
6156
assert set (result ) >= some_expected_attrs
6161
6157
6162
6158
6163
- def test_dir_non_string (data_set ):
6159
+ def test_dir_non_string (ds ):
6164
6160
# add a numbered key to ensure this doesn't break dir
6165
- data_set [5 ] = "foo"
6166
- result = dir (data_set )
6161
+ ds [5 ] = "foo"
6162
+ result = dir (ds )
6167
6163
assert 5 not in result
6168
6164
6169
6165
# GH2172
@@ -6173,16 +6169,16 @@ def test_dir_non_string(data_set):
6173
6169
dir (x2 )
6174
6170
6175
6171
6176
- def test_dir_unicode (data_set ):
6177
- data_set ["unicode" ] = "uni"
6178
- result = dir (data_set )
6172
+ def test_dir_unicode (ds ):
6173
+ ds ["unicode" ] = "uni"
6174
+ result = dir (ds )
6179
6175
assert "unicode" in result
6180
6176
6181
6177
6182
6178
@pytest .fixture (params = [1 ])
6183
- def ds (request ):
6179
+ def ds (request , backend ):
6184
6180
if request .param == 1 :
6185
- return Dataset (
6181
+ ds = Dataset (
6186
6182
dict (
6187
6183
z1 = (["y" , "x" ], np .random .randn (2 , 8 )),
6188
6184
z2 = (["time" , "y" ], np .random .randn (10 , 2 )),
@@ -6194,21 +6190,29 @@ def ds(request):
6194
6190
y = range (2 ),
6195
6191
),
6196
6192
)
6197
-
6198
- if request .param == 2 :
6199
- return Dataset (
6200
- {
6201
- "z1" : (["time" , "y" ], np .random .randn (10 , 2 )),
6202
- "z2" : (["time" ], np .random .randn (10 )),
6203
- "z3" : (["x" , "time" ], np .random .randn (8 , 10 )),
6204
- },
6205
- {
6206
- "x" : ("x" , np .linspace (0 , 1.0 , 8 )),
6207
- "time" : ("time" , np .linspace (0 , 1.0 , 10 )),
6208
- "c" : ("y" , ["a" , "b" ]),
6209
- "y" : range (2 ),
6210
- },
6193
+ elif request .param == 2 :
6194
+ ds = Dataset (
6195
+ dict (
6196
+ z1 = (["time" , "y" ], np .random .randn (10 , 2 )),
6197
+ z2 = (["time" ], np .random .randn (10 )),
6198
+ z3 = (["x" , "time" ], np .random .randn (8 , 10 )),
6199
+ ),
6200
+ dict (
6201
+ x = ("x" , np .linspace (0 , 1.0 , 8 )),
6202
+ time = ("time" , np .linspace (0 , 1.0 , 10 )),
6203
+ c = ("y" , ["a" , "b" ]),
6204
+ y = range (2 ),
6205
+ ),
6211
6206
)
6207
+ elif request .param == 3 :
6208
+ ds = create_test_data ()
6209
+ else :
6210
+ raise ValueError
6211
+
6212
+ if backend == "dask" :
6213
+ return ds .chunk ()
6214
+
6215
+ return ds
6212
6216
6213
6217
6214
6218
def test_coarsen_absent_dims_error (ds ):
@@ -6526,6 +6530,7 @@ def test_rolling_properties(ds):
6526
6530
@pytest .mark .parametrize ("center" , (True , False , None ))
6527
6531
@pytest .mark .parametrize ("min_periods" , (1 , None ))
6528
6532
@pytest .mark .parametrize ("key" , ("z1" , "z2" ))
6533
+ @pytest .mark .parametrize ("backend" , ["numpy" ], indirect = True )
6529
6534
def test_rolling_wrapped_bottleneck (ds , name , center , min_periods , key ):
6530
6535
bn = pytest .importorskip ("bottleneck" , minversion = "1.1" )
6531
6536
@@ -6551,13 +6556,15 @@ def test_rolling_wrapped_bottleneck(ds, name, center, min_periods, key):
6551
6556
6552
6557
6553
6558
@requires_numbagg
6559
+ @pytest .mark .parametrize ("backend" , ["numpy" ], indirect = True )
6554
6560
def test_rolling_exp (ds ):
6555
6561
6556
6562
result = ds .rolling_exp (time = 10 , window_type = "span" ).mean ()
6557
6563
assert isinstance (result , Dataset )
6558
6564
6559
6565
6560
6566
@requires_numbagg
6567
+ @pytest .mark .parametrize ("backend" , ["numpy" ], indirect = True )
6561
6568
def test_rolling_exp_keep_attrs (ds ):
6562
6569
6563
6570
attrs_global = {"attrs" : "global" }
0 commit comments