darray¶
-
class
minkit.darray(array, ndim=1, length=None, backend=None)[source]¶ Bases:
minkit.farrayArray of floats.
Parameters: - array (numpy.ndarray or reikna.cluda.api.Array) – original array.
- ndim (int) – number of dimensions.
- length (int or None) – length of the array.
- backend (Backend or None) – backend where to put the array.
Attributes Summary
aopAssociated object to do array operations. backendBackend interface. dtypeData type. lengthLength as a numpy.int32instance.ndimNumber of dimensions of the array. shapeShape of the array. sizeSize of the array. uaUnderlying array. Methods Summary
argmax()Return the index with the maximum value. as_ndarray()Return the underlying array as a numpy.ndarrayinstance.astype(dtype)Convert the array into the given data type. copy()Copy this array. from_ndarray(a, backend)Create this class from a numpy.ndarrayinstance.get(index)Get an element of the array. max()Minimum value of the elements in the array. min()Minimum value of the elements in the array. slice(a)Get a slice of this array, that can be done using a boolean mask or an array of integers. sum()Sum the elements in the array. take_column([i])Take elements of the array using a period. take_slice([start, end])Take a slice of entries from the array. to_backend(backend)Send the array to the given backend. Attributes Documentation
-
aop¶ Associated object to do array operations.
-
backend¶ Backend interface.
-
dtype¶ Data type.
-
length¶ Length as a
numpy.int32instance.
-
ndim¶ Number of dimensions of the array.
-
shape¶ Shape of the array.
-
size¶ Size of the array.
-
ua¶ Underlying array.
Methods Documentation
-
argmax()[source]¶ Return the index with the maximum value.
Returns: Index with the maximum value. Return type: int
-
as_ndarray()¶ Return the underlying array as a
numpy.ndarrayinstance. If the underlying array is already of this type, no copy is done.Returns: underlying array as a numpy.ndarray.Return type: numpy.ndarray
-
astype(dtype)¶ Convert the array into the given data type. Only conversions from
farrayandcarrayobjects are allowed.Parameters: dtype (numpy.dtype) – data type. Returns: Converted array. Return type: farray or carray Raises: ValueError – If the conversion is not allowed.
-
copy()¶ Copy this array.
Returns: Copy of this array.
-
classmethod
from_ndarray(a, backend)[source]¶ Create this class from a
numpy.ndarrayinstance. If the number of dimensions is greater than one, the array is flattened, and each column is assumed to belong to a different parameter.Parameters: - a (numpy.ndarray) – array.
- backend (Backend) – backend where to create this array.
Returns: Newly created array.
-
get(index)¶ Get an element of the array. If the number of dimensions is greater than one, the output contains the value of each column in the array at the given index.
Parameters: index (int) – index to access. Returns: value(s) at the given index. Return type: numpy.ndarray Raises: IndexError – If there is an attempt to access an element out of range.
-
max()[source]¶ Minimum value of the elements in the array.
Returns: maximum of the elements. Return type: float
-
min()[source]¶ Minimum value of the elements in the array.
Returns: minimum of the elements. Return type: float
-
slice(a)[source]¶ Get a slice of this array, that can be done using a boolean mask or an array of integers.
Parameters: a (barray or iarray) – mask or indices array. Returns: slice of this array. Return type: darray Raises: ValueError – If the method is called for a data type different to bool or integer.
-
take_column(i=0)[source]¶ Take elements of the array using a period.
Parameters: i (int) – column to take the elements. Returns: reduced array. Return type: marray