reno.components.HistoricalValue#

class reno.components.HistoricalValue(tracked_ref, index_eq)#

Bases: Reference

A wrapper class for a reference, specifically for getting a previous value indexed by some other equation.

Methods

__init__(tracked_ref, index_eq)

Create a node to refer to a previous value of a tracked reference.

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])

Execute the compute graph for this equation, this needs to be implemented in every subclass.

find_parts_of_type(search_type[, ...])

Recursively search for all EquationParts in the tree of the specified type.

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)

Get the string representation for referring to this reference, italicized and as a function of t to highlight it's a different timestep.

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.

parse(arg_strs, refs)

Convert a set of argument strings and references into a HistoricalValue node.

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()

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.

Attributes

dtype

The type of each underlying value.

model

Get the model associated with this historical value.

shape

The size of the data dimension, 1 by default.

timeseries

Returns symbolic operation for getting a timeseries view of the data.

label

Label is what's used in any visual representation (e.g. allows spaces where name does not.).

doc

A docstring to explain/describe the reference.

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

Return repr(self).

Return type:

str

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

Execute the compute graph for this equation, this needs to be implemented in every subclass.

Note that throughout a compute tree, this should effectively recurse through .eval() calls to all subparts as well.

Parameters:
  • t (int) – Timestep along simulation at which to evaluate.

  • save (bool) – Whether to store/track/cache the output in a tracked matrix. This is really only applicable to ``TrackedReference``s, but given recursive nature of this function, needs to always be passed down through all subsequent calls.

  • force (bool) – Whether to ignore a previously cached value and compute regardless.

  • kwargs (dict) – Any additional arguments to pass through evaluation tree.

Return type:

int | float | ndarray

get_shape()#

Get the size of the additional “data” dimension.

Prefer using shape property over directly calling this function.

Override this in any subclass to control how shape is calculated.

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

latex(**kwargs)#

Get the string representation for referring to this reference, italicized and as a function of t to highlight it’s a different timestep.

Parameters:

kwargs (dict)

Return type:

str

property model: Model#

Get the model associated with this historical value.

static parse(arg_strs, refs)#

Convert a set of argument strings and references into a HistoricalValue node.

Parsing these has to be handled differently from normal operations because it has to parse two separate references.

Parameters:
  • arg_strs (list[str])

  • refs (dict[str, Reference])

Return type:

HistoricalValue

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()#

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.

Return type:

str