@@ -269,7 +269,7 @@ class PolyhedralComplex(GenericCellComplex):
269
269
"""
270
270
def __init__ (self , maximal_cells = None , backend = None , maximality_check = True ,
271
271
face_to_face_check = False , is_mutable = True , is_immutable = False ,
272
- ambient_dim = None ):
272
+ ambient_dim = None ) -> None :
273
273
r"""
274
274
Define a PolyhedralComplex.
275
275
@@ -341,7 +341,7 @@ def __init__(self, maximal_cells=None, backend=None, maximality_check=True,
341
341
if not is_mutable or is_immutable :
342
342
self .set_immutable ()
343
343
344
- def cells (self , subcomplex = None ):
344
+ def cells (self , subcomplex = None ) -> dict :
345
345
"""
346
346
The cells of this polyhedral complex, in the form of a dictionary:
347
347
the keys are integers, representing dimension, and the value
@@ -419,7 +419,7 @@ def cell_iterator(self, increasing=True):
419
419
if d in cells :
420
420
yield from cells [d ]
421
421
422
- def _n_cells_sorted (self , n , subcomplex = None ):
422
+ def _n_cells_sorted (self , n , subcomplex = None ) -> list :
423
423
"""
424
424
Sorted list of cells of dimension ``n`` of this polyhedral complex.
425
425
@@ -447,7 +447,7 @@ def _n_cells_sorted(self, n, subcomplex=None):
447
447
return sorted (n_cells ,
448
448
key = lambda p : (p .vertices (), p .rays (), p .lines ()))
449
449
450
- def cells_sorted (self , subcomplex = None ):
450
+ def cells_sorted (self , subcomplex = None ) -> list :
451
451
"""
452
452
The sorted list of the cells of this polyhedral complex
453
453
in non-increasing dimensions.
@@ -469,10 +469,10 @@ def cells_sorted(self, subcomplex=None):
469
469
"""
470
470
cells = []
471
471
for n in range (self ._dim , - 1 , - 1 ):
472
- cells += self ._n_cells_sorted (n , subcomplex )
472
+ cells . extend ( self ._n_cells_sorted (n , subcomplex ) )
473
473
return cells
474
474
475
- def maximal_cells (self ):
475
+ def maximal_cells (self ) -> dict :
476
476
"""
477
477
The maximal cells of this polyhedral complex, in the form of a
478
478
dictionary: the keys are integers, representing dimension, and the
@@ -546,7 +546,7 @@ def maximal_cell_iterator(self, increasing=False):
546
546
if d in maximal_cells :
547
547
yield from maximal_cells [d ]
548
548
549
- def n_maximal_cells (self , n ):
549
+ def n_maximal_cells (self , n ) -> list :
550
550
r"""
551
551
List of maximal cells of dimension ``n`` of this polyhedral complex.
552
552
@@ -584,10 +584,9 @@ def n_maximal_cells(self, n):
584
584
"""
585
585
if n in self .maximal_cells ():
586
586
return list (self .maximal_cells ()[n ])
587
- else :
588
- return []
587
+ return []
589
588
590
- def _n_maximal_cells_sorted (self , n ):
589
+ def _n_maximal_cells_sorted (self , n ) -> list :
591
590
"""
592
591
Sorted list of maximal cells of dimension ``n`` of this polyhedral
593
592
complex.
@@ -613,7 +612,7 @@ def _n_maximal_cells_sorted(self, n):
613
612
return sorted (n_maximal_cells ,
614
613
key = lambda p : (p .vertices (), p .rays (), p .lines ()))
615
614
616
- def maximal_cells_sorted (self ):
615
+ def maximal_cells_sorted (self ) -> list :
617
616
"""
618
617
Return the sorted list of the maximal cells of this polyhedral complex
619
618
by non-increasing dimensions.
@@ -629,11 +628,11 @@ def maximal_cells_sorted(self):
629
628
if self ._maximal_cells_sorted is None :
630
629
maximal_cells = []
631
630
for n in range (self ._dim , - 1 , - 1 ):
632
- maximal_cells += self ._n_maximal_cells_sorted (n )
631
+ maximal_cells . extend ( self ._n_maximal_cells_sorted (n ) )
633
632
self ._maximal_cells_sorted = maximal_cells
634
633
return self ._maximal_cells_sorted
635
634
636
- def is_maximal_cell (self , c ):
635
+ def is_maximal_cell (self , c ) -> bool :
637
636
"""
638
637
Return whether the given cell ``c`` is a maximal cell of ``self``.
639
638
@@ -664,7 +663,7 @@ def is_maximal_cell(self, c):
664
663
# return (c in self.n_maximal_cells(d)) # use set instead of list
665
664
return (d in self .maximal_cells ()) and (c in self .maximal_cells ()[d ])
666
665
667
- def is_cell (self , c ):
666
+ def is_cell (self , c ) -> bool :
668
667
"""
669
668
Return whether the given cell ``c`` is a cell of ``self``.
670
669
@@ -798,7 +797,7 @@ def plot(self, **kwds):
798
797
g += cell .plot (** options )
799
798
return g
800
799
801
- def is_pure (self ):
800
+ def is_pure (self ) -> bool :
802
801
"""
803
802
Test if this polyhedral complex is pure.
804
803
@@ -828,10 +827,11 @@ def is_pure(self):
828
827
"""
829
828
return len (self ._maximal_cells ) == 1
830
829
831
- def is_full_dimensional (self ):
830
+ def is_full_dimensional (self ) -> bool :
832
831
"""
833
- Return whether this polyhedral complex is full-dimensional:
834
- its dimension is equal to its ambient dimension.
832
+ Return whether this polyhedral complex is full-dimensional.
833
+
834
+ This means that its dimension is equal to its ambient dimension.
835
835
836
836
EXAMPLES::
837
837
@@ -846,7 +846,7 @@ def is_full_dimensional(self):
846
846
"""
847
847
return self ._dim == self ._ambient_dim
848
848
849
- def __hash__ (self ):
849
+ def __hash__ (self ) -> int :
850
850
"""
851
851
Compute the hash value of ``self`` using its ``maximal_cells_sorted``.
852
852
@@ -871,7 +871,7 @@ def __hash__(self):
871
871
"call set_immutable()" )
872
872
return hash (tuple (self .maximal_cells_sorted ()))
873
873
874
- def __eq__ (self , right ):
874
+ def __eq__ (self , right ) -> bool :
875
875
"""
876
876
Two polyhedral complexes are equal iff their maximal cells are equal.
877
877
@@ -889,7 +889,7 @@ def __eq__(self, right):
889
889
return isinstance (right , PolyhedralComplex ) and (
890
890
self .maximal_cells_sorted () == right .maximal_cells_sorted ())
891
891
892
- def __ne__ (self , right ):
892
+ def __ne__ (self , right ) -> bool :
893
893
"""
894
894
Return ``True`` if ``self`` and ``right`` are not equal.
895
895
@@ -943,7 +943,7 @@ def _an_element_(self):
943
943
from sage .categories .sets_cat import EmptySetError
944
944
raise EmptySetError ("the complex is empty" )
945
945
946
- def __contains__ (self , x ):
946
+ def __contains__ (self , x ) -> bool :
947
947
"""
948
948
Return ``True`` if ``x`` is a polyhedron which is contained in this complex.
949
949
@@ -1031,7 +1031,7 @@ def face_poset(self):
1031
1031
self .cells () # poset is obtained and cached in cells()
1032
1032
return self ._face_poset
1033
1033
1034
- def is_subcomplex (self , other ):
1034
+ def is_subcomplex (self , other ) -> bool :
1035
1035
r"""
1036
1036
Return whether ``self`` is a subcomplex of ``other``.
1037
1037
@@ -1059,7 +1059,7 @@ def is_subcomplex(self, other):
1059
1059
return False
1060
1060
return True
1061
1061
1062
- def is_compact (self ):
1062
+ def is_compact (self ) -> bool :
1063
1063
"""
1064
1064
Test for boundedness of the polyhedral complex.
1065
1065
@@ -1128,7 +1128,7 @@ def graph(self):
1128
1128
d [v ] = []
1129
1129
return Graph (d )
1130
1130
1131
- def is_connected (self ):
1131
+ def is_connected (self ) -> bool :
1132
1132
"""
1133
1133
Return whether ``self`` is connected.
1134
1134
@@ -1252,7 +1252,7 @@ def connected_component(self, cell=None):
1252
1252
is_immutable = self ._is_immutable ,
1253
1253
backend = self ._backend )
1254
1254
1255
- def connected_components (self ):
1255
+ def connected_components (self ) -> list :
1256
1256
"""
1257
1257
Return the connected components of this polyhedral complex,
1258
1258
as list of (sub-)PolyhedralComplexes.
@@ -1303,11 +1303,10 @@ def connected_components(self):
1303
1303
lists_of_facets = [
1304
1304
[f for f in self .maximal_cell_iterator () if f in faces ]
1305
1305
for faces in lists_of_faces ]
1306
- results = [PolyhedralComplex (facets , maximality_check = False ,
1307
- is_immutable = self ._is_immutable ,
1308
- backend = self ._backend )
1309
- for facets in lists_of_facets ]
1310
- return results
1306
+ return [PolyhedralComplex (facets , maximality_check = False ,
1307
+ is_immutable = self ._is_immutable ,
1308
+ backend = self ._backend )
1309
+ for facets in lists_of_facets ]
1311
1310
1312
1311
def n_skeleton (self , n ):
1313
1312
r"""
@@ -1445,7 +1444,7 @@ def boundary_subcomplex(self):
1445
1444
ans .set_immutable ()
1446
1445
return ans
1447
1446
1448
- def relative_boundary_cells (self ):
1447
+ def relative_boundary_cells (self ) -> list :
1449
1448
r"""
1450
1449
Return the maximal cells of the relative-boundary sub-complex.
1451
1450
@@ -1501,10 +1500,10 @@ def relative_boundary_cells(self):
1501
1500
faces = self .n_cells (d - 1 )
1502
1501
ans = [face for face in faces if len (poset .upper_covers (face )) == 1 ]
1503
1502
if not self .is_pure ():
1504
- ans += [ p for p in poset .maximal_elements () if p .dimension () < d ]
1503
+ ans . extend ( p for p in poset .maximal_elements () if p .dimension () < d )
1505
1504
return ans
1506
1505
1507
- def is_convex (self ):
1506
+ def is_convex (self ) -> bool :
1508
1507
r"""
1509
1508
Return whether the set of points in ``self`` is a convex set.
1510
1509
@@ -1863,7 +1862,7 @@ def alexander_whitney(self, cell, dim_left):
1863
1862
# this function overrides the standard one for GenericCellComplex,
1864
1863
# this one counts the number of maximal cells, not all cells, to
1865
1864
# avoid calling and computing self.cells()
1866
- def _repr_ (self ):
1865
+ def _repr_ (self ) -> str :
1867
1866
"""
1868
1867
Print representation.
1869
1868
@@ -1891,7 +1890,7 @@ def _repr_(self):
1891
1890
else :
1892
1891
return "Polyhedral complex with %s maximal cells" % num
1893
1892
1894
- def set_immutable (self ):
1893
+ def set_immutable (self ) -> None :
1895
1894
"""
1896
1895
Make this polyhedral complex immutable.
1897
1896
@@ -1906,7 +1905,7 @@ def set_immutable(self):
1906
1905
"""
1907
1906
self ._is_immutable = True
1908
1907
1909
- def is_mutable (self ):
1908
+ def is_mutable (self ) -> bool :
1910
1909
"""
1911
1910
Return whether ``self`` is mutable.
1912
1911
@@ -1930,7 +1929,7 @@ def is_mutable(self):
1930
1929
"""
1931
1930
return not self ._is_immutable
1932
1931
1933
- def is_immutable (self ):
1932
+ def is_immutable (self ) -> bool :
1934
1933
"""
1935
1934
Return whether ``self`` is immutable.
1936
1935
@@ -2224,7 +2223,7 @@ def remove_cell(self, cell, check=False):
2224
2223
self ._is_convex = None
2225
2224
self ._polyhedron = None
2226
2225
2227
- def is_simplicial_complex (self ):
2226
+ def is_simplicial_complex (self ) -> bool :
2228
2227
"""
2229
2228
Test if this polyhedral complex is a simplicial complex.
2230
2229
@@ -2243,7 +2242,7 @@ def is_simplicial_complex(self):
2243
2242
"""
2244
2243
return all (p .is_simplex () for p in self .maximal_cell_iterator ())
2245
2244
2246
- def is_polyhedral_fan (self ):
2245
+ def is_polyhedral_fan (self ) -> bool :
2247
2246
"""
2248
2247
Test if this polyhedral complex is a polyhedral fan.
2249
2248
@@ -2266,7 +2265,7 @@ def is_polyhedral_fan(self):
2266
2265
vector (p .vertices_list ()[0 ]) == p .ambient_space ().zero ())
2267
2266
for p in self .maximal_cell_iterator ())
2268
2267
2269
- def is_simplicial_fan (self ):
2268
+ def is_simplicial_fan (self ) -> bool :
2270
2269
"""
2271
2270
Test if this polyhedral complex is a simplicial fan.
2272
2271
@@ -2470,7 +2469,7 @@ def subdivide(self, make_simplicial=False,
2470
2469
############################################################
2471
2470
2472
2471
2473
- def cells_list_to_cells_dict (cells_list ):
2472
+ def cells_list_to_cells_dict (cells_list ) -> dict :
2474
2473
r"""
2475
2474
Helper function that returns the dictionary whose keys are the dimensions,
2476
2475
and the value associated to an integer `d` is the set of `d`-dimensional
0 commit comments