(obj)
| 1408 | |
| 1409 | @pytest.mark.parametrize("obj", [make_da(), make_ds()]) |
| 1410 | def test_map_blocks_da_ds_with_template(obj): |
| 1411 | func = lambda x: x.isel(x=[1]) |
| 1412 | # a simple .isel(x=[1, 5, 9]) puts all those in a single chunk. |
| 1413 | template = xr.concat([obj.isel(x=[i]) for i in [1, 5, 9]], data_vars=None, dim="x") |
| 1414 | with raise_if_dask_computes(): |
| 1415 | actual = xr.map_blocks(func, obj, template=template) |
| 1416 | assert_identical(actual, template) |
| 1417 | |
| 1418 | # Check that indexes are written into the graph directly |
| 1419 | dsk = dict(actual.__dask_graph__()) |
| 1420 | assert {k for k in dsk if "x-coordinate" in k} |
| 1421 | assert all( |
| 1422 | isinstance(v, PandasIndex) for k, v in dsk.items() if "x-coordinate" in k |
| 1423 | ) |
| 1424 | |
| 1425 | with raise_if_dask_computes(): |
| 1426 | actual = obj.map_blocks(func, template=template) |
| 1427 | assert_identical(actual, template) |
| 1428 | |
| 1429 | |
| 1430 | def test_map_blocks_roundtrip_string_index(): |
nothing calls this directly
no test coverage detected
searching dependent graphs…