Skip to content
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 40 additions & 77 deletions python/cudf/cudf/pandas/scripts/pandas-testing-plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,32 @@ def patch_testing_functions():
pytest.raises = replace_kwargs({"match": None})(pytest.raises)


# Node ids (matched by substring) whose only discrepancy from pandas is a
# small (~1e-6) GPU-vs-CPU floating-point difference in transcendental numpy
# ufuncs. Matching tests are tagged with the ``tolerant_index_compare`` marker
# during collection (see ``pytest_collection_modifyitems``), and
# ``relax_exact_index_compare`` relaxes ``tm.assert_index_equal`` from its
# default exact check to a tolerant one (with a tight ``rtol``) for them.
NODEIDS_TOLERANT_INDEX_COMPARE = ("test_numpy_ufuncs_basic",)


@pytest.fixture(autouse=True)
def relax_exact_index_compare(request):
if request.node.get_closest_marker("tolerant_index_compare") is None:
yield
return
import pandas._testing as tm

original = tm.assert_index_equal
tm.assert_index_equal = replace_kwargs(
Comment thread
Matt711 marked this conversation as resolved.
{"check_exact": False, "rtol": 1e-6}
)(original)
try:
yield
finally:
tm.assert_index_equal = original


# Dictionary to store function call counts
function_call_counts = defaultdict(lambda: defaultdict(int)) # type: ignore[var-annotated]

