Opened 11 years ago
Closed 3 years ago
#7516 closed defect (fixed)
bug in pickling quotient module over pid
Reported by:  was  Owned by:  was 

Priority:  major  Milestone:  sage8.1 
Component:  linear algebra  Keywords:  
Cc:  Merged in:  
Authors:  Simon Brandhorst  Reviewers:  Travis Scrimshaw 
Report Upstream:  N/A  Work issues:  
Branch:  ea6a00b (Commits, GitHub, GitLab)  Commit:  ea6a00ba4750d97546755784041b5d3cee2f2de9 
Dependencies:  Stopgaps: 
Description
This is from the "report a problem" link in the notebook:
If you have a vector space, that is a quotient of a subspace of another vector space, then after coercing elements into it, something goes wrong in (un)pickling it.
sage: V = VectorSpace(QQ, 2) sage: W = V.subspace([V([1,1])]) sage: Z = W.subspace([]) sage: WmodZ = W / Z sage: WmodZ(W(0)) (0) sage: loads(dumps(WmodZ))  AttributeError Traceback (most recent call last) /home/bosman/sage/<ipython console> in <module>() /home/bosman/sage4.2linuxUbuntu_9.04i686Linux/local/lib/python2.6/sitepackages/sage/structure/sage_object.so in sage.structure.sage_object.loads (sage/structure/sage_object.c:8769)() /home/bosman/sage4.2linuxUbuntu_9.04i686Linux/local/lib/python2.6/sitepackages/sage/modules/free_module.pyc in __hash__(self) 4576 True 4577 """ > 4578 return hash(self.__basis) 4579 4580 def construction(self): AttributeError: 'FreeModule_submodule_field' object has no attribute '_FreeModule_submodule_with_basis_pid__basis'
Attachments (1)
Change History (15)
comment:1 Changed 11 years ago by
Changed 11 years ago by
comment:2 Changed 11 years ago by
 Status changed from new to needs_review
comment:3 Changed 11 years ago by
 Status changed from needs_review to needs_info
If I understand the patch correctly, it violates a very essential assumption about hash codes: The hash has to be the same for objects that are equal. But with the patch, it may be possible that during unpickling the hash "0" is returned, while afterwards a completely different value is returned for the same object.
This is giving me headache. Isn't it be possible that things are put in the wrong hash bucket?
Wouldn't it be a cleaner solution to ensure that self.__basis is defined during unpickling before the hash is requested?
Could you explain why your solution is correct?
comment:4 Changed 8 years ago by
 Milestone changed from sage5.11 to sage5.12
comment:5 Changed 7 years ago by
 Milestone changed from sage6.1 to sage6.2
comment:6 Changed 7 years ago by
 Milestone changed from sage6.2 to sage6.3
comment:7 Changed 7 years ago by
 Milestone changed from sage6.3 to sage6.4
comment:8 followup: ↓ 9 Changed 3 years ago by
sage: V = VectorSpace(QQ, 2) sage: W = V.subspace([V([1,1])]) sage: Z = W.subspace([]) sage: WmodZ = W / Z sage: WmodZ(W(0)) (0) sage: loads(dumps(WmodZ)) Vector space quotient V/W of dimension 1 over Rational Field where V: Vector space of degree 2 and dimension 1 over Rational Field Basis matrix: [1 1] W: Vector space of degree 2 and dimension 0 over Rational Field Basis matrix: []
Works for me. Add a doctest and close?
comment:9 in reply to: ↑ 8 Changed 3 years ago by
comment:10 Changed 3 years ago by
 Branch set to u/sbrandhorst/bug_in_pickling_quotient_module_over_pid
comment:11 Changed 3 years ago by
 Commit set to ea6a00ba4750d97546755784041b5d3cee2f2de9
 Status changed from needs_info to needs_review
New commits:
ea6a00b  Added a doctest for pickling.

comment:12 Changed 3 years ago by
 Milestone changed from sage6.4 to sage8.1
 Reviewers set to Travis Scrimshaw
Once you put your real name as author, you can set a positive review.
comment:13 Changed 3 years ago by
 Status changed from needs_review to positive_review
comment:14 Changed 3 years ago by
 Branch changed from u/sbrandhorst/bug_in_pickling_quotient_module_over_pid to ea6a00ba4750d97546755784041b5d3cee2f2de9
 Resolution set to fixed
 Status changed from positive_review to closed
NOTE: This bug does not happen for Free modules over ZZ. It's only over a field where the issue happens.