Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
{Polyhedron_base, Polyhedron_base}.base_extend: Handle backend.
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Koeppe committed Sep 30, 2018
1 parent b84538e commit 260739d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
13 changes: 12 additions & 1 deletion src/sage/geometry/polyhedron/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,8 @@ def base_extend(self, base_ring, backend=None):
"""
Return a new polyhedron over a larger base ring.
This method can also be used to change the backend.
INPUT:
- ``base_ring`` -- the new base ring.
Expand All @@ -394,7 +396,7 @@ def base_extend(self, base_ring, backend=None):
OUTPUT:
The same polyhedron, but over a larger base ring.
The same polyhedron, but over a larger base ring and possibly with a changed backend.
EXAMPLES::
Expand All @@ -404,6 +406,15 @@ def base_extend(self, base_ring, backend=None):
A 2-dimensional polyhedron in QQ^2 defined as the convex hull of 2 vertices and 1 ray
sage: P.base_extend(QQ) == P
True
TESTS:
Test that :trac:`22575` is fixed::
sage: Q = P.base_extend(ZZ, backend='field')
sage: Q.backend()
'field'
"""
new_parent = self.parent().base_extend(base_ring, backend)
return new_parent(self)
Expand Down
14 changes: 12 additions & 2 deletions src/sage/geometry/polyhedron/parent.py
Original file line number Diff line number Diff line change
Expand Up @@ -541,11 +541,21 @@ def base_extend(self, base_ring, backend=None):
Polyhedra in QQ^3
sage: Polyhedra(ZZ,3).an_element().base_extend(QQ)
A 3-dimensional polyhedron in QQ^3 defined as the convex hull of 4 vertices
TESTS:
Test that :trac:`22575` is fixed::
sage: P = Polyhedra(ZZ,3).base_extend(QQ, backend='field')
sage: P.backend()
'field'
"""
if self.base_ring().has_coerce_map_from(base_ring):
if (self.base_ring().has_coerce_map_from(base_ring)
and (backend is None or self.backend() == backend)):
return self
elif base_ring.has_coerce_map_from(self.base_ring()):
return Polyhedra(base_ring, self.ambient_dim())
return Polyhedra(base_ring, self.ambient_dim(), backend=backend)

def _coerce_base_ring(self, other):
r"""
Expand Down

0 comments on commit 260739d

Please sign in to comment.