From 2c7bc21e3be653ab214a837cca4e45c0a14e5482 Mon Sep 17 00:00:00 2001 From: tom Date: Mon, 26 Feb 2024 14:32:33 +0100 Subject: [PATCH 1/5] second approach to fix setitem parametrizations --- pandas/tests/extension/base/setitem.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pandas/tests/extension/base/setitem.py b/pandas/tests/extension/base/setitem.py index 3fb2fc09eaa79..afefc121c7edf 100644 --- a/pandas/tests/extension/base/setitem.py +++ b/pandas/tests/extension/base/setitem.py @@ -202,24 +202,24 @@ def test_setitem_integer_array(self, data, idx, box_in_series): arr[idx] = arr[0] tm.assert_equal(arr, expected) + @pytest.mark.filterwarnings("ignore::FutureWarning") @pytest.mark.parametrize( "idx, box_in_series", [ ([0, 1, 2, pd.NA], False), pytest.param( - [0, 1, 2, pd.NA], True, marks=pytest.mark.xfail(reason="GH-31948") + [0, 1, 2, pd.NA], + True, + marks=pytest.mark.xfail(reason="KeyError: '[0 1 2 ] not in index'"), ), (pd.array([0, 1, 2, pd.NA], dtype="Int64"), False), - # TODO: change False to True? - (pd.array([0, 1, 2, pd.NA], dtype="Int64"), False), # noqa: PT014 + (pd.array([0, 1, 2, pd.NA], dtype="Int64"), True), ], ids=["list-False", "list-True", "integer-array-False", "integer-array-True"], ) def test_setitem_integer_with_missing_raises(self, data, idx, box_in_series): arr = data.copy() - # TODO(xfail) this raises KeyError about labels not found (it tries label-based) - # for list of labels with Series if box_in_series: arr = pd.Series(data, index=[chr(100 + i) for i in range(len(data))]) From e468c22aaeb0749b8772198310b5e3b3beeed0e4 Mon Sep 17 00:00:00 2001 From: tom Date: Mon, 4 Mar 2024 12:33:01 +0100 Subject: [PATCH 2/5] dont catch value errors --- pandas/core/internals/blocks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/internals/blocks.py b/pandas/core/internals/blocks.py index 80c8a1e8ef5c7..1196880cd1f41 100644 --- a/pandas/core/internals/blocks.py +++ b/pandas/core/internals/blocks.py @@ -1665,7 +1665,7 @@ def setitem(self, indexer, value): try: values[indexer] = value - except (ValueError, TypeError): + except TypeError: if isinstance(self.dtype, IntervalDtype): # see TestSetitemFloatIntervalWithIntIntervalValues nb = self.coerce_to_target_dtype(orig_value, warn_on_upcast=True) From 38b8cce142d514485c61443a66725a8de3d7242a Mon Sep 17 00:00:00 2001 From: tom Date: Mon, 4 Mar 2024 14:04:24 +0100 Subject: [PATCH 3/5] catch value errors that should raise --- pandas/core/internals/blocks.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pandas/core/internals/blocks.py b/pandas/core/internals/blocks.py index 1196880cd1f41..ef5300d3b8ea5 100644 --- a/pandas/core/internals/blocks.py +++ b/pandas/core/internals/blocks.py @@ -1665,7 +1665,9 @@ def setitem(self, indexer, value): try: values[indexer] = value - except TypeError: + except (ValueError, TypeError) as e: + if str(e) == "Cannot index with an integer indexer containing NA values": + raise if isinstance(self.dtype, IntervalDtype): # see TestSetitemFloatIntervalWithIntIntervalValues nb = self.coerce_to_target_dtype(orig_value, warn_on_upcast=True) From 6c6540d477b86a77d4d201176cf15a60d8212c87 Mon Sep 17 00:00:00 2001 From: tom Date: Mon, 4 Mar 2024 14:14:52 +0100 Subject: [PATCH 4/5] update circle ci image --- .circleci/config.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 90afb1ce29684..4953ab5665134 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -3,7 +3,7 @@ version: 2.1 jobs: test-arm: machine: - image: ubuntu-2004:2022.04.1 + image: ubuntu-2004:2024.01.1 resource_class: arm.large environment: ENV_FILE: ci/deps/circle-310-arm64.yaml @@ -46,7 +46,7 @@ jobs: cibw-build: type: string machine: - image: ubuntu-2004:2022.04.1 + image: ubuntu-2004:2024.01.1 resource_class: arm.large environment: TRIGGER_SOURCE: << pipeline.trigger_source >> From d0bb8142c1cf62c0a7131374d37a34c706b1e43f Mon Sep 17 00:00:00 2001 From: tom Date: Mon, 4 Mar 2024 14:42:06 +0100 Subject: [PATCH 5/5] revert update circle ci image --- .circleci/config.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 4953ab5665134..90afb1ce29684 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -3,7 +3,7 @@ version: 2.1 jobs: test-arm: machine: - image: ubuntu-2004:2024.01.1 + image: ubuntu-2004:2022.04.1 resource_class: arm.large environment: ENV_FILE: ci/deps/circle-310-arm64.yaml @@ -46,7 +46,7 @@ jobs: cibw-build: type: string machine: - image: ubuntu-2004:2024.01.1 + image: ubuntu-2004:2022.04.1 resource_class: arm.large environment: TRIGGER_SOURCE: << pipeline.trigger_source >>