From e5a2067a0289b6867ff03302686cbdcbcf945436 Mon Sep 17 00:00:00 2001 From: Joris Van den Bossche Date: Mon, 16 Sep 2024 22:06:58 +0200 Subject: [PATCH] Backport PR #59818 on branch 2.2.x (BUG: Remove np._get_promotion_state usage) (#59821) BUG: Remove np._get_promotion_state usage (#59818) (cherry picked from commit 081dcdee8d754af90e307cf2311b06b3d02fae2a) Co-authored-by: Lysandros Nikolaou --- pandas/tests/series/indexing/test_setitem.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pandas/tests/series/indexing/test_setitem.py b/pandas/tests/series/indexing/test_setitem.py index 23137f0975fb1..29ad674d1cadf 100644 --- a/pandas/tests/series/indexing/test_setitem.py +++ b/pandas/tests/series/indexing/test_setitem.py @@ -3,10 +3,12 @@ datetime, ) from decimal import Decimal +import os import numpy as np import pytest +from pandas.compat import WASM from pandas.compat.numpy import np_version_gte1p24 from pandas.errors import IndexingError @@ -1443,7 +1445,11 @@ def obj(self): marks=pytest.mark.xfail( ( not np_version_gte1p24 - or (np_version_gte1p24 and np._get_promotion_state() != "weak") + or ( + 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",