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

have cudf work with new or old versions #88

Merged
merged 1 commit into from
Dec 2, 2024
Merged
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
16 changes: 11 additions & 5 deletions src/akimbo/cudf.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ def dec_cu(op, match=match_string):
def f(lay, **kwargs):
# op(column, ...)->column
col = op(lay._to_cudf(cudf, None, len(lay)), **kwargs)
return from_cudf(cudf.Series._from_column(col)).layout
if hasattr(cudf.Series, "_from_column"):
return from_cudf(cudf.Series._from_column(col)).layout
return from_cudf(cudf.Series(col)).layout

return dec(func=f, match=match, inmode="ak")

Expand All @@ -60,9 +62,11 @@ def f(lay, **kwargs):
def f(lay, method=meth, **kwargs):
# this is different from dec_cu, because we need to instantiate StringMethods
# before getting the method from it
col = getattr(
StringMethods(cudf.Series._from_column(lay._to_cudf(cudf, None, len(lay)))), method
)(**kwargs)
if hasattr(cudf.Series, "_from_column"):
ser = cudf.Series._from_column(lay._to_cudf(cudf, None, len(lay)))
else:
ser = cudf.Series(lay._to_cudf(cudf, None, len(lay)))
col = getattr(StringMethods(ser), method)(**kwargs)
return from_cudf(col).layout

setattr(CudfStringAccessor, meth, dec(func=f, match=match_string, inmode="ak"))
Expand All @@ -87,7 +91,9 @@ def f(lay, method=meth, **kwargs):
else:
# attributes giving components
col = m
return from_cudf(cudf.Series._from_column(col)).layout
if hasattr(cudf.Series, "_from_column"):
return from_cudf(cudf.Series._from_column(col)).layout
return from_cudf(cudf.Series(col)).layout

if isinstance(getattr(DatetimeColumn, meth), property):
setattr(
Expand Down
Loading