Just for fun played around with the convergence criteria a little (see #23). Not sure if this is the way we want to go, but I tried to simplify the interface a little bit.
By implementing the __bool__ functionality, we can perform checks as follows, but not sure if this might conflict with if ... checks for checking with respect to None. It might be nicer to just provide a property or a function call, as done in the current code.
converged = MaxIter(10)
while not converged:
...
Also added the __and__ and __or__ that return either a And or Or variant, to combine different criteria
converged = MaxIter(10) & ObjectiveChange(1e-3) # requires both to return true
converged = MaxIter(10) | ObjectiveChange(1e-3) # requires either to return true
Not sure if this is nice, or just gimmicky. This can then also be chained, although haven't tried that in-depth,
converged = a & b & c | d & e | f
Although this isn't the most readable way to express such a big relation of criteria 😅
Just for fun played around with the convergence criteria a little (see #23). Not sure if this is the way we want to go, but I tried to simplify the interface a little bit.
By implementing the
__bool__
functionality, we can perform checks as follows, but not sure if this might conflict withif ...
checks for checking with respect to None. It might be nicer to just provide a property or a function call, as done in the current code.Also added the
__and__
and__or__
that return either aAnd
orOr
variant, to combine different criteriaNot sure if this is nice, or just gimmicky. This can then also be chained, although haven't tried that in-depth,
Although this isn't the most readable way to express such a big relation of criteria 😅
Interested to hear your thoughts