()
| 1328 | |
| 1329 | @requires_dask |
| 1330 | def test_apply_dask_new_output_dimension() -> None: |
| 1331 | import dask.array as da |
| 1332 | |
| 1333 | array = da.ones((2, 2), chunks=(1, 1)) |
| 1334 | data_array = xr.DataArray(array, dims=("x", "y")) |
| 1335 | |
| 1336 | def stack_negative(obj): |
| 1337 | def func(x): |
| 1338 | return np.stack([x, -x], axis=-1) |
| 1339 | |
| 1340 | return apply_ufunc( |
| 1341 | func, |
| 1342 | obj, |
| 1343 | output_core_dims=[["sign"]], |
| 1344 | dask="parallelized", |
| 1345 | output_dtypes=[obj.dtype], |
| 1346 | dask_gufunc_kwargs=dict(output_sizes={"sign": 2}), |
| 1347 | ) |
| 1348 | |
| 1349 | expected = stack_negative(data_array.compute()) |
| 1350 | |
| 1351 | actual = stack_negative(data_array) |
| 1352 | assert actual.dims == ("x", "y", "sign") |
| 1353 | assert actual.shape == (2, 2, 2) |
| 1354 | assert isinstance(actual.data, da.Array) |
| 1355 | assert_identical(expected, actual) |
| 1356 | |
| 1357 | |
| 1358 | @requires_dask |
nothing calls this directly
no test coverage detected
searching dependent graphs…