()
| 1866 | |
| 1867 | @requires_dask |
| 1868 | def test_vectorize_dask_new_output_dims() -> None: |
| 1869 | # regression test for GH3574 |
| 1870 | # run vectorization in dask.array.gufunc by using `dask='parallelized'` |
| 1871 | data_array = xr.DataArray([[0, 1, 2], [1, 2, 3]], dims=("x", "y")) |
| 1872 | func = lambda x: x[np.newaxis, ...] |
| 1873 | expected = data_array.expand_dims("z") |
| 1874 | actual = apply_ufunc( |
| 1875 | func, |
| 1876 | data_array.chunk({"x": 1}), |
| 1877 | output_core_dims=[["z"]], |
| 1878 | vectorize=True, |
| 1879 | dask="parallelized", |
| 1880 | output_dtypes=[float], |
| 1881 | dask_gufunc_kwargs=dict(output_sizes={"z": 1}), |
| 1882 | ).transpose(*expected.dims) |
| 1883 | assert_identical(expected, actual) |
| 1884 | |
| 1885 | with pytest.raises( |
| 1886 | ValueError, match=r"dimension 'z1' in 'output_sizes' must correspond" |
| 1887 | ): |
| 1888 | apply_ufunc( |
| 1889 | func, |
| 1890 | data_array.chunk({"x": 1}), |
| 1891 | output_core_dims=[["z"]], |
| 1892 | vectorize=True, |
| 1893 | dask="parallelized", |
| 1894 | output_dtypes=[float], |
| 1895 | dask_gufunc_kwargs=dict(output_sizes={"z1": 1}), |
| 1896 | ) |
| 1897 | |
| 1898 | with pytest.raises( |
| 1899 | ValueError, match=r"dimension 'z' in 'output_core_dims' needs corresponding" |
| 1900 | ): |
| 1901 | apply_ufunc( |
| 1902 | func, |
| 1903 | data_array.chunk({"x": 1}), |
| 1904 | output_core_dims=[["z"]], |
| 1905 | vectorize=True, |
| 1906 | dask="parallelized", |
| 1907 | output_dtypes=[float], |
| 1908 | ) |
| 1909 | |
| 1910 | |
| 1911 | def test_output_wrong_number() -> None: |
nothing calls this directly
no test coverage detected
searching dependent graphs…