-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
decide on how to handle empty_like
#7940
Comments
Edit: this comment was nonsense |
a little more context. For some "slow to load" datasets, this can accidentally load the whole thing when one isn't ready for it. |
I might be wrong, but I think those are not ufuncs, and since However, Edit: actually, does |
zeros_like is essentially |
Note that there's a difference between Anyways, there might be something wrong with the way |
Ahhhh! thanks |
it seems to get this to work we would need to:
def full_like(array, fill_value, *, dtype=None):
if dtype is None:
dtype = array.dtype
return np.full(shape=array.shape, dtype=dtype, fill_value=fill_value)
functions = {np.full_like: full_like}
class CustomArray(InaccessibleArray):
def __array_function__(self, func, types, args, kwargs):
return functions[func](*args, **kwargs) With that, a modified version of the code would succeed without import xarray as xr
import numpy as np
array = CustomArray(np.zeros((3, 3), dtype="uint8"))
da = xr.DataArray(array, dims=["x", "y"])
xr.zeros_like(da) |
I didn't check if modifying |
Is your feature request related to a problem?
calling
np.empty_like
seems to be instantiating the whole array.Describe the solution you'd like
I'm not too sure. This is why I raised this as a "feature" and not a bug.
On one hand, it is pretty hard to "get" the underlying class.
Is it a:
I think that there are also some nuances between:
Describe alternatives you've considered
for now, i'm trying to avoid
empty_like
orzeros_like
.In general, we haven't seen much benefit from dask and cuda still needs careful memory management.
Additional context
No response
The text was updated successfully, but these errors were encountered: