reno.components.Operation#
- class reno.components.Operation(*operands)#
Bases:
EquationPartParent 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.
Methods
__init__(*operands)Create an operation node involving the passed sub equation parts.
astype(dtype)Returns a symbolic operation to convert the output of this equation to the specified type.
clip(min, max)Returns a symbolic operation for enforcing the output is between the passed min and max.
equal(obj)Returns a symbolic operation for checking equality with passed object.
eval([t, save, force])'wrap' all operation eval functions so we get better error handling.
find_parts_of_type(search_type[, ...])Recursively search for all EquationParts in the tree of the specified type.
Get the size of the additional "data" dimension.
get_type()Get the type of the target output of this equation expression.
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)Get a string of latex representing this op.
mean([axis])Returns a symbolic operation to find the series-wise mean of the array.
not_equal(obj)Returns a symbolic operation for checking inequality with passed object.
op_eval(**kwargs)Any new operations should implement this method.
op_latex(**kwargs)Output the latex string for this operation.
op_repr()Get a string representation for the op name/label.
op_types()Get a list of all defined operations/Operation subclasses.
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([include_ref_types])Recursively find a list of all References immediately underneath this part.
series_max()Returns a symbolic operation to find the series-wise maximum of the array.
series_min()Returns a symbolic operation to find the series-wise minimum of the array.
sum([axis])Returns a symbolic operation to find the series-wise sum of the array.
Attributes
If defined, this is what gets printed as the 'label' for the operation in the repr, and is what's used during parsing.
dtypeThe type of each underlying value.
shapeThe size of the data dimension, 1 by default.
timeseriesReturns symbolic operation for getting a timeseries view of the data.
Use this to "hide" a sub_equation_part in the string repr, e.g. if it's important for computation but isn't part of parsing.
- Parameters:
operands (list[EquationPart])
- 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).
- Return type:
str
- 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)
kwargs (dict)
- Return type:
int | float | ndarray
- get_shape()#
Get the size of the additional “data” dimension.
Prefer using
shapeproperty over directly calling this function.“Broadcasts” any size 1 dims to a larger dim node if present.
- Return type:
int
- get_type()#
Get the type of the target output of this equation expression.
Prefer using
dtypeproperty over directly calling this function.- Return type:
type
- latex(**kwargs)#
Get a string of latex representing this op.
Wrapper around op_latex, subclasses should override that function as opposed to this one.
- Parameters:
kwargs (dict)
- Return type:
str
- non_repr_part_indices#
Use this to “hide” a sub_equation_part in the string repr, e.g. if it’s important for computation but isn’t part of parsing.
- op_eval(**kwargs)#
Any new operations should implement this method.
Put all evaluation logic in here, as opposed to overriding eval.
- Parameters:
kwargs (dict)
- Return type:
int | float | ndarray
- op_latex(**kwargs)#
Output the latex string for this operation. Override this in subclasses.
- Parameters:
kwargs (dict)
- Return type:
str
- 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 all defined operations/Operation subclasses.
- Return type:
list[type]