Ticket #10021 (closed enhancement: fixed)

Opened 3 years ago

Last modified 3 years ago

Empty LatticePolytope fails

Reported by: vbraun Owned by: mhampton
Priority: major Milestone: sage-4.6
Component: geometry Keywords:
Cc: novoselt Work issues:
Report Upstream: N/A Reviewers: Andrey Novoseltsev
Authors: Volker Braun Merged in: sage-4.6.alpha2
Dependencies: Stopgaps:

Description

As return values for Polyhedron.lattice_polytope() we sometimes want to return empty lattice polytopes. Alas, this does not work:

Lsage: LatticePolytope( matrix(ZZ,3,0) )
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)

/home/vbraun/opt/sage-4.5.3/devel/sage-main/<ipython console> in <module>()

/home/vbraun/Sage/sage/local/lib/python2.6/site-packages/sage/geometry/lattice_polytope.pyc in LatticePolytope(data, desc, compute_vertices, copy_vertices, n)
    264         return data
    265     else:
--> 266         return LatticePolytopeClass(data, desc, compute_vertices, copy_vertices, n)
    267 
    268 copy_reg.constructor(LatticePolytope)   # "safe for unpickling"

/home/vbraun/Sage/sage/local/lib/python2.6/site-packages/sage/geometry/lattice_polytope.pyc in __init__(self, data, desc, compute_vertices, copy_vertices, n)
    402             if compute_vertices:
    403                 self._vertices = data       # Temporary assignment
--> 404                 self._compute_dim(compute_vertices=True)
    405             else:
    406                 if copy_vertices:

/home/vbraun/Sage/sage/local/lib/python2.6/site-packages/sage/geometry/lattice_polytope.pyc in _compute_dim(self, compute_vertices)
    494         else:
    495             points = self._vertices.columns(copy=False)
--> 496         p0 = points[0]
    497         if p0 != 0:
    498             points = [point - p0 for point in points]

IndexError: list index out of range

The attached patch fixes this and adds a suitable doctest.

Attachments

trax_10021_empty_lattice_polytopes.patch Download (6.2 KB) - added by vbraun 3 years ago.
Initial patch
trax_10021_empty_lattice_polytopes.2.patch Download (6.2 KB) - added by vbraun 3 years ago.
indentation fix in docstring

Change History

Changed 3 years ago by vbraun

Initial patch

comment:1 Changed 3 years ago by vbraun

  • Cc novoselt added
  • Status changed from new to needs_review

Changed 3 years ago by vbraun

indentation fix in docstring

comment:2 Changed 3 years ago by novoselt

  • Status changed from needs_review to positive_review
  • Reviewers set to Andrey Novoseltsev
  • Type changed from defect to enhancement
  • Authors set to Volker Braun

Nice improvements!

comment:3 Changed 3 years ago by davidloeffler

  • Milestone changed from sage-4.6.1 to sage-4.6

comment:4 Changed 3 years ago by mpatel

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