From aadb59c3f512e9815f9bb77980d2538858304347 Mon Sep 17 00:00:00 2001 From: Lysandros Nikolaou Date: Mon, 16 Sep 2024 12:38:01 +0200 Subject: [PATCH 1/4] BUG: Remove np._get_promotion_state usage --- .github/workflows/unit-tests.yml | 1 - pandas/tests/series/indexing/test_setitem.py | 5 ----- 2 files changed, 6 deletions(-) diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index d145836f3e596..740f3f4de2c6c 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -86,7 +86,6 @@ jobs: TEST_ARGS: ${{ matrix.test_args || '' }} PYTEST_WORKERS: 'auto' PYTEST_TARGET: ${{ matrix.pytest_target || 'pandas' }} - NPY_PROMOTION_STATE: ${{ matrix.env_file == 'actions-311-numpydev.yaml' && 'weak' || 'legacy' }} # Clipboard tests QT_QPA_PLATFORM: offscreen REMOVE_PYARROW: ${{ matrix.name == 'Future infer strings (without pyarrow)' && '1' || '0' }} diff --git a/pandas/tests/series/indexing/test_setitem.py b/pandas/tests/series/indexing/test_setitem.py index 71ba2dab671ef..f7dbd9fe454a4 100644 --- a/pandas/tests/series/indexing/test_setitem.py +++ b/pandas/tests/series/indexing/test_setitem.py @@ -11,7 +11,6 @@ from pandas._config import using_string_dtype from pandas.compat import HAS_PYARROW -from pandas.compat.numpy import np_version_gte1p24 from pandas.errors import IndexingError from pandas.core.dtypes.common import is_list_like @@ -1444,10 +1443,6 @@ def obj(self): np.float32, False, marks=pytest.mark.xfail( - ( - not np_version_gte1p24 - or (np_version_gte1p24 and np._get_promotion_state() != "weak") - ), reason="np.float32(1.1) ends up as 1.100000023841858, so " "np_can_hold_element raises and we cast to float64", ), From 4fcf438543f5041eb504fb171b5bca3efe381d9d Mon Sep 17 00:00:00 2001 From: Lysandros Nikolaou Date: Mon, 16 Sep 2024 13:00:27 +0200 Subject: [PATCH 2/4] Add NPY_PROMOTION_STATE env variable back --- .github/workflows/unit-tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index 740f3f4de2c6c..d145836f3e596 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -86,6 +86,7 @@ jobs: TEST_ARGS: ${{ matrix.test_args || '' }} PYTEST_WORKERS: 'auto' PYTEST_TARGET: ${{ matrix.pytest_target || 'pandas' }} + NPY_PROMOTION_STATE: ${{ matrix.env_file == 'actions-311-numpydev.yaml' && 'weak' || 'legacy' }} # Clipboard tests QT_QPA_PLATFORM: offscreen REMOVE_PYARROW: ${{ matrix.name == 'Future infer strings (without pyarrow)' && '1' || '0' }} From 85e756b58ed2e05a238e4d62fa9852f97cb5a098 Mon Sep 17 00:00:00 2001 From: Lysandros Nikolaou Date: Mon, 16 Sep 2024 13:51:03 +0200 Subject: [PATCH 3/4] Use NPY_PROMOTION_STATE environment variable --- pandas/tests/series/indexing/test_setitem.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pandas/tests/series/indexing/test_setitem.py b/pandas/tests/series/indexing/test_setitem.py index f7dbd9fe454a4..85a1c869e92fe 100644 --- a/pandas/tests/series/indexing/test_setitem.py +++ b/pandas/tests/series/indexing/test_setitem.py @@ -4,6 +4,7 @@ datetime, ) from decimal import Decimal +import os import numpy as np import pytest @@ -11,6 +12,7 @@ from pandas._config import using_string_dtype from pandas.compat import HAS_PYARROW +from pandas.compat.numpy import np_version_gte1p24 from pandas.errors import IndexingError from pandas.core.dtypes.common import is_list_like @@ -1443,6 +1445,13 @@ def obj(self): np.float32, False, marks=pytest.mark.xfail( + ( + not np_version_gte1p24 + or ( + np_version_gte1p24 + and os.environ.get("NPY_PROMOTION_STATE", "weak") != "weak" + ) + ), reason="np.float32(1.1) ends up as 1.100000023841858, so " "np_can_hold_element raises and we cast to float64", ), From 515030103a617872368f6bdeb16e27c3d1ff5735 Mon Sep 17 00:00:00 2001 From: Lysandros Nikolaou Date: Mon, 16 Sep 2024 18:35:05 +0200 Subject: [PATCH 4/4] Mark test as xfail on WASM --- pandas/tests/series/indexing/test_setitem.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pandas/tests/series/indexing/test_setitem.py b/pandas/tests/series/indexing/test_setitem.py index 85a1c869e92fe..789e3ac752097 100644 --- a/pandas/tests/series/indexing/test_setitem.py +++ b/pandas/tests/series/indexing/test_setitem.py @@ -11,7 +11,10 @@ from pandas._config import using_string_dtype -from pandas.compat import HAS_PYARROW +from pandas.compat import ( + HAS_PYARROW, + WASM, +) from pandas.compat.numpy import np_version_gte1p24 from pandas.errors import IndexingError @@ -1451,6 +1454,7 @@ def obj(self): np_version_gte1p24 and os.environ.get("NPY_PROMOTION_STATE", "weak") != "weak" ) + or WASM ), reason="np.float32(1.1) ends up as 1.100000023841858, so " "np_can_hold_element raises and we cast to float64",