Module mpython.helpers.np
Struct cannot expose np.ndarray attributes/methods, as they may conflict with its keys.
This module implements external functions to access these attributes.
Some attributes/methods do not need to be implemented here, as they already exist in the numpy namespace. Examples include:
np.ndim
np.shape
np.size
np.reshape
np.squeeze
np.copy
np.ravel
as well as all math functions (np.sum
, np.mean
, etc.)
Functions
def T(array)
-
Expand source code
def T(array): """Equivalent to `array.T`.""" kls = type(array) return np.ndarray.view(array, np.ndarray).T.view(kls)
Equivalent to
array.T
. def base(array)
-
Expand source code
def base(array): """Equivalent to `array.base`.""" return np.ndarray.view(array, np.ndarray).base
Equivalent to
array.base
. def data(array)
-
Expand source code
def data(array): """Equivalent to `array.data`.""" return np.ndarray.view(array, np.ndarray).data
Equivalent to
array.data
. def dtype(array)
-
Expand source code
def dtype(array): """Equivalent to `array.dtype`.""" return np.ndarray.view(array, np.ndarray).dtype
Equivalent to
array.dtype
. def dump(array, file)
-
Expand source code
def dump(array, file): """Equivalent to `array.dump(file)`.""" return np.ndarray.dump(array, file)
Equivalent to
array.dump(file)
. def dumps(array, file)
-
Expand source code
def dumps(array, file): """Equivalent to `array.dumps(file)`.""" return np.ndarray.dumps(array, file)
Equivalent to
array.dumps(file)
. def fill(array, value)
-
Expand source code
def fill(array, value): """Equivalent to `array.fill(value)`.""" return np.ndarray.fill(array, value)
Equivalent to
array.fill(value)
. def flags(array)
-
Expand source code
def flags(array): """Equivalent to `array.flags`.""" return np.ndarray.view(array, np.ndarray).flags
Equivalent to
array.flags
. def flat(array)
-
Expand source code
def flat(array): """Equivalent to `array.flat`.""" return np.ndarray.view(array, np.ndarray).flat
Equivalent to
array.flat
. def flatten(array)
-
Expand source code
def flatten(array): """Equivalent to `array.flatten()`.""" return np.ndarray.flatten(array)
Equivalent to
array.flatten()
. def item(array)
-
Expand source code
def item(array): """Equivalent to `array.item()`.""" return np.ndarray.item(array)
Equivalent to
array.item()
. def mT(array)
-
Expand source code
def mT(array): """Equivalent to `array.mT`.""" kls = type(array) return np.ndarray.view(array, np.ndarray).mT.view(kls)
Equivalent to
array.mT
. def resize(array, *new_shape, **kwargs) ‑> None
-
Expand source code
def resize(array, *new_shape, **kwargs) -> None: """Equivalent to `array.resize(*new_shape)`.""" np.ndarray.resize(array, *new_shape, **kwargs)
Equivalent to
array.resize(*new_shape)
. def strides(array)
-
Expand source code
def strides(array): """Equivalent to `array.strides`.""" return np.ndarray.view(array, np.ndarray).strides
Equivalent to
array.strides
. def tolist(array)
-
Expand source code
def tolist(array): """Equivalent to `array.tolist()`.""" return np.ndarray.tolist(array)
Equivalent to
array.tolist()
.