inversion_ideas.conditions.CustomCondition#
- class inversion_ideas.conditions.CustomCondition(func)#
Define a custom
Conditionobject through a function.- Parameters:
- funcCallable
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.
Methods
Methods#
Methods documentation
- CustomCondition.__call__(model)#
Call self as a function.
- classmethod CustomCondition.create(func)#
Create a
CustomConditionobject directly from a function.- Parameters:
- funcCallable
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.
- Returns:
- CustomCondition
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)#
Display information about the condition for a given model.
- CustomCondition.initialize()#
Initialize the condition.
- CustomCondition.update(model)#
Update the condition.