Skip to content

Commit d72c36f

Browse files
author
Release Manager
committed
gh-39739: minor details in the quivers folder
essentially some kind of polishing, nothing serious ### 📝 Checklist - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. URL: #39739 Reported by: Frédéric Chapoton Reviewer(s): David Coudert
2 parents f619fa8 + eac444e commit d72c36f

File tree

10 files changed

+79
-70
lines changed

10 files changed

+79
-70
lines changed

build/pkgs/configure/checksums.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
tarball=configure-VERSION.tar.gz
2-
sha1=cf47109a468a471ce0f23aba3764402cc1584f8a
3-
sha256=fd3d723cb2ff95675654deb30548173c3caba60558a51a77674a4b1ba9b5c00d
2+
sha1=05933158792d643c07f552136aff01c8919cb265
3+
sha256=297db0e7a2db3dbd7c3a51aab55ffee1ecf1db22ffb38a2d5a6c4c3203503b22
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
765b1ab8027f9e2b5fafc4bdac903e494d0eca7c
1+
695b517e5ad9feb1d4dcb8a22eab568480db6289

src/sage/quivers/algebra.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@
1919
# https://www.gnu.org/licenses/
2020
# ****************************************************************************
2121

22-
from sage.misc.cachefunc import cached_method
2322
from sage.combinat.free_module import CombinatorialFreeModule
23+
from sage.misc.cachefunc import cached_method
24+
2425
from .algebra_elements import PathAlgebraElement
2526

2627

src/sage/quivers/algebra_elements.pyx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -322,13 +322,13 @@ cdef class PathAlgebraElement(RingElement):
322322
sage: len(X^5)
323323
17
324324
"""
325-
cdef size_t l = 0
325+
cdef size_t ell = 0
326326
cdef path_homog_poly_t *H = self.data
327327
while H != NULL:
328328
sig_check()
329-
l += H.poly.nterms
329+
ell += H.poly.nterms
330330
H = H.nxt
331-
return l
331+
return ell
332332

333333
cpdef ssize_t degree(self) except -2:
334334
"""

src/sage/quivers/ar_quiver.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,18 @@
1212
# https://www.gnu.org/licenses/
1313
# ****************************************************************************
1414

15-
from sage.structure.unique_representation import UniqueRepresentation
16-
from sage.structure.parent import Parent
17-
from sage.structure.element import Element
18-
from sage.structure.richcmp import richcmp
19-
from sage.structure.global_options import GlobalOptions
2015
from sage.categories.sets_cat import Sets
21-
from sage.sets.family import Family
22-
from sage.combinat.root_system.cartan_type import CartanType
2316
from sage.combinat.free_module import CombinatorialFreeModule
24-
from sage.rings.integer_ring import ZZ
25-
from sage.misc.cachefunc import cached_method
17+
from sage.combinat.root_system.cartan_type import CartanType
2618
from sage.graphs.digraph import DiGraph
19+
from sage.misc.cachefunc import cached_method
20+
from sage.rings.integer_ring import ZZ
21+
from sage.sets.family import Family
22+
from sage.structure.element import Element
23+
from sage.structure.global_options import GlobalOptions
24+
from sage.structure.parent import Parent
25+
from sage.structure.richcmp import richcmp
26+
from sage.structure.unique_representation import UniqueRepresentation
2727

2828

2929
class AuslanderReitenQuiver(UniqueRepresentation, Parent):
@@ -600,7 +600,7 @@ def _dim_vecs_level(self, k):
600600
elif k > 1:
601601
if k > self._max_level:
602602
return {}
603-
prev = self._dim_vecs_level(k-1)
603+
prev = self._dim_vecs_level(k - 1)
604604
if k > self._max_level: # this might get set on the recursive call
605605
return {}
606606
ret = {}
@@ -624,7 +624,7 @@ def _dim_vecs_level(self, k):
624624
for v in Q.vertex_iterator()}
625625

626626
elif k < -1:
627-
prev = self._dim_vecs_level(k+1)
627+
prev = self._dim_vecs_level(k + 1)
628628
ret = {}
629629
for v in self._top_sort:
630630
if v not in prev: # assumption: this vertex will never reappear

