#15050: Bug in pickling of toric varieties
----------------------------------+-----------------------------
Reporter: vbraun | Owner:
Type: defect | Status: new
Priority: major | Milestone: sage-5.12
Component: algebraic geometry | Keywords:
Merged in: | Authors:
Reviewers: | Report Upstream: N/A
Work issues: | Branch:
Commit: | Dependencies:
Stopgaps: |
----------------------------------+-----------------------------
{{{
sage: variety = toric_varieties.P(1)
sage: variety.cohomology_ring()
Rational cohomology ring of a 1-d CPR-Fano toric variety covered by 2
affine patches
sage: pickle = dumps(variety)
sage: loads(pickle)
---------------------------------------------------------------------------
AttributeError Traceback (most recent call
last)
<ipython-input-13-41fbbbe8d1ed> in <module>()
----> 1 loads(pickle)
/home/vbraun/Code/sage.git/local/lib/python2.7/site-
packages/sage/structure/sage_object.so in sage.structure.sage_object.loads
(sage/structure/sage_object.c:11044)()
/home/vbraun/Code/sage.git/local/lib/python2.7/site-
packages/sage/structure/unique_representation.pyc in unreduce(cls, args,
keywords)
599
600 """
--> 601 return cls(*args, **keywords)
602
603
/home/vbraun/Code/sage.git/local/lib/python2.7/site-
packages/sage/misc/classcall_metaclass.so in
sage.misc.classcall_metaclass.ClasscallMetaclass.__call__
(sage/misc/classcall_metaclass.c:1224)()
/home/vbraun/Code/sage.git/local/lib/python2.7/site-
packages/sage/misc/cachefunc.so in
sage.misc.cachefunc.WeakCachedFunction.__call__
(sage/misc/cachefunc.c:5347)()
/home/vbraun/Code/sage.git/local/lib/python/weakref.pyc in
__getitem__(self, key)
54
55 def __getitem__(self, key):
---> 56 o = self.data[key]()
57 if o is None:
58 raise KeyError, key
/home/vbraun/Code/sage.git/local/lib/python2.7/site-
packages/sage/structure/category_object.so in
sage.structure.category_object.CategoryObject.__hash__
(sage/structure/category_object.c:8312)()
/home/vbraun/Code/sage.git/local/lib/python2.7/site-
packages/sage/structure/sage_object.so in
sage.structure.sage_object.SageObject.__repr__
(sage/structure/sage_object.c:1921)()
/home/vbraun/Code/sage.git/local/lib/python2.7/site-
packages/sage/schemes/toric/fano_variety.pyc in _repr_(self)
746 """
747 return ("%d-d CPR-Fano toric variety covered by %d affine
patches"
--> 748 % (self.dimension_relative(),
self.fan().ngenerating_cones()))
749
750 def anticanonical_hypersurface(self, **kwds):
/home/vbraun/Code/sage.git/local/lib/python2.7/site-
packages/sage/schemes/generic/ambient_space.pyc in
dimension_relative(self)
393 2
394 """
--> 395 return self._dimension_relative
/home/vbraun/Code/sage.git/local/lib/python2.7/site-
packages/sage/structure/parent.so in
sage.structure.parent.Parent.__getattr__ (sage/structure/parent.c:6736)()
<type 'str'>: (<type 'exceptions.AttributeError'>,
AttributeError('CPRFanoToricVariety_field_with_category' object has no
attribute '_dimension_relative',))
}}}
Analysis:
* There is a circular reference between the !ToricVariety and the
!CohomologyRing.
* The unpickler therefore must work with half-constructed objects and
only later fill in the attributes.
* The !CohomologyRing inherits from !UniqueRepresentation, so it will
try to look in the unique representation cache
* For that, we need `__hash__()` of the toric variety which is provided
by !CategoryObject
* The hash depends on `__repr__()` which accesses attributes of the
toric variety that are not yet filled in.
--
Ticket URL: <http://trac.sagemath.org/ticket/15050>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/groups/opt_out.