Skip to content

user_defined

Contains the base classes to support .params and .attr containers for user-defined parameters and attributes.

AttrContainerMixin(*args, **kwargs)

Source code in pyoframe/user_defined.py
def __init__(self, *args, **kwargs) -> None:
    super().__init__(*args, **kwargs)
    self.attr = Container(preprocess=self._preprocess_attr)

Container(preprocess=None)

A container for user-defined attributes or parameters.

Parameters:

Name Type Description Default
preprocess

Callable[str, Any], optional A function to preprocess user-defined values before adding them to the container.

None

Examples:

>>> params = Container()
>>> params.a = 1
>>> params.b = 2
>>> params.a
1
>>> params.b
2
>>> for k, v in params:
...     print(k, v)
a 1
b 2
Source code in pyoframe/user_defined.py
def __init__(self, preprocess=None):
    self._preprocess = preprocess
    self._attributes = {}