Skip to content

cleanup and code details in cluster_algebra_quiver #40393

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/sage/combinat/cluster_algebra_quiver/all.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
- :ref:`sage.combinat.cluster_algebra_quiver.cluster_seed`
"""
# install the docstring of this module to the containing package
from sage.misc.lazy_import import lazy_import
from sage.misc.namespace_package import install_doc
install_doc(__package__, __doc__)

from sage.misc.lazy_import import lazy_import
install_doc(__package__, __doc__)
lazy_import("sage.combinat.cluster_algebra_quiver.quiver_mutation_type",
"QuiverMutationType")
lazy_import("sage.combinat.cluster_algebra_quiver.quiver", "ClusterQuiver")
Expand Down
103 changes: 51 additions & 52 deletions src/sage/combinat/cluster_algebra_quiver/cluster_seed.py
Original file line number Diff line number Diff line change
Expand Up @@ -2497,9 +2497,9 @@
sequence = self.first_green_vertex()
elif sequence == 'red':
sequence = self.first_red_vertex()
elif sequence == 'urban' or sequence == 'urban_renewal':
elif sequence in {'urban', 'urban_renewal'}:
sequence = self.first_urban_renewal()
elif sequence == 'all_urbans' or sequence == 'all_urban_renewals':
elif sequence in {'all_urbans', 'all_urban_renewals'}:
sequence = self.urban_renewals()
elif hasattr(self, sequence):
sequence = getattr(self, sequence)()
Expand Down Expand Up @@ -2575,33 +2575,32 @@
' "indices", or "cluster_vars"')

# Classifies the input_type. Raises warnings if the input is ambiguous, and errors if the input is not all of the same type.
else:
if is_vertices:
input_type = "vertices"
for x in seqq:
if is_indices and seed._nlist[x] != x:
print("Input can be ambiguously interpreted as both"
" vertices and indices."
elif is_vertices:
input_type = "vertices"
for x in seqq:
if is_indices and seed._nlist[x] != x:
print("Input can be ambiguously interpreted as both"
" vertices and indices."
" Mutating at vertices by default.")
break

elif is_cluster_vars:
cluster_var_index = seed.cluster_index(x)
vertex_index = seed._nlist.index(x)
if isinstance(cluster_var_index, int) and cluster_var_index != vertex_index:
print("Input can be ambiguously interpreted as"
" both vertices and cluster variables."
" Mutating at vertices by default.")
break

elif is_cluster_vars:
cluster_var_index = seed.cluster_index(x)
vertex_index = seed._nlist.index(x)
if isinstance(cluster_var_index, int) and cluster_var_index != vertex_index:
print("Input can be ambiguously interpreted as"
" both vertices and cluster variables."
" Mutating at vertices by default.")
break

# It should be impossible to interpret an index as a cluster variable.
elif is_indices:
input_type = "indices"
elif is_cluster_vars:
input_type = "cluster_vars"
else:
raise ValueError('mutation sequences must consist of exactly'
' one of vertices, indices, or cluster variables')
# It should be impossible to interpret an index as a cluster variable.
elif is_indices:
input_type = "indices"
elif is_cluster_vars:
input_type = "cluster_vars"
else:
raise ValueError('mutation sequences must consist of exactly'

Check warning on line 2602 in src/sage/combinat/cluster_algebra_quiver/cluster_seed.py

View check run for this annotation

Codecov / codecov/patch

src/sage/combinat/cluster_algebra_quiver/cluster_seed.py#L2602

Added line #L2602 was not covered by tests
' one of vertices, indices, or cluster variables')

if input_type == "cluster_vars" and len(seqq) > 1:
mutation_seed = deepcopy(seed)
Expand Down Expand Up @@ -3497,8 +3496,8 @@
Check that :issue:`14638` is fixed::

sage: S = ClusterSeed(['E',6])
sage: MC = S.mutation_class(depth=7); len(MC) # long time
534
sage: MC = S.mutation_class(depth=6); len(MC) # long time
388

Infinite type examples::

Expand Down Expand Up @@ -4170,7 +4169,7 @@
A seed for a cluster algebra of rank 10 of type ['E', 8, [1, 1]]
sage: S._mutation_type = S._quiver._mutation_type = None; S
A seed for a cluster algebra of rank 10
sage: S.mutation_type() # long time

Check warning on line 4172 in src/sage/combinat/cluster_algebra_quiver/cluster_seed.py

View workflow job for this annotation

GitHub Actions / Conda (ubuntu, Python 3.12, new)

Warning: slow doctest:

slow doctest:

Check warning on line 4172 in src/sage/combinat/cluster_algebra_quiver/cluster_seed.py

View workflow job for this annotation

GitHub Actions / test-long (src/sage/[a-f]*)

Warning: slow doctest:

slow doctest:
['E', 8, [1, 1]]

- the not yet working affine type D::
Expand Down Expand Up @@ -4266,11 +4265,10 @@
oddT = set(T).intersection(PathSubset(a1, 0))
evenT = set(T).symmetric_difference(oddT)
ans = ans + S.x(0)**(b*len(evenT)) * S.x(1)**(c*len(oddT))
else:
if is_LeeLiZel_allowable(T, a2, a1, c, b):
oddT = set(T).intersection(PathSubset(a2, 0))
evenT = set(T).symmetric_difference(oddT)
ans = ans + S.x(0)**(b*len(oddT)) * S.x(1)**(c*len(evenT))
elif is_LeeLiZel_allowable(T, a2, a1, c, b):
oddT = set(T).intersection(PathSubset(a2, 0))
evenT = set(T).symmetric_difference(oddT)
ans = ans + S.x(0)**(b*len(oddT)) * S.x(1)**(c*len(evenT))
ans = ans*S.x(0)**(-a1)*S.x(1)**(-a2)
return ans
elif algorithm == 'just_numbers':
Expand Down Expand Up @@ -4425,15 +4423,15 @@

while True:
R = PolynomialRing(QQ, gens, order='invlex')
I = R.ideal(rels)
J = R.ideal(initial_product)
ideal_I = R.ideal(rels)
ideal_J = R.ideal(initial_product)
if verbose:
msg = 'Computing relations among {} generators'
print(msg.format(len(gens)))
start = time.time()
ISat = I.saturation(J)[0]
spend = time.time() - start
ISat = ideal_I.saturation(ideal_J)[0]
if verbose:
spend = time.time() - start

Check warning on line 4434 in src/sage/combinat/cluster_algebra_quiver/cluster_seed.py

View check run for this annotation

Codecov / codecov/patch

src/sage/combinat/cluster_algebra_quiver/cluster_seed.py#L4434

Added line #L4434 was not covered by tests
msg = 'Computed {} relations in {} seconds'
print(msg.format(len(ISat.gens()), spend))
deep_ideal = R.ideal(deep_gens) + ISat
Expand All @@ -4445,7 +4443,7 @@
spend = time.time() - start
if M == initial_product_ideal:
if verbose:
print('Verified that there are no new elements in', spend, 'seconds')
print(f'Verified that there are no new elements in {spend} seconds')

Check warning on line 4446 in src/sage/combinat/cluster_algebra_quiver/cluster_seed.py

View check run for this annotation

Codecov / codecov/patch

src/sage/combinat/cluster_algebra_quiver/cluster_seed.py#L4446

Added line #L4446 was not covered by tests
print('Returning a presentation for the upper bound')
return R.quotient_ring(ISat)
else:
Expand Down Expand Up @@ -4689,7 +4687,7 @@
# Computes the Laurent Polynomial for each vector in the decomposition.
finalP = []
# Laurent polynomial for each vector in {0,1}^n
for i in range(len(vd)):
for i, vdi in enumerate(vd):
numerator = 0
if cList[i]:
# If the vector in vd is negative then it did not
Expand All @@ -4706,19 +4704,20 @@
expn = 0
# The exponent is determined by the vectors a,s, and the matrix B.
for k in range(num_cols):
expn += (vd[i][0][k]-s[k])*max(0, B[j][k])+s[k]*max(0, -B[j][k])
term *= x ** expn
expn += (vdi[0][k]-s[k])*max(0, B[j][k])+s[k]*max(0, -B[j][k])
term *= x**expn
numerator += term
# Gives a numerator for the negative vector, or else the product would be zero.
else:
numerator = 1

# Uses the vectors in vd to calculates the denominator of the Laurent.
denominator = 1
for l in range(num_cols):
denominator = denominator * (R.gen(l))**vd[i][0][l]
powers = vdi[0]
for ell in range(num_cols):
denominator = denominator * R.gen(ell)**powers[ell]
# Each copy of a vector in vd contributes a factor of the Laurent polynomial calculated from it.
final = (numerator / denominator)**vd[i][1]
final = (numerator / denominator)**vdi[1]
finalP.append(final)
laurentP = 1
# The UCA element for the vector a is the product of the elements produced from the vectors in its decomposition.
Expand Down Expand Up @@ -4756,15 +4755,15 @@
"""
if p == 0 and q == 0:
return 1
elif p < 0 or q < 0:
if p < 0 or q < 0:
return 0
else:
if c*a1*q <= b*a2*p:
return sum((-1)**(k-1)*coeff_recurs(p-k, q, a1, a2, b, c)*_bino(a2-c*q+k-1, k)
for k in range(1, p+1))
else:
return sum((-1)**(k-1)*coeff_recurs(p, q-k, a1, a2, b, c)*_bino(a1-b*p+k-1, k)
for k in range(1, q+1))
if c * a1 * q <= b * a2 * p:
return sum((-1)**(k - 1) * coeff_recurs(p - k, q, a1, a2, b, c)
*_bino(a2 - c * q + k - 1, k)
for k in range(1, p + 1))
return sum((-1)**(k - 1) * coeff_recurs(p, q - k, a1, a2, b, c)
*_bino(a1 - b * p + k - 1, k)
for k in range(1, q + 1))


def PathSubset(n, m):
Expand Down
4 changes: 2 additions & 2 deletions src/sage/combinat/cluster_algebra_quiver/interact.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ def cluster_interact(self, fig_size=1, circular=True, kind='seed'):
description="Show last mutation vertex")

mut_buttons = widgets.ToggleButtons(options=list(range(self._n)),
style={'button_width':'initial'},
description='Mutate at: ')
style={'button_width': 'initial'},
description='Mutate at: ')

which_plot = widgets.Dropdown(options=['circular', 'spring'],
value='circular' if circular else "spring",
Expand Down
Loading
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy