Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
127 changes: 59 additions & 68 deletions ci/cudf_pandas_scripts/run_tests.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
# SPDX-FileCopyrightText: Copyright (c) 2023-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-FileCopyrightText: Copyright (c) 2023-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

set -eoxu pipefail
Expand Down Expand Up @@ -81,72 +81,63 @@ python -m pytest -p cudf.pandas \
-k "profiler" \
./python/cudf/cudf_pandas_tests/

version_lte() {
[ "$1" = "$(echo -e "$1\n$2" | sort -V | head -n1)" ]
}

read -r -a versions <<< "$(python ci/utils/get_matrix_values.py dependencies.yaml test_cudf_pandas_compat pandas_compat_version)"

if version_lte "${RAPIDS_PY_VERSION}" "3.13"; then
for version in "${versions[@]}"; do
rapids-logger "Testing cudf.pandas compatibility with pandas ${version}.*"

# Generate requirements for this pandas compat version.
# Each entry pins numpy<2 + the specific pandas minor line + the CUDA-appropriate cupy<14.
# cupy>=14 dropped support for numpy<2 (see https://github.com/cupy/cupy/pull/9406).
pandas_requirements_txt="pandas-compat-${version}-requirements.txt"
rapids-dependency-file-generator \
--config dependencies.yaml \
--file-key test_cudf_pandas_compat \
--output requirements \
--matrix "cuda=${RAPIDS_CUDA_VERSION};pandas_compat_version=${version}" \
> "${pandas_requirements_txt}"

env_name="venv_pandas_${version}"
python -m venv --clear "${env_name}"
# shellcheck disable=SC1090
source "${env_name}/bin/activate"

# notes:
#
# * echo to expand wildcard before adding `[test,cudf-pandas-tests]` requires for pip
# * need to provide --constraint="${PIP_CONSTRAINT}" because that environment variable is
# ignored if any other --constraint are passed via the CLI
#
rapids-pip-retry install \
-v \
--constraint ./constraints.txt \
--constraint "${PIP_CONSTRAINT}" \
"$(echo "${CUDF_WHEELHOUSE}"/cudf_"${RAPIDS_PY_CUDA_SUFFIX}"*.whl)[test,cudf-pandas-tests]" \
"$(echo "${LIBCUDF_WHEELHOUSE}"/libcudf_"${RAPIDS_PY_CUDA_SUFFIX}"*.whl)" \
"$(echo "${PYLIBCUDF_WHEELHOUSE}"/pylibcudf_"${RAPIDS_PY_CUDA_SUFFIX}"*.whl)" \
-r "${pandas_requirements_txt}"

python -m pytest -p cudf.pandas \
--ignore=./python/cudf/cudf_pandas_tests/third_party_integration_tests/ \
--numprocesses=8 \
--dist=worksteal \
-k "not profiler" \
-m "not serial" \
--config-file=./python/cudf/pyproject.toml \
--cov-config=./python/cudf/.coveragerc \
--cov=cudf \
--cov-report=xml:"${RAPIDS_COVERAGE_DIR}/cudf-pandas-coverage.xml" \
--cov-report=term \
./python/cudf/cudf_pandas_tests/

# NOTE: We don't currently run serial tests (only 1 as of 2025-07-25)
# with multiple versions of pandas.

python -m pytest -p cudf.pandas \
--ignore=./python/cudf/cudf_pandas_tests/third_party_integration_tests/ \
--numprocesses=0 \
-k "profiler" \
./python/cudf/cudf_pandas_tests/

deactivate
rm -rf "${env_name}" "${pandas_requirements_txt}"
done
else
rapids-logger "Python ${RAPIDS_PY_VERSION} detected (>= 3.13). Skipping cudf.pandas compatibility tests with numpy<2"
fi
for version in "${versions[@]}"; do
rapids-logger "Testing cudf.pandas compatibility with pandas ${version}.*"

# Generate requirements for this pandas compat version.
# Each entry pins the specific pandas minor line and the CUDA-appropriate cupy.
pandas_requirements_txt="pandas-compat-${version}-requirements.txt"
rapids-dependency-file-generator \
--config dependencies.yaml \
--file-key test_cudf_pandas_compat \
--output requirements \
--matrix "cuda=${RAPIDS_CUDA_VERSION};pandas_compat_version=${version}" \
> "${pandas_requirements_txt}"

env_name="venv_pandas_${version}"
python -m venv --clear "${env_name}"
# shellcheck disable=SC1090
source "${env_name}/bin/activate"

# notes:
#
# * echo to expand wildcard before adding `[test,cudf-pandas-tests]` requires for pip
# * need to provide --constraint="${PIP_CONSTRAINT}" because that environment variable is
# ignored if any other --constraint are passed via the CLI
#
rapids-pip-retry install \
-v \
--constraint ./constraints.txt \
--constraint "${PIP_CONSTRAINT}" \
"$(echo "${CUDF_WHEELHOUSE}"/cudf_"${RAPIDS_PY_CUDA_SUFFIX}"*.whl)[test,cudf-pandas-tests]" \
"$(echo "${LIBCUDF_WHEELHOUSE}"/libcudf_"${RAPIDS_PY_CUDA_SUFFIX}"*.whl)" \
"$(echo "${PYLIBCUDF_WHEELHOUSE}"/pylibcudf_"${RAPIDS_PY_CUDA_SUFFIX}"*.whl)" \
-r "${pandas_requirements_txt}"

