reno.components.TimeRef#

class reno.components.TimeRef#

Bases: Reference

A reference to the current simulation timestep that can be used in equations.

Example

>>> from reno.components import TimeRef
>>> t = TimeRef()
>>> t + 3
(+ t 3)
>>> (t + 3).eval(4)
7

Methods

__init__()

clip(min, max)

equal(obj)

eval([t, save, force])

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

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)

String representation suitable for a latex display.

not_equal(obj)

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

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

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.

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

Return repr(self).

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.

Return type:

int

latex(**kwargs)#

String representation suitable for a latex display.

Return type:

str

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