reno.components.Variable#

class reno.components.Variable(eq=None, label=None, doc=None, min=None, max=None, dim=1, user=False, group='', dtype=None)#

Bases: TrackedReference

A variable is a static value(s) or function that can be used as part of other equations, e.g. flow definitons.

https://insightmaker.com/docs/variables

Methods

__init__([eq, label, doc, min, max, dim, ...])

clip(min, max)

debug_equation(t[, sample])

equal(obj)

equation(**kwargs)

Get the representation of the full equation for a variable as a latex string.

eval([t, save, compute_mask, force])

Compute the equation for the given timestep.

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.

from_dict(data, refs)

Deserialize reference and parse data from dictionary previously saved from to_dict().

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.

history(index_eq)

Get a reference to a previous value of this reference.

initial_vals()

Variables can be set to distributions, so the inital vals in that case will be a population samled from the eq distribution.

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.

max_refs()

Get any references found in the max constraint equation.

min_refs()

Get any references found in the min constraint equation.

not_equal(obj)

populate(n, steps)

Initialize the matrix of values with size n x steps.

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.

resolve_init_array(obj_or_eq)

Convert a number or scalar/distribution into correct starting array.

seek_refs()

Immediate refs only, depth=1.

series_max()

series_min()

sum([axis])

to_dict()

Serialize class into a dictionary for saving to file.

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

user

If True, use visual interface to allow changing it via widgets.

model

Keep a reference to container model, makes it easier to compare refs across multiple models.

init

Initial value/equation for initial value for stock/flow/var at t=0

dim

Size of an optional extra dimension, allowing a given reference to describe a vector of values at every timestep.

implicit

Implicit components (normally created as subcomponents of more advanced operations) don't show up in diagrams, latex, or output JSON, since they are created by operations.

computed_mask

Follows same shape as value (up through first two dimensions), set of booleans indicating which values have already been evaluated and saved.

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'#
__setattr__(name, value)#

Implement setattr(self, name, value).

debug_equation(t, sample=0, **kwargs)#
equation(**kwargs)#

Get the representation of the full equation for a variable as a latex string.

Return type:

str

initial_vals()#

Variables can be set to distributions, so the inital vals in that case will be a population samled from the eq distribution.

user#

If True, use visual interface to allow changing it via widgets.