reno.components.Metric#
- class reno.components.Metric(eq=None, label=None)#
Bases:
ReferenceAn equation for a measurement or observation on the overall simulation.
These run in a separate after-simulation analysis.
Generally intended to be a series aggregate type equation (e.g. using series_min/series_max/sum on slices of values across time from references computed during the simulation etc.
Methods
__init__([eq, label])Create a metric equation node.
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.
debug_equation(t[, sample])Get a latex string output with the debug version of this equation.
equal(obj)Returns a symbolic operation for checking equality with passed object.
equation(**kwargs)Get the representation of the full equation for the metric as a latex string.
eval([t, save, force])Compute the equation for the given timestep.
find_parts_of_type(search_type[, ...])Recursively search for all EquationParts in the tree of the specified type.
from_dict(data, refs)Deserialize reference and parse data from dictionary previously saved from
to_dict().get_shape()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)String representation suitable for a latex display.
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.
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.
qual_name([dot])Get a string with both the model and the reference name if this model is a submodel of something else.
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.
to_dict()Serialize class into a dictionary for saving to file.
Attributes
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.
Keep a reference to container model, makes it easier to compare refs across multiple models.
labelLabel is what's used in any visual representation (e.g. allows spaces where name does not.).
docA docstring to explain/describe the reference.
- Parameters:
eq (EquationPart)
label (str)
- __annotations__ = {}#
- __module__ = 'reno.components'#
- __repr__()#
Return repr(self).
- Return type:
str
- __setattr__(name, value)#
Implement setattr(self, name, value).
- Parameters:
name (str)
value (Any)
- debug_equation(t, sample=0, **kwargs)#
Get a latex string output with the debug version of this equation.
- Parameters:
t (int)
sample (int)
kwargs (dict)
- Return type:
str
- equation(**kwargs)#
Get the representation of the full equation for the metric as a latex string.
- Parameters:
kwargs (dict)
- Return type:
str
- eval(t=0, save=False, force=False, **kwargs)#
Compute the equation for the given timestep.
- Parameters:
t (int)
save (bool)
force (bool)
kwargs (dict)
- Return type:
int | float | ndarray
- from_dict(data, refs)#
Deserialize reference and parse data from dictionary previously saved from
to_dict().- Parameters:
data (dict)
refs (dict[str, TrackedReference])
- Return type:
None
- model#
Keep a reference to container model, makes it easier to compare refs across multiple models.
- pt(**refs)#
Get a pytensor graph representing this piece of an equation.
- Parameters:
refs (dict[str, TensorVariable])
- Return type:
TensorVariable
- pt_str(**refs)#
Construct a string containing relevant pytensor code for this piece of the equation. This is useful for “compiling” into pymc code.
- Parameters:
refs (dict[str, str])
- Return type:
str
- qual_name(dot=False)#
Get a string with both the model and the reference name if this model is a submodel of something else.
This is primarily used for helping distinguish things in a multimodel setup.
- Parameters:
dot (bool)
- Return type:
str
- to_dict()#
Serialize class into a dictionary for saving to file.
- Return type:
dict