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

Commit 2b1d108

Browse files
author
Matthias Koeppe
committed
Merge #31919
2 parents 1f7826d + 686d0af commit 2b1d108

File tree

3 files changed

+115
-5
lines changed

3 files changed

+115
-5
lines changed

src/sage/geometry/convex_set.py

+76-3
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,15 @@ def is_universe(self):
4444
OUTPUT:
4545
4646
Boolean.
47+
48+
TESTS::
49+
50+
sage: from sage.geometry.convex_set import ConvexSet_base
51+
sage: C = ConvexSet_base()
52+
sage: C.is_universe()
53+
Traceback (most recent call last):
54+
...
55+
NotImplementedError: <abstract method dim at ...>
4756
"""
4857
if not self.is_full_dimensional():
4958
return False
@@ -53,6 +62,15 @@ def is_universe(self):
5362
def dim(self):
5463
r"""
5564
Return the dimension of ``self``.
65+
66+
TESTS::
67+
68+
sage: from sage.geometry.convex_set import ConvexSet_base
69+
sage: C = ConvexSet_base()
70+
sage: C.dim()
71+
Traceback (most recent call last):
72+
...
73+
NotImplementedError: <abstract method dim at ...>
5674
"""
5775

5876
def dimension(self):
@@ -88,6 +106,15 @@ def ambient(self):
88106
def ambient_dim(self):
89107
r"""
90108
Return the dimension of the ambient convex set or space.
109+
110+
TESTS::
111+
112+
sage: from sage.geometry.convex_set import ConvexSet_base
113+
sage: C = ConvexSet_base()
114+
sage: C.ambient_dim()
115+
Traceback (most recent call last):
116+
...
117+
NotImplementedError: <abstract method ambient_dim at ...>
91118
"""
92119

93120
def ambient_dimension(self):
@@ -111,11 +138,15 @@ def codimension(self):
111138
r"""
112139
Return the codimension of ``self`` in `self.ambient()``.
113140
114-
An alias is :meth:`codim`.
115-
116141
EXAMPLES::
117142
118-
sage: Polyhedron(vertices=[(1,2,3)], rays=[(1,0,0)]).codimension()
143+
sage: P = Polyhedron(vertices=[(1,2,3)], rays=[(1,0,0)])
144+
sage: P.codimension()
145+
2
146+
147+
An alias is :meth:`codim`::
148+
149+
sage: P.codim()
119150
2
120151
"""
121152
return self.ambient_dim() - self.dim()
@@ -359,13 +390,28 @@ def _test_convex_set(self, tester=None, **options):
359390
tester.assertTrue(self == cl_self)
360391
if self.is_compact():
361392
tester.assertTrue(self.is_closed())
393+
from sage.misc.sage_unittest import TestSuite
394+
if relint_self is not None and relint_self is not self:
395+
tester.info("\n Running the test suite of self.relative_interior()")
396+
TestSuite(relint_self).run(verbose=tester._verbose,
397+
prefix=tester._prefix + " ")
398+
tester.info(tester._prefix + " ", newline=False)
362399

363400
# Optional methods
364401

365402
@abstract_method(optional=True)
366403
def affine_hull(self):
367404
r"""
368405
Return the affine hull of ``self``.
406+
407+
TESTS::
408+
409+
sage: from sage.geometry.convex_set import ConvexSet_base
410+
sage: C = ConvexSet_base()
411+
sage: C.affine_hull()
412+
Traceback (most recent call last):
413+
...
414+
TypeError: 'NotImplementedType' object is not callable
369415
"""
370416

371417
@abstract_method(optional=True)
@@ -380,6 +426,15 @@ def cartesian_product(self, other):
380426
OUTPUT:
381427
382428
The Cartesian product of ``self`` and ``other``.
429+
430+
TESTS::
431+
432+
sage: from sage.geometry.convex_set import ConvexSet_base
433+
sage: C = ConvexSet_base()
434+
sage: C.cartesian_product(C)
435+
Traceback (most recent call last):
436+
...
437+
TypeError: 'NotImplementedType' object is not callable
383438
"""
384439

385440
@abstract_method(optional=True)
@@ -390,6 +445,15 @@ def contains(self, point):
390445
INPUT:
391446
392447
- ``point`` -- a point or its coordinates
448+
449+
TESTS::
450+
451+
sage: from sage.geometry.convex_set import ConvexSet_base
452+
sage: C = ConvexSet_base()
453+
sage: C.contains(vector([0, 0]))
454+
Traceback (most recent call last):
455+
...
456+
TypeError: 'NotImplementedType' object is not callable
393457
"""
394458

395459
def _test_contains(self, tester=None, **options):
@@ -463,6 +527,15 @@ def intersection(self, other):
463527
OUTPUT:
464528
465529
The intersection.
530+
531+
TESTS::
532+
533+
sage: from sage.geometry.convex_set import ConvexSet_base
534+
sage: C = ConvexSet_base()
535+
sage: C.intersection(C)
536+
Traceback (most recent call last):
537+
...
538+
TypeError: 'NotImplementedType' object is not callable
466539
"""
467540

468541

src/sage/geometry/polyhedron/base.py

+13
Original file line numberDiff line numberDiff line change
@@ -4797,6 +4797,11 @@ def product(self, other):
47974797
sage: P1 * 2.0
47984798
A 1-dimensional polyhedron in RDF^1 defined as the convex hull of 2 vertices
47994799
4800+
An alias is :meth:`cartesian_product`::
4801+
4802+
sage: P1.cartesian_product(P2) == P1.product(P2)
4803+
True
4804+
48004805
TESTS:
48014806
48024807
Check that :trac:`15253` is fixed::
@@ -8455,7 +8460,15 @@ def interior(self):
84558460
sage: P_lower.interior()
84568461
The empty polyhedron in ZZ^2
84578462
8463+
TESTS::
8464+
8465+
sage: Empty = Polyhedron(ambient_dim=2); Empty
8466+
The empty polyhedron in ZZ^2
8467+
sage: Empty.interior() is Empty
8468+
True
84588469
"""
8470+
if self.is_open():
8471+
return self
84598472
if not self.is_full_dimensional():
84608473
return self.parent().element_class(self.parent(), None, None)
84618474
return self.relative_interior()

src/sage/geometry/relative_interior.py

+26-2
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ def ambient_dim(self):
7979
sage: segment.ambient_dim()
8080
2
8181
sage: ri_segment = segment.relative_interior(); ri_segment
82-
Relative interior of a 1-dimensional polyhedron in ZZ^2 defined as the convex hull of 2 vertices
82+
Relative interior of
83+
a 1-dimensional polyhedron in ZZ^2 defined as the convex hull of 2 vertices
8384
sage: ri_segment.ambient_dim()
8485
2
8586
"""
@@ -95,7 +96,8 @@ def dim(self):
9596
sage: segment.dim()
9697
1
9798
sage: ri_segment = segment.relative_interior(); ri_segment
98-
Relative interior of a 1-dimensional polyhedron in ZZ^2 defined as the convex hull of 2 vertices
99+
Relative interior of
100+
a 1-dimensional polyhedron in ZZ^2 defined as the convex hull of 2 vertices
99101
sage: ri_segment.dim()
100102
1
101103
"""
@@ -154,6 +156,28 @@ def closure(self):
154156
"""
155157
return self._polyhedron
156158

159+
def is_universe(self):
160+
r"""
161+
Return whether ``self`` is the whole ambient space
162+
163+
OUTPUT:
164+
165+
Boolean.
166+
167+
EXAMPLES::
168+
169+
sage: segment = Polyhedron([[1, 2], [3, 4]])
170+
sage: ri_segment = segment.relative_interior(); ri_segment
171+
Relative interior of
172+
a 1-dimensional polyhedron in ZZ^2 defined as the convex hull of 2 vertices
173+
sage: ri_segment.is_universe()
174+
False
175+
"""
176+
# Relies on ``self`` not set up for polyhedra that are already
177+
# relatively open themselves.
178+
assert not self._polyhedron.is_universe()
179+
return False
180+
157181
def is_closed(self):
158182
r"""
159183
Return whether ``self`` is closed.

0 commit comments

Comments
 (0)