MCPcopy
hub / github.com/pydata/xarray / test_map_blocks_roundtrip_string_index

Function test_map_blocks_roundtrip_string_index

xarray/tests/test_dask.py:1430–1446  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1428
1429
1430def test_map_blocks_roundtrip_string_index():
1431 ds = xr.Dataset(
1432 {"data": (["label"], [1, 2, 3])}, coords={"label": ["foo", "bar", "baz"]}
1433 ).chunk(label=1)
1434 assert ds.label.dtype == np.dtype("=U3")
1435
1436 mapped = ds.map_blocks(lambda x: x, template=ds)
1437 assert mapped.label.dtype == ds.label.dtype
1438
1439 mapped = ds.map_blocks(lambda x: x, template=None)
1440 assert mapped.label.dtype == ds.label.dtype
1441
1442 mapped = ds.data.map_blocks(lambda x: x, template=ds.data)
1443 assert mapped.label.dtype == ds.label.dtype
1444
1445 mapped = ds.data.map_blocks(lambda x: x, template=None)
1446 assert mapped.label.dtype == ds.label.dtype
1447
1448
1449def test_map_blocks_template_convert_object():

Callers

nothing calls this directly

Calls 3

chunkMethod · 0.45
dtypeMethod · 0.45
map_blocksMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…