reno.components.Operation#

class reno.components.Operation(*operands)#

Bases: EquationPart

Parent class to represent a mathematical operation in an equation.

Pretty useless by itself, look in reno/ops.py, we use a parent class to make it easier to distinguish/find parts of an equation that are operations.

Parameters:

operands (list[EquationParts]) – The sub equations the operation is applying across.

Methods

__init__(*operands)

clip(min, max)

equal(obj)

eval([t, save, force])

'wrap' all operation eval functions so we get better error handling.

find_refs_of_type(search_type[, already_checked])

Actually recursive as opposed to seek_refs, returns a list of all equation parts matching passed type.

get_shape()

For now this is returning an integer because we only allow a single additional dimension.

get_type()

Similar to shape, this gets computed recursively, used to automatically determine if the value needs to be initialized with a certain numpy type.

is_static()

Convenience shortcut for reno.utils.is_static() - True if this equation doesn't rely on any dynamic values (thus constant), False if it does.

latex(**kwargs)

Construct a string representation of this portion of the equation for use in a latex display.

not_equal(obj)

op_eval(**kwargs)

Any new operations should implement this method.

op_repr()

Get a string representation for the op name/label, used for printing and parsing.

op_types()

Get a list of classes that inherit from this one, in other words all of the possible defined operations.

pt(**refs)

Get a pytensor graph representing this piece of an equation.

pt_str(**refs)

Construct a string containing relevant pytensor code for this piece of the equation.

seek_refs()

Immediate refs only, depth=1.

series_max()

series_min()

sum([axis])

Attributes

OP_REPR

If defined, this is what gets printed as the 'label' for the operation in the repr, and is what's used during parsing.

dtype

The type of each underlying value.

shape

The size of the data dimension, 1 by default.

timeseries

Get a timeseries view of the data (includes all historical data across all timesteps.)

OP_REPR = None#

If defined, this is what gets printed as the ‘label’ for the operation in the repr, and is what’s used during parsing. Otherwise, just uses class name.

__annotations__ = {}#
__module__ = 'reno.components'#
__repr__()#

Return repr(self).

eval(t=0, save=False, force=False, **kwargs)#

‘wrap’ all operation eval functions so we get better error handling.

Parameters:
  • t (int)

  • save (bool)

  • force (bool)

Return type:

int | float | ndarray

get_shape()#

For now this is returning an integer because we only allow a single additional dimension. Note that this shape _does not_ incoporate time or batch dimensions, only the “data” dimension if applicable. This should be overridden by subclasses, e.g. operations which would change the shape.

Return type:

int

get_type()#

Similar to shape, this gets computed recursively, used to automatically determine if the value needs to be initialized with a certain numpy type.

Return type:

type

op_eval(**kwargs)#

Any new operations should implement this method. (Put all evaluation logic in here, as opposed to overriding eval.)

Return type:

int | float | ndarray

classmethod op_repr()#

Get a string representation for the op name/label, used for printing and parsing.

Return type:

str

static op_types()#

Get a list of classes that inherit from this one, in other words all of the possible defined operations.

Return type:

list[type]