summaryrefslogtreecommitdiff
path: root/numpy/doc/basics.py
diff options
context:
space:
mode:
authorNico Schlömer <nico.schloemer@gmail.com>2023-04-20 18:00:59 +0200
committerGitHub <noreply@github.com>2023-04-20 18:00:59 +0200
commit1acac891f99075128450aacf2a4538de3ff9d028 (patch)
treed7de52ce7cbac0e2ae51eb68ec2ca4289a9eb77f /numpy/doc/basics.py
parent64e692f741da5bf781870de7f6cd1aa5bb5a4070 (diff)
downloadnumpy-1acac891f99075128450aacf2a4538de3ff9d028.tar.gz
DEP: deprecate scalar conversions for arrays with ndim > 0 (#10615)
This PR reflects some of the progress achieved in issue #10404 and is used to asses the impact of the changes. With the changes in this PR, `float(numpy.array([1.0])` now gives a warning; likewise some other things: ```python import numpy a = numpy.random.rand(10, 1) a[0] = numpy.array([1.0]) # okay a[0] = numpy.array(1.0) # okay a[0] = 1.0 # okay b = numpy.random.rand(10) b[0] = numpy.array([1.0]) # ValueError: setting an array element with a sequence. b[0, ...] = numpy.array([1.0]) # okay b[0] = numpy.array(1.0) # okay b[0] = 1.0 # okay ``` This aligns the behavior of numpy arrays with that of lists: ```python float([3.14]) ``` ``` TypeError: float() argument must be a string or a number, not 'list' ``` ```python import numpy as np a = np.random.rand(5) a[0] = [3.14] ``` ``` ValueError: setting an array element with a sequence. ``` Fixes #10404.
Diffstat (limited to 'numpy/doc/basics.py')
0 files changed, 0 insertions, 0 deletions