-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
BUG: Fix display with nested NumPy arrays #10222
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
Conversation
Thank you for opening this pull request! It may take us a few days to respond here, so thank you for being patient. |
Currently, the following will fail to display: ```python import xarray as xr import numpy as np x = np.empty((2, 2), dtype=object) for i in range(2): for j in range(2): x[i, j] = np.zeros(2) # Set to 1D array of size 2 ds = xr.DataArray(x) ds ``` Whenever there are `size==1` arrays, it currently does work: ```python import xarray as xr import numpy as np x = np.empty((2, 2), dtype=object) for i in range(2): for j in range(2): x[i, j] = np.zeros((1, 1, 1)) # Set to 3D array of size 1 ds = xr.DataArray(x) ds For context, I am running into this issue in https://github.com/pipefunc/pipefunc where one can put the resulting objects into `xarray.Dataset`s. For example, see the docs here https://pipefunc.readthedocs.io/en/latest/examples/physics-simulation/ (search for `xarray.Dataset`).
41dfa16
to
bf78f2c
Compare
Now test_slice_in_title_single_item_array is failing with:
This test was introduced in #5948 and touches the exact same code that I changed. I think the test that is failing now is wrong and should be updated to |
OK please update the test in that case. Merging in main should fix the other "array api" failures |
@dcherian, I updated the tests, all is passing except some (I believe) unrelated failure. |
Currently, the following will fail to display:
Click to see the error message
Whenever there are
size==1
arrays, it currently does work:Should I add these examples as regression tests anywhere, if so, where?
For context, I am running into this issue in https://github.com/pipefunc/pipefunc where one can put the resulting objects into
xarray.Dataset
s.For example, see the docs here https://pipefunc.readthedocs.io/en/latest/examples/physics-simulation/ (search for
xarray.Dataset
).whats-new.rst
api.rst