Enable cudf.pandas test_numpy_ufuncs_basic via tolerant Index comparison - #22924
Conversation
|
Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
test_numpy_ufuncs_basic via tolerant Index comparison
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (1)
📝 WalkthroughSummary by CodeRabbit
WalkthroughThe pandas testing plugin gains a Changespandas testing plugin – tolerance fixture and xfail mapping cleanup
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
/merge |
…rison (NVIDIA#22924) The cudf.pandas `pandas-tests` plugin xfailed 77 `tests/indexes/test_numpy_compat.py::test_numpy_ufuncs_basic[...]` parametrizations. 75 of them were not real failures: the GPU results are numerically correct and only differ from NumPy's CPU results by ~1 ULP for transcendental ufuncs (`sin`, `cos`, `tan`, `exp`, `log`, `sinh`, ...). They were xfailed only because `pandas._testing.assert_index_equal` compares `Index` values **exactly** (`check_exact=True`) by default, so the last-bit drift trips the assertion even though the values agree to `rtol=1e-5`. This PR lets those tests run and pass instead of being xfailed: - Adds a node-id-scoped, autouse fixture `relax_exact_index_compare` that, only for node ids matching `TOLERANT_INDEX_COMPARE_SUBSTRINGS` (currently `test_numpy_ufuncs_basic`), patches `tm.assert_index_equal` to inject `check_exact=False` (NumPy/pandas default `rtol`/`atol`) and restores it afterward. It reuses the existing `replace_kwargs` helper and is scoped by node id, so no other test's comparison is affected. - Drops the 75 now-passing entries from `NODEIDS_THAT_FAIL`. Two entries are intentionally **kept** xfailed because they are *not* a tolerance issue: `complex64-log2` and `complex128-log2`. There, `log2(0+0j)` yields `-inf+nanj` on the GPU (cupy) vs `-inf+0j` on the CPU (NumPy) — a structural `nan`-vs-`0` mismatch in the imaginary part that no `rtol`/`atol` can bridge. Their xfail reason is updated to say so. ### Safety / scope - The relaxation only loosens **value** comparison; dtype correctness is still enforced — `test_numpy_ufuncs_basic` makes its own explicit `assert result.dtype == ...` checks, which run independently of `assert_index_equal`. - The fixture is gated on the test node id, so the rest of the pandas-test suite continues to compare exactly. ### Verification Running `test_numpy_ufuncs_basic` with the updated plugin: **746 passed, 2 xfailed, 0 failures, 0 XPASS**. The tolerance margin is comfortable (~100× for float32 ULP drift, far larger for complex128), so it should hold across CI hardware. Authors: - GALI PREM SAGAR (https://github.com/galipremsagar) Approvers: - Matthew Murray (https://github.com/Matt711) URL: NVIDIA#22924
Description
The cudf.pandas
pandas-testsplugin xfailed 77tests/indexes/test_numpy_compat.py::test_numpy_ufuncs_basic[...]parametrizations. 75 of them were not real failures: the GPU results are numerically correct and only differ from NumPy's CPU results by ~1 ULP for transcendental ufuncs (sin,cos,tan,exp,log,sinh, ...). They were xfailed only becausepandas._testing.assert_index_equalcomparesIndexvalues exactly (check_exact=True) by default, so the last-bit drift trips the assertion even though the values agree tortol=1e-5.This PR lets those tests run and pass instead of being xfailed:
relax_exact_index_comparethat, only for node ids matchingTOLERANT_INDEX_COMPARE_SUBSTRINGS(currentlytest_numpy_ufuncs_basic), patchestm.assert_index_equalto injectcheck_exact=False(NumPy/pandas defaultrtol/atol) and restores it afterward. It reuses the existingreplace_kwargshelper and is scoped by node id, so no other test's comparison is affected.NODEIDS_THAT_FAIL.Two entries are intentionally kept xfailed because they are not a tolerance issue:
complex64-log2andcomplex128-log2. There,log2(0+0j)yields-inf+nanjon the GPU (cupy) vs-inf+0jon the CPU (NumPy) — a structuralnan-vs-0mismatch in the imaginary part that nortol/atolcan bridge. Their xfail reason is updated to say so.Safety / scope
test_numpy_ufuncs_basicmakes its own explicitassert result.dtype == ...checks, which run independently ofassert_index_equal.Verification
Running
test_numpy_ufuncs_basicwith the updated plugin: 746 passed, 2 xfailed, 0 failures, 0 XPASS. The tolerance margin is comfortable (~100× for float32 ULP drift, far larger for complex128), so it should hold across CI hardware.Checklist