Skip to content

Commit 79a0456

Browse files
committed
suggested enhancements
1 parent ef43673 commit 79a0456

File tree

3 files changed

+22
-24
lines changed

3 files changed

+22
-24
lines changed

src/sage/combinat/cluster_algebra_quiver/cluster_seed.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4755,14 +4755,15 @@ def coeff_recurs(p, q, a1, a2, b, c):
47554755
"""
47564756
if p == 0 and q == 0:
47574757
return 1
4758-
elif p < 0 or q < 0:
4758+
if p < 0 or q < 0:
47594759
return 0
4760-
elif c*a1*q <= b*a2*p:
4761-
return sum((-1)**(k-1)*coeff_recurs(p-k, q, a1, a2, b, c)*_bino(a2-c*q+k-1, k)
4762-
for k in range(1, p+1))
4763-
else:
4764-
return sum((-1)**(k-1)*coeff_recurs(p, q-k, a1, a2, b, c)*_bino(a1-b*p+k-1, k)
4765-
for k in range(1, q+1))
4760+
if c * a1 * q <= b * a2 * p:
4761+
return sum((-1)**(k - 1) * coeff_recurs(p - k, q, a1, a2, b, c)
4762+
*_bino(a2 - c * q + k - 1, k)
4763+
for k in range(1, p + 1))
4764+
return sum((-1)**(k - 1) * coeff_recurs(p, q - k, a1, a2, b, c)
4765+
*_bino(a1 - b * p + k - 1, k)
4766+
for k in range(1, q + 1))
47664767

47674768

47684769
def PathSubset(n, m):

src/sage/combinat/cluster_algebra_quiver/mutation_class.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ def _mutation_class_iter(dg, n, m, depth=infinity, return_dig6=False, show_depth
310310
depth_counter = 0
311311
if up_to_equivalence:
312312
iso, orbits = _dg_canonical_form(dg, mlist)
313-
iso_inv = {iso[a]: a for a in iso}
313+
iso_inv = {iso_a: a for a, iso_a in iso.items()}
314314

315315
dig6 = _digraph_to_dig6(dg, hashable=True)
316316
dig6s = {}
@@ -346,7 +346,7 @@ def _mutation_class_iter(dg, n, m, depth=infinity, return_dig6=False, show_depth
346346
if up_to_equivalence:
347347
iso, orbits = _dg_canonical_form(dg_new, mlist)
348348
i_new = iso[i]
349-
iso_inv = {iso[a]: a for a in iso}
349+
iso_inv = {iso_a: a for a, iso_a in iso.items()}
350350
else:
351351
i_new = i
352352
dig6_new = _digraph_to_dig6(dg_new, hashable=True)
@@ -357,7 +357,8 @@ def _mutation_class_iter(dg, n, m, depth=infinity, return_dig6=False, show_depth
357357
gets_bigger = True
358358
if up_to_equivalence:
359359
orbits = [orbit[0] for orbit in orbits if i_new not in orbit]
360-
iso_history = {a: dig6s[key][2][iso_inv[a]] for a in iso}
360+
d6_key = dig6s[key][2]
361+
iso_history = {a: d6_key[iso_inv[a]] for a in iso}
361362
i_history = iso_history[i_new]
362363
history = dig6s[key][1] + [i_history]
363364
dig6s[dig6_new] = [orbits, history, iso_history]

src/sage/combinat/cluster_algebra_quiver/mutation_type.py

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -707,8 +707,7 @@ def _connected_mutation_type(dg):
707707
return _check_special_BC_cases(dg, n, ['CD'], [None], ['D'], [[v]])
708708
else:
709709
return _check_special_BC_cases(dg, n, ['CD'], [None], ['D'])
710-
else:
711-
return mt_tmp
710+
return mt_tmp
712711
elif label1 == (1, -2) and label2 == (2, -1):
713712
if n == 4 and (nr_same_neighbors == 2 or nr_other_neighbors == 1):
714713
return QuiverMutationType(['BD', n - 1, 1])
@@ -724,35 +723,32 @@ def _connected_mutation_type(dg):
724723
if nr_same_neighbors + nr_other_neighbors > 1:
725724
# _reset_dg(dg, vertices, dict_in_out, [v])
726725
return _check_special_BC_cases(dg, n, ['BD'], [None], ['D'], [[v]])
727-
else:
728-
return _check_special_BC_cases(dg, n, ['BD'], [None], ['D'])
726+
return _check_special_BC_cases(dg, n, ['BD'], [None], ['D'])
729727
else:
730728
return mt_tmp
731729
else:
732730
return _false_return()
733731
elif dict_in_out[v1][2] == 1 and dict_in_out[v2][2] == 1:
734732
if label1 == (1, -2) and label2 == (1, -2):
735733
return _check_special_BC_cases(dg, n, ['BC'], [1], ['A'])
736-
elif label1 == (2, -1) and label2 == (2, -1):
734+
if label1 == (2, -1) and label2 == (2, -1):
737735
return _check_special_BC_cases(dg, n, ['BC'], [1], ['A'])
738-
elif label1 == (1, -2) and label2 == (2, -1):
736+
if label1 == (1, -2) and label2 == (2, -1):
739737
return _check_special_BC_cases(dg, n, ['CC'], [1], ['A'])
740-
elif label1 == (2, -1) and label2 == (1, -2):
738+
if label1 == (2, -1) and label2 == (1, -2):
741739
return _check_special_BC_cases(dg, n, ['BB'], [1], ['A'])
742-
else:
743-
return _false_return()
740+
return _false_return()
744741
elif dict_in_out[v][0] == dict_in_out[v][1] == 1 and dict_in_out[v1][0] == dict_in_out[v1][1] == 1 and dict_in_out[v2][0] == dict_in_out[v2][1] == 1:
745742
_reset_dg(dg, vertices, dict_in_out, [v])
746743
if n == 4 and (label1, label2) == ((2, -1), (1, -2)):
747744
return _check_special_BC_cases(dg, n, ['CD'], [1], ['A'])
748-
elif n > 4 and (label1, label2) == ((2, -1), (1, -2)):
745+
if n > 4 and (label1, label2) == ((2, -1), (1, -2)):
749746
return _check_special_BC_cases(dg, n, ['CD'], [1], ['D'])
750-
elif n == 4 and (label1, label2) == ((1, -2), (2, -1)):
747+
if n == 4 and (label1, label2) == ((1, -2), (2, -1)):
751748
return _check_special_BC_cases(dg, n, ['BD'], [1], ['A'])
752-
elif n > 4 and (label1, label2) == ((1, -2), (2, -1)):
749+
if n > 4 and (label1, label2) == ((1, -2), (2, -1)):
753750
return _check_special_BC_cases(dg, n, ['BD'], [1], ['D'])
754-
else:
755-
return _false_return()
751+
return _false_return()
756752
else:
757753
return _false_return()
758754

0 commit comments

Comments
 (0)