The N-Dimensional array (cupynumeric.ndarray
)#
Constructing arrays#
New arrays can be constructed using the routines detailed in Array creation routines, and also by using the low-level ndarray constructor:
Calculation#
|
Returns True if all elements evaluate to True. |
|
Returns True if any of the elements of a evaluate to True. |
Array Attributes#
Memory Layout#
Information about the memory layout of the array. |
|
Tuple of array dimensions. |
|
Tuple of bytes to step in each dimension when traversing an array. |
|
Number of array dimensions. |
|
Python buffer object pointing to the start of the array's data. |
|
Number of elements in the array. |
|
The element size of this data-type object. |
|
Total bytes consumed by the elements of the array. |
|
Base object if memory is from some other object. |
|
An object to simplify the interaction of the array with the ctypes module. |
Data Type#
Data-type of the array's elements. |
Other Attributes#
The transposed array. |
|
The real part of the array. |
|
The imaginary part of the array. |
|
A 1-D iterator over the array. |
Array Methods#
Array conversion#
|
Copy an element of an array to a standard Python scalar and return it. |
Return the array as an |
|
|
Insert scalar into an array (scalar is cast to array's dtype, if possible) |
|
A compatibility alias for tobytes, with exactly the same behavior. |
|
Construct Python bytes containing the raw data bytes in the array. |
|
Write array to a file as text or binary (default). |
|
Dump a pickle of the array to the specified file. |
Returns the pickle of the array as a string. |
|
|
Copy of the array, cast to a specified type. |
Get a copy of the iterator as a 1-D array. |
|
|
New view of array with the same data. |
|
|
|
|
|
Set array flags WRITEABLE, ALIGNED, WRITEBACKIFCOPY, respectively. |
|
Fill the array with a scalar value. |
Shape manipulation#
|
Returns an array containing the same data with a new shape. |
|
Returns a view of the array with axes transposed. |
|
Return a view of the array with axis1 and axis2 interchanged. |
|
Return a copy of the array collapsed into one dimension. |
|
Return a flattened array. |
|
Remove axes of length one from a. |
Item selection and manipulation#
|
Take elements from an array along an axis. |
|
Replaces specified elements of the array with given values. |
|
Use an index array to construct a new array from a set of choices. |
|
Sort an array in-place. |
|
Returns the indices that would sort this array. |
|
Partition of an array in-place. |
|
Returns the indices that would partition this array. |
|
Find the indices into a sorted array a such that, if the corresponding elements in v were inserted before the indices, the order of a would be preserved. |
Return the indices of the elements that are non-zero. |
|
|
Return selected slices of an array along given axis. |
|
Return specified diagonals. |
|
Return the sum along diagonals of the array. |
Calculation#
|
a.max(axis=None, out=None, keepdims=False, initial=<no value>, |
|
Return indices of the maximum values along the given axis. |
|
a.min(axis=None, out=None, keepdims=False, initial=<no value>, |
|
Return indices of the minimum values along the given axis. |
|
Return an array whose values are limited to |
Complex-conjugate all elements. |
|
Return the complex conjugate, element-wise. |
|
|
Return the dot product of this array with |
|
Reverse the order of elements in an array along the given axis. |
|
a.sum(axis=None, dtype=None, out=None, keepdims=False, initial=0, where=None) |
|
|
|
Returns the average of the array elements along given axis. |
|
Returns the variance of the array elements along given axis. |
|
a.prod(axis=None, dtype=None, out=None, keepdims=False, initial=1, where=True) |
|
|
|
Returns True if all elements evaluate to True. |
|
Returns True if any of the elements of a evaluate to True. |
Find the unique elements of an array. |
Arithmetic, matrix multiplication, and comparison operations#
|
Return |
|
Return |
|
Return |
|
Return |
|
Return |
|
Return |
Truth value of an array(bool()):
Return |
Unary operations:
|
Return |
|
Return |
Return |
|
Return |
Arithmetic:
|
Return |
|
Return |
|
Return |
|
Return |
|
Return |
|
Return |
|
Return |
|
Return |
|
Return |
|
Return |
|
Return |
|
Return |
|
Return |
Arithmetic, in-place:
|
Return |
Return |
|
|
Return |
Return |
|
|
Return |
|
Return |
Return |
|
|
Return |
Return |
|
|
Return |
Return |
|
Return |
Matrix Multiplication:
|
Return |
|
Return |
|
Return |
Special methods#
For standard library functions:
Used if |
|
|
Deep copy of array. |
For pickling. |
|
|
For unpickling. |
Basic customization:
|
|
|
Returns either a new reference to self if dtype is not given or a new array of provided data type if dtype is different from the current dtype of the array. |
Container customization: (see Indexing)
Return |
|
|
Return |
|
Set |
|
Return |
Conversion; .. the operations int(), float() and complex(). They work only on arrays that have one element in them and return the appropriate scalar.
Return |
|
Return |
|
String representations:
Return |
|
Return |