(obj)
| 1465 | |
| 1466 | @pytest.mark.parametrize("obj", [make_da(), make_ds()]) |
| 1467 | def test_map_blocks_errors_bad_template(obj): |
| 1468 | with pytest.raises(ValueError, match=r"unexpected coordinate variables"): |
| 1469 | xr.map_blocks(lambda x: x.assign_coords(a=10), obj, template=obj).compute() |
| 1470 | with pytest.raises(ValueError, match=r"does not contain coordinate variables"): |
| 1471 | xr.map_blocks(lambda x: x.drop_vars("cxy"), obj, template=obj).compute() |
| 1472 | with pytest.raises(ValueError, match=r"Dimensions {'x'} missing"): |
| 1473 | xr.map_blocks(lambda x: x.isel(x=1), obj, template=obj).compute() |
| 1474 | with pytest.raises(ValueError, match=r"Received dimension 'x' of length 1"): |
| 1475 | xr.map_blocks(lambda x: x.isel(x=[1]), obj, template=obj).compute() |
| 1476 | with pytest.raises(TypeError, match=r"must be a DataArray"): |
| 1477 | xr.map_blocks(lambda x: x.isel(x=[1]), obj, template=(obj,)).compute() # type: ignore[arg-type] |
| 1478 | with pytest.raises(ValueError, match=r"map_blocks requires that one block"): |
| 1479 | xr.map_blocks( |
| 1480 | lambda x: x.isel(x=[1]).assign_coords(x=10), obj, template=obj.isel(x=[1]) |
| 1481 | ).compute() |
| 1482 | with pytest.raises(ValueError, match=r"Expected index 'x' to be"): |
| 1483 | xr.map_blocks( |
| 1484 | lambda a: a.isel(x=[1]).assign_coords(x=[120]), # assign bad index values |
| 1485 | obj, |
| 1486 | template=xr.concat( |
| 1487 | [obj.isel(x=[i]) for i in [1, 5, 9]], data_vars=None, dim="x" |
| 1488 | ), |
| 1489 | ).compute() |
| 1490 | |
| 1491 | |
| 1492 | def test_map_blocks_errors_bad_template_2(map_ds): |
nothing calls this directly
no test coverage detected
searching dependent graphs…