discretize.utils.Zero

Inheritance diagram of Zero
class discretize.utils.Zero[source]

Carries out arithmetic operations between 0 and arbitrary quantities.

This class was designed to manage basic arithmetic operations between 0 and numpy.ndarray of any shape. It is a short circuiting evaluation that will return the expected values.

Examples

>>> import numpy as np
>>> from discretize.utils import Zero
>>> Z = Zero()
>>> Z
Zero
>>> x = np.arange(5)
>>> x + Z
array([0, 1, 2, 3, 4])
>>> Z - x
array([ 0, -1, -2, -3, -4])
>>> Z * x
Zero
>>> Z @ x
Zero
>>> Z[0]
Zero

Attributes

T

Returns the Zero class as an operator

ndim

Returns the dimension of Zero class, i.e. None.

shape

Returns the shape Zero class, i.e. None.

Methods

transpose()

Returns the transpose of the Zero class, i.e. itself.