-
-
Notifications
You must be signed in to change notification settings - Fork 9.9k
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
DEP: records: Deprecate treating shape=0 as shape=None #15217
Conversation
`shape=n` is a shorthand for `shape=(n,)` except in the case when `n==0`, when it is a shorthand for `shape=None`. This special case is dangerous, as it makes `fromrecords(..., shape=len(a))` behave surprisingly when a is an empty sequence. Users impacted by this warning either: * Have a bug in their code, and will need to either: - wait for the deprecation to expire - change their code to use `(len(a),)` instead of `len(a)` * Are using the non-preferred spellling, and will need to replace a literal `0` or `False` with `None`
8e831b7
to
bc6d573
Compare
Should hit the mailing list |
No tests? |
Will add some tests at some point, and hit the mailing list. I doubt we'll get any resistance for deprecating an undocumented, untested, and hard-to-guess API when |
If it is not documented and hard to hit, it would be tempting to just change the behaviour without a |
I do not care about hitting the mailing list. It is just nonsense, no? Release notes would be good though. We could skip the deprecation by considering it a clear bug. I am not opposed to that, but since the work is already here for the deprecation, might as well go through it maybe. |
+1 Even though the old code explicitly checks for
The behavior is not documented; indeed, the docstrings for these |
@seberg, @WarrenWeckesser: can I get you two to agree on whether this should be merged as is, or modified such that the deprecation is skipped? |
If there is consensus that this is a bug fix that does not require a deprecation cycle, then removing the deprecation from the PR would be preferable, to avoid future work. It would also simplify how the unit tests will be implemented in the PR. @seberg, what do you think? |
I will just merge it as is. Can be followed up with an actual change by the next release IMO. Doing the deprecation (especially in cases that are easy to get rid of it), cannot really hurt. |
* `numpy.core.records.fromarrays` | ||
* `numpy.core.records.fromrecords` | ||
* `numpy.core.records.fromstring` | ||
* `numpy.core.records.fromfile` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this broke towncrier generation of the release notes since the template does not have a blank line between the end of this bullet list and the link to the PR, it is rendered as
as an array length like any other integer is. The affected functions are:
* `numpy.core.records.fromarrays`
* `numpy.core.records.fromrecords`
* `numpy.core.records.fromstring`
* `numpy.core.records.fromfile`
(`gh-15217 <https://github.com/numpy/numpy/pull/15217>`__)
Not sure how this passed CI ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possible that the tests ran when the extra blank line was around (i.e. we merge the ragged-array PR again)
shape=n
is a shorthand forshape=(n,)
except in the case whenn==0
, when it is a shorthand forshape=None
.This special case is dangerous, as it makes
fromrecords(..., shape=len(a))
behave surprisingly when a is an empty sequence.Users impacted by this warning either:
(len(a),)
instead oflen(a)
0
orFalse
withNone