Skip to content

Commit 90a51fc

Browse files
committed
src/sage/geometry/cone.py: reviewer suggestions in Hilbert_basis()
Tighten the whitespace around list/generator comprehensions, and simplify the control flow in two instances by eliminating an if/else branch. (Only one of these was suggested by the reviewer, but the other is in a similar spirit.) Thanks to Martin Rubey for the suggestions.
1 parent 43a03a3 commit 90a51fc

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

src/sage/geometry/cone.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4450,38 +4450,38 @@ def Hilbert_basis(self):
44504450
The primal Normaliz algorithm, see [Normaliz]_.
44514451
"""
44524452

4453-
if self.is_strictly_convex():
4454-
# Used in lieu of our linear_subspace() for containment
4455-
# testing. None of the points we test can be zero, so
4456-
# checking the empty tuple is equivalent to checking a
4457-
# trivial subspace, and the empty tuple is faster.
4458-
L = ()
4459-
else:
4453+
# Used in lieu of our linear_subspace() for containment
4454+
# testing when this cone is strictly convex. None of the
4455+
# points we test can be zero, so checking the empty tuple is
4456+
# equivalent to checking a trivial subspace, and the empty
4457+
# tuple is faster.
4458+
L = ()
4459+
4460+
if not self.is_strictly_convex():
44604461
# Our linear_subspace(), but as a cone, so that
44614462
# containment testing using "in" works properly.
4462-
L = Cone( (c*r for c in (1,-1) for r in self.lines()),
4463-
self.lattice() )
4463+
L = Cone((c*r for c in (1, -1) for r in self.lines()),
4464+
self.lattice())
44644465

44654466
irreducible = list(self.rays()) # these are irreducible for sure
44664467
irr_modified = False # have we appended to "irreducible"?
4467-
gens = [ x for x in self.semigroup_generators()
4468-
if x not in irreducible ]
4468+
gens = [x for x in self.semigroup_generators()
4469+
if x not in irreducible]
44694470

44704471
from itertools import chain
44714472
while gens:
44724473
x = gens.pop()
4473-
if all( (y in L) or (x-y not in self)
4474-
for y in chain(irreducible,gens) ):
4474+
if all((y in L) or (x-y not in self)
4475+
for y in chain(irreducible, gens)):
44754476
irreducible.append(x)
44764477
irr_modified = True
44774478

44784479
if irr_modified:
44794480
return PointCollection(irreducible, self.lattice())
4480-
else:
4481-
# Avoid the PointCollection overhead if nothing was
4482-
# added to the irreducible list beyond self.rays().
4483-
return self.rays()
44844481

4482+
# Avoid the PointCollection overhead if nothing was
4483+
# added to the irreducible list beyond self.rays().
4484+
return self.rays()
44854485

44864486
def Hilbert_coefficients(self, point, solver=None, verbose=0,
44874487
*, integrality_tolerance=1e-3):

0 commit comments

Comments
 (0)