yes, it's a bug, I opened https://github.com/sagemath/sage/issues/42142
On Thu, May 7, 2026 at 12:31 PM João Camarneiro <[email protected]> wrote: > > Thank you for the clarification! > > So the problem is that a non-integer point is picked as a base vertex of this > hyperplane. However this hyperplane does contain integer points which could > be used instead, wouldn't that be the expected behaviour when calling > affine_hull() from a polytope with base ring ZZ? > > Best, > João > > > On Thursday, 7 May 2026 at 05:52:36 UTC+1 [email protected] wrote: >> >> On Wed, May 6, 2026 at 9:28 PM João Camarneiro <[email protected]> wrote: >> > >> > Hi, >> > >> > I stumbled upon a strange error with the affine_hull() function for >> > polyhedra. A minimal example is: >> > >> > pp = Polyhedron(vertices=[[-1, -1, 1, -1], [-1, -1, 5, 1], [-1, 5, -1, 1], >> > [5, -1, -1, 1]]) >> > pp.affine_hull() >> > >> > This throws the following error: >> > TypeError: no conversion of this rational to integer >> > >> > If I add "base_ring = QQ", i.e. >> > pp = Polyhedron(vertices=[[-1, -1, 1, -1], [-1, -1, 5, 1], [-1, 5, -1, 1], >> > [5, -1, -1, 1]], base_ring=QQ) >> > pp.affine_hull() >> > >> > then everything works fine. >> >> Yes, sure, and you have a vertex with non-integer coordinate. >> >> sage: pp.affine_hull().lines() >> (A line in the direction (0, 0, 2, 1), >> A line in the direction (2, 0, 0, 1), >> A line in the direction (0, 2, 0, 1)) >> sage: pp.affine_hull().vertices() >> (A vertex at (0, 0, 0, -1/2),) >> >> It's because affine_hill() is given by Minkowski sum of a vertex and a >> linear hyperplane. >> (the latter given by 3 lines) >> >> The hull is an affine hyperplane {x | <x,(1, 1, 1, -2)>=1} >> sage: pp.affine_hull().Hrepresentation() >> (An equation (1, 1, 1, -2) x - 1 == 0,) >> No wonder this breaks for the default base_ring=ZZ. >> > >> > Is this a bug? >> >> it's a documentation bug, as it's not clear from the docs on >> affine_hull that you have such an >> unusual representation of the result. >> >> HTH >> Dima >> >> >> > >> > I am using Ubuntu 24.04 through WSL, and running SageMath version 10.8 on >> > a Jupyter Notebook. >> > >> > See below for the full error output. >> > Thanks! >> > >> > --------------------------------------------------------------------------- >> > TypeError Traceback (most recent call last) Cell In[1], line 2 1 pp = >> > Polyhedron(vertices=[[-Integer(1), -Integer(1), Integer(1), -Integer(1)], >> > [-Integer(1), -Integer(1), Integer(5), Integer(1)], [-Integer(1), >> > Integer(5), -Integer(1), Integer(1)], [Integer(5), -Integer(1), >> > -Integer(1), Integer(1)]]) ----> 2 pp.affine_hull() File >> > ~/miniforge3/envs/sage/lib/python3.12/site-packages/sage/geometry/polyhedron/base6.py:911, >> > in Polyhedron_base6.affine_hull(self, *args, **kwds) 909 return self 910 >> > self_as_face = self.faces(self.dimension())[0] --> 911 return >> > self_as_face.affine_tangent_cone() File >> > ~/miniforge3/envs/sage/lib/python3.12/site-packages/sage/misc/cachefunc.pyx:2353, >> > in sage.misc.cachefunc.CachedMethodCallerNoArgs.__call__() 2351 if >> > self.cache is None: 2352 f = self.f -> 2353 self.cache = f(self._instance) >> > 2354 return self.cache 2355 File >> > ~/miniforge3/envs/sage/lib/python3.12/site-packages/sage/geometry/polyhedron/face.py:941, >> > in PolyhedronFace.affine_tangent_cone(self) 937 new_ieqs = [H for H in >> > self.ambient_Hrepresentation() 938 if H.is_inequality()] 939 new_eqns = [H >> > for H in self.ambient_Hrepresentation() 940 if H.is_equation()] --> 941 >> > return parent.element_class(parent, None, [new_ieqs, new_eqns]) File >> > ~/miniforge3/envs/sage/lib/python3.12/site-packages/sage/geometry/polyhedron/backend_ppl.py:70, >> > in Polyhedron_ppl.__init__(self, parent, Vrep, Hrep, ppl_polyhedron, >> > mutable, **kwds) 68 Polyhedron_mutable.__init__(self, parent, Vrep, Hrep, >> > **kwds) 69 if not mutable: ---> 70 self.set_immutable() File >> > ~/miniforge3/envs/sage/lib/python3.12/site-packages/sage/geometry/polyhedron/backend_ppl.py:193, >> > in Polyhedron_ppl.set_immutable(self) 190 except TypeError as e: 191 # >> > Apparently the polyhedron is (no longer) integral. 192 self._clear_cache() >> > --> 193 raise e 194 if not hasattr(self, '_Hrepresentation'): 195 >> > self._init_Hrepresentation_from_ppl(True) File >> > ~/miniforge3/envs/sage/lib/python3.12/site-packages/sage/geometry/polyhedron/backend_ppl.py:189, >> > in Polyhedron_ppl.set_immutable(self) 187 if not hasattr(self, >> > '_Vrepresentation'): 188 try: --> 189 >> > self._init_Vrepresentation_from_ppl(True) 190 except TypeError as e: 191 # >> > Apparently the polyhedron is (no longer) integral. 192 self._clear_cache() >> > File >> > ~/miniforge3/envs/sage/lib/python3.12/site-packages/sage/geometry/polyhedron/backend_ppl.py:309, >> > in Polyhedron_ppl._init_Vrepresentation_from_ppl(self, minimize) 307 >> > parent._make_Vertex(self, coefficients) 308 else: --> 309 >> > parent._make_Vertex(self, [x/d for x in coefficients]) 310 elif >> > g.is_ray(): 311 parent._make_Ray(self, coefficients) File >> > ~/miniforge3/envs/sage/lib/python3.12/site-packages/sage/geometry/polyhedron/parent.py:1096, >> > in Polyhedra_base._make_Vertex(self, polyhedron, data) 1094 except >> > IndexError: 1095 obj = Vertex(self) -> 1096 obj._set_data(polyhedron, >> > data) 1097 return obj File >> > ~/miniforge3/envs/sage/lib/python3.12/site-packages/sage/geometry/polyhedron/representation.py:1160, >> > in Vrepresentation._set_data(self, polyhedron, data) 1157 if len(data) != >> > self._vector.degree(): 1158 raise ValueError('V-representation data >> > requires a list of length ambient_dim') -> 1160 self._vector[:] = data >> > 1162 self._index = len(polyhedron._Vrepresentation) 1163 >> > polyhedron._Vrepresentation.append(self) File >> > ~/miniforge3/envs/sage/lib/python3.12/site-packages/sage/modules/free_module_element.pyx:1961, >> > in sage.modules.free_module_element.FreeModuleElement.__setitem__() 1959 >> > if isinstance(i, slice): 1960 PySlice_GetIndicesEx(i, d, &start, &stop, >> > &step, &slicelength) -> 1961 values = [R(x) for x in value] 1962 if >> > len(values) != slicelength: 1963 raise IndexError("slice assignment would >> > change dimension") File >> > ~/miniforge3/envs/sage/lib/python3.12/site-packages/sage/structure/parent.pyx:899, >> > in sage.structure.parent.Parent.__call__() 897 if mor is not None: 898 if >> > no_extra_args: --> 899 return mor._call_(x) 900 else: 901 return >> > mor._call_with_args(x, args, kwds) File >> > ~/miniforge3/envs/sage/lib/python3.12/site-packages/sage/rings/rational.pyx:4214, >> > in sage.rings.rational.Q_to_Z._call_() 4212 """ 4213 if not >> > mpz_cmp_si(mpq_denref((<Rational>x).value), 1) == 0: -> 4214 raise >> > TypeError("no conversion of this rational to integer") 4215 cdef Integer n >> > = Integer.__new__(Integer) 4216 >> > n.set_from_mpz(mpq_numref((<Rational>x).value)) TypeError: no conversion >> > of this rational to integer >> > >> > -- >> > You received this message because you are subscribed to the Google Groups >> > "sage-support" group. >> > To unsubscribe from this group and stop receiving emails from it, send an >> > email to [email protected]. >> > To view this discussion visit >> > https://groups.google.com/d/msgid/sage-support/700916ed-e068-4ef0-82da-6bb743b0dbb4n%40googlegroups.com. > > -- > You received this message because you are subscribed to the Google Groups > "sage-support" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion visit > https://groups.google.com/d/msgid/sage-support/de19e5e2-0699-4a88-9217-98111b1f3f8bn%40googlegroups.com. -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion visit https://groups.google.com/d/msgid/sage-support/CAAWYfq387uUhW%2BS8GbLu9dZ7KQuY%2Ban5gn-t3%2B4%2BbPZT6240Tw%40mail.gmail.com.
