Skip to content

Commit bd0fd97

Browse files
authored
Fix some dask tests (#9321)
* Fix some dask tests * Cleanup
1 parent e2981d3 commit bd0fd97

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

xarray/tests/test_dask.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -640,8 +640,10 @@ def counting_get(*args, **kwargs):
640640

641641
def test_duplicate_dims(self):
642642
data = np.random.normal(size=(4, 4))
643-
arr = DataArray(data, dims=("x", "x"))
644-
chunked_array = arr.chunk({"x": 2})
643+
with pytest.warns(UserWarning, match="Duplicate dimension"):
644+
arr = DataArray(data, dims=("x", "x"))
645+
with pytest.warns(UserWarning, match="Duplicate dimension"):
646+
chunked_array = arr.chunk({"x": 2})
645647
assert chunked_array.chunks == ((2, 2), (2, 2))
646648
assert chunked_array.chunksizes == {"x": (2, 2)}
647649

@@ -1364,7 +1366,8 @@ def test_map_blocks_ds_transformations(func, map_ds):
13641366
@pytest.mark.parametrize("obj", [make_da(), make_ds()])
13651367
def test_map_blocks_da_ds_with_template(obj):
13661368
func = lambda x: x.isel(x=[1])
1367-
template = obj.isel(x=[1, 5, 9])
1369+
# a simple .isel(x=[1, 5, 9]) puts all those in a single chunk.
1370+
template = xr.concat([obj.isel(x=[i]) for i in [1, 5, 9]], dim="x")
13681371
with raise_if_dask_computes():
13691372
actual = xr.map_blocks(func, obj, template=template)
13701373
assert_identical(actual, template)
@@ -1395,15 +1398,16 @@ def test_map_blocks_roundtrip_string_index():
13951398

13961399
def test_map_blocks_template_convert_object():
13971400
da = make_da()
1401+
ds = da.to_dataset()
1402+
13981403
func = lambda x: x.to_dataset().isel(x=[1])
1399-
template = da.to_dataset().isel(x=[1, 5, 9])
1404+
template = xr.concat([da.to_dataset().isel(x=[i]) for i in [1, 5, 9]], dim="x")
14001405
with raise_if_dask_computes():
14011406
actual = xr.map_blocks(func, da, template=template)
14021407
assert_identical(actual, template)
14031408

1404-
ds = da.to_dataset()
14051409
func = lambda x: x.to_dataarray().isel(x=[1])
1406-
template = ds.to_dataarray().isel(x=[1, 5, 9])
1410+
template = xr.concat([ds.to_dataarray().isel(x=[i]) for i in [1, 5, 9]], dim="x")
14071411
with raise_if_dask_computes():
14081412
actual = xr.map_blocks(func, ds, template=template)
14091413
assert_identical(actual, template)
@@ -1429,7 +1433,7 @@ def test_map_blocks_errors_bad_template(obj):
14291433
xr.map_blocks(
14301434
lambda a: a.isel(x=[1]).assign_coords(x=[120]), # assign bad index values
14311435
obj,
1432-
template=obj.isel(x=[1, 5, 9]),
1436+
template=xr.concat([obj.isel(x=[i]) for i in [1, 5, 9]], dim="x"),
14331437
).compute()
14341438

14351439

xarray/tests/test_variable.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -318,12 +318,11 @@ def test_datetime64_valid_range(self):
318318
with pytest.raises(pderror, match=r"Out of bounds nanosecond"):
319319
self.cls(["t"], [data])
320320

321-
@pytest.mark.xfail(reason="pandas issue 36615")
322321
@pytest.mark.filterwarnings("ignore:Converting non-nanosecond")
323322
def test_timedelta64_valid_range(self):
324323
data = np.timedelta64("200000", "D")
325324
pderror = pd.errors.OutOfBoundsTimedelta
326-
with pytest.raises(pderror, match=r"Out of bounds nanosecond"):
325+
with pytest.raises(pderror, match=r"Cannot convert"):
327326
self.cls(["t"], [data])
328327

329328
def test_pandas_data(self):
@@ -2301,20 +2300,20 @@ def test_chunk(self):
23012300
assert blocked.chunks == ((3,), (3, 1))
23022301
assert blocked.data.name != first_dask_name
23032302

2304-
@pytest.mark.xfail
2303+
@pytest.mark.skip
23052304
def test_0d_object_array_with_list(self):
23062305
super().test_0d_object_array_with_list()
23072306

2308-
@pytest.mark.xfail
2307+
@pytest.mark.skip
23092308
def test_array_interface(self):
23102309
# dask array does not have `argsort`
23112310
super().test_array_interface()
23122311

2313-
@pytest.mark.xfail
2312+
@pytest.mark.skip
23142313
def test_copy_index(self):
23152314
super().test_copy_index()
23162315

2317-
@pytest.mark.xfail
2316+
@pytest.mark.skip
23182317
@pytest.mark.filterwarnings("ignore:elementwise comparison failed.*:FutureWarning")
23192318
def test_eq_all_dtypes(self):
23202319
super().test_eq_all_dtypes()

0 commit comments

Comments
 (0)