You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fortunately there's a test already test_optimizers.test_pickle, so this is easy to reproduce. Adding SR3 as an optimizer to the test parametrization produces a similar error message (because some of the relevant lines have been changed from your version).
Context get_regularization is a way for SR3 to lookup a regularization function from a string name. There's a similar function get_prox. The function they return get sassigned to self.reg and self.prox respectively.
Additional troubleshooting notes:
We have a decorator _validate_prox_and_reg_inputs to add guard code, so we need to use @functools.wraps in order to pickle (easy, done)
What we're wrapping needs to be a name available at module-level (e.g. regularization_l2) (easy, done)
Because we're decorating dynamically, the _validate...()version and the actual module level names have different definitions, raising a PicklingError. (hard)
We currently have to delay decoration since (a) we need to know whether we're using a weighted regularizer to decorate, but (b) the guard code we're adding in the decorator doesn't run until later.
The solution is to either apply to guards within SR3 where they call self.prox and self.reg or decorate at the source. If decorated at the source, we need to remove the "weighted" version of strings and merely use the type of the weight to infer whether the user wants weighted regularizers.
Heads up @himkwtn this is an issue that existed before you, but since it involves code you wrote in #544 and #548 it might be interesting. I'll CC you on the PR if you want to see the fix.
Unable to pickle objects created using
SINDy(optimizer=ps.TrappingSR3())
. My current work around is to use dill.Reproducing code example:
Error message:
PySINDy/Python version information:
The text was updated successfully, but these errors were encountered: