Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
7 changes: 7 additions & 0 deletions docs/cudf/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,13 @@ def on_missing_reference(app, env, node, contnode):
("py:class", "Value"),
("py:class", "polars.lazyframe.frame.LazyFrame"),
("py:class", "cudf_polars.engine.persisted_result.PersistedBackend"),
# pylibcudf typing aliases rendered as bare names in autodoc signatures.
("py:class", "ColumnNameSpec"),
("py:class", "CudaStreamLike"),
("py:class", "Datasource"),
("py:class", "Span"),
("py:class", "SupportsArrayInterface"),
("py:class", "SupportsCudaArrayInterface"),
]
# Temporarily disable nitpick warnings for pandas: https://github.com/pandas-dev/pandas/issues/64584
nitpick_ignore_regex = [
Expand Down
13 changes: 11 additions & 2 deletions python/cudf/cudf/pandas/scripts/pandas-testing-plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -1814,8 +1814,6 @@ def pytest_unconfigure(config):
"tests/groupby/test_missing.py::test_groupby_column_index_name_lost_fill_funcs[bfill]": "AssertionError: Index are different",
"tests/groupby/test_missing.py::test_groupby_column_index_name_lost_fill_funcs[ffill]": "AssertionError: Index are different",
"tests/groupby/test_missing.py::test_indices_with_missing": "TODO: Add a reason for failure",
"tests/groupby/test_numeric_only.py::TestNumericOnly::test_extrema[max]": "Failed: DID NOT RAISE <class 'TypeError'>",
"tests/groupby/test_numeric_only.py::TestNumericOnly::test_extrema[min]": "Failed: DID NOT RAISE <class 'TypeError'>",
"tests/groupby/test_reductions.py::test_basic_aggregations[float32]": "AssertionError: Attributes of Series are different",
"tests/groupby/test_reductions.py::test_basic_aggregations[int32]": "AssertionError: Attributes of Series are different",
"tests/groupby/test_reductions.py::test_groupby_mean_no_overflow": "TODO: Add a reason for failure",
Expand Down Expand Up @@ -5243,6 +5241,13 @@ def pytest_unconfigure(config):
"tests/window/moments/test_moments_consistency_rolling.py::test_rolling_apply_consistency_sum[all_data7-rolling_consistency_cases0-False-sum]": "pandas xfails, but xpasses with cudf.pandas",
}

# Keep keys in alphabetical order
NODEIDS_THAT_MAY_FAIL = {
"tests/groupby/test_numeric_only.py::TestNumericOnly::test_extrema[max]": "Environment-sensitive TypeError expectation",
"tests/groupby/test_numeric_only.py::TestNumericOnly::test_extrema[min]": "Environment-sensitive TypeError expectation",
"tests/io/test_spss.py::test_spss_metadata": "pandas 3.0.3 metadata expectation is incompatible with pyreadstat 1.3.6",
}


def pytest_configure(config):
config.addinivalue_line(
Expand Down Expand Up @@ -5272,5 +5277,9 @@ def pytest_collection_modifyitems(session, config, items):
)
) is not None:
item.add_marker(pytest.mark.skip(reason=reason))
elif (
reason := NODEIDS_THAT_MAY_FAIL.get(item.nodeid, None)
) is not None:
item.add_marker(pytest.mark.xfail(reason=reason, strict=False))
elif (reason := NODEIDS_THAT_FAIL.get(item.nodeid, None)) is not None:
item.add_marker(pytest.mark.xfail(reason=reason))
4 changes: 3 additions & 1 deletion python/pylibcudf/pylibcudf/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# 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

# If libcudf was installed as a wheel, we must request it to load the library symbols.
Expand Down Expand Up @@ -52,6 +52,7 @@
transform,
transpose,
types,
typing,
unary,
utilities,
utils,
Expand Down Expand Up @@ -110,6 +111,7 @@
"transform",
"transpose",
"types",
"typing",
"unary",
"utilities",
"utils",
Expand Down
4 changes: 2 additions & 2 deletions python/pylibcudf/pylibcudf/aggregation.pyx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION.
# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

from cython.operator cimport dereference
Expand Down Expand Up @@ -428,7 +428,7 @@ cpdef Aggregation median():
return Aggregation.from_libcudf(move(make_median_aggregation[aggregation]()))


cpdef Aggregation quantile(list quantiles, interpolation interp = interpolation.LINEAR):
cpdef Aggregation quantile(list quantiles: list[float], interpolation interp = interpolation.LINEAR):
"""Create a quantile aggregation.

For details, see :cpp:func:`make_quantile_aggregation`.
Expand Down
6 changes: 5 additions & 1 deletion python/pylibcudf/pylibcudf/binaryop.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ from .scalar cimport Scalar
from .types cimport DataType
from .utils cimport _get_stream, _get_memory_resource
from cuda.bindings.cyruntime cimport cudaStream_t
from typing import TYPE_CHECKING

if TYPE_CHECKING:
from pylibcudf.typing import CudaStreamLike

__all__ = ["BinaryOperator", "binary_operation", "is_supported_operation"]

Expand All @@ -30,7 +34,7 @@ cpdef Column binary_operation(
RightBinaryOperand rhs,
binary_operator op,
DataType output_type,
object stream=None,
object stream: CudaStreamLike | None = None,
DeviceMemoryResource mr=None,
):
"""Perform a binary operation between a column and another column or scalar.
Expand Down
60 changes: 41 additions & 19 deletions python/pylibcudf/pylibcudf/column.pyx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# SPDX-FileCopyrightText: Copyright (c) 2023-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

