From d634770b67229f9c67e2646c7ba28a277c806631 Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Sat, 5 Jul 2025 12:07:38 +0200 Subject: [PATCH 1/3] Expression not assigned --- xarray/coding/variables.py | 10 +++------- xarray/tests/test_dask.py | 3 ++- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/xarray/coding/variables.py b/xarray/coding/variables.py index 3b7be898ccf..eff08c74500 100644 --- a/xarray/coding/variables.py +++ b/xarray/coding/variables.py @@ -164,10 +164,8 @@ def _check_fill_values(attrs, name, dtype): Issue SerializationWarning if appropriate. """ raw_fill_dict = {} - [ + for attr in ("missing_value", "_FillValue"): pop_to(attrs, raw_fill_dict, attr, name=name) - for attr in ("missing_value", "_FillValue") - ] encoded_fill_values = set() for k in list(raw_fill_dict): v = raw_fill_dict[k] @@ -376,11 +374,9 @@ def decode(self, variable: Variable, name: T_Name = None): dims, data, attrs, encoding = unpack_for_decoding(variable) - # Even if _Unsigned is use, retain on-disk _FillValue - [ + # Even if _Unsigned is used, retain on-disk _FillValue + for attr, value in raw_fill_dict.items(): safe_setitem(encoding, attr, value, name=name) - for attr, value in raw_fill_dict.items() - ] if "_Unsigned" in attrs: unsigned = pop_to(attrs, encoding, "_Unsigned") diff --git a/xarray/tests/test_dask.py b/xarray/tests/test_dask.py index ccb832ee522..6f0c4f28eab 100644 --- a/xarray/tests/test_dask.py +++ b/xarray/tests/test_dask.py @@ -1129,7 +1129,8 @@ def test_unify_chunks(map_ds): def test_unify_chunks_shallow_copy(obj, transform): obj = transform(obj) unified = obj.unify_chunks() - assert_identical(obj, unified) and obj is not obj.unify_chunks() + assert_identical(obj, unified) + assert obj is not obj.unify_chunks() @pytest.mark.parametrize("obj", [make_da()]) From a29d4bc4394c93740ab0b25140be878223d99413 Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Tue, 8 Jul 2025 08:34:15 +0200 Subject: [PATCH 2/3] Use unified instead of calling obj.unify_chunks() --- xarray/tests/test_dask.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xarray/tests/test_dask.py b/xarray/tests/test_dask.py index 6f0c4f28eab..768fcc82267 100644 --- a/xarray/tests/test_dask.py +++ b/xarray/tests/test_dask.py @@ -1130,7 +1130,7 @@ def test_unify_chunks_shallow_copy(obj, transform): obj = transform(obj) unified = obj.unify_chunks() assert_identical(obj, unified) - assert obj is not obj.unify_chunks() + assert obj is not unified @pytest.mark.parametrize("obj", [make_da()]) From ec818f85d394e0158506a26ec7c0c560a3cab28e Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Sun, 6 Jul 2025 17:14:00 +0200 Subject: [PATCH 3/3] This assertion probably never worked I guess the `and` was meant to disable the assertion. Commenting it out with `#` instead. --- xarray/tests/test_dask.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xarray/tests/test_dask.py b/xarray/tests/test_dask.py index 768fcc82267..9024f2ae677 100644 --- a/xarray/tests/test_dask.py +++ b/xarray/tests/test_dask.py @@ -1130,7 +1130,7 @@ def test_unify_chunks_shallow_copy(obj, transform): obj = transform(obj) unified = obj.unify_chunks() assert_identical(obj, unified) - assert obj is not unified + # assert obj is not unified @pytest.mark.parametrize("obj", [make_da()])