From f35e7b3b487f69f7e306556df8402cf86d27c86c Mon Sep 17 00:00:00 2001 From: Jonathan Neuhauser Date: Fri, 9 May 2025 11:20:22 +0200 Subject: [PATCH] Enable .conjugate on Dask arrays, #10302 --- xarray/computation/ops.py | 2 +- xarray/tests/test_dask.py | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/xarray/computation/ops.py b/xarray/computation/ops.py index 26739134896..61834a85acf 100644 --- a/xarray/computation/ops.py +++ b/xarray/computation/ops.py @@ -283,7 +283,7 @@ def inplace_to_noninplace_op(f): # _typed_ops.py uses the following wrapped functions as a kind of unary operator argsort = _method_wrapper("argsort") conj = _method_wrapper("conj") -conjugate = _method_wrapper("conjugate") +conjugate = _method_wrapper("conj") round_ = _func_slash_method_wrapper(duck_array_ops.around, name="round") diff --git a/xarray/tests/test_dask.py b/xarray/tests/test_dask.py index dede0b01f1d..f14bacc1211 100644 --- a/xarray/tests/test_dask.py +++ b/xarray/tests/test_dask.py @@ -1822,3 +1822,15 @@ def test_idxmin_chunking(): actual = da.idxmin("time") assert actual.chunksizes == {k: da.chunksizes[k] for k in ["x", "y"]} assert_identical(actual, da.compute().idxmin("time")) + + +def test_conjugate(): + # Test for https://github.com/pydata/xarray/issues/10302 + z = 1j * da.arange(100) + + data = xr.DataArray(z, coords={"x": np.arange(100)}) + + conj_data = data.conjugate() + assert dask.is_dask_collection(conj_data) + + assert_equal(conj_data, data.conj())