src/sage/quivers/homspace.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@
1818
# https://www.gnu.org/licenses/
1919
# ****************************************************************************
2020
from __future__ import annotations
21+
2122
from sage.categories.homset import Homset
22-
from sage.quivers.morphism import QuiverRepHom
2323
from sage.misc.cachefunc import cached_method
24+
from sage.quivers.morphism import QuiverRepHom
2425

2526

2627
class QuiverHomSpace(Homset):

src/sage/quivers/morphism.py

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,10 @@ def __init__(self, domain, codomain, data={}):
173173
# this is the case it will be loaded directly into _vector and then
174174
# _assert_valid_hom is called.
175175

176-
from sage.quivers.representation import QuiverRepElement, QuiverRep_with_path_basis
176+
from sage.quivers.representation import (
177+
QuiverRep_with_path_basis,
178+
QuiverRepElement,
179+
)
177180

178181
self._domain = domain
179182
self._codomain = codomain
@@ -210,25 +213,24 @@ def __init__(self, domain, codomain, data={}):
210213
# If data is not a list create one, then create a dict from it
211214
if isinstance(data, list):
212215
im_list = data
213-
else:
214-
# If data is a QuiverRepHom, create a list from it
215-
if isinstance(data, QuiverRepHom):
216-
f = data._domain.coerce_map_from(domain)
217-
g = self._codomain.coerce_map_from(data._codomain)
218-
im_list = [g(data(f(x))) for x in domain.gens()]
216+
# If data is a QuiverRepHom, create a list from it
217+
elif isinstance(data, QuiverRepHom):
218+
f = data._domain.coerce_map_from(domain)
219+
g = self._codomain.coerce_map_from(data._codomain)
220+
im_list = [g(data(f(x))) for x in domain.gens()]
219221

220-
# The only case left is that data is a QuiverRepElement
221-
else:
222-
if not isinstance(data, QuiverRepElement):
223-
raise TypeError("input data must be dictionary, list, "
224-
"QuiverRepElement or vector")
225-
if not isinstance(domain, QuiverRep_with_path_basis):
226-
raise TypeError("if data is a QuiverRepElement then domain "
227-
"must be a QuiverRep_with_path_basis.")
228-
if data not in codomain:
229-
raise ValueError("if data is a QuiverRepElement then it must "
230-
"be an element of codomain")
231-
im_list = [codomain.right_edge_action(data, p) for v in domain._quiver for p in domain._bases[v]]
222+
# The only case left is that data is a QuiverRepElement
223+
else:
224+
if not isinstance(data, QuiverRepElement):
225+
raise TypeError("input data must be dictionary, list, "
226+
"QuiverRepElement or vector")
227+
if not isinstance(domain, QuiverRep_with_path_basis):
228+
raise TypeError("if data is a QuiverRepElement then domain "
229+
"must be a QuiverRep_with_path_basis.")
230+
if data not in codomain:
231+
raise ValueError("if data is a QuiverRepElement then it must "
232+
"be an element of codomain")
233+
im_list = [codomain.right_edge_action(data, p) for v in domain._quiver for p in domain._bases[v]]
232234

233235
# WARNING: This code assumes that the function QuiverRep.gens() returns
234236
# the generators ordered first by vertex and then by the order of the
@@ -337,7 +339,7 @@ def _call_(self, x):
337339
if not isinstance(x, QuiverRepElement):
338340
raise ValueError("QuiverRepHom can only be called on QuiverRepElement")
339341

340-
elements = dict((v, self.get_map(v)(x._elems[v])) for v in self._quiver)
342+
elements = {v: self.get_map(v)(x._elems[v]) for v in self._quiver}
341343
return self._codomain(elements)
342344

343345
def __add__(left, right):
@@ -952,7 +954,7 @@ def kernel(self):
952954
sage: g.kernel().dimension_vector()
953955
(0, 1, 0)
954956
"""
955-
spaces = dict((v, self.get_map(v).kernel()) for v in self._quiver)
957+
spaces = {v: self.get_map(v).kernel() for v in self._quiver}
956958
return self._domain._submodule(spaces)
957959

958960
def image(self):
@@ -979,7 +981,7 @@ def image(self):
979981
sage: g.image().dimension_vector()
980982
(0, 1, 1)
981983
"""
982-
spaces = dict((v, self.get_map(v).image()) for v in self._quiver)
984+
spaces = {v: self.get_map(v).image() for v in self._quiver}
983985
return self._codomain._submodule(spaces)
984986

