sagemath / sage

Main repository of SageMath
https://www.sagemath.org
Other
1.33k stars 453 forks source link

Pickling for morphisms of modules with basis defined by a matrix #17957

Open nthiery opened 9 years ago

nthiery commented 9 years ago

The class sage.modules.module_with_basis_morphism.ModuleMorphismFromMatrix and TriangularModuleMorphism with inverse_on_support="compute" do not pickle properly. See the comments and examples near their respective TestSuite test.

A first potential route would be to use pickling by construction for those classes. Another one -- more general -- would be to implement pickling for methods of dictionaries / builtin types:

sage: d = {1:2}
sage: dumps(d.__getitem__)
...
TypeError: expected string or Unicode object, NoneType found

sage: dumps(dict.__getitem__)
...
PicklingError: Can't pickle <type 'method_descriptor'>: attribute lookup __builtin__.method_descriptor failed

This is a follow up to #8678.

Component: pickling

Issue created by migration from https://trac.sagemath.org/ticket/17957

nthiery commented 9 years ago

Description changed:

--- 
+++ 
@@ -1,3 +1,5 @@
 A few classes for morphisms of modules with basis don't pickle properly. See the comments close to the ``TestSuite`` calls in ``src/sage/modules/module_with_basis_morphism.py``.

+One potential route would be to use pickling by construction.
+
 This is a follow up to #8678.
nthiery commented 9 years ago

Description changed:

--- 
+++ 
@@ -1,5 +1,9 @@
-A few classes for morphisms of modules with basis don't pickle properly. See the comments close to the ``TestSuite`` calls in ``src/sage/modules/module_with_basis_morphism.py``.
+The class
+`sage.modules.module_with_basis_morphism.ModuleMorphismFromMatrix`
+does not pickle properly. See the comment and example near it's
+``TestSuite`` test.

 One potential route would be to use pickling by construction.

 This is a follow up to #8678.
+
nthiery commented 9 years ago

Description changed:

--- 
+++ 
@@ -1,9 +1,23 @@
 The class
 `sage.modules.module_with_basis_morphism.ModuleMorphismFromMatrix`
-does not pickle properly. See the comment and example near it's
-``TestSuite`` test.
+and `TriangularModuleMorphism` with `inverse_on_support="compute"`
+do not pickle properly. See the comments and examples near their
+respective ``TestSuite`` test.

-One potential route would be to use pickling by construction.
+A first potential route would be to use pickling by construction for
+those classes. Another one -- more general -- would be to implement
+pickling for methods of dictionaries / builtin types:
+
+```
+sage: d = {1:2}
+sage: dumps(d.__getitem__)
+...
+TypeError: expected string or Unicode object, NoneType found
+
+sage: dumps(dict.__getitem__)
+...
+PicklingError: Can't pickle <type 'method_descriptor'>: attribute lookup __builtin__.method_descriptor failed
+```

 This is a follow up to #8678.