Skip to content

Commit 3a662c6

Browse files
committed
MAINT: sync test_ufunc.py with main for PR #63088
1 parent 714d8a7 commit 3a662c6

File tree

1 file changed

+6
-24
lines changed

1 file changed

+6
-24
lines changed

pandas/tests/series/test_ufunc.py

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,6 @@
99
import pandas._testing as tm
1010
from pandas.arrays import SparseArray
1111

12-
# Probe whether np.fix works with Series without raising due to read-only out
13-
# This avoids relying solely on is_numpy_dev, which may not reflect CI pinning.
14-
try:
15-
_ser = pd.Series([-1.5, -0.5])
16-
_probe_result = np.fix(_ser)
17-
_NP_FIX_WORKS = True
18-
except Exception: # pragma: no cover - best-effort environment probe
19-
_NP_FIX_WORKS = False
20-
2112

2213
@pytest.fixture(params=[np.add, np.logaddexp])
2314
def ufunc(request):
@@ -247,12 +238,6 @@ def __init__(self, value) -> None:
247238
def __add__(self, other):
248239
return self.value + other.value
249240

250-
def __eq__(self, other) -> bool:
251-
return type(other) is Dummy and self.value == other.value
252-
253-
def __repr__(self) -> str:
254-
return f"Dummy({self.value})"
255-
256241
arr = np.array([Dummy(0), Dummy(1)])
257242
ser = pd.Series(arr)
258243
tm.assert_series_equal(np.add(ser, ser), pd.Series(np.add(ser, arr)))
@@ -472,15 +457,12 @@ def add3(x, y, z):
472457
ufunc(ser, ser, df)
473458

474459

475-
@pytest.mark.xfail(
476-
condition=not _NP_FIX_WORKS,
477-
reason="see https://github.com/pandas-dev/pandas/pull/51082",
478-
strict=True,
479-
)
480-
def test_np_fix():
481-
# np.fix is not a ufunc but is composed of several ufunc calls under the hood
482-
# with `out` and `where` keywords
460+
def test_np_trunc():
461+
# This used to test np.fix, which is not a ufunc but is composed of
462+
# several ufunc calls under the hood with `out` and `where` keywords. But numpy
463+
# is deprecating that (or at least discussing deprecating) in favor of np.trunc,
464+
# which _is_ a ufunc without the out keyword usage.
483465
ser = pd.Series([-1.5, -0.5, 0.5, 1.5])
484-
result = np.fix(ser)
466+
result = np.trunc(ser)
485467
expected = pd.Series([-1.0, -0.0, 0.0, 1.0])
486468
tm.assert_series_equal(result, expected)

0 commit comments

Comments
 (0)