python -m pytest -p cudf.pandas \
--ignore=./python/cudf/cudf_pandas_tests/third_party_integration_tests/ \
--numprocesses=8 \
--dist=worksteal \
-k "not profiler" \
-m "not serial" \
--config-file=./python/cudf/pyproject.toml \
--cov-config=./python/cudf/.coveragerc \
--cov=cudf \
--cov-report=xml:"${RAPIDS_COVERAGE_DIR}/cudf-pandas-coverage.xml" \
--cov-report=term \
./python/cudf/cudf_pandas_tests/

# NOTE: We don't currently run serial tests (only 1 as of 2025-07-25)
# with multiple versions of pandas.

python -m pytest -p cudf.pandas \
--ignore=./python/cudf/cudf_pandas_tests/third_party_integration_tests/ \
--numprocesses=0 \
-k "profiler" \
./python/cudf/cudf_pandas_tests/

deactivate
rm -rf "${env_name}" "${pandas_requirements_txt}"
done
8 changes: 1 addition & 7 deletions python/cudf/cudf/pandas/_wrappers/numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import cupy
import cupy._core.flags
import numpy
from packaging import version
from numpy._core.multiarray import flagsobj as _numpy_flagsobj

from cudf.options import _env_get_bool

Expand Down Expand Up @@ -324,12 +324,6 @@ def _ndarray_fsproxy_fast_to_slow(self):
},
)

if version.parse(numpy.__version__) >= version.parse("2.0"):
# NumPy 2 introduced `_core` and gives warnings for access to `core`.
from numpy._core.multiarray import flagsobj as _numpy_flagsobj
else:
from numpy.core.multiarray import flagsobj as _numpy_flagsobj

# Mapping flags between slow and fast types
_ndarray_flags = make_intermediate_proxy_type(
"_ndarray_flags",
Expand Down
31 changes: 1 addition & 30 deletions python/cudf/cudf/tests/indexes/test_interval.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# SPDX-FileCopyrightText: Copyright (c) 2023-2026, NVIDIA CORPORATION.
# SPDX-FileCopyrightText: Copyright (c) 2023-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
import numpy as np
import pandas as pd
import pyarrow as pa
import pytest
from packaging.version import parse

import cudf
from cudf.core.index import IntervalIndex, interval_range
Expand Down Expand Up @@ -121,14 +120,6 @@ def test_interval_range_periods_basic_dtype(start_t, end_t, periods_t):
gindex = cudf.interval_range(
start=start, end=end, periods=periods, closed="left"
)
if (
parse(np.__version__) < parse("2")
and pindex.dtype.subtype != gindex.dtype.subtype
):
# NEP 50 in numpy 2 changes pandas' subtype result to match cudf
pindex = pindex.astype(
pd.IntervalDtype(gindex.dtype.subtype, pindex.dtype.closed)
)

assert_eq(pindex, gindex)

Expand Down Expand Up @@ -172,16 +163,6 @@ def test_interval_range_periods_freq_end_dtype(periods_t, freq_t, end_t):
gindex = cudf.interval_range(
end=end, freq=freq, periods=periods, closed="left"
)
if (
parse(np.__version__) < parse("2")
and pindex.dtype.subtype != gindex.dtype.subtype
):
# NEP 50 in numpy 2 changes pandas' subtype result to match cudf
pindex = pindex.astype(
pd.IntervalDtype(
subtype=gindex.dtype.subtype, closed=pindex.dtype.closed
)
)
assert_eq(pindex, gindex)


Expand Down Expand Up @@ -211,16 +192,6 @@ def test_interval_range_periods_freq_start_dtype(periods_t, freq_t, start_t):
gindex = cudf.interval_range(
start=start, freq=freq, periods=periods, closed="left"
)
if (
parse(np.__version__) < parse("2")
and pindex.dtype.subtype != gindex.dtype.subtype
):
# NEP 50 in numpy 2 changes pandas' subtype result to match cudf
pindex = pindex.astype(
pd.IntervalDtype(
subtype=gindex.dtype.subtype, closed=pindex.dtype.closed
)
)
assert_eq(pindex, gindex)


Expand Down
16 changes: 2 additions & 14 deletions python/cudf/cudf/tests/test_doctests.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: Copyright (c) 2022-2026, NVIDIA CORPORATION.
# SPDX-FileCopyrightText: Copyright (c) 2022-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
import contextlib
import doctest
Expand All @@ -7,18 +7,9 @@

import numpy as np
import pytest
from packaging import version

import cudf

_SKIP_DOCTESTS = frozenset(
{
"register_dataframe_accessor",
"register_index_accessor",
"register_series_accessor",
}
)

# modules that will be searched for doctests
tests = [
cudf,
Expand Down Expand Up @@ -126,10 +117,7 @@ class TestDoctests:
def printoptions(cls):
# TODO: NumPy now prints scalars as `np.int8(1)`, etc. this should

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you want to fix this TODO while you're here? If it's hard, it's fine to defer on that.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Appeared straightforward enough with an agent. Done in e50cbcb

# be adapted evantually.
if version.parse(np.__version__) >= version.parse("2.0"):
with np.printoptions(legacy="1.25"):
yield
else:
with np.printoptions(legacy="1.25"):
yield

@pytest.mark.parametrize(
Expand Down
Loading