from collections.abc import Iterable, Sequence
from cython.operator cimport dereference

from cpython.exc cimport PyErr_Occurred
Expand Down Expand Up @@ -58,15 +59,19 @@ from .traits cimport (
from .types cimport DataType, size_of, type_id
from pylibcudf.types import TypeId
from .utils cimport _get_stream, _get_memory_resource
from pylibcudf.typing import SupportsArrayInterface, SupportsCudaArrayInterface
from typing import TYPE_CHECKING

if TYPE_CHECKING:
from pylibcudf.typing import CudaStreamLike

from .gpumemoryview import _datatype_from_dtype_desc
from ._interop_helpers import ArrowLike, ColumnMetadata, _ObjectWithArrowMetadata

from itertools import accumulate
import array
import functools
import operator
from itertools import accumulate
from typing import Iterable
from cuda.bindings.cyruntime cimport cudaStream_t

try:
Expand All @@ -77,7 +82,12 @@ except ImportError as e:
pa_err = e


__all__ = ["Column", "ListsColumnView", "StructsColumnView", "is_c_contiguous"]
__all__ = [
"Column",
"ListsColumnView",
"StructsColumnView",
"is_c_contiguous",
]


cdef is_iterable(obj):
Expand Down Expand Up @@ -157,7 +167,7 @@ class ArrayInterfaceWrapper:
self.__array_interface__ = iface


cdef gpumemoryview _copy_array_to_device(object buf, object stream=None):
cdef gpumemoryview _copy_array_to_device(object buf, object stream: CudaStreamLike | None = None):
"""
Copy a host-side array.array buffer to device memory.

Expand Down Expand Up @@ -346,7 +356,7 @@ cdef class Column:
def __init__(
self, DataType data_type not None, size_type size, object data,
object mask, size_type null_count, size_type offset,
children, bint validate=True
children: Iterable[Column], bint validate=True
):
children = list(children)
if not all(isinstance(c, Column) for c in children):
Expand Down Expand Up @@ -406,7 +416,7 @@ cdef class Column:
def from_arrow(
obj: ArrowLike,
dtype: DataType | None = None,
object stream=None,
object stream: CudaStreamLike | None = None,
DeviceMemoryResource mr=None
) -> ArrowLike:
"""
Expand Down Expand Up @@ -604,7 +614,7 @@ cdef class Column:
DeviceBuffer buff,
DataType dtype,
size_type size,
children,
children: Iterable[Column],
):
"""
Create a Column from an RMM DeviceBuffer.
Expand Down Expand Up @@ -813,7 +823,7 @@ cdef class Column:
def from_scalar(
Scalar slr,
size_type size,
object stream=None,
object stream: CudaStreamLike | None = None,
DeviceMemoryResource mr=None,
):
"""Create a Column from a Scalar.
Expand Down Expand Up @@ -846,7 +856,7 @@ cdef class Column:
)
return Column.from_libcudf(move(c_result), _stream, mr)

cpdef Scalar to_scalar(self, object stream=None, DeviceMemoryResource mr=None):
cpdef Scalar to_scalar(self, object stream: CudaStreamLike | None = None, DeviceMemoryResource mr=None):
"""
Return the first value of 1-element column as a Scalar.

Expand Down Expand Up @@ -882,7 +892,7 @@ cdef class Column:
def all_null_like(
Column like,
size_type size,
object stream=None,
object stream: CudaStreamLike | None = None,
DeviceMemoryResource mr=None,
):
"""Create an all null column from a template.
Expand Down Expand Up @@ -921,7 +931,7 @@ cdef class Column:
tuple shape,
DataType dtype,
Column base=None,
object stream=None,
object stream: CudaStreamLike | None = None,
):
"""
Construct a list Column from a gpumemoryview and array
Expand Down Expand Up @@ -974,7 +984,11 @@ cdef class Column:
return nested

@classmethod
def from_array_interface(cls, obj, object stream=None):
def from_array_interface(
cls,
obj: SupportsArrayInterface,
object stream: CudaStreamLike | None = None,
):
"""
Create a Column from an object implementing the NumPy Array Interface.

Expand Down Expand Up @@ -1028,7 +1042,11 @@ cdef class Column:
)

