@@ -370,7 +370,7 @@ def __init__(self, data, frozen=None, is_principal=False, user_labels=None, user
370
370
self ._init_exch = dict (islice (self ._init_vars .items (), self ._n ))
371
371
self ._U = PolynomialRing (QQ , [f'y{ i } ' for i in range (self ._n )])
372
372
self ._F = {i : self ._U (1 ) for i in self ._init_exch .values ()}
373
- self ._R = PolynomialRing (QQ , [ val for val in self ._init_vars .values ()] )
373
+ self ._R = PolynomialRing (QQ , list ( self ._init_vars .values ()) )
374
374
self ._y = {self ._U .gen (j ): prod ([self ._R .gen (i )** self ._M [i , j ] for i in range (self ._n , self ._n + self ._m )])
375
375
for j in range (self ._n )}
376
376
self ._yhat = {self ._U .gen (j ): prod ([self ._R .gen (i )** self ._M [i , j ] for i in range (self ._n + self ._m )])
@@ -695,7 +695,7 @@ def use_fpolys(self, use=True, user_labels=None, user_labels_prefix=None):
695
695
self ._init_exch = dict (islice (self ._init_vars .items (), self ._n ))
696
696
self ._U = PolynomialRing (QQ , [f'y{ i } ' for i in range (self ._n )])
697
697
self ._F = {i : self ._U (1 ) for i in self ._init_exch .values ()}
698
- self ._R = PolynomialRing (QQ , [ val for val in self ._init_vars .values ()] )
698
+ self ._R = PolynomialRing (QQ , list ( self ._init_vars .values ()) )
699
699
self ._y = {self ._U .gen (j ): prod ([self ._R .gen (i )** self ._M [i , j ] for i in range (self ._n , self ._n + self ._m )])
700
700
for j in range (self ._n )}
701
701
self ._yhat = {self ._U .gen (j ): prod ([self ._R .gen (i )** self ._M [i , j ] for i in range (self ._n + self ._m )])
@@ -3556,7 +3556,7 @@ def mutation_class_iter(self, depth=infinity, show_depth=False,
3556
3556
dc += ' ' * (5 - len (dc ))
3557
3557
nr = str (len (clusters ))
3558
3558
nr += ' ' * (10 - len (nr ))
3559
- print ("Depth: %s found: %s Time: %.2f s" % ( dc , nr , timer2 - timer ) )
3559
+ print (f "Depth: { dc } found: { nr } Time: { timer2 - timer :.2f } s" )
3560
3560
3561
3561
# Each time we get bigger and we haven't hit the full depth
3562
3562
while gets_bigger and depth_counter < depth :
@@ -3592,11 +3592,11 @@ def mutation_class_iter(self, depth=infinity, show_depth=False,
3592
3592
if only_sink_source :
3593
3593
orbits = list (range (n ))
3594
3594
else :
3595
- orbits = [index for index in range (n ) if index > i or sd2 ._M [index ,i ] != 0 ]
3595
+ orbits = [index for index in range (n ) if index > i or sd2 ._M [index , i ] != 0 ]
3596
3596
3597
3597
clusters [cl2 ] = [sd2 , orbits , clusters [key ][2 ]+ [i ]]
3598
3598
if return_paths :
3599
- yield (sd2 ,clusters [cl2 ][2 ])
3599
+ yield (sd2 , clusters [cl2 ][2 ])
3600
3600
else :
3601
3601
yield sd2
3602
3602
depth_counter += 1
@@ -3606,7 +3606,7 @@ def mutation_class_iter(self, depth=infinity, show_depth=False,
3606
3606
dc += ' ' * (5 - len (dc ))
3607
3607
nr = str (len (clusters ))
3608
3608
nr += ' ' * (10 - len (nr ))
3609
- print ("Depth: %s found: %s Time: % .2f s" % ( dc , nr , timer2 - timer ) )
3609
+ print (f "Depth: { dc } found: { nr } Time: { timer2 - timer : .2f} s" )
3610
3610
3611
3611
def mutation_class (self , depth = infinity , show_depth = False , return_paths = False ,
3612
3612
up_to_equivalence = True , only_sink_source = False ):
@@ -3773,7 +3773,7 @@ def cluster_class(self, depth=infinity, show_depth=False, up_to_equivalence=True
3773
3773
if depth is infinity and not self .is_finite ():
3774
3774
raise ValueError ('The variable class can - for infinite types - only be computed up to a given depth' )
3775
3775
3776
- return [ c for c in self .cluster_class_iter (depth = depth , show_depth = show_depth , up_to_equivalence = up_to_equivalence )]
3776
+ return list ( self .cluster_class_iter (depth = depth , show_depth = show_depth , up_to_equivalence = up_to_equivalence ))
3777
3777
3778
3778
def b_matrix_class_iter (self , depth = infinity , up_to_equivalence = True ):
3779
3779
r"""
@@ -3989,51 +3989,51 @@ def variable_class_iter(self, depth=infinity, ignore_bipartite_belt=False):
3989
3989
(x0^8 + 4*x0^6 + 3*x0^4*x1^2 + 2*x0^2*x1^4 + x1^6 + 6*x0^4 + 6*x0^2*x1^2 + 3*x1^4 + 4*x0^2 + 3*x1^2 + 1)/(x0^3*x1^4)
3990
3990
(x0^6 + 3*x0^4 + 2*x0^2*x1^2 + x1^4 + 3*x0^2 + 2*x1^2 + 1)/(x0^2*x1^3)
3991
3991
"""
3992
- mut_iter = self .mutation_class_iter (depth = depth ,show_depth = False )
3992
+ mut_iter = self .mutation_class_iter (depth = depth , show_depth = False )
3993
3993
var_class = set ()
3994
3994
3995
3995
for seed in mut_iter :
3996
3996
if seed is self :
3997
3997
seed = ClusterSeed (seed )
3998
3998
if not ignore_bipartite_belt and seed .is_bipartite ():
3999
3999
bipartition = seed .is_bipartite (return_bipartition = True )
4000
- bipartition = (list (bipartition [0 ]),list (bipartition [1 ]))
4000
+ bipartition = (list (bipartition [0 ]), list (bipartition [1 ]))
4001
4001
if depth is not infinity :
4002
4002
print ("Found a bipartite seed - restarting the depth counter at zero and constructing the variable class using its bipartite belt." )
4003
4003
depth_counter = 0
4004
4004
end = False
4005
4005
seed2 = ClusterSeed (seed )
4006
4006
for c in seed .cluster ():
4007
4007
if c not in var_class :
4008
- yield ClusterVariable (FractionField (seed ._R ), c .numerator (), c .denominator (), mutation_type = self ._mutation_type , variable_type = 'cluster variable' ,xdim = seed ._n )
4008
+ yield ClusterVariable (FractionField (seed ._R ), c .numerator (), c .denominator (), mutation_type = self ._mutation_type , variable_type = 'cluster variable' , xdim = seed ._n )
4009
4009
var_class = var_class .union (seed .cluster ())
4010
4010
4011
4011
init_cluster = set (seed .cluster ())
4012
4012
while not end and depth_counter < depth :
4013
4013
depth_counter += 1
4014
4014
seed .mutate (bipartition [0 ])
4015
4015
seed .mutate (bipartition [1 ])
4016
- if set (seed .cluster ()) in [set (seed2 .cluster ()),init_cluster ]:
4016
+ if set (seed .cluster ()) in [set (seed2 .cluster ()), init_cluster ]:
4017
4017
end = True
4018
4018
if not end :
4019
4019
for c in seed .cluster ():
4020
4020
if c not in var_class :
4021
- yield ClusterVariable (FractionField (seed ._R ), c .numerator (), c .denominator (), mutation_type = self ._mutation_type , variable_type = 'cluster variable' ,xdim = seed ._n )
4021
+ yield ClusterVariable (FractionField (seed ._R ), c .numerator (), c .denominator (), mutation_type = self ._mutation_type , variable_type = 'cluster variable' , xdim = seed ._n )
4022
4022
var_class = var_class .union (seed .cluster ())
4023
4023
seed2 .mutate (bipartition [1 ])
4024
4024
seed2 .mutate (bipartition [0 ])
4025
- if set (seed2 .cluster ()) in [set (seed .cluster ()),init_cluster ]:
4025
+ if set (seed2 .cluster ()) in [set (seed .cluster ()), init_cluster ]:
4026
4026
end = True
4027
4027
if not end :
4028
4028
for c in seed2 .cluster ():
4029
4029
if c not in var_class :
4030
- yield ClusterVariable (FractionField (seed ._R ), c .numerator (), c .denominator (), mutation_type = self ._mutation_type , variable_type = 'cluster variable' ,xdim = seed ._n )
4030
+ yield ClusterVariable (FractionField (seed ._R ), c .numerator (), c .denominator (), mutation_type = self ._mutation_type , variable_type = 'cluster variable' , xdim = seed ._n )
4031
4031
var_class = var_class .union (seed2 .cluster ())
4032
4032
return
4033
4033
else :
4034
4034
for c in seed .cluster ():
4035
4035
if c not in var_class :
4036
- yield ClusterVariable (FractionField (seed ._R ), c .numerator (), c .denominator (), mutation_type = self ._mutation_type , variable_type = 'cluster variable' ,xdim = seed ._n )
4036
+ yield ClusterVariable (FractionField (seed ._R ), c .numerator (), c .denominator (), mutation_type = self ._mutation_type , variable_type = 'cluster variable' , xdim = seed ._n )
4037
4037
var_class = var_class .union (seed .cluster ())
4038
4038
4039
4039
def variable_class (self , depth = infinity , ignore_bipartite_belt = False ):
@@ -4120,7 +4120,7 @@ def is_mutation_finite(self, nr_of_checks=None, return_path=False):
4120
4120
sage: S.is_mutation_finite()
4121
4121
False
4122
4122
"""
4123
- is_finite , path = is_mutation_finite (copy (self ._M ),nr_of_checks = nr_of_checks )
4123
+ is_finite , path = is_mutation_finite (copy (self ._M ), nr_of_checks = nr_of_checks )
4124
4124
if return_path :
4125
4125
return is_finite , path
4126
4126
else :
@@ -4403,8 +4403,8 @@ def find_upper_bound(self, verbose=False):
4403
4403
"""
4404
4404
rank = self .n ()
4405
4405
4406
- xvars = ['x{}' . format ( t ) for t in range (rank )]
4407
- xpvars = ['x{}p' . format ( t ) for t in range (rank )]
4406
+ xvars = [f 'x{ t } ' for t in range (rank )]
4407
+ xpvars = [f 'x{ t } p' for t in range (rank )]
4408
4408
gens = xvars + xpvars
4409
4409
initial_product = '*' .join (g for g in xvars )
4410
4410
@@ -4418,8 +4418,7 @@ def find_upper_bound(self, verbose=False):
4418
4418
for s in range (rank ))
4419
4419
deep_gens += [neighbor_product ]
4420
4420
4421
- rels = ["-{}*{}+{}" .format (gens [t ], gens [t + rank ],
4422
- lower_var [t + rank ].numerator ())
4421
+ rels = [f"-{ gens [t ]} *{ gens [t + rank ]} +{ lower_var [t + rank ].numerator ()} "
4423
4422
for t in range (rank )]
4424
4423
4425
4424
while True :
@@ -4509,9 +4508,9 @@ def get_upper_cluster_algebra_element(self, a):
4509
4508
if len (a ) != B .ncols ():
4510
4509
raise ValueError ('The length of the input vector must be the same as the number of columns of B.' )
4511
4510
# Runs helper functions.
4512
- v = _vector_decomposition (a ,B .nrows ())
4511
+ v = _vector_decomposition (a , B .nrows ())
4513
4512
c = self ._compute_compatible_vectors (v )
4514
- return self ._produce_upper_cluster_algebra_element (v ,c )
4513
+ return self ._produce_upper_cluster_algebra_element (v , c )
4515
4514
4516
4515
def LLM_gen_set (self , size_limit = - 1 ):
4517
4516
r"""
@@ -4793,7 +4792,7 @@ def PathSubset(n, m):
4793
4792
sage: PathSubset(4,4)
4794
4793
{0, 1, 2, 3, 4, 5, 6, 7}
4795
4794
"""
4796
- S = set ( 2 * i + 1 for i in range (n ))
4795
+ S = { 2 * i + 1 for i in range (n )}
4797
4796
if m > 0 :
4798
4797
for j in range (n ):
4799
4798
if ((j + 1 )* m ) // n - (j * m ) // n == 1 :
@@ -4831,7 +4830,7 @@ def SetToPath(T):
4831
4830
return ans
4832
4831
4833
4832
4834
- def is_LeeLiZel_allowable (T ,n , m , b , c ):
4833
+ def is_LeeLiZel_allowable (T , n , m , b , c ):
4835
4834
"""
4836
4835
Check if the subset `T` contributes to the computation of the greedy element `x[m,n]` in the rank two `(b,c)`-cluster algebra.
4837
4836
0 commit comments