inversion_ideas.conditions.CustomCondition#
- class inversion_ideas.conditions.CustomCondition(func)[source]#
Define a custom
Conditionobject through a function.- Parameters:
- func
Callable Function to use as the condition. It should take a model as only argument and return a bool to evaluate whether the condition is valid or not for that particular model.
- func
Methods
Methods#
Methods documentation
- classmethod CustomCondition.create(func)[source]#
Create a
CustomConditionobject directly from a function.- Parameters:
- func
Callable Function to use as the condition. It should take a model as only argument and return a bool to evaluate whether the condition is valid or not for that particular model.
- func
- Returns:
Examples
>>> import numpy as np >>> >>> def is_all_positive(model): ... return np.all(model > 0) >>> >>> condition = CustomCondition.create(is_all_positive) >>> model = np.array([1, 2, 3]) >>> print(condition(model)) True
>>> model = np.array([-1, 2, 3]) >>> print(condition(model)) False
- CustomCondition.info(model)[source]#
Display information about the condition for a given model.
- Parameters:
- model(n_params,)
array Array with model values.
- model(n_params,)
- Returns:
rich.tree.Treerick.tree.Treeobject containing information about the condition.
- CustomCondition.update(model)[source]#
Update the condition.
- Parameters:
- model(n_params,)
array Array with model values.
- model(n_params,)