Skip to content

Commit

Permalink
a few other details, as suggested
Browse files Browse the repository at this point in the history
  • Loading branch information
fchapoton committed Jun 22, 2024
1 parent e74fb37 commit 6effe6e
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 59 deletions.
35 changes: 18 additions & 17 deletions src/sage/combinat/crystals/alcove_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,10 +394,10 @@ def vertices(self):
EXAMPLES::
sage: C = crystals.AlcovePaths(['C',2],[1,0])
sage: C = crystals.AlcovePaths(['C', 2], [1, 0])
sage: C.vertices()
[[], [0], [0, 1], [0, 1, 2]]
sage: C = crystals.AlcovePaths(['C',2,1],[2,1],False)
sage: C = crystals.AlcovePaths(['C', 2, 1], [2, 1], False)
sage: len(C.vertices())
80
Expand Down Expand Up @@ -434,13 +434,13 @@ def vertices(self):
lst2 = []
for x in lst:
suc = getattr(x[0], successors)()
for j in range(x[1][-1]+1, len_lambda_chain):
for j in range(x[1][-1] + 1, len_lambda_chain):
temp = x[0] * prod(
[s[k] for k in lambda_chain[j].root.associated_reflection()])
if temp in suc:
lst2.append((temp, x[1]+[j]))
l.append((temp, x[1]+[j]))
if lst2 == []:
lst2.append((temp, x[1] + [j]))
l.append((temp, x[1] + [j]))
if not lst2:
break
else:
lst = lst2
Expand Down Expand Up @@ -677,7 +677,7 @@ def weight(self):
weight = -self.parent().weight
for i in self.value[::-1]:
root = root_space(i.root)
weight = -i.height*root + weight.reflection(root)
weight = -i.height * root + weight.reflection(root)

WLR = self.parent().weight_lattice_realization()
if self.cartan_type().is_affine() and self.parent()._highest_weight_crystal:
Expand Down Expand Up @@ -855,7 +855,7 @@ def _folding_data(self, i):
x = R(sign_Beta * Beta, k)

if (
(j < len(J) - 1 and J[j] < x <= J[j+1]) or
(j < len(J) - 1 and J[j] < x <= J[j + 1]) or
(j == len(J) - 1 and J[j] < x)
):
signs[x] = sign_Beta
Expand Down Expand Up @@ -902,15 +902,15 @@ def e(self, i):
KR_test = finite_cartan_type and i == 0 and m_index < len(gi) - 1
KR_test = KR_test and M >= 1

######################################################################
###################################################################
# NOTE:
# In the KR_case we want to insure that positions[m_index] is in J
# If m_index > 0 then it's always true
# If m_index == 0 then M >=1 guarantees this
######################################################################
###################################################################

if ((not finite_cartan_type or i != 0) and m_index < len(gi) - 1 # alpha_i is a simple root
) or KR_test:
if ((not finite_cartan_type or i != 0) and m_index < len(gi) - 1) or KR_test:
# first condition above means that alpha_i is a simple root

J.remove(positions[m_index])
if m_index + 1 < len(positions):
Expand Down Expand Up @@ -1040,10 +1040,10 @@ def f(self, i):
#
# otherwise if m_index - 1 > 0 then (C2) is enough

if ((not finite_cartan_type or i != 0) and M > 0 # alpha_i is a simple root
) or KR_test: # KR case
if ((not finite_cartan_type or i != 0) and M > 0) or KR_test:
# first condition above means that alpha_i is a simple root

J.append(positions[m_index-1])
J.append(positions[m_index - 1])
if m_index < len(positions):
# if m_index != 'infinity'
# thus positions[m_index] makes sense
Expand Down Expand Up @@ -1658,8 +1658,9 @@ def __init__(self, parent, root, height):
if not 0 <= height < max_height:
raise ValueError("%d out of allowed range [%d,%d)" % (height, 0, max_height))

v = [height/max_height]
v.extend(x/max_height for x in root.associated_coroot().to_vector())
v = [height / max_height]
v.extend(x / max_height
for x in root.associated_coroot().to_vector())
# v.insert(0, height/max_height)

