DEP: issue deprecation warning when creating ragged array (NEP 34)#14794
DEP: issue deprecation warning when creating ragged array (NEP 34)#14794rgommers merged 10 commits intonumpy:masterfrom
Conversation
numpy/core/tests/test_multiarray.py
Outdated
There was a problem hiding this comment.
These are the real NEP 34 tests (from here down in this file): they test that the behaviour has not changed when using the dtype=object kwarg, and that the warning does not seem to have false-positives when no dtype is used.
|
The ppc64le build failure is not related to this PR. |
|
I think it would be good to get this into 1.18 so it can be deprecated in 1.20 |
|
The NEP was accepted, this is ready for final review |
| {% if definitions[category]['showcontent'] %} | ||
| {% for text, values in sections[section][category].items() %} | ||
| {{ text }} | ||
|
|
There was a problem hiding this comment.
Deliberate. The changenote has a link as the last line, which confuses sphinx when assembling the notes into the final text unless it is followed by a blank line
eric-wieser
left a comment
There was a problem hiding this comment.
Looks good to me, probably worth a quick lookover by @seberg
| # None of these should raise, even though they are missing dtype=object | ||
| a = np.array([[[Decimal(1)]]]) | ||
| a = np.array([1, Decimal(1)]) | ||
| a = np.array([[1], [Decimal(1)]]) |
There was a problem hiding this comment.
In principle could be nice to add that similar cases (also None) such as [None, [None, None]] do correctly warn. (although maybe I missed a test that checks this already)
There was a problem hiding this comment.
Do you mean specifically ragged lists of objects? In the tests above this ragged arrays of integers are checked.
seberg
left a comment
There was a problem hiding this comment.
Cool! Looks good to me. Did not really expect it would be quite this simple :). From my side, can be merged right away.
| /* NumPy 1.18, 2019-11-01 */ | ||
| if (DEPRECATE("Creating an ndarray with automatic object " | ||
| "dtype is deprecated, use dtype=object if you intended " | ||
| "it, otherwise specify an exact dtype") < 0) |
There was a problem hiding this comment.
could style nit, that the indentation should be deeper, but please ignore if you want.
There was a problem hiding this comment.
Will try to sneak it into another PR
REV: Revert "Merge pull request #14794 from mattip/nep-0034-impl"
Since numpy 1.18 creating ragged arrays requires explit opt-in via dtype-object [1]. Let's to that then. [1]: numpy/numpy#14794
Since numpy 1.18 creating ragged arrays requires explit opt-in via dtype-object [1]. Let's to that then. [1]: numpy/numpy#14794
Since numpy 1.18 creating ragged arrays requires explit opt-in via dtype-object [1]. Let's to that then. [1]: numpy/numpy#14794
A demo of the direction ofImplement NEP 34 (deprecating automatic object detection of ragged arrays). It seems to workexcept forincluding record arraysI needed to filter the DeprecationWarning in `assert_equal(x, y) since they could be ragged lists.