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

Commit 6547b5b

Browse files
committed
Stop using deprecated methods in other modules.
1 parent 2cea458 commit 6547b5b

File tree

3 files changed

+76
-36
lines changed

3 files changed

+76
-36
lines changed

src/sage/geometry/fan.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -671,8 +671,9 @@ def FaceFan(polytope, lattice=None):
671671
if is_LatticePolytope(polytope):
672672
if any(d <= 0 for d in polytope.distances([0]*polytope.dim())):
673673
raise interior_point_error
674-
cones = (facet.vertices() for facet in polytope.facets())
674+
cones = (f.ambient_vertex_indices() for f in polytope.facets_lp())
675675
rays = polytope.vertices()
676+
is_complete = polytope.dim() == polytope.lattice_dim()
676677
else:
677678
origin = polytope.ambient_space().zero()
678679
if not (polytope.is_compact() and
@@ -681,13 +682,13 @@ def FaceFan(polytope, lattice=None):
681682
cones = [ [ v.index() for v in facet.incident() ]
682683
for facet in polytope.inequalities() ]
683684
rays = [vector(_) for _ in polytope.vertices()]
685+
is_complete = polytope.dim() == polytope.ambient_dim()
684686
if lattice is None:
685687
# Since default lattice polytopes are in the M lattice,
686688
# treat polyhedra as being there as well.
687689
lattice = ToricLattice(len(origin)).dual()
688-
fan = Fan(cones, rays, lattice=lattice, check=False,
689-
is_complete=(polytope.dim() == polytope.ambient_dim()))
690-
return fan
690+
return Fan(cones, rays, lattice=lattice, check=False,
691+
is_complete=is_complete)
691692

692693

693694
def NormalFan(polytope, lattice=None):
@@ -752,21 +753,23 @@ def NormalFan(polytope, lattice=None):
752753
sage: fan1.is_equivalent(fan2)
753754
True
754755
"""
756+
dimension_error = ValueError(
757+
'the normal fan is only defined for full-dimensional polytopes')
755758
from sage.geometry.lattice_polytope import is_LatticePolytope
756-
if polytope.dim() != polytope.ambient_dim():
757-
raise ValueError('the normal fan is only defined for full-dimensional polytopes')
758759
if is_LatticePolytope(polytope):
760+
if polytope.dim() != polytope.lattice_dim():
761+
raise dimension_error
759762
rays = polytope.facet_normals()
760-
cones = (vertex.facets() for vertex in polytope.faces(dim=0))
763+
cones = (v.ambient_facet_indices() for v in polytope.faces_lp(dim=0))
761764
else:
765+
if polytope.dim() != polytope.ambient_dim():
766+
raise dimension_error
762767
if not polytope.is_compact():
763768
raise NotImplementedError('the normal fan is only supported for polytopes (compact polyhedra).')
764769
cones = [ [ ieq.index() for ieq in vertex.incident() ]
765770
for vertex in polytope.vertices() ]
766771
rays =[ ieq.A() for ieq in polytope.inequalities() ]
767-
fan = Fan(cones, rays, lattice=lattice, check=False,
768-
is_complete=(polytope.dim() == polytope.ambient_dim()))
769-
return fan
772+
return Fan(cones, rays, lattice=lattice, check=False, is_complete=True)
770773

771774

772775
def Fan2d(rays, lattice=None):

src/sage/geometry/lattice_polytope.py

Lines changed: 61 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -763,6 +763,10 @@ def _compute_faces(self):
763763
... (-1,0,0), (0,-1,0), (0,0,0), (0,0,0)])
764764
sage: p._compute_faces()
765765
sage: p.facets()
766+
doctest:...: DeprecationWarning: the output of this method will change, use facets_lp instead to get facets as lattice polytopes
767+
See http://trac.sagemath.org/19071 for details.
768+
doctest:...: DeprecationWarning: the output of this method will change, use faces_lp instead to get faces as lattice polytopes
769+
See http://trac.sagemath.org/19071 for details.
766770
[[0, 3], [2, 3], [0, 1], [1, 2]]
767771
"""
768772
# Remove with 19071 deprecations
@@ -955,6 +959,8 @@ def _face_split_points(self, face):
955959
956960
sage: c = lattice_polytope.cross_polytope(3).polar()
957961
sage: f = c.facets()[0]
962+
doctest:...: DeprecationWarning: the output of this method will change, use facets_lp instead to get facets as lattice polytopes
963+
See http://trac.sagemath.org/19071 for details.
958964
sage: v = f.__dict__.pop("_interior_points", None)
959965
sage: "_interior_points" in f.__dict__
960966
False
@@ -1981,10 +1987,16 @@ def edges(self):
19811987
19821988
sage: o = lattice_polytope.cross_polytope(3)
19831989
sage: len(o.edges())
1990+
doctest:...: DeprecationWarning: the output of this method will change, use edges_lp instead to get edges as lattice polytopes
1991+
See http://trac.sagemath.org/19071 for details.
1992+
doctest:...: DeprecationWarning: the output of this method will change, use faces_lp instead to get faces as lattice polytopes
1993+
See http://trac.sagemath.org/19071 for details.
19841994
12
19851995
sage: o.edges()
19861996
[[1, 5], [0, 5], [0, 1], [3, 5], [1, 3], [4, 5], [0, 4], [3, 4], [1, 2], [0, 2], [2, 3], [2, 4]]
19871997
"""
1998+
deprecation(19071, "the output of this method will change, use edges_lp"
1999+
" instead to get edges as lattice polytopes")
19882000
return self.faces(dim=1)
19892001

19902002
def edges_lp(self):
@@ -2651,13 +2663,19 @@ def facets(self):
26512663
26522664
sage: o = lattice_polytope.cross_polytope(3)
26532665
sage: o.facets()
2666+
doctest:...: DeprecationWarning: the output of this method will change, use facets_lp instead to get facets as lattice polytopes
2667+
See http://trac.sagemath.org/19071 for details.
26542668
[[0, 1, 5], [1, 3, 5], [0, 4, 5], [3, 4, 5], [0, 1, 2], [1, 2, 3], [0, 2, 4], [2, 3, 4]]
26552669
26562670
Facets are the same as faces of codimension one::
26572671
26582672
sage: o.facets() is o.faces(codim=1)
2673+
doctest:...: DeprecationWarning: the output of this method will change, use faces_lp instead to get faces as lattice polytopes
2674+
See http://trac.sagemath.org/19071 for details.
26592675
True
26602676
"""
2677+
deprecation(19071, "the output of this method will change, use facets_lp"
2678+
" instead to get facets as lattice polytopes")
26612679
return self.faces(codim=1)
26622680

26632681
def facets_lp(self):
@@ -4243,25 +4261,20 @@ def traverse_boundary(self):
42434261
42444262
sage: p = lattice_polytope.cross_polytope(2).polar()
42454263
sage: p.traverse_boundary()
4246-
[0, 1, 3, 2]
4264+
[2, 0, 1, 3]
42474265
"""
42484266
if self.dim() != 2:
42494267
raise ValueError("Boundary can be traversed only for 2-polytopes!")
4250-
edges = self.edges()
4251-
l = [0]
4252-
for e in edges:
4253-
if 0 in e.vertices():
4254-
next = e.vertices()[0] if e.vertices()[0] != 0 else e.vertices()[1]
4255-
l.append(next)
4256-
prev = 0
4268+
zero_faces = set(self.faces_lp(0))
4269+
l = [self.faces_lp(0)[0]]
4270+
prev, next = zero_faces.intersection(l[0].adjacent())
4271+
l = [prev, l[0], next]
42574272
while len(l) < self.nvertices():
4258-
for e in edges:
4259-
if next in e.vertices() and prev not in e.vertices():
4260-
prev = next
4261-
next = e.vertices()[0] if e.vertices()[0] != next else e.vertices()[1]
4262-
l.append(next)
4263-
break
4264-
return l
4273+
prev, next = zero_faces.intersection(l[-1].adjacent())
4274+
if next == l[-2]:
4275+
next = prev
4276+
l.append(next)
4277+
return [self.vertices().index(v.vertex(0)) for v in l]
42654278

42664279
def vertex(self, i):
42674280
r"""
@@ -4307,15 +4320,9 @@ def vertex_facet_pairing_matrix(self):
43074320
[2 2 0 0 0 2]
43084321
"""
43094322
V = self.vertices()
4310-
PM = []
4311-
for i in range(len(self.facets())):
4312-
n = self.facet_normal(i)
4313-
c = self.facet_constant(i)
4314-
row = []
4315-
for v in V:
4316-
row.append(n.dot_product(v) + c)
4317-
PM.append(row)
4318-
PM = matrix(ZZ, PM)
4323+
nv = self.nvertices()
4324+
PM = matrix(ZZ, [n * V + vector(ZZ, [c] * nv)
4325+
for n, c in zip(self.facet_normals(), self.facet_constants())])
43194326
PM.set_immutable()
43204327
return PM
43214328

@@ -5266,6 +5273,8 @@ def __reduce__(self):
52665273
52675274
sage: p = lattice_polytope.cross_polytope(2)
52685275
sage: f = p.facets()[0]
5276+
doctest:...: DeprecationWarning: the output of this method will change, use facets_lp instead to get facets as lattice polytopes
5277+
See http://trac.sagemath.org/19071 for details.
52695278
sage: fl = loads(f.dumps())
52705279
sage: f.vertices() == fl.vertices()
52715280
True
@@ -5292,6 +5301,8 @@ def _repr_(self):
52925301
52935302
sage: o = lattice_polytope.cross_polytope(3)
52945303
sage: f = o.facets()[0]
5304+
doctest:...: DeprecationWarning: the output of this method will change, use facets_lp instead to get facets as lattice polytopes
5305+
See http://trac.sagemath.org/19071 for details.
52955306
sage: f._repr_()
52965307
'[0, 1, 5]'
52975308
"""
@@ -5308,6 +5319,8 @@ def boundary_points(self):
53085319
sage: o = lattice_polytope.cross_polytope(3)
53095320
sage: cube = o.polar()
53105321
sage: face = cube.facets()[0]
5322+
doctest:...: DeprecationWarning: the output of this method will change, use facets_lp instead to get facets as lattice polytopes
5323+
See http://trac.sagemath.org/19071 for details.
53115324
sage: face.boundary_points()
53125325
[0, 2, 4, 6, 8, 9, 11, 12]
53135326
"""
@@ -5336,6 +5349,8 @@ def facets(self):
53365349
sage: edge
53375350
[1, 5]
53385351
sage: o.facets()[0]
5352+
doctest:...: DeprecationWarning: the output of this method will change, use facets_lp instead to get facets as lattice polytopes
5353+
See http://trac.sagemath.org/19071 for details.
53395354
[0, 1, 5]
53405355
sage: o.facets()[1]
53415356
[1, 3, 5]
@@ -5375,6 +5390,8 @@ def interior_points(self):
53755390
sage: o = lattice_polytope.cross_polytope(3)
53765391
sage: cube = o.polar()
53775392
sage: face = cube.facets()[0]
5393+
doctest:...: DeprecationWarning: the output of this method will change, use facets_lp instead to get facets as lattice polytopes
5394+
See http://trac.sagemath.org/19071 for details.
53785395
sage: face.interior_points()
53795396
[10]
53805397
"""
@@ -5394,6 +5411,8 @@ def nboundary_points(self):
53945411
sage: o = lattice_polytope.cross_polytope(3)
53955412
sage: cube = o.polar()
53965413
sage: face = cube.facets()[0]
5414+
doctest:...: DeprecationWarning: the output of this method will change, use facets_lp instead to get facets as lattice polytopes
5415+
See http://trac.sagemath.org/19071 for details.
53975416
sage: face.nboundary_points()
53985417
8
53995418
"""
@@ -5425,6 +5444,8 @@ def ninterior_points(self):
54255444
sage: o = lattice_polytope.cross_polytope(3)
54265445
sage: cube = o.polar()
54275446
sage: face = cube.facets()[0]
5447+
doctest:...: DeprecationWarning: the output of this method will change, use facets_lp instead to get facets as lattice polytopes
5448+
See http://trac.sagemath.org/19071 for details.
54285449
sage: face.ninterior_points()
54295450
1
54305451
"""
@@ -5443,6 +5464,8 @@ def npoints(self):
54435464
sage: o = lattice_polytope.cross_polytope(3)
54445465
sage: cube = o.polar()
54455466
sage: face = cube.facets()[0]
5467+
doctest:...: DeprecationWarning: the output of this method will change, use facets_lp instead to get facets as lattice polytopes
5468+
See http://trac.sagemath.org/19071 for details.
54465469
sage: face.npoints()
54475470
9
54485471
"""
@@ -5461,6 +5484,8 @@ def nvertices(self):
54615484
sage: o = lattice_polytope.cross_polytope(3)
54625485
sage: cube = o.polar()
54635486
sage: face = cube.facets()[0]
5487+
doctest:...: DeprecationWarning: the output of this method will change, use facets_lp instead to get facets as lattice polytopes
5488+
See http://trac.sagemath.org/19071 for details.
54645489
sage: face.nvertices()
54655490
4
54665491
"""
@@ -5479,6 +5504,8 @@ def ordered_points(self):
54795504
sage: o = lattice_polytope.cross_polytope(3)
54805505
sage: c = o.polar()
54815506
sage: e = c.edges()[0]
5507+
doctest:...: DeprecationWarning: the output of this method will change, use edges_lp instead to get edges as lattice polytopes
5508+
See http://trac.sagemath.org/19071 for details.
54825509
sage: e.vertices()
54835510
[0, 1]
54845511
sage: e.ordered_points()
@@ -5512,6 +5539,8 @@ def points(self):
55125539
sage: o = lattice_polytope.cross_polytope(3)
55135540
sage: cube = o.polar()
55145541
sage: face = cube.facets()[0]
5542+
doctest:...: DeprecationWarning: the output of this method will change, use facets_lp instead to get facets as lattice polytopes
5543+
See http://trac.sagemath.org/19071 for details.
55155544
sage: face.points()
55165545
[0, 2, 4, 6, 8, 9, 10, 11, 12]
55175546
"""
@@ -5532,9 +5561,15 @@ def traverse_boundary(self):
55325561
55335562
sage: c = lattice_polytope.cross_polytope(3).polar()
55345563
sage: f = c.facets()[0]
5564+
doctest:...: DeprecationWarning: the output of this method will change, use facets_lp instead to get facets as lattice polytopes
5565+
See http://trac.sagemath.org/19071 for details.
55355566
sage: f.vertices()
55365567
[0, 2, 4, 6]
55375568
sage: f.traverse_boundary()
5569+
doctest:...: DeprecationWarning: the output of this method will change, use faces_lp instead to get faces as lattice polytopes
5570+
See http://trac.sagemath.org/19071 for details.
5571+
doctest:...: DeprecationWarning: the output of this method will change, use edges_lp instead to get edges as lattice polytopes
5572+
See http://trac.sagemath.org/19071 for details.
55385573
[0, 4, 6, 2]
55395574
"""
55405575
if self not in self._polytope.faces(dim=2):
@@ -5567,6 +5602,8 @@ def vertices(self):
55675602
sage: o = lattice_polytope.cross_polytope(3)
55685603
sage: cube = o.polar()
55695604
sage: face = cube.facets()[0]
5605+
doctest:...: DeprecationWarning: the output of this method will change, use facets_lp instead to get facets as lattice polytopes
5606+
See http://trac.sagemath.org/19071 for details.
55705607
sage: face.vertices()
55715608
[0, 2, 4, 6]
55725609
"""

src/sage/schemes/toric/fano_variety.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -608,8 +608,8 @@ def CPRFanoToricVariety(Delta=None,
608608
# single facet of Delta_polar, otherwise they do not form a
609609
# subdivision of the face fan of Delta_polar
610610
if check:
611-
facet_sets = [frozenset(facet.points())
612-
for facet in Delta_polar.facets()]
611+
facet_sets = [frozenset(facet.ambient_point_indices())
612+
for facet in Delta_polar.facets_lp()]
613613
for chart in charts:
614614
is_bad = True
615615
for fset in facet_sets:

0 commit comments

Comments
 (0)