@@ -186,7 +186,7 @@ class TamariIntervalPoset(Element,
186
186
The Tamari interval of size 0 induced by relations []
187
187
"""
188
188
@staticmethod
189
- def __classcall_private__ (cls , * args , ** opts ):
189
+ def __classcall_private__ (cls , * args , ** opts ) -> TIP :
190
190
r"""
191
191
Ensure that interval-posets created by the enumerated sets and
192
192
directly are the same and that they are instances of
@@ -246,7 +246,7 @@ def __init__(self, parent, size, relations=None, check=True):
246
246
Element .__init__ (self , parent )
247
247
248
248
self ._cover_relations = tuple (self ._poset .cover_relations ())
249
- self ._latex_options = dict ()
249
+ self ._latex_options = {}
250
250
251
251
def set_latex_options (self , D ):
252
252
r"""
@@ -537,7 +537,7 @@ def draw_decreasing(i, j) -> str:
537
537
538
538
return start + nodes + relations + end
539
539
540
- def poset (self ):
540
+ def poset (self ) -> Poset :
541
541
r"""
542
542
Return ``self`` as a labelled poset.
543
543
@@ -2531,8 +2531,8 @@ def extract_tree(x, y, tilt, common):
2531
2531
break
2532
2532
return BinaryTree ([left_tree , right_tree ], check = False )
2533
2533
2534
- TIP = self .parent ()
2535
- return [TIP .from_binary_trees (extract_tree (cx , cy , t_low , common ),
2534
+ tip = self .parent ()
2535
+ return [tip .from_binary_trees (extract_tree (cx , cy , t_low , common ),
2536
2536
extract_tree (cx , cy , t_up , common ))
2537
2537
for cx , cy in common ]
2538
2538
@@ -3042,12 +3042,12 @@ def final_forest(element) -> TIP:
3042
3042
"""
3043
3043
if isinstance (element , TamariIntervalPoset ):
3044
3044
return element .final_forest ()
3045
- elif element in DyckWords ():
3045
+ if element in DyckWords ():
3046
3046
binary_tree = element .to_binary_tree_tamari ()
3047
3047
elif element in BinaryTrees () or element in LabelledBinaryTrees ():
3048
3048
binary_tree = element
3049
3049
else :
3050
- raise ValueError ("do not know how to construct the final forest of {}" . format ( element ) )
3050
+ raise ValueError (f "do not know how to construct the final forest of { element } " )
3051
3051
3052
3052
def get_relations (bt , start = 1 ):
3053
3053
r"""
@@ -3074,7 +3074,7 @@ def get_relations(bt, start=1):
3074
3074
relations .extend ([(j , index ) for j in rroots ])
3075
3075
return roots , relations , rindex
3076
3076
3077
- roots , relations , index = get_relations (binary_tree )
3077
+ _ , relations , index = get_relations (binary_tree )
3078
3078
P = FinitePoset (DiGraph ([list (range (1 , index )), relations ],
3079
3079
format = 'vertices_and_edges' )) # type:ignore
3080
3080
return TamariIntervalPoset (P , check = False ) # type:ignore
@@ -3146,16 +3146,15 @@ def initial_forest(element) -> TIP:
3146
3146
Traceback (most recent call last):
3147
3147
...
3148
3148
ValueError: do not know how to construct the initial forest of mont
3149
-
3150
3149
"""
3151
3150
if isinstance (element , TamariIntervalPoset ):
3152
3151
return element .initial_forest ()
3153
- elif element in DyckWords ():
3152
+ if element in DyckWords ():
3154
3153
binary_tree = element .to_binary_tree_tamari ()
3155
3154
elif element in BinaryTrees () or element in LabelledBinaryTrees ():
3156
3155
binary_tree = element
3157
3156
else :
3158
- raise ValueError ("do not know how to construct the initial forest of {}" . format ( element ) )
3157
+ raise ValueError (f "do not know how to construct the initial forest of { element } " )
3159
3158
3160
3159
def get_relations (bt , start = 1 ):
3161
3160
r"""
@@ -3182,7 +3181,7 @@ def get_relations(bt, start=1):
3182
3181
relations .extend ([(j , index ) for j in lroots ])
3183
3182
return roots , relations , rindex
3184
3183
3185
- roots , relations , index = get_relations (binary_tree )
3184
+ _ , relations , index = get_relations (binary_tree )
3186
3185
P = FinitePoset (DiGraph ([list (range (1 , index )), relations ],
3187
3186
format = 'vertices_and_edges' )) # type:ignore
3188
3187
return TamariIntervalPoset (P , check = False ) # type:ignore
@@ -3437,7 +3436,6 @@ def from_minimal_schnyder_wood(graph) -> TIP:
3437
3436
sage: TIP.from_minimal_schnyder_wood(G)
3438
3437
The Tamari interval of size 3 induced by relations [(2, 3), (2, 1)]
3439
3438
"""
3440
- from sage .graphs .digraph import DiGraph
3441
3439
from sage .combinat .dyck_word import DyckWord
3442
3440
color_a = graph .incoming_edges (- 1 )[0 ][2 ]
3443
3441
color_b = graph .incoming_edges (- 2 )[0 ][2 ]
@@ -3468,20 +3466,18 @@ def from_minimal_schnyder_wood(graph) -> TIP:
3468
3466
def clockwise_labelling (gr , vertex ):
3469
3467
if len (gr ) == 1 :
3470
3468
return [vertex ]
3471
- else :
3472
- lbl = [vertex ]
3473
- for w in voisins_in [vertex ]:
3474
- lbl += clockwise_labelling (gr , w )
3475
- return lbl
3469
+ lbl = [vertex ]
3470
+ for w in voisins_in [vertex ]:
3471
+ lbl += clockwise_labelling (gr , w )
3472
+ return lbl
3476
3473
3477
3474
def profil (gr , vertex ):
3478
3475
if len (gr ) == 1 :
3479
3476
return []
3480
- else :
3481
- lbl = []
3482
- for w in voisins_in [vertex ]:
3483
- lbl += [1 ] + profil (gr , w ) + [0 ]
3484
- return lbl
3477
+ lbl = []
3478
+ for w in voisins_in [vertex ]:
3479
+ lbl += [1 ] + profil (gr , w ) + [0 ]
3480
+ return lbl
3485
3481
3486
3482
dyckword_bottom = profil (graph0 , - 1 )
3487
3483
# this is the profile of the planar graph graph0
@@ -3503,8 +3499,8 @@ def profil(gr, vertex):
3503
3499
3504
3500
dyckword_bottom = DyckWord (dyckword_bottom ) # type:ignore
3505
3501
dyckword_top = DyckWord (dyckword_top ) # type:ignore
3506
- TIP = TamariIntervalPosets (len (dyckword_bottom ) // 2 )
3507
- return TIP .from_dyck_words (dyckword_bottom , dyckword_top )
3502
+ tip = TamariIntervalPosets (len (dyckword_bottom ) // 2 )
3503
+ return tip .from_dyck_words (dyckword_bottom , dyckword_top )
3508
3504
3509
3505
def __call__ (self , * args , ** keywords ):
3510
3506
r"""
@@ -3534,7 +3530,7 @@ def __call__(self, *args, **keywords):
3534
3530
if len (args ) == 1 and isinstance (args [0 ], FinitePoset ):
3535
3531
return self .element_class (self , args [0 ])
3536
3532
3537
- return super (TamariIntervalPosets , self ).__call__ (* args , ** keywords )
3533
+ return super ().__call__ (* args , ** keywords )
3538
3534
3539
3535
def le (self , el1 , el2 ) -> bool :
3540
3536
r"""
@@ -3669,7 +3665,7 @@ def __init__(self, size):
3669
3665
"""
3670
3666
# there is a natural order on interval-posets through inclusions
3671
3667
# that is why we use the FinitePosets category
3672
- super (TamariIntervalPosets_size , self ).__init__ (category = (FinitePosets (), FiniteEnumeratedSets ()))
3668
+ super ().__init__ (category = (FinitePosets (), FiniteEnumeratedSets ()))
3673
3669
3674
3670
self ._size = size
3675
3671
@@ -3680,7 +3676,7 @@ def _repr_(self) -> str:
3680
3676
sage: TamariIntervalPosets(3)
3681
3677
Interval-posets of size 3
3682
3678
"""
3683
- return "Interval-posets of size {}" . format ( self ._size )
3679
+ return f "Interval-posets of size { self ._size } "
3684
3680
3685
3681
def __contains__ (self , x ) -> bool :
3686
3682
r"""
@@ -3813,10 +3809,10 @@ def random_element(self) -> TIP:
3813
3809
from sage .graphs .generators .random import RandomTriangulation
3814
3810
n = self ._size
3815
3811
tri = RandomTriangulation (n + 3 )
3816
- TIP = TamariIntervalPosets
3812
+ tip = TamariIntervalPosets
3817
3813
schnyder = minimal_schnyder_wood (tri , root_edge = (- 1 , - 2 ),
3818
3814
check = False )
3819
- return TIP .from_minimal_schnyder_wood (schnyder )
3815
+ return tip .from_minimal_schnyder_wood (schnyder )
3820
3816
3821
3817
@lazy_attribute
3822
3818
def _parent_for (self ):
0 commit comments