Skip to content

Commit

Permalink
Add __array_interface__ to cudf.pandas numpy.ndarray proxy (#15936)
Browse files Browse the repository at this point in the history
closes #15926

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

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

URL: #15936
  • Loading branch information
mroeschke committed Jun 7, 2024
1 parent 0067444 commit 139ed6c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions python/cudf/cudf/pandas/_wrappers/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,10 @@ def cuda_array_interface(self: _FastSlowProxy):
return self._fsproxy_fast.__cuda_array_interface__


@property # type: ignore
def array_interface(self: _FastSlowProxy):
return self._fsproxy_slow.__array_interface__


def custom_iter(self: _FastSlowProxy):
return iter(self._fsproxy_slow)
2 changes: 2 additions & 0 deletions python/cudf/cudf/pandas/_wrappers/numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
make_intermediate_proxy_type,
)
from .common import (
array_interface,
array_method,
arrow_array_method,
cuda_array_interface,
Expand Down Expand Up @@ -115,6 +116,7 @@ def wrap_ndarray(cls, arr: cupy.ndarray | numpy.ndarray, constructor):
# So that pa.array(wrapped-numpy-array) works
"__arrow_array__": arrow_array_method,
"__cuda_array_interface__": cuda_array_interface,
"__array_interface__": array_interface,
# ndarrays are unhashable
"__hash__": None,
# iter(cupy-array) produces an iterable of zero-dim device
Expand Down

0 comments on commit 139ed6c

Please sign in to comment.