Reputation: 183
I typed in my IDLE (python 2.7.8 Windows 64bit) the following line after importing pylab as pl:
import pylab as pl
pl.ndarray([3,2,1])
producing this:
array([[[ 7.89725907e-316],
[ 7.83323137e-316]],
[[ 1.52244036e-316],
[ 8.00633853e-316]],
[[ 8.59792562e-316],
[ 8.20678215e-316]]])
Why has this happened?
Upvotes: 0
Views: 24
Reputation: 24278
ndarray
is the class underlying numpy arrays. It's not meant to call to construct arrays. Use pl. array([3, 2, 1])
instead.
The ndarray
docstring says:
ndarray(shape, dtype=float, buffer=None, offset=0, strides=None, order=None)
An array object represents a multidimensional, homogeneous array of fixed-size items. An associated data-type object describes the format of each element in the array (its byte-order, how many bytes it occupies in memory, whether it is an integer, a floating point number, or something else, etc.)
Arrays should be constructed using
array
,zeros
orempty
(refer to the See Also section below). The parameters given here refer to a low-level method (ndarray(...)
) for instantiating an array.
Upvotes: 2