-
-
Notifications
You must be signed in to change notification settings - Fork 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
cftime plotting fails on upstream-dev #4265
Comments
Thanks for noting this @dcherian; it seems like there may have been a change in NumPy that caused this. E.g. with NumPy master this doesn't work: >>> import numpy as np
>>> np.__version__
'1.20.0.dev0+2d12d0c'
>>> a = np.array([[1., 2.], [3., 4.]])
>>> a[:, 0] = (np.array([0.]), np.array([3650.]))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: setting an array element with a sequence. The requested array would exceed the maximum number of dimension of 1. But with earlier versions of NumPy it does: >>> import numpy as np
>>> np.__version__
'1.19.1'
>>> a = np.array([[1., 2.], [3., 4.]])
>>> a[:, 0] = (np.array([0.]), np.array([3650.]))
>>> a
array([[0.00e+00, 2.00e+00],
[3.65e+03, 4.00e+00]]) I'll need to investigate more to see whether this is something to bring up in the matplotlib or NumPy issue tracker (it could be nc-time-axis related too). I'm not sure if there's anything we can do in xarray to fix this. It's probably best to xfail these tests for the time being. |
xfailed with: #4271 |
I think this NumPy issue is related: numpy/numpy#16939. numpy/numpy#16943 was merged yesterday, which appears to have at least allowed this to continue to work for the time being: >>> import numpy as np
>>> a = np.array([[1., 2.], [3., 4.]])
>>> a[:, 0] = (np.array([0.]), np.array([3650.]))
<stdin>:1: DeprecationWarning: setting an array element with a sequence. This was supported in some cases where the elements are arrays with a single element. For example `np.array([1, np.array([2])], dtype=int)`. In the future this will raise the same ValueError as `np.array([1, [2]], dtype=int)`. Given that this will be deprecated, I think it's still worthwhile to investigate what's causing this upstream in matplotlib or nc-time-axis, but it should be safe to un-xfail these tests again. |
I think I tracked down the root of this odd behavior in nc-time-axis; see SciTools/nc-time-axis#45 for more details. |
nice work spencer! |
seen in https://dev.azure.com/xarray/xarray/_build/results?buildId=3365&view=logs&jobId=2280efed-fda1-53bd-9213-1fa8ec9b4fa8&j=2280efed-fda1-53bd-9213-1fa8ec9b4fa8&t=175181ee-1928-5a6b-f537-168f7a8b7c2d
e.g.
The text was updated successfully, but these errors were encountered: