nums.numpy.array
-
nums.numpy.
array
(object, dtype=None, copy=True, order='K', ndmin=0, subok=False)[source] Creates a BlockArray.
This docstring was copied from numpy.array.
Some inconsistencies with the NumS version may exist.
- Parameters
object (array_like) – An array, any object exposing the array interface, an object whose __array__ method returns an array, or any (nested) sequence.
dtype (data-type, optional) – The desired data-type for the array. If not given, then the type will be determined as the minimum type required to hold the objects in the sequence.
copy (bool, optional) – If true (default), then the object is copied. Otherwise, a copy will only be made if __array__ returns a copy, if obj is a nested sequence, or if a copy is needed to satisfy any of the other requirements (dtype, order, etc.).
order ({'K'}, optional) –
Specify the memory layout of the array. If object is not an array, the newly created array will be in C order (row major) unless ‘F’ is specified, in which case it will be in Fortran order (column major). If object is an array the following holds.
order
no copy
copy=True
’K’
unchanged
F & C order preserved, otherwise most similar order
’A’
unchanged
F order if input is F and not C, otherwise C order
’C’
C order
C order
’F’
F order
F order
When
copy=False
and a copy is made for other reasons, the result is the same as ifcopy=True
, with some exceptions for A, see the Notes section. The default order is ‘K’.subok (bool, optional) – If True, then sub-classes will be passed-through, otherwise the returned array will be forced to be a base-class array (default).
ndmin (int, optional) – Specifies the minimum number of dimensions that the resulting array should have. Ones will be pre-pended to the shape as needed to meet this requirement.
- Returns
out – An array object satisfying the specified requirements.
- Return type
See also
empty_like
Return an empty array with shape and type of input.
ones_like
Return an array of ones with shape and type of input.
zeros_like
Return an array of zeros with shape and type of input.
full_like
Return a new array with shape of input filled with value.
empty
Return a new uninitialized array.
ones
Return a new array setting values to one.
zeros
Return a new array setting values to zero.
full
Return a new array of given shape filled with value.
Notes
Only order=’K’ is supported.
Only ndmin=0 is currently supported.
subok must be False
Examples
The doctests shown below are copied from NumPy. They won’t show the correct result until you operate
get()
.>>> nps.array([1, 2, 3]).get() array([1, 2, 3])
Upcasting:
>>> nps.array([1, 2, 3.0]).get() array([ 1., 2., 3.])
More than one dimension:
>>> nps.array([[1, 2], [3, 4]]).get() array([[1, 2], [3, 4]])
Type provided:
>>> nps.array([1, 2, 3], dtype=complex).get() array([ 1.+0.j, 2.+0.j, 3.+0.j])