reno.ops.mean#
- class reno.ops.mean(a, axis=0)#
Bases:
OperationAverage across the values of a vector (either timeseries or data dim).
String notation:
(mean A)Example
>>> import reno as r >>> a = r.Variable([0, 1, 2, 3]) >>> a.mean().eval() np.float64(1.5) >>> m = r.Model() >>> t = r.TimeRef() >>> m.v0 = r.Variable(t + 1) >>> m.v1 = r.Variable(m.v0.timeseries[t-2:t].mean()) >>> m() >>> m.v0.value array([[ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]) >>> m.v1.value array([[nan, 1. , 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5]])
Methods
__init__(**kwargs)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
OP_REPRIf 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.
non_repr_part_indices- Parameters:
a (EquationOrValue)
axis (int)
- __annotations__ = {}#
- __module__ = 'reno.ops'#
- 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
- 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:
ndarray
- op_latex(**kwargs)#
Output the latex string for this operation. Override this in subclasses.
- Parameters:
kwargs (dict)
- 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