|
9 | 9 | import pandas._testing as tm |
10 | 10 | from pandas.arrays import SparseArray |
11 | 11 |
|
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 | | - |
21 | 12 |
|
22 | 13 | @pytest.fixture(params=[np.add, np.logaddexp]) |
23 | 14 | def ufunc(request): |
@@ -247,12 +238,6 @@ def __init__(self, value) -> None: |
247 | 238 | def __add__(self, other): |
248 | 239 | return self.value + other.value |
249 | 240 |
|
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 | | - |
256 | 241 | arr = np.array([Dummy(0), Dummy(1)]) |
257 | 242 | ser = pd.Series(arr) |
258 | 243 | tm.assert_series_equal(np.add(ser, ser), pd.Series(np.add(ser, arr))) |
@@ -472,15 +457,12 @@ def add3(x, y, z): |
472 | 457 | ufunc(ser, ser, df) |
473 | 458 |
|
474 | 459 |
|
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. |
483 | 465 | ser = pd.Series([-1.5, -0.5, 0.5, 1.5]) |
484 | | - result = np.fix(ser) |
| 466 | + result = np.trunc(ser) |
485 | 467 | expected = pd.Series([-1.0, -0.0, 0.0, 1.0]) |
486 | 468 | tm.assert_series_equal(result, expected) |
0 commit comments