985987
def cokernel(self):
@@ -1051,7 +1053,7 @@ def linear_dual(self):
10511053
"""
10521054
# The effect of the functor D is that it just transposes the matrix of
10531055
# a hom
1054-
maps = dict((v, self.get_matrix(v).transpose()) for v in self._quiver)
1056+
maps = {v: self.get_matrix(v).transpose() for v in self._quiver}
10551057
return self._codomain.linear_dual().hom(maps, self._domain.linear_dual())
10561058

10571059
def algebraic_dual(self):
@@ -1232,7 +1234,7 @@ def lift(self, x):
12321234
ValueError: element is not in the image
12331235
"""
12341236
# Lift at each vertex
1235-
elems = dict((v, self.get_map(v).lift(x._elems[v])) for v in self._quiver)
1237+
elems = {v: self.get_map(v).lift(x._elems[v]) for v in self._quiver}
12361238
return self._domain(elems)
12371239

12381240
###########################################################################

src/sage/quivers/path_semigroup.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,17 @@
1818
# https://www.gnu.org/licenses/
1919
# ****************************************************************************
2020

21+
from sage.categories.finite_enumerated_sets import FiniteEnumeratedSets
22+
from sage.categories.infinite_enumerated_sets import InfiniteEnumeratedSets
23+
from sage.categories.monoids import Monoids
24+
from sage.categories.semigroups import Semigroups
25+
from sage.misc.cachefunc import cached_method
26+
from sage.misc.lazy_attribute import lazy_attribute
2127
from sage.rings.integer import Integer
2228
from sage.rings.integer_ring import ZZ
2329
from sage.structure.parent import Parent
2430
from sage.structure.unique_representation import UniqueRepresentation
25-
from sage.categories.semigroups import Semigroups
26-
from sage.categories.monoids import Monoids
27-
from sage.categories.infinite_enumerated_sets import InfiniteEnumeratedSets
28-
from sage.categories.finite_enumerated_sets import FiniteEnumeratedSets
29-
from sage.misc.cachefunc import cached_method
30-
from sage.misc.lazy_attribute import lazy_attribute
31+
3132
from .paths import QuiverPath
3233
from .representation import QuiverRep
3334

@@ -1131,14 +1132,16 @@ def _v_to_e(path):
11311132
if len(path) == 1:
11321133
return [self.element_class(self, path[0], path[0], [])]
11331134
paths = []
1134-
l = Q.edge_label(path[0], path[1])
1135-
if isinstance(l, str):
1135+
ell = Q.edge_label(path[0], path[1])
1136+
if isinstance(ell, str):
11361137
for b in _v_to_e(path[1:]):
1137-
paths.append(self([(path[0], path[1], l)] + list(b), check=False))
1138+
paths.append(self([(path[0], path[1], ell)]
1139+
+ list(b), check=False))
11381140
else:
1139-
for a in l:
1141+
for a in ell:
11401142
for b in _v_to_e(path[1:]):
1141-
paths.append(self([(path[0], path[1], a)] + list(b), check=False))
1143+
paths.append(self([(path[0], path[1], a)]
1144+
+ list(b), check=False))
11421145
return paths
11431146

11441147
# For each vertex path we append the resulting edge paths

src/sage/quivers/paths.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -760,10 +760,10 @@ cdef class QuiverPath(MonoidElement):
760760
out._end = self._start
761761
sig_check()
762762
biseq_init(out._path, self._path.length, self._path.itembitsize)
763-
cdef mp_size_t l = self._path.length - 1
763+
cdef mp_size_t ell = self._path.length - 1
764764
for i in range(self._path.length):
765765
sig_check()
766-
biseq_inititem(out._path, i, biseq_getitem(self._path, l-i))
766+
biseq_inititem(out._path, i, biseq_getitem(self._path, ell - i))
767767
return out
768768

769769

