Skip to content

Commit

Permalink
Use more pylibcudf Python enums in cudf._lib (#17288)
Browse files Browse the repository at this point in the history
Similar to #17287. Also remove a `plc` naming shadowing

Authors:
  - Matthew Roeschke (https://github.com/mroeschke)

Approvers:
  - Matthew Murray (https://github.com/Matt711)

URL: #17288
  • Loading branch information
mroeschke authored Nov 9, 2024
1 parent e399e95 commit 7a499f6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
7 changes: 2 additions & 5 deletions python/cudf/cudf/_lib/groupby.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ from cudf._lib.utils cimport columns_from_pylibcudf_table

from cudf._lib.scalar import as_device_scalar

from pylibcudf.libcudf.replace cimport replace_policy
from pylibcudf.libcudf.scalar.scalar cimport scalar

import pylibcudf
Expand Down Expand Up @@ -244,13 +243,11 @@ cdef class GroupBy:
return columns_from_pylibcudf_table(shifts), columns_from_pylibcudf_table(keys)

def replace_nulls(self, list values, object method):
# TODO: This is using an enum (replace_policy) that has not been exposed in
# pylibcudf yet. We'll want to fix that import once it is in pylibcudf.
_, replaced = self._groupby.replace_nulls(
pylibcudf.table.Table([c.to_pylibcudf(mode="read") for c in values]),
[
replace_policy.PRECEDING
if method == 'ffill' else replace_policy.FOLLOWING
pylibcudf.replace.ReplacePolicy.PRECEDING
if method == 'ffill' else pylibcudf.replace.ReplacePolicy.FOLLOWING
] * len(values),
)

Expand Down
2 changes: 1 addition & 1 deletion python/cudf/cudf/_lib/json.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ cpdef read_json(object filepaths_or_buffers,
)
df = cudf.DataFrame._from_data(
*_data_from_columns(
columns=[Column.from_pylibcudf(plc) for plc in res_cols],
columns=[Column.from_pylibcudf(col) for col in res_cols],
column_names=res_col_names,
index_names=None
)
Expand Down
8 changes: 6 additions & 2 deletions python/cudf/cudf/_lib/lists.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ from cudf.core.buffer import acquire_spill_lock

from libcpp cimport bool

from pylibcudf.libcudf.types cimport null_order, size_type
from pylibcudf.libcudf.types cimport size_type

from cudf._lib.column cimport Column
from cudf._lib.utils cimport columns_from_pylibcudf_table
Expand Down Expand Up @@ -49,7 +49,11 @@ def sort_lists(Column col, bool ascending, str na_position):
plc.lists.sort_lists(
col.to_pylibcudf(mode="read"),
ascending,
null_order.BEFORE if na_position == "first" else null_order.AFTER,
(
plc.types.NullOrder.BEFORE
if na_position == "first"
else plc.types.NullOrder.AFTER
),
False,
)
)
Expand Down

0 comments on commit 7a499f6

Please sign in to comment.