inversion_ideas.base.WrappedArray#

class inversion_ideas.base.WrappedArray(array)#

Wraps a Numpy array into a class.

Wraps a single Numpy array into a class to create custom hyperparameter classes.

Parameters:
arrayarray

Array to be wrapped.

Attributes

T

Transpose.

dtype

The data-type for the wrapped array.

ndim

Number of dimensions in the wrapped array.

shape

Shape of the wrapped array.

size

Total number of elements in the wrapped array.

Methods

max([axis, out])

Maximum value in the wrapped array along a given axis.

min([axis, out])

Minimum value in the wrapped array along a given axis.

transpose()

Transpose.

copy

Examples

Wrap an array using this class:

>>> import numpy as np
>>> a = np.array([1., 2., 3., 4., 5.])
>>> array_wrapped = WrappedArray(a)
>>> array_wrapped
WrappedArray([1., 2., 3., 4., 5.])

We can operate with this array_wrapped as with any other array:

>>> array_wrapped * 2
array([ 2.,  4.,  6.,  8., 10.])
>>> array_wrapped @ array_wrapped
np.float64(55.0)

We can also pass it to Numpy functions:

>>> np.mean(array_wrapped)
np.float64(3.0)
>>> np.abs(array_wrapped)
array([1., 2., 3., 4., 5.])

Attributes#

WrappedArray.T#

Transpose.

Returns:
array
WrappedArray.dtype#

The data-type for the wrapped array.

WrappedArray.ndim#

Number of dimensions in the wrapped array.

Returns:
int
WrappedArray.shape#

Shape of the wrapped array.

Returns:
tuple of int
WrappedArray.size#

Total number of elements in the wrapped array.

Returns:
int

Methods#

Methods documentation

WrappedArray.copy()#

WrappedArray.max(axis=None, out=None, **kwargs)#

Maximum value in the wrapped array along a given axis.

See also

numpy.max

upstream function


WrappedArray.min(axis=None, out=None, **kwargs)#

Minimum value in the wrapped array along a given axis.

See also

numpy.min

upstream function


WrappedArray.transpose()#

Transpose.

Returns:
array