-
Notifications
You must be signed in to change notification settings - Fork 215
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
ENH: Support obects with __array__ method #573
Comments
Yes, it would be great to have support for |
Oh, sorry, I hadn't checked that xarray had this interface. Anyway, our use case is that we have In [1]: import xarray as xr
In [2]: from pyproj import Proj
In [6]: prj(xr.DataArray([1, 2, 3]), xr.DataArray([1, 2, 3]))
TypeError: input must be an array, list, tuple or scalar
In [7]: import dask.array as da
In [8]: prj(da.from_array([1, 2, 3]), da.from_array([1, 2, 3]))
TypeError: input must be an array, list, tuple or scalar It would be nice if pyproj wouldn't just choke on these. Just calling eg |
Okay, so if I interpreted that correctly, you would be okay with getting a numpy array returned? Next step is to check if dask has the same |
I'd be ok with that. Maybe @djhoese has an opinion on this ? |
Part of me wishes pyproj could magically know how to handle dask arrays in a dask-friendly way (map_blocks wrapper), but I think converting to a numpy array and returning a numpy array matches xarray behavior. For example, when there are methods in xarray that dask doesn't support I believe xarray just converts to numpy and continues on processing. |
Looks like the dask array also has __array__, so I think the code could be updated to just call that function and it would work for both. |
Implemented in #625 |
Looks like this will also work with pandas.Series.__array__ |
https://docs.scipy.org/doc/numpy/reference/arrays.interface.html
Had the thought, putting here to look into.
The text was updated successfully, but these errors were encountered: