Skip to content

Commit ad8ac86

Browse files
committed
Python optimization of the code
1 parent b27a7ba commit ad8ac86

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/sage/geometry/fan.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2444,7 +2444,7 @@ def is_regular(self):
24442444
Check if ``self`` is regular.
24452445
24462446
A rational polyhedral fan is *regular* if it is the normal fan of a
2447-
polytope.
2447+
polytope.
24482448
24492449
OUTPUT: ``True`` if ``self`` is complete and ``False`` otherwise
24502450
@@ -2478,14 +2478,15 @@ def is_regular(self):
24782478
from sage.geometry.triangulation.point_configuration import PointConfiguration
24792479
from sage.geometry.polyhedron.constructor import Polyhedron
24802480
pc = PointConfiguration(self.rays())
2481-
v_pc = [vector(pc.point(i)) for i in range(pc.n_points())]
2482-
v_r = [vector(list(r)) for r in self.rays()]
2483-
cone_indices = [_.ambient_ray_indices() for _ in self.generating_cones()]
2484-
translator = [v_pc.index(v_r[i]) for i in range(pc.n_points())]
2481+
v_pc = [tuple(p) for p in pc]
2482+
pc_to_indices = {tuple(p):i for (i,p) in enumerate(pc)}
2483+
indices_to_vr = [tuple(r) for r in self.rays()]
2484+
cone_indices = [cone.ambient_ray_indices() for cone in self.generating_cones()]
2485+
translator = [pc_to_indices[t] for t in indices_to_vr]
24852486
translated_cone_indices = [[translator[i] for i in ci] for ci in cone_indices]
24862487
dc_pc = pc.deformation_cone(translated_cone_indices)
24872488
lift = dc_pc.an_element()
2488-
ieqs = [[lift[i]] + list(v_pc[i]) for i in range(self.nrays())]
2489+
ieqs = [(lift_i,) + v for (lift_i, v) in zip(lift, v_pc)]
24892490
poly = Polyhedron(ieqs=ieqs)
24902491
return self.is_equivalent(poly.normal_fan())
24912492

0 commit comments

Comments
 (0)