WrappedOptimizer allows users to make SINDy-compatible optimizers (which accept unbiasing and normalizing) from generic regression optimizers. However, its called on a range of SINDy optimizers that natively prevent unbiasing.
Reproducing code example:
import pysindy as ps
ps.TrappingSR3(unbias=True) # ValueError: Trapping does not allow unbiasing
ps.WrappedOptimizer(ps.TrappingSR3(), unbias=True) # Should raise a ValueError but does not
Solution
Pretty straightforwardly, we can prevent this by implementing WrappedOptimizer.__new__(cls, optimizer, ...) and checking the type of optimizer. If it's already a ps.BaseOptimzer, then just return it (potentially, verifying that a conflicting unbias is not present)
WrappedOptimizer allows users to make SINDy-compatible optimizers (which accept unbiasing and normalizing) from generic regression optimizers. However, its called on a range of SINDy optimizers that natively prevent unbiasing.
Reproducing code example:
Solution
Pretty straightforwardly, we can prevent this by implementing
WrappedOptimizer.__new__(cls, optimizer, ...)
and checking the type of optimizer. If it's already aps.BaseOptimzer
, then just return it (potentially, verifying that a conflicting unbias is not present)