Opened 9 years ago

Closed 9 years ago

#10024 closed defect (fixed)

dump()/dumps() fails for class Polyhedron

Reported by: terhorst Owned by: mhampton
Priority: minor Milestone: sage-4.6.1
Component: geometry Keywords: polyhedron polyhedra pickle dumps dump
Cc: vbraun Merged in: sage-4.6.1.alpha0
Authors: Volker Braun Reviewers: Andrey Novoseltsev
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Description

Polyhedra (objects of class Polyhedron) cannot be dumped or saved:

sage: polytopes.dodecahedron(QQ).dumps()
---------------------------------------------------------------------------
PicklingError                             Traceback (most recent call last)

/home/terhorst/<ipython console> in <module>()

/opt/sage/local/lib/python2.6/site-packages/sage/structure/sage_object.so in sage.structure.sage_object.SageObject.dumps (sage/structure/sage_object.c:2108)()

PicklingError: Can't pickle <type 'function'>: attribute lookup __builtin__.function failed

As a workaround, I pickle a hash of the rays, vertices, and lines defining the polyhedron.

Attachments (1)

trac_10024_dump_fails_for_Polyhedron.patch (9.4 KB) - added by vbraun 9 years ago.
Initial patch

Download all attachments as: .zip

Change History (5)

comment:1 Changed 9 years ago by novoselt

  • Authors polyhedron polyhedra pickle dumps dump deleted
  • Cc vbraun added
  • Keywords polyhedron polyhedra pickle dumps dump added

Changed 9 years ago by vbraun

Initial patch

comment:2 Changed 9 years ago by vbraun

  • Authors set to Volker Braun
  • Milestone set to sage-4.6.1
  • Status changed from new to needs_review

Patch fixes load/dump and adds comparisons, for example, P<=Q means P is a not-necessarily-strict subpolyhedron of Q.

comment:3 Changed 9 years ago by novoselt

  • Reviewers set to Andrey Novoseltsev
  • Status changed from needs_review to positive_review
  1. I think __setstate__ would look better without checks for exclude_keys which is unnecessary.
  2. Equality/"non-equality" tests seem to be not the most efficient ones, although for generic polyhedra it is not obvious what one should do instead.
  3. Chosen definition of ==, i.e. equality as sets of points, fits nicely together with other containment checks, but is inconsistent with the current situation for cones and fans. This bugs me a little bit, but not too much and I still prefer cones to take into account the ray order.

Anyway, all this is more like just thinking aloud, I am satisfied with the patch as is and switching it to positive review! (But feel free to address the first issue if you want ;-))

comment:4 Changed 9 years ago by jdemeyer

  • Merged in set to sage-4.6.1.alpha0
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.