You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
numpy-dev using a dtype with a subarray field is deprecated #10815
@astrofrog reported DeprecationWarning: using a dtype with a subarray field is deprecated. warnings using numpy-dev in v4.0.x (example log). Since v4.0.x is installing numpy from master, while master installs from "nightly" (i.e., weekly) wheel, we won't see it until numpy's wheel is updated.
E DeprecationWarning: using a dtype with a subarray field is deprecated.
This can lead to inconsistent behaviour due to the resulting dtype being different from the input dtype.
You may try to use `dtype=dtype.base`, which should give the same result for most inputs,
but does not guarantee the output dimensions to match the subarray ones. (Deprecated NumPy 1.20)
In this case, c._base.format is a string, so I am not sure what dtype.base means in this context. @mhvk , any advise?
Thanks for the ping, I hope this will be easy to solve, these type of deprecations are not easy decisions :( (the issue is that the current behaviour is inconsistent when data is an array, or includes arrays). We could try to walk that line differently, maybe...
In the examples of the build log, it seems the array always consists of only an empty list, but I assume that is not necessary, since an np.empty(0) call would handle that fine as well? Do you know what data is, or is it arbitrary user input?
@pllim but in that case you probably have some control over it? I.e. it might always be an array, or always a sequence of tuples that has the correct shape?
@seberg - while I can fix the failures, I do wonder about the more general case - I thought it would make more sense as a new issue, so numpy/numpy#17511
I think this will have been fixed by numpy/numpy#17596, so we need to look out whether the deprecation warning error disappears once that hits "nightly".
Activity
seberg commentedon Oct 8, 2020
Thanks for the ping, I hope this will be easy to solve, these type of deprecations are not easy decisions :( (the issue is that the current behaviour is inconsistent when
datais an array, or includes arrays). We could try to walk that line differently, maybe...In the examples of the build log, it seems the array always consists of only an empty list, but I assume that is not necessary, since an
np.empty(0)call would handle that fine as well? Do you know whatdatais, or is it arbitrary user input?pllim commentedon Oct 8, 2020
Probably falls under "arbitrary," as this code is set up to parse in any number of XML data files meeting the VOTable format standards.
seberg commentedon Oct 8, 2020
@pllim but in that case you probably have some control over it? I.e. it might always be an array, or always a sequence of tuples that has the correct shape?
pllim commentedon Oct 8, 2020
Theoretically, yes.
mhvk commentedon Oct 8, 2020
@pllim - the fix that @seberg suggested (replacing
np.array([], dtype=)withnp.empty(0, dtype=)does seem to work. I'll make a PR...p.s. This solves a real annoyance with numpy:
So, magically, the output dtype is not the input dtype!
mhvk commentedon Oct 8, 2020
Oops, it solves the
astropy.io.votableproblems - I'll now look at theastropy.tableones....pllim commentedon Oct 8, 2020
Thank you, all! Looking forward to the PR. 😄
mhvk commentedon Oct 8, 2020
@seberg - while I can fix the failures, I do wonder about the more general case - I thought it would make more sense as a new issue, so numpy/numpy#17511
mhvk commentedon Oct 29, 2020
I think this will have been fixed by numpy/numpy#17596, so we need to look out whether the deprecation warning error disappears once that hits "nightly".