param.reactive.reactive_ops.overrides#

property reactive_ops.overrides: InputOverrides#

A mutable mapping of overrides for the inputs of this node.

Allows assigning values in the mapping addressed by keyword name or positional index. Setting one makes this node compute as if that input held the given value, leaving the input itself, and therefore its other consumers, untouched. Deleting the key unmasks the original input.

>>> import param
>>> fx = param.rx(2)
>>> expr = param.rx(10).rx.pipe(lambda value, fx: value * fx, fx=fx)
>>> expr.rx.overrides['fx'] = 1
>>> expr.rx.value
10
>>> del expr.rx.overrides['fx']
>>> expr.rx.value
20

An override may also be a reference, e.g. a Parameter, an expression, a bound function, a widget, which the node then follows:

>>> expr.rx.overrides['fx'] = param.rx(3)
>>> expr.rx.value
30

Positional indices follow the call the operation makes, so they count the value it is applied to: in a.rx.pipe(f, b) index 0 is a and index 1 is b, and in a * b index 0 is a. A reflected operator swaps them, 1 + a calls add(1, a), so a is index 1.

>>> expr.rx.overrides[0] = 100
>>> expr.rx.value
300

A positional input of a function applied with pipe() may also be addressed by its parameter name, if the function’s signature allows passing it by keyword; the override is still stored under its index. A keyword input of the same name takes precedence.

.args and .kwargs give the positional and keyword overrides as separate mappings, and assigning to either replaces all of its overrides at once, invalidating the node a single time:

>>> expr.rx.overrides.args = (5,)
>>> expr.rx.overrides.kwargs = {}
>>> expr.rx.value
10

The override stands in for the input and is resolved in its place, ahead of the guards the input would have faced, i.e. it even overrides input holding errors or undefined values. Any value masks the input, including None, so an override that follows a reference keeps masking when that reference happens to hold None.

Overrides are node-local, like .rx.meta: a derived node (expr + 1) has its own, empty mapping.

Returns:

The mutable mapping of overridden inputs for this node.

Return type:

InputOverrides

Raises:

AttributeError – If the .rx namespace does not belong to an rx node, or if the node has no inputs because it is the input of an expression.