@classmethod
def from_cuda_array_interface(cls, obj, object stream=None):
def from_cuda_array_interface(
cls,
obj: SupportsCudaArrayInterface,
object stream: CudaStreamLike | None = None,
):
"""
Create a Column from an object implementing the CUDA Array Interface.

Expand Down Expand Up @@ -1067,7 +1085,11 @@ cdef class Column:
)

@classmethod
def from_array(cls, obj, object stream=None):
def from_array(
cls,
obj: SupportsCudaArrayInterface | SupportsArrayInterface,
object stream: CudaStreamLike | None = None,
):
"""
Create a Column from any object which supports the NumPy
or CUDA array interface.
Expand Down Expand Up @@ -1113,7 +1135,7 @@ cdef class Column:
def from_iterable_of_py(
obj: Iterable,
dtype: DataType | None = None,
object stream=None
object stream: CudaStreamLike | None = None
) -> Column:
"""
Create a Column from a Python iterable of scalar values or nested iterables.
Expand Down Expand Up @@ -1399,7 +1421,7 @@ cdef class Column:
"""The children of the column."""
return self._children

cpdef Column copy(self, object stream=None, DeviceMemoryResource mr=None):
cpdef Column copy(self, object stream: CudaStreamLike | None = None, DeviceMemoryResource mr=None):
"""Create a copy of the column."""
cdef unique_ptr[column] c_result
cdef Stream _stream = _get_stream(stream)
Expand Down Expand Up @@ -1461,7 +1483,7 @@ cdef class Column:

return PyCapsule_New(<void*>raw_schema_ptr, 'arrow_schema', _release_schema)

def _to_host_array(self, object stream):
def _to_host_array(self, object stream: CudaStreamLike):
cdef ArrowArray* raw_host_array_ptr
cdef Stream _stream = _get_stream(stream)
cdef cudaStream_t _cs = _stream.view().value()
Expand Down Expand Up @@ -1532,7 +1554,7 @@ cdef class ListsColumnView:
"""
return lists_column_view(self._column.view())

cpdef Column get_sliced_child(self, object stream=None):
cpdef Column get_sliced_child(self, object stream: CudaStreamLike | None = None):
"""
Get the list elements child properly sliced to match parent's view.

Expand Down Expand Up @@ -1570,7 +1592,7 @@ cdef class StructsColumnView:
"""
return structs_column_view(self._column.view())

cpdef Column get_sliced_child(self, int index, object stream=None):
cpdef Column get_sliced_child(self, int index, object stream: CudaStreamLike | None = None):
"""
Get the struct elements child properly sliced to match parent's view.

Expand Down
22 changes: 13 additions & 9 deletions python/pylibcudf/pylibcudf/column_factories.pyx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION.
# SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
from libcpp.memory cimport unique_ptr
from libcpp.utility cimport move
Expand All @@ -20,6 +20,10 @@ from .types cimport DataType, type_id

from .types import MaskState, TypeId
from .utils cimport _get_stream, _get_memory_resource
from typing import TYPE_CHECKING

if TYPE_CHECKING:
from pylibcudf.typing import CudaStreamLike
from cuda.bindings.cyruntime cimport cudaStream_t


Expand All @@ -34,8 +38,8 @@ __all__ = [
]

cpdef Column make_empty_column(
MakeEmptyColumnOperand type_or_id,
object stream=None,
MakeEmptyColumnOperand type_or_id: DataType | TypeId,
object stream: CudaStreamLike | None = None,
DeviceMemoryResource mr=None,
):
"""Creates an empty column of the specified type.
Expand Down Expand Up @@ -83,7 +87,7 @@ cpdef Column make_numeric_column(
DataType type_,
size_type size,
MaskArg mstate,
object stream=None,
object stream: CudaStreamLike | None = None,
DeviceMemoryResource mr=None,
):
"""Creates an empty numeric column.
Expand Down Expand Up @@ -122,7 +126,7 @@ cpdef Column make_fixed_point_column(
DataType type_,
size_type size,
MaskArg mstate,
object stream=None,
object stream: CudaStreamLike | None = None,
DeviceMemoryResource mr=None,
):

Expand Down Expand Up @@ -158,7 +162,7 @@ cpdef Column make_timestamp_column(
DataType type_,
size_type size,
MaskArg mstate,
object stream=None,
object stream: CudaStreamLike | None = None,
DeviceMemoryResource mr=None,
):

Expand Down Expand Up @@ -194,7 +198,7 @@ cpdef Column make_duration_column(
DataType type_,
size_type size,
MaskArg mstate,
object stream=None,
object stream: CudaStreamLike | None = None,
DeviceMemoryResource mr=None,
):

Expand Down Expand Up @@ -230,7 +234,7 @@ cpdef Column make_fixed_width_column(
DataType type_,
size_type size,
MaskArg mstate,
object stream=None,
object stream: CudaStreamLike | None = None,
DeviceMemoryResource mr=None,
):

Expand Down Expand Up @@ -264,7 +268,7 @@ cpdef Column make_fixed_width_column(

cpdef Column make_empty_lists_column(
DataType child_type,
object stream=None,
object stream: CudaStreamLike | None = None,
DeviceMemoryResource mr=None,
):
"""Creates an empty column of the specified type.
Expand Down
Loading
Loading