Opened 10 years ago

Closed 8 years ago

#10344 closed defect (duplicate)

Polyhedron incorrectly handles RR-vertices

Reported by: novoselt Owned by: mhampton
Priority: major Milestone: sage-duplicate/invalid/wontfix
Component: geometry Keywords: sd40.5
Cc: vbraun Merged in:
Authors: Reviewers: Volker Braun
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges


sage: p = Polyhedron(vertices=[vector(RR, [1/2, 3/4]), vector(RR, [4, 5])])
sage: p
A 0-dimensional polyhedron in QQ^2 defined as the convex hull of 1 vertex.
sage: p.vertices()
[[0, 0]]
sage: p = Polyhedron(vertices=[vector([1/2, 3/4]), vector([4, 5])])
sage: p
A 1-dimensional polyhedron in QQ^2 defined as the convex hull of 2 vertices.
sage: p.vertices()
[[1/2, 3/4], [4, 5]]

I think that the first case should give either a numerical polyhedron or at least an error message.

Change History (5)

comment:1 Changed 9 years ago by novoselt

  • Keywords sd40.5 added

There is some change in this behaviour:

sage: Polyhedron(vertices=[vector(RR, [1/2, 3/4]), vector(RR, [4, 5])])
AttributeError                            Traceback (most recent call last)

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

/home/novoselt/sage-5.1.beta0/local/lib/python2.7/site-packages/sage/misc/decorators.pyc in wrapper(*args, **kwds)
    685                     kwds[new_name] = kwds[old_name]
    686                     del kwds[old_name]
--> 687             return func(*args, **kwds)
    689         return wrapper

/home/novoselt/sage-5.1.beta0/local/lib/python2.7/site-packages/sage/geometry/polyhedron/constructor.pyc in Polyhedron(vertices, rays, lines, ieqs, eqns, base_ring, minimize, verbose, backend)
    285     if base_ring is QQ:
    286         from backend_ppl import Polyhedron_QQ_ppl
--> 287         return Polyhedron_QQ_ppl(ambient_dim, Vrep, Hrep, minimize=minimize)
    288     elif base_ring is RDF:
    289         from backend_cdd import Polyhedron_RDF_cdd

/home/novoselt/sage-5.1.beta0/local/lib/python2.7/site-packages/sage/geometry/polyhedron/base.pyc in __init__(self, ambient_dim, Vrep, Hrep, **kwds)
    124             if len(vertices)==0:
    125                 vertices = [[0] * ambient_dim]
--> 126             self._init_from_Vrepresentation(ambient_dim, vertices, rays, lines, **kwds)
    127         elif Hrep is not None:
    128             ieqs, eqns = Hrep

/home/novoselt/sage-5.1.beta0/local/lib/python2.7/site-packages/sage/geometry/polyhedron/backend_ppl.pyc in _init_from_Vrepresentation(self, ambient_dim, vertices, rays, lines, minimize)
     70         if vertices is None: vertices = []
     71         for v in vertices:
---> 72             d = lcm([denominator(v_i) for v_i in v])
     73             dv = [ ZZ(d*v_i) for v_i in v ]
     74             gs.insert(point(Linear_Expression(dv, 0), d))

/home/novoselt/sage-5.1.beta0/local/lib/python2.7/site-packages/sage/misc/functional.pyc in denominator(x)
    320     if isinstance(x, (int, long)):
    321         return 1
--> 322     return x.denominator()
    324 def det(x):

/home/novoselt/sage-5.1.beta0/local/lib/python2.7/site-packages/sage/structure/ in sage.structure.element.Element.__getattr__ (sage/structure/element.c:2984)()

/home/novoselt/sage-5.1.beta0/local/lib/python2.7/site-packages/sage/structure/ in sage.structure.parent.getattr_from_other_class (sage/structure/parent.c:3396)()

AttributeError: 'sage.rings.real_mpfr.RealNumber' object has no attribute 'denominator'

Would be nice to have a better error message or handle it - if I replace RR with RDF there is still an error despite RDF support with field=RDF.

comment:2 Changed 9 years ago by vbraun

This is fixed by #11763, which brings sanity to coercion as a side-effect:

sage: Polyhedron(vertices=[vector(RR, [1/2, 3/4]), vector(RR, [4, 5])])
A 1-dimensional polyhedron in RDF^2 defined as the convex hull of 2 vertices

comment:3 Changed 8 years ago by novoselt

  • Milestone changed from sage-5.11 to sage-duplicate/invalid/wontfix
  • Status changed from new to needs_review

comment:4 Changed 8 years ago by novoselt

  • Reviewers set to Volker Braun
  • Status changed from needs_review to positive_review

comment:5 Changed 8 years ago by jdemeyer

  • Resolution set to duplicate
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.