-
Notifications
You must be signed in to change notification settings - Fork 54
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
Introduce DNDarray.__array__()
method
#1154
Conversation
Thank you for the PR! |
Thank you for the PR! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From my point of view the changes look fine 👍
Therefore I recommend merging if the CI succeeds.
Thank you for the PR! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
Description
This method returns a view of the underlying process-local array as numpy ndarray. If the DNDarray is on GPU, the array is copied to CPU first.
With this change, passing a DNDarray to
np.asarray()
returns a valid np.ndarray. This is needed for interoperability with other libraries in the numpy ecosystem.Basic example with
xarray
:If the DNDarray is distributed, the example above will return an xarray of the local slice of data on each MPI process.
Related: #1031
Issue/s resolved: #1153
Changes proposed:
DNDarray.__array__()
methodDNDarray.numpy()
methodType of change
Memory requirements
NA
Performance
NA
Due Diligence
Does this change modify the behaviour of other functions? If so, which?
no