diff options
author | Sebastian Berg <sebastian@sipsolutions.net> | 2020-07-24 15:16:37 -0500 |
---|---|---|
committer | Sebastian Berg <sebastian@sipsolutions.net> | 2020-07-24 15:16:37 -0500 |
commit | ba09393c2401a7a5ca32a21dc975eaa59ea3d825 (patch) | |
tree | 79ffa79fac81858aab83be001784a16f3b690a4a /numpy/lib/tests/test_format.py | |
parent | 2d12d0c2f7ac7b5e79d95b958b4c75871029b9a6 (diff) | |
download | numpy-ba09393c2401a7a5ca32a21dc975eaa59ea3d825.tar.gz |
DEP: Deprecate size-one ragged array coercion
Previously, code such as:
```
np.array([0, np.array([0])], dtype=np.int64)
```
worked by discovering the array as having a shape of `(2,)` and
then using `int(np.array([0]))` (which currently succeeds).
This is also a ragged array, and thus deprecated here earlier on.
(As a detail, in the new code the assignment should occur as
an array assignment and not using the `__int__`/`__float__`
Python protocols.)
Two details to note:
1. This still skips the deprecation for sequences which are not
array-likes. We assume that sequences will always fail the
conversion to a number.
2. The conversion to a number (or string, etc.) may still fail
after the DeprecationWarning is given. This is not ideal, but
narrowing it down seems tedious, since the actual assignment
happens in a later step.
I.e. `np.array([0, np.array([None])], dtype=np.int64)` will give
the warning, but then fail anyway, since the array cannot be
assigned.
Closes gh-16939
Diffstat (limited to 'numpy/lib/tests/test_format.py')
0 files changed, 0 insertions, 0 deletions