Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove cudf._lib.round in favor of inlining pylibcudf #17430

Merged
merged 8 commits into from
Dec 6, 2024
1 change: 0 additions & 1 deletion python/cudf/cudf/_lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ set(cython_sources
orc.pyx
parquet.pyx
reduce.pyx
round.pyx
scalar.pyx
sort.pyx
stream_compaction.pyx
Expand Down
1 change: 0 additions & 1 deletion python/cudf/cudf/_lib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
orc,
parquet,
reduce,
round,
sort,
stream_compaction,
string_casting,
Expand Down
39 changes: 0 additions & 39 deletions python/cudf/cudf/_lib/round.pyx

This file was deleted.

19 changes: 14 additions & 5 deletions python/cudf/cudf/core/column/numerical_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from __future__ import annotations

from typing import TYPE_CHECKING, cast
from typing import TYPE_CHECKING, Literal, cast

import numpy as np

Expand Down Expand Up @@ -246,12 +246,21 @@ def corr(self, other: NumericalBaseColumn) -> float:
return cov / lhs_std / rhs_std

def round(
self, decimals: int = 0, how: str = "half_even"
self,
decimals: int = 0,
how: Literal["half_even", "half_up"] = "half_even",
) -> NumericalBaseColumn:
if not cudf.api.types.is_integer(decimals):
raise TypeError("Values in decimals must be integers")
"""Round the values in the Column to the given number of decimals."""
return libcudf.round.round(self, decimal_places=decimals, how=how)
raise TypeError("decimals must an integer")
mroeschke marked this conversation as resolved.
Show resolved Hide resolved
if how not in {"half_even", "half_up"}:
raise ValueError(f"{how=} must be either 'half_even' or 'half_up'")
plc_how = plc.round.RoundingMethod[how.upper()]
with acquire_spill_lock():
return type(self).from_pylibcudf( # type: ignore[return-value]
plc.round.round(
self.to_pylibcudf(mode="read"), decimals, plc_how
)
)

def _scan(self, op: str) -> ColumnBase:
return libcudf.reduce.scan(
Expand Down
Loading