# the map from (root, height) --> _cmp_v is injective
Expand Down
52 changes: 25 additions & 27 deletions src/sage/combinat/crystals/generalized_young_walls.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,13 +390,14 @@ def number_of_parts(self):
i = 0
while i < len(new):
r = new[i]
if r == [] or r in new[i+1:]:
if not r or r in new[i + 1:]:
new.pop(i)
elif r[0] == n and len(r) % (n+1) == 0:
for j in range(n+1):
temp = [k % (n+1) for k in range(j+len(r)/(n+1)-1, j-1, -1)]
elif r[0] == n and not len(r) % (n + 1):
for j in range(n + 1):
temp = [k % (n + 1)
for k in range(j + len(r) // (n + 1) - 1, j - 1, -1)]
if temp not in new:
new.insert(i+1, temp)
new.insert(i + 1, temp)
new.pop(i)
else:
i += 1
Expand Down Expand Up @@ -425,7 +426,7 @@ def sum_of_weighted_row_lengths(self):
15
"""
n = self.parent().cartan_type().rank() - 1
m = lambda i: len([1 for r in self.data if r and r[0] == (i-1) % (n+1)])
m = lambda i: len([1 for r in self.data if r and r[0] == (i - 1) % (n + 1)])
for r in self.data:
if r and r[0] == n:
raise ValueError('Statistic only valid for generalized Young walls in Y_0')
Expand Down Expand Up @@ -510,11 +511,12 @@ def latex_large(self):
'\\begin{tikzpicture}[baseline=5,scale=.45] \n \\foreach \\x [count=\\s from 0] in \n{{},{1,0,3,2},{2,1},{3,2,1,0,3,2},{},{},{2}} \n{\\foreach \\y [count=\\t from 0] in \\x { \\node[font=\\scriptsize] at (-\\t,\\s) {$\\y$}; \n \\draw (-\\t+.5,\\s+.5) to (-\\t-.5,\\s+.5); \n \\draw (-\\t+.5,\\s-.5) to (-\\t-.5,\\s-.5); \n \\draw (-\\t-.5,\\s-.5) to (-\\t-.5,\\s+.5); } \n \\draw[-,thick] (.5,\\s+1) to (.5,-.5) to (-\\t-1,-.5); } \n \\end{tikzpicture} \n'
"""
s = ""
if self.data == []:
if not self.data:
s += "\\emptyset"
else:
s += "\\begin{tikzpicture}[baseline=5,scale=.45] \n \\foreach \\x [count=\\s from 0] in \n"
s += "{" + ','.join("{" + ','.join(str(i) for i in r) + "}" for r in self.data) + "} \n"
s += "{" + ','.join("{" + ','.join(str(i) for i in r) + "}"
for r in self.data) + "} \n"
s += "{\\foreach \\y [count=\\t from 0] in \\x { \\node[font=\\scriptsize] at (-\\t,\\s) {$\\y$}; \n \\draw (-\\t+.5,\\s+.5) to (-\\t-.5,\\s+.5); \n \\draw (-\\t+.5,\\s-.5) to (-\\t-.5,\\s-.5); \n \\draw (-\\t-.5,\\s-.5) to (-\\t-.5,\\s+.5); } \n \\draw[-,thick] (.5,\\s+1) to (.5,-.5) to (-\\t-1,-.5); } \n \\end{tikzpicture} \n"
return s

Expand All @@ -529,11 +531,12 @@ def _latex_(self):
'\\begin{tikzpicture}[baseline=5,scale=.25] \\foreach \\x [count=\\s from 0] in \n{{},{1,0,3,2},{2,1},{3,2,1,0,3,2},{},{},{2}} \n{\\foreach \\y [count=\\t from 0] in \\x { \\node[font=\\tiny] at (-\\t,\\s) {$\\y$}; \n \\draw (-\\t+.5,\\s+.5) to (-\\t-.5,\\s+.5); \n \\draw (-\\t+.5,\\s-.5) to (-\\t-.5,\\s-.5); \n \\draw (-\\t-.5,\\s-.5) to (-\\t-.5,\\s+.5); } \n \\draw[-] (.5,\\s+1) to (.5,-.5) to (-\\t-1,-.5); } \n \\end{tikzpicture} \n'
"""
s = ""
if self.data == []:
if not self.data:
s += "\\emptyset"

Check warning on line 535 in src/sage/combinat/crystals/generalized_young_walls.py

View check run for this annotation

Codecov / codecov/patch

src/sage/combinat/crystals/generalized_young_walls.py#L535

Added line #L535 was not covered by tests
else:
s += "\\begin{tikzpicture}[baseline=5,scale=.25] \\foreach \\x [count=\\s from 0] in \n"
s += "{" + ','.join("{" + ','.join(str(i) for i in r) + "}" for r in self.data) + "} \n"
s += "{" + ','.join("{" + ','.join(str(i) for i in r) + "}"
for r in self.data) + "} \n"
s += "{\\foreach \\y [count=\\t from 0] in \\x { \\node[font=\\tiny] at (-\\t,\\s) {$\\y$}; \n \\draw (-\\t+.5,\\s+.5) to (-\\t-.5,\\s+.5); \n \\draw (-\\t+.5,\\s-.5) to (-\\t-.5,\\s-.5); \n \\draw (-\\t-.5,\\s-.5) to (-\\t-.5,\\s+.5); } \n \\draw[-] (.5,\\s+1) to (.5,-.5) to (-\\t-1,-.5); } \n \\end{tikzpicture} \n"
return s

Expand All @@ -554,13 +557,13 @@ def weight(self, root_lattice=False):
sage: x.weight(root_lattice=True)
-2*alpha[0] - 3*alpha[1] - 5*alpha[2] - 3*alpha[3]
"""
E = self.cartan_type().root_system().weight_lattice(extended=True)
L = self.cartan_type().root_system().root_lattice()
alpha = L.simple_roots()
W = [-1*alpha[i] for r in self.data for i in r]
W = sum(-1 * alpha[i] for r in self.data for i in r)
if not root_lattice:
return E(sum(W))
return L(sum(W))
E = self.cartan_type().root_system().weight_lattice(extended=True)
return E(W)
return L(W)

def epsilon(self, i):
r"""
Expand All @@ -584,7 +587,7 @@ def epsilon(self, i):
self = self.e(i)
if self is None:
break
eps = eps+1
eps += 1
return eps

def Epsilon(self):
Expand All @@ -598,7 +601,7 @@ def Epsilon(self):
Lambda[0] + 3*Lambda[2]
"""
La = self.cartan_type().root_system().weight_lattice().fundamental_weights()
return sum(self.epsilon(i)*La[i] for i in self.index_set())
return sum(self.epsilon(i) * La[i] for i in self.index_set())

def phi(self, i):
r"""
Expand Down Expand Up @@ -632,7 +635,7 @@ def Phi(self):
2*Lambda[0] + Lambda[1] - Lambda[2] + Lambda[3]
"""
La = self.cartan_type().root_system().weight_lattice(extended=True).fundamental_weights()
return sum(self.phi(i)*La[i] for i in self.index_set())
return sum(self.phi(i) * La[i] for i in self.index_set())

def column(self, k):
r"""
Expand All @@ -648,13 +651,8 @@ def column(self, k):
sage: hw.column(1)
[]
"""
C = []
for row in self.data:
if k-1 < len(row):
C.append(row[k-1])
else:
C.append(None)
return C
return [row[k - 1] if k - 1 < len(row) else None
for row in self.data]

def a(self, i, k):
r"""
Expand Down Expand Up @@ -713,14 +711,14 @@ def in_highest_weight_crystal(self, La):
ac = self.parent().weight_lattice_realization().simple_coroots()
n = self.cartan_type().classical().rank()
index_set = self.index_set()
for k in range(1, self.cols+1):
for k in range(1, self.cols + 1):
for j in index_set:
if self.a(j, k) - self.a((j-1) % (n+1), k) <= 0:
if self.a(j, k) - self.a((j - 1) % (n + 1), k) <= 0:
continue
else:
p_not_found = True
for p in index_set:
if (j+k) % (n+1) == (p+1) % (n+1) and self.a(j, k) - self.a((j-1) % (n+1), k) <= La.scalar(ac[p]):
if (j + k - p - 1) % (n + 1) == 0 and self.a(j, k) - self.a((j - 1) % (n + 1), k) <= La.scalar(ac[p]):
p_not_found = False
continue
else:
Expand Down
29 changes: 14 additions & 15 deletions src/sage/combinat/crystals/kirillov_reshetikhin.py
Original file line number Diff line number Diff line change
Expand Up @@ -1481,7 +1481,7 @@ class KR_type_CElement(KirillovReshetikhinGenericCrystalElement):
EXAMPLES::
sage: K=crystals.KirillovReshetikhin(['C',3,1],1,2)
sage: K = crystals.KirillovReshetikhin(['C', 3, 1], 1, 2)
sage: type(K.module_generators[0])
<class 'sage.combinat.crystals.kirillov_reshetikhin.KR_type_C_with_category.element_class'>
"""
Expand All @@ -1493,7 +1493,7 @@ def e0(self):
EXAMPLES::
sage: K=crystals.KirillovReshetikhin(['C',3,1],1,2)
sage: K = crystals.KirillovReshetikhin(['C', 3, 1], 1, 2)
sage: b = K(rows=[])
sage: b.e(0) # indirect doctest
[[-1, -1]]
Expand All @@ -1511,7 +1511,7 @@ def f0(self):
EXAMPLES::
sage: K=crystals.KirillovReshetikhin(['C',3,1],1,2)
sage: K = crystals.KirillovReshetikhin(['C', 3, 1], 1, 2)
sage: b = K(rows=[])
sage: b.f(0) # indirect doctest
[[1, 1]]
Expand Down Expand Up @@ -2341,7 +2341,7 @@ class KR_type_BnElement(KirillovReshetikhinGenericCrystalElement):
EXAMPLES::
sage: K=crystals.KirillovReshetikhin(['B',3,1],3,2)
sage: K = crystals.KirillovReshetikhin(['B', 3, 1], 3, 2)
sage: type(K.module_generators[0])
<class 'sage.combinat.crystals.kirillov_reshetikhin.KR_type_Bn_with_category.element_class'>
"""
Expand Down Expand Up @@ -2370,10 +2370,9 @@ def f0(self):
EXAMPLES::
sage: K=crystals.KirillovReshetikhin(['B',3,1],3,1)
sage: K = crystals.KirillovReshetikhin(['B', 3, 1], 3, 1)
sage: b = K.module_generators[0]
sage: b.f(0) # indirect doctest
"""
b = self.parent().to_ambient_crystal()(self).f_string([0, 0])
if b is None:
Expand All @@ -2387,7 +2386,7 @@ def epsilon0(self):
EXAMPLES::
sage: K=crystals.KirillovReshetikhin(['B',3,1],3,1)
sage: K = crystals.KirillovReshetikhin(['B', 3, 1], 3, 1)
sage: b = K.module_generators[0]
sage: b.epsilon(0) # indirect doctest
1
Expand All @@ -2402,7 +2401,7 @@ def phi0(self):
EXAMPLES::
sage: K=crystals.KirillovReshetikhin(['B',3,1],3,1)
sage: K = crystals.KirillovReshetikhin(['B', 3, 1], 3, 1)
sage: b = K.module_generators[0]
sage: b.phi(0) # indirect doctest
0
Expand Down Expand Up @@ -2512,7 +2511,7 @@ class KR_type_CnElement(KirillovReshetikhinGenericCrystalElement):
EXAMPLES::
sage: K=crystals.KirillovReshetikhin(['C',3,1],3,2)
sage: K = crystals.KirillovReshetikhin(['C', 3, 1], 3, 2)
sage: type(K.module_generators[0])
<class 'sage.combinat.crystals.kirillov_reshetikhin.KR_type_Cn_with_category.element_class'>
"""
Expand All @@ -2526,7 +2525,7 @@ def e0(self):
EXAMPLES::
sage: K=crystals.KirillovReshetikhin(['C',3,1],3,2)
sage: K = crystals.KirillovReshetikhin(['C', 3, 1], 3, 2)
sage: b = K.module_generators[0]
sage: b.e(0) # indirect doctest
[[1, 2], [2, 3], [3, -1]]
Expand Down Expand Up @@ -2580,7 +2579,7 @@ def epsilon0(self):
EXAMPLES::
sage: K = crystals.KirillovReshetikhin(['C',3,1],3,1)
sage: K = crystals.KirillovReshetikhin(['C', 3, 1], 3, 1)
sage: b = K.module_generators[0]
sage: b.epsilon(0) # indirect doctest
1
Expand All @@ -2597,7 +2596,7 @@ def phi0(self):
EXAMPLES::
sage: K=crystals.KirillovReshetikhin(['C',3,1],3,1)
sage: K = crystals.KirillovReshetikhin(['C', 3, 1], 3, 1)
sage: b = K.module_generators[0]
sage: b.phi(0) # indirect doctest
0
Expand Down Expand Up @@ -2806,7 +2805,7 @@ class KR_type_Dn_twistedElement(KirillovReshetikhinGenericCrystalElement):
EXAMPLES::
sage: K=crystals.KirillovReshetikhin(['D',4,2],3,2)
sage: K = crystals.KirillovReshetikhin(['D', 4, 2], 3, 2)
sage: type(K.module_generators[0])
<class 'sage.combinat.crystals.kirillov_reshetikhin.KR_type_Dn_twisted_with_category.element_class'>
"""
Expand All @@ -2820,7 +2819,7 @@ def e0(self):
EXAMPLES::
sage: K=crystals.KirillovReshetikhin(['D',4,2],3,3)
sage: K = crystals.KirillovReshetikhin(['D', 4, 2], 3, 3)
sage: b = K.module_generators[0]
sage: b.e(0) # indirect doctest
[+++, [[2], [3], [0]]]
Expand Down Expand Up @@ -2888,7 +2887,7 @@ def epsilon0(self):
EXAMPLES::
sage: K=crystals.KirillovReshetikhin(['D',4,2],3,1)
sage: K = crystals.KirillovReshetikhin(['D', 4, 2], 3, 1)
sage: b = K.module_generators[0]
sage: b.epsilon(0) # indirect doctest
1
Expand Down

0 comments on commit 6effe6e

Please sign in to comment.