src/sage/quivers/representation.py

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -448,11 +448,12 @@
448448
# https://www.gnu.org/licenses/
449449
# ****************************************************************************
450450
from __future__ import annotations
451-
from sage.structure.factory import UniqueFactory
452-
from sage.modules.module import Module
453-
from sage.structure.element import ModuleElement
451+
454452
from sage.misc.cachefunc import cached_method
455453
from sage.misc.fast_methods import WithEqualityById
454+
from sage.modules.module import Module
455+
from sage.structure.element import ModuleElement
456+
from sage.structure.factory import UniqueFactory
456457

457458

458459
class QuiverRepFactory(UniqueFactory):
@@ -706,8 +707,8 @@ def create_key(self, k, P, *args, **kwds):
706707
#
707708
# Note that the first space is assigned to key[3] and the first
708709
# vertex is 1 so the space assigned to vertex v is key[2 + v]
709-
from sage.matrix.constructor import Matrix
710710
from sage.categories.morphism import Morphism
711+
from sage.matrix.constructor import Matrix
711712
for x in P._sorted_edges:
712713
if x in maps:
713714
e = maps[x]
@@ -2469,10 +2470,11 @@ def direct_sum(self, modules, return_maps=False):
24692470
raise ValueError("cannot direct sum modules with different base rings")
24702471

24712472
# Get the dimensions of all spaces at each vertex
2472-
dims = dict((v, [x._spaces[v].dimension() for x in mods]) for v in self._quiver)
2473+
dims = {v: [x._spaces[v].dimension() for x in mods]
2474+
for v in self._quiver}
24732475

24742476
# Create spaces of the correct dimensions
2475-
spaces = dict((v, self.base_ring()**sum(dims[v])) for v in self._quiver)
2477+
spaces = {v: self.base_ring()**sum(dims[v]) for v in self._quiver}
24762478

24772479
# Take block sums of matrices to form the maps
24782480
from sage.matrix.constructor import block_diagonal_matrix
@@ -2486,7 +2488,7 @@ def direct_sum(self, modules, return_maps=False):
24862488
return result
24872489

24882490
# Create the inclusions and projections
2489-
from sage.matrix.constructor import block_matrix, Matrix
2491+
from sage.matrix.constructor import Matrix, block_matrix
24902492
from sage.rings.integer import Integer
24912493
iota = []
24922494
pi = []
@@ -2754,7 +2756,7 @@ def __init__(self, k, P, basis):
27542756
maps[e][i, j] = k.one()
27552757

27562758
# Create the spaces and then the representation
2757-
spaces = dict((v, len(self._bases[v])) for v in Q)
2759+
spaces = {v: len(self._bases[v]) for v in Q}
27582760
super().__init__(k, P, spaces, maps)
27592761

27602762
# Try and create the matrices for the left edge action of edges. If it
@@ -2765,10 +2767,10 @@ def __init__(self, k, P, basis):
27652767
action_mats[e] = {}
27662768
for v in self._quiver:
27672769
# Start with the zero matrix and fill in
2768-
l = len(self._bases[v])
2769-
action_mats[e][v] = Matrix(k, l, l)
2770+
ell = len(self._bases[v])
2771+
action_mats[e][v] = Matrix(k, ell, ell)
27702772

2771-
for j in range(l):
2773+
for j in range(ell):
27722774
if e[1] == self._bases[v][j].initial_vertex():
27732775
try:
27742776
action_mats[e][v][self._bases[v].index(P([e], check=False) * self._bases[v][j]), j] = k.one()
@@ -2783,12 +2785,12 @@ def __init__(self, k, P, basis):
27832785
action_mats[e] = {}
27842786
for v in self._quiver:
27852787
# Start with the zero matrix and fill in
2786-
l = len(self._bases[v])
2787-
action_mats[e][v] = Matrix(k, l, l)
2788+
ell = len(self._bases[v])
2789+
action_mats[e][v] = Matrix(k, ell, ell)
27882790

27892791
# Paths not beginning at vert are sent to zero, paths beginning
27902792
# at vert are fixed
2791-
for i in range(l):
2793+
for i in range(ell):
27922794
if self._bases[v][i].initial_vertex() == vert:
27932795
action_mats[e][v][i, i] = k.one()
27942796

0 commit comments

Comments
 (0)