Skip to content

Commit 2f246df

Browse files
authored
test: fixup log for cuDF (#2565)
fixup log for cuDF
1 parent 40ac119 commit 2f246df

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

narwhals/_pandas_like/series.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,9 +1023,12 @@ def log(self, base: float) -> Self:
10231023
dtype_backend = get_dtype_backend(native.dtype, implementation=implementation)
10241024

10251025
if implementation.is_cudf():
1026-
import cupy as cp
1026+
import cupy as cp # ignore-banned-import # cuDF dependency.
10271027

1028-
return self._with_native(cp.log(native) / cp.log(base))
1028+
native = self.native
1029+
log_arr = cp.log(native) / cp.log(base)
1030+
result_native = type(native)(log_arr, index=native.index, name=native.name)
1031+
return self._with_native(result_native)
10291032

10301033
if dtype_backend == "pyarrow":
10311034
import pyarrow.compute as pc

utils/import_check.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
BANNED_IMPORTS = {
77
"cudf",
8+
"cupy",
89
"dask",
910
"dask.dataframe",
1011
"dask_expr",

0 commit comments

Comments
 (0)