Skip to content

Commit 9646a4e

Browse files
author
Release Manager
committed
sagemathgh-39389: minor detail in combin. polyhedron using the faster binomial method ### 📝 Checklist - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. URL: sagemath#39389 Reported by: Frédéric Chapoton Reviewer(s): David Coudert
2 parents 9ba87b6 + c67f73d commit 9646a4e

File tree

1 file changed

+9
-10
lines changed
  • src/sage/geometry/polyhedron/combinatorial_polyhedron

1 file changed

+9
-10
lines changed

src/sage/geometry/polyhedron/combinatorial_polyhedron/base.pyx

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1943,15 +1943,14 @@ cdef class CombinatorialPolyhedron(SageObject):
19431943
"""
19441944
if self.is_simplex():
19451945
return self.dim() + 1
1946-
else:
1947-
from sage.arith.misc import binomial
1948-
k = 1
1949-
while self.f_vector()[k+1] == binomial(self.n_vertices(), k + 1):
1950-
k += 1
1951-
return k
1946+
cdef int k = 2
1947+
f = self.f_vector()
1948+
while f[k] == self.n_vertices().binomial(k):
1949+
k += 1
1950+
return k - 1
19521951

19531952
@cached_method
1954-
def is_neighborly(self, k=None):
1953+
def is_neighborly(self, k=None) -> bool:
19551954
r"""
19561955
Return whether the polyhedron is neighborly.
19571956

@@ -2000,7 +1999,7 @@ cdef class CombinatorialPolyhedron(SageObject):
20001999
return all(self.f_vector()[i+1] == binomial(self.n_vertices(), i + 1)
20012000
for i in range(1, k))
20022001

2003-
def is_simplex(self):
2002+
def is_simplex(self) -> bool:
20042003
r"""
20052004
Return whether the polyhedron is a simplex.
20062005

@@ -2014,10 +2013,10 @@ cdef class CombinatorialPolyhedron(SageObject):
20142013
sage: CombinatorialPolyhedron([[0,1],[0,2],[1,2]]).is_simplex()
20152014
True
20162015
"""
2017-
return self.is_bounded() and (self.dim()+1 == self.n_vertices())
2016+
return self.is_bounded() and (self.dim() + 1 == self.n_vertices())
20182017

20192018
@cached_method
2020-
def is_simplicial(self):
2019+
def is_simplicial(self) -> bool:
20212020
r"""
20222021
Test whether the polytope is simplicial.
20232022

0 commit comments

Comments
 (0)