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
In practice, unpickle_global loads the module, and search for the full class name HopfAlgebrasWithBasis.TensorProducts in the dictionary of the module.
In the case of a nested class above which comes from a functorial construction, there currently are cases where, upon importing the module, the base class of the nested class has not yet been initialized, which leads to errors:
The initialization is indeed done upon accessing the class for the first time from its surrounding class:
sage: HopfAlgebrasWithBasis.TensorProducts
Now everything works:
sage: cls is HopfAlgebrasWithBasis.TensorProducts
True
sage: cls(QQ)
Category of tensor products of hopf algebras with basis over Rational Field
Not sure what's the best way to proceed; forcing the unpickling
to unpickle instead the base class HopfAlgebrasWithBasis, and then recover TensorProducts by a getattr ?
I'll add the original non-working example that was found by Pauline.
After poking around a bit, I'd be tempted to customize the pickling so that a nested class foo.A.B would be unpickled as getattr(getattr(foo, "A"),"B"). This would however not resolve the unpickling of old pickles.
Classes are pickled by name in Sage, and reconstructed as in this example upon unpickling:
In practice,
unpickle_global
loads the module, and search for the full class nameHopfAlgebrasWithBasis.TensorProducts
in the dictionary of the module.In the case of a nested class above which comes from a functorial construction, there currently are cases where, upon importing the module, the base class of the nested class has not yet been initialized, which leads to errors:
The initialization is indeed done upon accessing the class for the first time from its surrounding class:
Now everything works:
Not sure what's the best way to proceed; forcing the unpickling
to unpickle instead the base class
HopfAlgebrasWithBasis
, and then recoverTensorProducts
by agetattr
?I'll add the original non-working example that was found by Pauline.
Component: pickling
Issue created by migration from https://trac.sagemath.org/ticket/25491
The text was updated successfully, but these errors were encountered: