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

Commit

Permalink
handling small dimensional cases
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Kliem committed Mar 28, 2020
1 parent 97e5999 commit 082debd
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/sage/geometry/polyhedron/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2797,9 +2797,25 @@ def centroid(self, engine='auto', **kwds):
Traceback (most recent call last):
...
NotImplementedError: the polyhedron is not compact
The centroid of an empty polyhedron is not defined::
sage: Polyhedron().centroid()
Traceback (most recent call last):
...
ZeroDivisionError: rational division by zero
TESTS::
sage: Polyhedron(vertices=[[0,1]]).centroid()
(0, 1)
"""
if not self.is_compact():
raise NotImplementedError("the polyhedron is not compact")
if self.n_vertices() == self.dim() + 1:
# The centroid of a simplex is its center.
return self.center()

triangulation = self.triangulate(engine=engine, **kwds)

if self.ambient_dim() == self.dim():
Expand Down

0 comments on commit 082debd

Please sign in to comment.