Expand Down Expand Up @@ -3127,72 +3153,8 @@ def pytest_unconfigure(config):
"tests/indexes/test_indexing.py::TestGetIndexer::test_get_indexer_base[multi]": "TODO: Add a reason for failure",
"tests/indexes/test_indexing.py::TestGetIndexer::test_get_indexer_base[tuples]": "TODO: Add a reason for failure",
"tests/indexes/test_indexing.py::TestTake::test_take_indexer_type": "TODO: Add a reason for failure",
"tests/indexes/test_numpy_compat.py::test_numpy_ufuncs_basic[complex128-arccos]": "TODO: Add a reason for failure",
"tests/indexes/test_numpy_compat.py::test_numpy_ufuncs_basic[complex128-arccosh]": "TODO: Add a reason for failure",
"tests/indexes/test_numpy_compat.py::test_numpy_ufuncs_basic[complex128-arcsin]": "TODO: Add a reason for failure",
"tests/indexes/test_numpy_compat.py::test_numpy_ufuncs_basic[complex128-arcsinh]": "TODO: Add a reason for failure",
"tests/indexes/test_numpy_compat.py::test_numpy_ufuncs_basic[complex128-arctan]": "TODO: Add a reason for failure",
"tests/indexes/test_numpy_compat.py::test_numpy_ufuncs_basic[complex128-arctanh]": "TODO: Add a reason for failure",
"tests/indexes/test_numpy_compat.py::test_numpy_ufuncs_basic[complex128-cos]": "TODO: Add a reason for failure",
"tests/indexes/test_numpy_compat.py::test_numpy_ufuncs_basic[complex128-cosh]": "TODO: Add a reason for failure",
"tests/indexes/test_numpy_compat.py::test_numpy_ufuncs_basic[complex128-exp2]": "TODO: Add a reason for failure",
"tests/indexes/test_numpy_compat.py::test_numpy_ufuncs_basic[complex128-exp]": "TODO: Add a reason for failure",
"tests/indexes/test_numpy_compat.py::test_numpy_ufuncs_basic[complex128-expm1]": "TODO: Add a reason for failure",
"tests/indexes/test_numpy_compat.py::test_numpy_ufuncs_basic[complex128-log10]": "TODO: Add a reason for failure",
"tests/indexes/test_numpy_compat.py::test_numpy_ufuncs_basic[complex128-log1p]": "TODO: Add a reason for failure",
"tests/indexes/test_numpy_compat.py::test_numpy_ufuncs_basic[complex128-log2]": "TODO: Add a reason for failure",
"tests/indexes/test_numpy_compat.py::test_numpy_ufuncs_basic[complex128-log]": "TODO: Add a reason for failure",
"tests/indexes/test_numpy_compat.py::test_numpy_ufuncs_basic[complex128-sin]": "TODO: Add a reason for failure",
"tests/indexes/test_numpy_compat.py::test_numpy_ufuncs_basic[complex128-sinh]": "TODO: Add a reason for failure",
"tests/indexes/test_numpy_compat.py::test_numpy_ufuncs_basic[complex128-tan]": "TODO: Add a reason for failure",
"tests/indexes/test_numpy_compat.py::test_numpy_ufuncs_basic[complex128-tanh]": "TODO: Add a reason for failure",
"tests/indexes/test_numpy_compat.py::test_numpy_ufuncs_basic[complex64-arccos]": "TODO: Add a reason for failure",
"tests/indexes/test_numpy_compat.py::test_numpy_ufuncs_basic[complex64-arccosh]": "TODO: Add a reason for failure",
"tests/indexes/test_numpy_compat.py::test_numpy_ufuncs_basic[complex64-arcsin]": "TODO: Add a reason for failure",
"tests/indexes/test_numpy_compat.py::test_numpy_ufuncs_basic[complex64-arcsinh]": "TODO: Add a reason for failure",
"tests/indexes/test_numpy_compat.py::test_numpy_ufuncs_basic[complex64-arctan]": "TODO: Add a reason for failure",
"tests/indexes/test_numpy_compat.py::test_numpy_ufuncs_basic[complex64-arctanh]": "TODO: Add a reason for failure",
"tests/indexes/test_numpy_compat.py::test_numpy_ufuncs_basic[complex64-cos]": "TODO: Add a reason for failure",
"tests/indexes/test_numpy_compat.py::test_numpy_ufuncs_basic[complex64-cosh]": "TODO: Add a reason for failure",
"tests/indexes/test_numpy_compat.py::test_numpy_ufuncs_basic[complex64-exp2]": "TODO: Add a reason for failure",
"tests/indexes/test_numpy_compat.py::test_numpy_ufuncs_basic[complex64-exp]": "TODO: Add a reason for failure",
"tests/indexes/test_numpy_compat.py::test_numpy_ufuncs_basic[complex64-expm1]": "TODO: Add a reason for failure",
"tests/indexes/test_numpy_compat.py::test_numpy_ufuncs_basic[complex64-log10]": "TODO: Add a reason for failure",
"tests/indexes/test_numpy_compat.py::test_numpy_ufuncs_basic[complex64-log1p]": "GPU complex64 precision differs from CPU",
"tests/indexes/test_numpy_compat.py::test_numpy_ufuncs_basic[complex64-log2]": "TODO: Add a reason for failure",
"tests/indexes/test_numpy_compat.py::test_numpy_ufuncs_basic[complex64-log]": "TODO: Add a reason for failure",
"tests/indexes/test_numpy_compat.py::test_numpy_ufuncs_basic[complex64-sin]": "TODO: Add a reason for failure",
"tests/indexes/test_numpy_compat.py::test_numpy_ufuncs_basic[complex64-sinh]": "TODO: Add a reason for failure",
"tests/indexes/test_numpy_compat.py::test_numpy_ufuncs_basic[complex64-tan]": "TODO: Add a reason for failure",
"tests/indexes/test_numpy_compat.py::test_numpy_ufuncs_basic[complex64-tanh]": "TODO: Add a reason for failure",
"tests/indexes/test_numpy_compat.py::test_numpy_ufuncs_basic[nullable_float-arccosh]": "AssertionError: Index are different",
"tests/indexes/test_numpy_compat.py::test_numpy_ufuncs_basic[nullable_float-arcsinh]": "AssertionError: Index are different",
"tests/indexes/test_numpy_compat.py::test_numpy_ufuncs_basic[nullable_float-cos]": "AssertionError: Index are different",
"tests/indexes/test_numpy_compat.py::test_numpy_ufuncs_basic[nullable_float-exp]": "AssertionError: Index are different",
"tests/indexes/test_numpy_compat.py::test_numpy_ufuncs_basic[nullable_float-expm1]": "AssertionError: Index are different",
"tests/indexes/test_numpy_compat.py::test_numpy_ufuncs_basic[nullable_float-log10]": "AssertionError: Index are different",
"tests/indexes/test_numpy_compat.py::test_numpy_ufuncs_basic[nullable_float-rad2deg]": "AssertionError: Index are different",
"tests/indexes/test_numpy_compat.py::test_numpy_ufuncs_basic[nullable_float-sin]": "AssertionError: Index are different",
"tests/indexes/test_numpy_compat.py::test_numpy_ufuncs_basic[nullable_float-sinh]": "AssertionError: Index are different",
"tests/indexes/test_numpy_compat.py::test_numpy_ufuncs_basic[nullable_float-tan]": "AssertionError: Index are different",
"tests/indexes/test_numpy_compat.py::test_numpy_ufuncs_basic[nullable_int-arcsinh]": "AssertionError: Index are different",
"tests/indexes/test_numpy_compat.py::test_numpy_ufuncs_basic[nullable_int-arctan]": "AssertionError: Index are different",
"tests/indexes/test_numpy_compat.py::test_numpy_ufuncs_basic[nullable_int-cos]": "AssertionError: Index are different",
"tests/indexes/test_numpy_compat.py::test_numpy_ufuncs_basic[nullable_int-log10]": "AssertionError: Index are different",
"tests/indexes/test_numpy_compat.py::test_numpy_ufuncs_basic[nullable_int-log2]": "AssertionError: Index are different",
"tests/indexes/test_numpy_compat.py::test_numpy_ufuncs_basic[nullable_int-sin]": "AssertionError: Index are different",
"tests/indexes/test_numpy_compat.py::test_numpy_ufuncs_basic[nullable_int-tan]": "AssertionError: Index are different",
"tests/indexes/test_numpy_compat.py::test_numpy_ufuncs_basic[nullable_int-tanh]": "AssertionError: Index are different",
"tests/indexes/test_numpy_compat.py::test_numpy_ufuncs_basic[nullable_uint-arccosh]": "AssertionError: Index are different",
"tests/indexes/test_numpy_compat.py::test_numpy_ufuncs_basic[nullable_uint-arcsinh]": "AssertionError: Index are different",
"tests/indexes/test_numpy_compat.py::test_numpy_ufuncs_basic[nullable_uint-cos]": "AssertionError: Index are different",
"tests/indexes/test_numpy_compat.py::test_numpy_ufuncs_basic[nullable_uint-exp]": "AssertionError: Index are different",
"tests/indexes/test_numpy_compat.py::test_numpy_ufuncs_basic[nullable_uint-expm1]": "AssertionError: Index are different",
"tests/indexes/test_numpy_compat.py::test_numpy_ufuncs_basic[nullable_uint-log10]": "AssertionError: Index are different",
"tests/indexes/test_numpy_compat.py::test_numpy_ufuncs_basic[nullable_uint-rad2deg]": "AssertionError: Index are different",
"tests/indexes/test_numpy_compat.py::test_numpy_ufuncs_basic[nullable_uint-sin]": "AssertionError: Index are different",
"tests/indexes/test_numpy_compat.py::test_numpy_ufuncs_basic[nullable_uint-sinh]": "AssertionError: Index are different",
"tests/indexes/test_numpy_compat.py::test_numpy_ufuncs_basic[nullable_uint-tan]": "AssertionError: Index are different",
"tests/indexes/test_numpy_compat.py::test_numpy_ufuncs_basic[complex128-log2]": "GPU log2(0+0j) yields -inf+nanj vs CPU -inf+0j (structural nan-vs-0, not a tolerance difference)",
"tests/indexes/test_numpy_compat.py::test_numpy_ufuncs_basic[complex64-log2]": "GPU log2(0+0j) yields -inf+nanj vs CPU -inf+0j (structural nan-vs-0, not a tolerance difference)",
"tests/indexes/test_numpy_compat.py::test_numpy_ufuncs_out[multi]": "TODO: Add a reason for failure",
"tests/indexes/test_numpy_compat.py::test_numpy_ufuncs_out[tuples]": "TODO: Add a reason for failure",
"tests/indexes/test_numpy_compat.py::test_numpy_ufuncs_reductions[multi-maximum]": "TODO: Add a reason for failure",
Expand Down Expand Up @@ -5960,17 +5922,6 @@ def pytest_unconfigure(config):
"tests/indexes/test_base.py::TestIndex::test_empty_fancy[bool-int64]": "Flaky/version-sensitive cudf.pandas dispatch",
"tests/indexes/test_base.py::TestIndex::test_empty_fancy[bool-uint32]": "Flaky/version-sensitive cudf.pandas dispatch",
"tests/indexes/test_base.py::TestIndex::test_empty_fancy[bool-uint64]": "Flaky/version-sensitive cudf.pandas dispatch",
"tests/indexes/test_numpy_compat.py::test_numpy_ufuncs_basic[nullable_float-arctan]": "Flaky/version-sensitive cudf.pandas dispatch",
"tests/indexes/test_numpy_compat.py::test_numpy_ufuncs_basic[nullable_float-cosh]": "Flaky/version-sensitive cudf.pandas dispatch",
"tests/indexes/test_numpy_compat.py::test_numpy_ufuncs_basic[nullable_float-log2]": "Flaky/version-sensitive cudf.pandas dispatch",
"tests/indexes/test_numpy_compat.py::test_numpy_ufuncs_basic[nullable_int-arccosh]": "Flaky/version-sensitive cudf.pandas dispatch",
"tests/indexes/test_numpy_compat.py::test_numpy_ufuncs_basic[nullable_int-cosh]": "Flaky/version-sensitive cudf.pandas dispatch",
"tests/indexes/test_numpy_compat.py::test_numpy_ufuncs_basic[nullable_int-expm1]": "Flaky/version-sensitive cudf.pandas dispatch",
"tests/indexes/test_numpy_compat.py::test_numpy_ufuncs_basic[nullable_int-log1p]": "Flaky/version-sensitive cudf.pandas dispatch",
"tests/indexes/test_numpy_compat.py::test_numpy_ufuncs_basic[nullable_int-sinh]": "Flaky/version-sensitive cudf.pandas dispatch",
"tests/indexes/test_numpy_compat.py::test_numpy_ufuncs_basic[nullable_uint-arctan]": "Flaky/version-sensitive cudf.pandas dispatch",
"tests/indexes/test_numpy_compat.py::test_numpy_ufuncs_basic[nullable_uint-cosh]": "Flaky/version-sensitive cudf.pandas dispatch",
"tests/indexes/test_numpy_compat.py::test_numpy_ufuncs_basic[nullable_uint-log2]": "Flaky/version-sensitive cudf.pandas dispatch",
"tests/indexes/test_old_base.py::TestBase::test_copy_shares_cache[simple_index0]": "Asserts private APIs",
"tests/indexes/test_old_base.py::TestBase::test_copy_shares_cache[simple_index13]": "Asserts private APIs",
"tests/indexes/test_old_base.py::TestBase::test_copy_shares_cache[simple_index1]": "Asserts private APIs",
Expand Down Expand Up @@ -7004,9 +6955,21 @@ def pytest_unconfigure(config):
}


def pytest_configure(config):
config.addinivalue_line(
"markers",
"tolerant_index_compare: relax tm.assert_index_equal to a tolerant "
"comparison for tests with small GPU-vs-CPU floating-point drift.",
)


@pytest.hookimpl(trylast=True)
def pytest_collection_modifyitems(session, config, items):
for item in items:
if any(
substr in item.nodeid for substr in NODEIDS_TOLERANT_INDEX_COMPARE
):
item.add_marker(pytest.mark.tolerant_index_compare)
if (reason := NODEIDS_TO_SKIP.get(item.nodeid, None)) is not None:
item.add_marker(pytest.mark.skip(reason=reason))
elif (
Expand Down
Loading