From 3336ac87fd1a0bd4b625dd2009f2b5cca70d78d0 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Thu, 25 May 2023 17:51:07 -0700 Subject: [PATCH 1/8] sage.combinat: Modularization fixes for imports --- src/sage/combinat/cluster_algebra_quiver/cluster_seed.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/sage/combinat/cluster_algebra_quiver/cluster_seed.py b/src/sage/combinat/cluster_algebra_quiver/cluster_seed.py index ae93b3e67af..a78d0facabd 100644 --- a/src/sage/combinat/cluster_algebra_quiver/cluster_seed.py +++ b/src/sage/combinat/cluster_algebra_quiver/cluster_seed.py @@ -44,10 +44,10 @@ from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing from sage.rings.fraction_field_element import FractionFieldElement from sage.sets.set import Set -from sage.graphs.digraph import DiGraph from sage.combinat.cluster_algebra_quiver.quiver_mutation_type import QuiverMutationType_Irreducible, QuiverMutationType_Reducible from sage.combinat.cluster_algebra_quiver.mutation_type import is_mutation_finite from random import randint +from sage.misc.lazy_import import lazy_import from sage.misc.misc_c import prod from sage.matrix.special import identity_matrix from sage.matrix.constructor import matrix @@ -57,6 +57,8 @@ from sage.combinat.cluster_algebra_quiver.interact import cluster_interact +lazy_import('sage.graphs.digraph', 'DiGraph') + class ClusterSeed(SageObject): r""" From 6fd4a5cd200dd4c45601badda62266bb0c9cb265 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sat, 3 Jun 2023 19:38:26 -0700 Subject: [PATCH 2/8] src/sage/combinat/cluster_algebra_quiver/quiver_mutation_type.py: Use lazy_import --- .../combinat/cluster_algebra_quiver/quiver_mutation_type.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/sage/combinat/cluster_algebra_quiver/quiver_mutation_type.py b/src/sage/combinat/cluster_algebra_quiver/quiver_mutation_type.py index 66b2385b3af..5725abcdebc 100644 --- a/src/sage/combinat/cluster_algebra_quiver/quiver_mutation_type.py +++ b/src/sage/combinat/cluster_algebra_quiver/quiver_mutation_type.py @@ -23,13 +23,15 @@ from copy import copy from sage.structure.unique_representation import UniqueRepresentation from sage.misc.cachefunc import cached_method +from sage.misc.lazy_import import lazy_import from sage.rings.integer_ring import ZZ from sage.rings.infinity import infinity from sage.graphs.digraph import DiGraph from sage.graphs.graph import Graph from sage.arith.misc import binomial, euler_phi from sage.misc.misc_c import prod -from sage.matrix.constructor import matrix + +lazy_import('sage.matrix.constructor', 'matrix') class QuiverMutationTypeFactory(SageObject): From 0598885e0f915d716a2e37fbb80df0c71c94c121 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Wed, 7 Jun 2023 22:25:52 -0700 Subject: [PATCH 3/8] sage.combinat: More # optional --- .../cluster_algebra_quiver/cluster_seed.py | 2 +- .../cluster_algebra_quiver/interact.py | 4 +-- .../cluster_algebra_quiver/mutation_class.py | 9 ++--- .../cluster_algebra_quiver/mutation_type.py | 15 ++++---- .../combinat/cluster_algebra_quiver/quiver.py | 18 +++++----- .../quiver_mutation_type.py | 35 ++++++++++--------- 6 files changed, 43 insertions(+), 40 deletions(-) diff --git a/src/sage/combinat/cluster_algebra_quiver/cluster_seed.py b/src/sage/combinat/cluster_algebra_quiver/cluster_seed.py index a78d0facabd..d219ba7355c 100644 --- a/src/sage/combinat/cluster_algebra_quiver/cluster_seed.py +++ b/src/sage/combinat/cluster_algebra_quiver/cluster_seed.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# sage.doctest - sage.graphs sage.modules r""" ClusterSeed diff --git a/src/sage/combinat/cluster_algebra_quiver/interact.py b/src/sage/combinat/cluster_algebra_quiver/interact.py index bf4bb87aba3..91af4634a44 100644 --- a/src/sage/combinat/cluster_algebra_quiver/interact.py +++ b/src/sage/combinat/cluster_algebra_quiver/interact.py @@ -25,8 +25,8 @@ def cluster_interact(self, fig_size=1, circular=True, kind='seed'): TESTS:: - sage: S = ClusterSeed(['A',4]) # optional - sage.graphs - sage: S.interact() # indirect doctest # optional - sage.graphs sage.symbolic + sage: S = ClusterSeed(['A',4]) # optional - sage.graphs sage.modules + sage: S.interact() # indirect doctest # optional - sage.graphs sage.modules sage.symbolic ...VBox(children=... """ if kind not in ['seed', 'quiver']: diff --git a/src/sage/combinat/cluster_algebra_quiver/mutation_class.py b/src/sage/combinat/cluster_algebra_quiver/mutation_class.py index 78cf328747c..b3740146fd3 100644 --- a/src/sage/combinat/cluster_algebra_quiver/mutation_class.py +++ b/src/sage/combinat/cluster_algebra_quiver/mutation_class.py @@ -1,3 +1,4 @@ +# sage.doctest: optional - sage.graphs r""" mutation_class @@ -41,11 +42,11 @@ def _principal_part(mat): EXAMPLES:: sage: from sage.combinat.cluster_algebra_quiver.mutation_class import _principal_part - sage: M = Matrix([[1,2],[3,4],[5,6]]); M + sage: M = Matrix([[1,2],[3,4],[5,6]]); M # optional - sage.modules [1 2] [3 4] [5 6] - sage: _principal_part(M) + sage: _principal_part(M) # optional - sage.modules [1 2] [3 4] """ @@ -159,7 +160,7 @@ def _matrix_to_digraph( M ): EXAMPLES:: sage: from sage.combinat.cluster_algebra_quiver.mutation_class import _matrix_to_digraph - sage: _matrix_to_digraph(matrix(3,[0,1,0,-1,0,-1,0,1,0])) + sage: _matrix_to_digraph(matrix(3,[0,1,0,-1,0,-1,0,1,0])) # optional - sage.modules Digraph on 3 vertices """ n = M.ncols() @@ -452,7 +453,7 @@ def _dig6_to_matrix( dig6 ): sage: from sage.combinat.cluster_algebra_quiver.quiver import ClusterQuiver sage: dg = ClusterQuiver(['A',4]).digraph() sage: data = _digraph_to_dig6(dg) - sage: _dig6_to_matrix(data) + sage: _dig6_to_matrix(data) # optional - sage.modules [ 0 1 0 0] [-1 0 -1 0] [ 0 1 0 1] diff --git a/src/sage/combinat/cluster_algebra_quiver/mutation_type.py b/src/sage/combinat/cluster_algebra_quiver/mutation_type.py index ba4759f56ae..e68fd90d7ee 100644 --- a/src/sage/combinat/cluster_algebra_quiver/mutation_type.py +++ b/src/sage/combinat/cluster_algebra_quiver/mutation_type.py @@ -1,3 +1,4 @@ +# sage.doctest: optional - sage.graphs r""" Helper functions for mutation types of quivers @@ -55,20 +56,20 @@ def is_mutation_finite(M, nr_of_checks=None): sage: from sage.combinat.cluster_algebra_quiver.mutation_type import is_mutation_finite sage: Q = ClusterQuiver(['A',10]) - sage: M = Q.b_matrix() - sage: is_mutation_finite(M) + sage: M = Q.b_matrix() # optional - sage.modules + sage: is_mutation_finite(M) # optional - sage.modules (True, None) sage: Q = ClusterQuiver([(0,1),(1,2),(2,3),(3,4),(4,5),(5,6),(6,7),(7,8),(2,9)]) - sage: M = Q.b_matrix() - sage: is_mutation_finite(M) # random + sage: M = Q.b_matrix() # optional - sage.modules + sage: is_mutation_finite(M) # random # optional - sage.modules (False, [9, 6, 9, 8, 9, 4, 0, 4, 5, 2, 1, 0, 1, 0, 7, 1, 9, 2, 5, 7, 8, 6, 3, 0, 2, 5, 4, 2, 6, 9, 2, 7, 3, 5, 3, 7, 9, 5, 9, 0, 2, 7, 9, 2, 4, 2, 1, 6, 9, 4, 3, 5, 0, 8, 2, 9, 5, 3, 7, 0, 1, 8, 3, 7, 2, 7, 3, 4, 8, 0, 4, 9, 5, 2, 8, 4, 8, 1, 7, 8, 9, 1, 5, 0, 8, 7, 4, 8, 9, 8, 0, 7, 4, 7, 1, 2, 8, 6, 1, 3, 9, 3, 9, 1, 3, 2, 4, 9, 5, 1, 2, 9, 4, 8, 5, 3, 4, 6, 8, 9, 2, 5, 9, 4, 6, 2, 1, 4, 9, 6, 0, 9, 8, 0, 4, 7, 9, 2, 1, 6]) Check that :trac:`19495` is fixed:: - sage: dg = DiGraph(); dg.add_vertex(0); S = ClusterSeed(dg); S + sage: dg = DiGraph(); dg.add_vertex(0); S = ClusterSeed(dg); S # optional - sage.modules A seed for a cluster algebra of rank 1 - sage: S.is_mutation_finite() + sage: S.is_mutation_finite() # optional - sage.modules True """ import random @@ -1428,7 +1429,7 @@ def _random_tests(mt, k, mut_class=None, nr_mut=5): TESTS:: sage: from sage.combinat.cluster_algebra_quiver.mutation_type import _random_tests - sage: _random_tests( ['A',3], 1) + sage: _random_tests( ['A',3], 1) # optional - sage.modules testing ['A', 3] """ from sage.combinat.cluster_algebra_quiver.quiver import ClusterQuiver diff --git a/src/sage/combinat/cluster_algebra_quiver/quiver.py b/src/sage/combinat/cluster_algebra_quiver/quiver.py index c02b38073ef..5ff46815bf4 100644 --- a/src/sage/combinat/cluster_algebra_quiver/quiver.py +++ b/src/sage/combinat/cluster_algebra_quiver/quiver.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# sage.doctest: optional - sage.graphs sage.modules r""" Quiver @@ -40,7 +40,6 @@ from sage.structure.sage_object import SageObject from copy import copy from sage.rings.integer_ring import ZZ -from sage.rings.cc import CC from sage.rings.infinity import infinity from sage.graphs.digraph import DiGraph from sage.graphs.graph import Graph @@ -67,14 +66,14 @@ class ClusterQuiver(SageObject): - ``data`` -- can be any of the following:: - * QuiverMutationType - * str - a string representing a QuiverMutationType or a common quiver type (see Examples) - * ClusterQuiver - * Matrix - a skew-symmetrizable matrix - * DiGraph - must be the input data for a quiver - * List of edges - must be the edge list of a digraph for a quiver + * :class:`QuiverMutationType` + * :class:`str` -- a string representing a :class:`QuiverMutationType` or a common quiver type (see Examples) + * :class:`ClusterQuiver` + * :class:`Matrix` -- a skew-symmetrizable matrix + * :class:`DiGraph` -- must be the input data for a quiver + * List of edges -- must be the edge list of a digraph for a quiver - - ``frozen`` -- (default:``None``) sets the list of frozen variables + - ``frozen`` -- (default: ``None``) sets the list of frozen variables if the input type is a :class:`DiGraph`, it is ignored otherwise - ``user_labels`` -- (default:``None``) sets the names of the labels for @@ -559,6 +558,7 @@ def plot(self, circular=True, center=(0, 0), directed=True, mark=None, from sage.plot.colors import rainbow from sage.graphs.graph_generators import GraphGenerators from sage.symbolic.constants import e, pi + from sage.rings.cc import CC from sage.rings.imaginary_unit import I graphs = GraphGenerators() # returns positions for graph vertices on two concentric cycles with radius 1 and 2 diff --git a/src/sage/combinat/cluster_algebra_quiver/quiver_mutation_type.py b/src/sage/combinat/cluster_algebra_quiver/quiver_mutation_type.py index 5725abcdebc..3d46db3a0fc 100644 --- a/src/sage/combinat/cluster_algebra_quiver/quiver_mutation_type.py +++ b/src/sage/combinat/cluster_algebra_quiver/quiver_mutation_type.py @@ -1,3 +1,4 @@ +# sage.doctest: optional - sage.graphs r""" Quiver mutation types @@ -326,7 +327,7 @@ def _samples(self): replacing all positive entries by their negatives and adding `2`'s on the main diagonal. -``QuiverMutationType`` constructs a quiver mutation type object. For +:class:`QuiverMutationType` constructs a quiver mutation type object. For more detail on the possible different types, please see the compendium. @@ -708,7 +709,7 @@ def show(self, circular=False, directed=True): TESTS:: sage: QMT = QuiverMutationType(['A',5]) - sage: QMT.show() # long time + sage: QMT.show() # long time # optional - sage.plot sage.symbolic """ self.plot(circular=circular, directed=directed).show() @@ -787,7 +788,7 @@ def b_matrix(self): sage: mut_type = QuiverMutationType(['A',5]); mut_type ['A', 5] - sage: mut_type.b_matrix() + sage: mut_type.b_matrix() # optional - sage.plot sage.symbolic [ 0 1 0 0 0] [-1 0 -1 0 0] [ 0 1 0 1 0] @@ -796,7 +797,7 @@ def b_matrix(self): sage: mut_type = QuiverMutationType(['A',3],['B',3]); mut_type [ ['A', 3], ['B', 3] ] - sage: mut_type.b_matrix() + sage: mut_type.b_matrix() # optional - sage.plot sage.symbolic [ 0 1 0 0 0 0] [-1 0 -1 0 0 0] [ 0 1 0 0 0 0] @@ -853,7 +854,7 @@ def cartan_matrix(self): sage: mut_type = QuiverMutationType(['A',5]); mut_type ['A', 5] - sage: mut_type.cartan_matrix() + sage: mut_type.cartan_matrix() # optional - sage.modules [ 2 -1 0 0 0] [-1 2 -1 0 0] [ 0 -1 2 -1 0] @@ -862,7 +863,7 @@ def cartan_matrix(self): sage: mut_type = QuiverMutationType(['A',3],['B',3]); mut_type [ ['A', 3], ['B', 3] ] - sage: mut_type.cartan_matrix() + sage: mut_type.cartan_matrix() # optional - sage.modules [ 2 -1 0 0 0 0] [-1 2 -1 0 0 0] [ 0 -1 2 0 0 0] @@ -1105,7 +1106,7 @@ def properties(self): class QuiverMutationType_Irreducible(QuiverMutationType_abstract): """ The mutation type for a cluster algebra or a quiver. Should not be - called directly, but through QuiverMutationType. + called directly, but through :class:`QuiverMutationType`. """ def __init__(self, letter, rank, twist=None): @@ -1694,7 +1695,7 @@ def class_size(self): which are mutation equivalent to the standard quiver of ``self`` (up to isomorphism) is returned. - Otherwise, ``NotImplemented`` is returned. + Otherwise, :obj:`NotImplemented` is returned. Formula for finite type A is taken from Torkildsen - Counting cluster-tilted algebras of type `A_n`. @@ -1898,7 +1899,7 @@ def class_size(self): def dual(self): """ - Return the QuiverMutationType which is dual to ``self``. + Return the :class:`QuiverMutationType` which is dual to ``self``. EXAMPLES:: @@ -1962,8 +1963,8 @@ def dual(self): class QuiverMutationType_Reducible(QuiverMutationType_abstract): """ The mutation type for a cluster algebra or a quiver. Should not be - called directly, but through QuiverMutationType. Inherits from - QuiverMutationType_abstract. + called directly, but through :class:`QuiverMutationType`. Inherits from + :class:`QuiverMutationType_abstract`. """ def __init__(self, *args): @@ -2056,7 +2057,7 @@ def class_size(self): which are mutation equivalent to the standard quiver of ``self`` (up to isomorphism) is returned. - Otherwise, ``NotImplemented`` is returned. + Otherwise, :obj:`NotImplemented` is returned. EXAMPLES:: @@ -2095,7 +2096,7 @@ def class_size(self): def dual(self): """ - Return the QuiverMutationType which is dual to ``self``. + Return the :class:`QuiverMutationType` which is dual to ``self``. EXAMPLES:: @@ -2296,7 +2297,7 @@ def save_quiver_data(n, up_to=True, types='ClassicalExceptional', verbose=True): INPUT: - - ``n``: the rank (or the upper limit on the rank) of the mutation + - ``n`` -- the rank (or the upper limit on the rank) of the mutation classes that are being saved. - ``up_to`` -- (default:``True``) if ``True``, saves data for @@ -2437,17 +2438,17 @@ def _edge_list_to_matrix(edges, nlist, mlist) -> matrix: sage: from sage.combinat.cluster_algebra_quiver.quiver_mutation_type import _edge_list_to_matrix sage: G = QuiverMutationType(['A', 2])._digraph - sage: _edge_list_to_matrix(G.edges(sort=True), [0, 1], []) + sage: _edge_list_to_matrix(G.edges(sort=True), [0, 1], []) # optional - sage.modules [ 0 1] [-1 0] sage: G2 = DiGraph([('a', 'b', 1)]) - sage: _edge_list_to_matrix(G2.edges(sort=True), ['a', 'b'], []) + sage: _edge_list_to_matrix(G2.edges(sort=True), ['a', 'b'], []) # optional - sage.modules [ 0 1] [-1 0] sage: G3 = DiGraph([('a', 'b', 1), ('b', 'c', 1)]) - sage: _edge_list_to_matrix(G3.edges(sort=True), ['a', 'b'], ['c']) + sage: _edge_list_to_matrix(G3.edges(sort=True), ['a', 'b'], ['c']) # optional - sage.modules [ 0 1] [-1 0] [ 0 -1] From 64ea0d811b8c5388f8b80cee9d90d1d94b7f93fb Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Fri, 9 Jun 2023 00:55:41 -0700 Subject: [PATCH 4/8] More # optional --- .../combinat/cluster_algebra_quiver/quiver_mutation_type.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sage/combinat/cluster_algebra_quiver/quiver_mutation_type.py b/src/sage/combinat/cluster_algebra_quiver/quiver_mutation_type.py index 3d46db3a0fc..9d9f4a0e0d3 100644 --- a/src/sage/combinat/cluster_algebra_quiver/quiver_mutation_type.py +++ b/src/sage/combinat/cluster_algebra_quiver/quiver_mutation_type.py @@ -788,7 +788,7 @@ def b_matrix(self): sage: mut_type = QuiverMutationType(['A',5]); mut_type ['A', 5] - sage: mut_type.b_matrix() # optional - sage.plot sage.symbolic + sage: mut_type.b_matrix() # optional - sage.modules [ 0 1 0 0 0] [-1 0 -1 0 0] [ 0 1 0 1 0] @@ -797,7 +797,7 @@ def b_matrix(self): sage: mut_type = QuiverMutationType(['A',3],['B',3]); mut_type [ ['A', 3], ['B', 3] ] - sage: mut_type.b_matrix() # optional - sage.plot sage.symbolic + sage: mut_type.b_matrix() # optional - sage.modules [ 0 1 0 0 0 0] [-1 0 -1 0 0 0] [ 0 1 0 0 0 0] From e591d538cb258a364d1d2091002cf40f84220213 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sun, 11 Jun 2023 23:46:00 -0700 Subject: [PATCH 5/8] sage.combinat: More # optional --- src/sage/combinat/cluster_algebra_quiver/cluster_seed.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/combinat/cluster_algebra_quiver/cluster_seed.py b/src/sage/combinat/cluster_algebra_quiver/cluster_seed.py index d219ba7355c..fbc7ce55d6d 100644 --- a/src/sage/combinat/cluster_algebra_quiver/cluster_seed.py +++ b/src/sage/combinat/cluster_algebra_quiver/cluster_seed.py @@ -1,4 +1,4 @@ -# sage.doctest - sage.graphs sage.modules +# sage.doctest: optional - sage.graphs sage.modules r""" ClusterSeed From d5d1057bcdf921dfa54afd699b1fd3b5d752f268 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Wed, 12 Jul 2023 17:59:24 -0700 Subject: [PATCH 6/8] ./sage -fixdoctests --distribution sagemath-categories --only-tags src/sage/combinat --- .../cluster_algebra_quiver/cluster_seed.py | 12 +++++------ .../cluster_algebra_quiver/interact.py | 4 ++-- .../cluster_algebra_quiver/mutation_class.py | 8 ++++---- .../cluster_algebra_quiver/mutation_type.py | 14 ++++++------- .../combinat/cluster_algebra_quiver/quiver.py | 14 ++++++------- .../quiver_mutation_type.py | 20 +++++++++---------- 6 files changed, 36 insertions(+), 36 deletions(-) diff --git a/src/sage/combinat/cluster_algebra_quiver/cluster_seed.py b/src/sage/combinat/cluster_algebra_quiver/cluster_seed.py index fbc7ce55d6d..72da7c2eff7 100644 --- a/src/sage/combinat/cluster_algebra_quiver/cluster_seed.py +++ b/src/sage/combinat/cluster_algebra_quiver/cluster_seed.py @@ -1042,11 +1042,11 @@ def plot(self, circular=False, mark=None, save_pos=False, force_c=False, with_gr EXAMPLES:: sage: S = ClusterSeed(['A',5]) - sage: S.plot() # optional - sage.plot sage.symbolic + sage: S.plot() # needs sage.plot sage.symbolic Graphics object consisting of 15 graphics primitives - sage: S.plot(circular=True) # optional - sage.plot sage.symbolic + sage: S.plot(circular=True) # needs sage.plot sage.symbolic Graphics object consisting of 15 graphics primitives - sage: S.plot(circular=True, mark=1) # optional - sage.plot sage.symbolic + sage: S.plot(circular=True, mark=1) # needs sage.plot sage.symbolic Graphics object consisting of 15 graphics primitives """ greens = [] @@ -1088,7 +1088,7 @@ def show(self, fig_size=1, circular=False, mark=None, save_pos=False, force_c=Fa TESTS:: sage: S = ClusterSeed(['A',5]) - sage: S.show() # long time # optional - sage.plot sage.symbolic + sage: S.show() # long time # needs sage.plot sage.symbolic """ greens = [] if with_greens: @@ -1122,7 +1122,7 @@ def interact(self, fig_size=1, circular=True): TESTS:: sage: S = ClusterSeed(['A',4]) - sage: S.interact() # optional - sage.plot sage.symbolic + sage: S.interact() # needs sage.plot sage.symbolic ...VBox(children=... """ return cluster_interact(self, fig_size, circular, kind='seed') @@ -1144,7 +1144,7 @@ def save_image(self, filename, circular=False, mark=None, save_pos=False): sage: S = ClusterSeed(['F',4,[1,2]]) sage: import tempfile - sage: with tempfile.NamedTemporaryFile(suffix=".png") as f: # optional - sage.plot sage.symbolic + sage: with tempfile.NamedTemporaryFile(suffix=".png") as f: # needs sage.plot sage.symbolic ....: S.save_image(f.name) """ graph_plot = self.plot(circular=circular, mark=mark, save_pos=save_pos) diff --git a/src/sage/combinat/cluster_algebra_quiver/interact.py b/src/sage/combinat/cluster_algebra_quiver/interact.py index 91af4634a44..695e3d1d449 100644 --- a/src/sage/combinat/cluster_algebra_quiver/interact.py +++ b/src/sage/combinat/cluster_algebra_quiver/interact.py @@ -25,8 +25,8 @@ def cluster_interact(self, fig_size=1, circular=True, kind='seed'): TESTS:: - sage: S = ClusterSeed(['A',4]) # optional - sage.graphs sage.modules - sage: S.interact() # indirect doctest # optional - sage.graphs sage.modules sage.symbolic + sage: S = ClusterSeed(['A',4]) # needs sage.graphs sage.modules + sage: S.interact() # indirect doctest # needs sage.graphs sage.modules sage.symbolic ...VBox(children=... """ if kind not in ['seed', 'quiver']: diff --git a/src/sage/combinat/cluster_algebra_quiver/mutation_class.py b/src/sage/combinat/cluster_algebra_quiver/mutation_class.py index b3740146fd3..6b3cd757464 100644 --- a/src/sage/combinat/cluster_algebra_quiver/mutation_class.py +++ b/src/sage/combinat/cluster_algebra_quiver/mutation_class.py @@ -42,11 +42,11 @@ def _principal_part(mat): EXAMPLES:: sage: from sage.combinat.cluster_algebra_quiver.mutation_class import _principal_part - sage: M = Matrix([[1,2],[3,4],[5,6]]); M # optional - sage.modules + sage: M = Matrix([[1,2],[3,4],[5,6]]); M # needs sage.modules [1 2] [3 4] [5 6] - sage: _principal_part(M) # optional - sage.modules + sage: _principal_part(M) # needs sage.modules [1 2] [3 4] """ @@ -160,7 +160,7 @@ def _matrix_to_digraph( M ): EXAMPLES:: sage: from sage.combinat.cluster_algebra_quiver.mutation_class import _matrix_to_digraph - sage: _matrix_to_digraph(matrix(3,[0,1,0,-1,0,-1,0,1,0])) # optional - sage.modules + sage: _matrix_to_digraph(matrix(3,[0,1,0,-1,0,-1,0,1,0])) # needs sage.modules Digraph on 3 vertices """ n = M.ncols() @@ -453,7 +453,7 @@ def _dig6_to_matrix( dig6 ): sage: from sage.combinat.cluster_algebra_quiver.quiver import ClusterQuiver sage: dg = ClusterQuiver(['A',4]).digraph() sage: data = _digraph_to_dig6(dg) - sage: _dig6_to_matrix(data) # optional - sage.modules + sage: _dig6_to_matrix(data) # needs sage.modules [ 0 1 0 0] [-1 0 -1 0] [ 0 1 0 1] diff --git a/src/sage/combinat/cluster_algebra_quiver/mutation_type.py b/src/sage/combinat/cluster_algebra_quiver/mutation_type.py index e68fd90d7ee..0f149348d0e 100644 --- a/src/sage/combinat/cluster_algebra_quiver/mutation_type.py +++ b/src/sage/combinat/cluster_algebra_quiver/mutation_type.py @@ -56,20 +56,20 @@ def is_mutation_finite(M, nr_of_checks=None): sage: from sage.combinat.cluster_algebra_quiver.mutation_type import is_mutation_finite sage: Q = ClusterQuiver(['A',10]) - sage: M = Q.b_matrix() # optional - sage.modules - sage: is_mutation_finite(M) # optional - sage.modules + sage: M = Q.b_matrix() # needs sage.modules + sage: is_mutation_finite(M) # needs sage.modules (True, None) sage: Q = ClusterQuiver([(0,1),(1,2),(2,3),(3,4),(4,5),(5,6),(6,7),(7,8),(2,9)]) - sage: M = Q.b_matrix() # optional - sage.modules - sage: is_mutation_finite(M) # random # optional - sage.modules + sage: M = Q.b_matrix() # needs sage.modules + sage: is_mutation_finite(M) # random # needs sage.modules (False, [9, 6, 9, 8, 9, 4, 0, 4, 5, 2, 1, 0, 1, 0, 7, 1, 9, 2, 5, 7, 8, 6, 3, 0, 2, 5, 4, 2, 6, 9, 2, 7, 3, 5, 3, 7, 9, 5, 9, 0, 2, 7, 9, 2, 4, 2, 1, 6, 9, 4, 3, 5, 0, 8, 2, 9, 5, 3, 7, 0, 1, 8, 3, 7, 2, 7, 3, 4, 8, 0, 4, 9, 5, 2, 8, 4, 8, 1, 7, 8, 9, 1, 5, 0, 8, 7, 4, 8, 9, 8, 0, 7, 4, 7, 1, 2, 8, 6, 1, 3, 9, 3, 9, 1, 3, 2, 4, 9, 5, 1, 2, 9, 4, 8, 5, 3, 4, 6, 8, 9, 2, 5, 9, 4, 6, 2, 1, 4, 9, 6, 0, 9, 8, 0, 4, 7, 9, 2, 1, 6]) Check that :trac:`19495` is fixed:: - sage: dg = DiGraph(); dg.add_vertex(0); S = ClusterSeed(dg); S # optional - sage.modules + sage: dg = DiGraph(); dg.add_vertex(0); S = ClusterSeed(dg); S # needs sage.modules A seed for a cluster algebra of rank 1 - sage: S.is_mutation_finite() # optional - sage.modules + sage: S.is_mutation_finite() # needs sage.modules True """ import random @@ -1429,7 +1429,7 @@ def _random_tests(mt, k, mut_class=None, nr_mut=5): TESTS:: sage: from sage.combinat.cluster_algebra_quiver.mutation_type import _random_tests - sage: _random_tests( ['A',3], 1) # optional - sage.modules + sage: _random_tests( ['A',3], 1) # needs sage.modules testing ['A', 3] """ from sage.combinat.cluster_algebra_quiver.quiver import ClusterQuiver diff --git a/src/sage/combinat/cluster_algebra_quiver/quiver.py b/src/sage/combinat/cluster_algebra_quiver/quiver.py index 5ff46815bf4..53a4e61d011 100644 --- a/src/sage/combinat/cluster_algebra_quiver/quiver.py +++ b/src/sage/combinat/cluster_algebra_quiver/quiver.py @@ -548,11 +548,11 @@ def plot(self, circular=True, center=(0, 0), directed=True, mark=None, EXAMPLES:: sage: Q = ClusterQuiver(['A',5]) - sage: Q.plot() # optional - sage.plot sage.symbolic + sage: Q.plot() # needs sage.plot sage.symbolic Graphics object consisting of 15 graphics primitives - sage: Q.plot(circular=True) # optional - sage.plot sage.symbolic + sage: Q.plot(circular=True) # needs sage.plot sage.symbolic Graphics object consisting of 15 graphics primitives - sage: Q.plot(circular=True, mark=1) # optional - sage.plot sage.symbolic + sage: Q.plot(circular=True, mark=1) # needs sage.plot sage.symbolic Graphics object consisting of 15 graphics primitives """ from sage.plot.colors import rainbow @@ -699,7 +699,7 @@ def interact(self, fig_size=1, circular=True): TESTS:: sage: S = ClusterQuiver(['A',4]) - sage: S.interact() # optional - sage.plot sage.symbolic + sage: S.interact() # needs sage.plot sage.symbolic ...VBox(children=... """ return cluster_interact(self, fig_size, circular, kind="quiver") @@ -717,7 +717,7 @@ def save_image(self, filename, circular=False): sage: Q = ClusterQuiver(['F',4,[1,2]]) sage: import tempfile - sage: with tempfile.NamedTemporaryFile(suffix=".png") as f: # optional - sage.plot sage.symbolic + sage: with tempfile.NamedTemporaryFile(suffix=".png") as f: # needs sage.plot sage.symbolic ....: Q.save_image(f.name) """ graph_plot = self.plot(circular=circular) @@ -742,7 +742,7 @@ def qmu_save(self, filename=None): sage: Q = ClusterQuiver(['F',4,[1,2]]) sage: import tempfile - sage: with tempfile.NamedTemporaryFile(suffix=".qmu") as f: # optional - sage.plot sage.symbolic + sage: with tempfile.NamedTemporaryFile(suffix=".qmu") as f: # needs sage.plot sage.symbolic ....: Q.qmu_save(f.name) Make sure we can save quivers with `m != n` frozen variables, see :trac:`14851`:: @@ -751,7 +751,7 @@ def qmu_save(self, filename=None): sage: T1 = S.principal_extension() sage: Q = T1.quiver() sage: import tempfile - sage: with tempfile.NamedTemporaryFile(suffix=".qmu") as f: # optional - sage.plot sage.symbolic + sage: with tempfile.NamedTemporaryFile(suffix=".qmu") as f: # needs sage.plot sage.symbolic ....: Q.qmu_save(f.name) """ M = self.b_matrix() diff --git a/src/sage/combinat/cluster_algebra_quiver/quiver_mutation_type.py b/src/sage/combinat/cluster_algebra_quiver/quiver_mutation_type.py index 9d9f4a0e0d3..3e91c58e50d 100644 --- a/src/sage/combinat/cluster_algebra_quiver/quiver_mutation_type.py +++ b/src/sage/combinat/cluster_algebra_quiver/quiver_mutation_type.py @@ -689,8 +689,8 @@ def plot(self, circular=False, directed=True): EXAMPLES:: sage: QMT = QuiverMutationType(['A',5]) - sage: pl = QMT.plot() # optional - sage.plot sage.symbolic - sage: pl = QMT.plot(circular=True) # optional - sage.plot sage.symbolic + sage: pl = QMT.plot() # needs sage.plot sage.symbolic + sage: pl = QMT.plot(circular=True) # needs sage.plot sage.symbolic """ return self.standard_quiver().plot(circular=circular, directed=directed) @@ -709,7 +709,7 @@ def show(self, circular=False, directed=True): TESTS:: sage: QMT = QuiverMutationType(['A',5]) - sage: QMT.show() # long time # optional - sage.plot sage.symbolic + sage: QMT.show() # long time # needs sage.plot sage.symbolic """ self.plot(circular=circular, directed=directed).show() @@ -788,7 +788,7 @@ def b_matrix(self): sage: mut_type = QuiverMutationType(['A',5]); mut_type ['A', 5] - sage: mut_type.b_matrix() # optional - sage.modules + sage: mut_type.b_matrix() # needs sage.modules [ 0 1 0 0 0] [-1 0 -1 0 0] [ 0 1 0 1 0] @@ -797,7 +797,7 @@ def b_matrix(self): sage: mut_type = QuiverMutationType(['A',3],['B',3]); mut_type [ ['A', 3], ['B', 3] ] - sage: mut_type.b_matrix() # optional - sage.modules + sage: mut_type.b_matrix() # needs sage.modules [ 0 1 0 0 0 0] [-1 0 -1 0 0 0] [ 0 1 0 0 0 0] @@ -854,7 +854,7 @@ def cartan_matrix(self): sage: mut_type = QuiverMutationType(['A',5]); mut_type ['A', 5] - sage: mut_type.cartan_matrix() # optional - sage.modules + sage: mut_type.cartan_matrix() # needs sage.modules [ 2 -1 0 0 0] [-1 2 -1 0 0] [ 0 -1 2 -1 0] @@ -863,7 +863,7 @@ def cartan_matrix(self): sage: mut_type = QuiverMutationType(['A',3],['B',3]); mut_type [ ['A', 3], ['B', 3] ] - sage: mut_type.cartan_matrix() # optional - sage.modules + sage: mut_type.cartan_matrix() # needs sage.modules [ 2 -1 0 0 0 0] [-1 2 -1 0 0 0] [ 0 -1 2 0 0 0] @@ -2438,17 +2438,17 @@ def _edge_list_to_matrix(edges, nlist, mlist) -> matrix: sage: from sage.combinat.cluster_algebra_quiver.quiver_mutation_type import _edge_list_to_matrix sage: G = QuiverMutationType(['A', 2])._digraph - sage: _edge_list_to_matrix(G.edges(sort=True), [0, 1], []) # optional - sage.modules + sage: _edge_list_to_matrix(G.edges(sort=True), [0, 1], []) # needs sage.modules [ 0 1] [-1 0] sage: G2 = DiGraph([('a', 'b', 1)]) - sage: _edge_list_to_matrix(G2.edges(sort=True), ['a', 'b'], []) # optional - sage.modules + sage: _edge_list_to_matrix(G2.edges(sort=True), ['a', 'b'], []) # needs sage.modules [ 0 1] [-1 0] sage: G3 = DiGraph([('a', 'b', 1), ('b', 'c', 1)]) - sage: _edge_list_to_matrix(G3.edges(sort=True), ['a', 'b'], ['c']) # optional - sage.modules + sage: _edge_list_to_matrix(G3.edges(sort=True), ['a', 'b'], ['c']) # needs sage.modules [ 0 1] [-1 0] [ 0 -1] From 6e8cfadf29dad3ffeebe4021316fdfc409cce563 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Thu, 13 Jul 2023 10:13:35 -0700 Subject: [PATCH 7/8] git grep -l 'sage.doctest:' src/sage/combinat/cluster_algebra_quiver | xargs sed -i.bak '/sage.doctest:/s/optional - sage/needs sage/' --- src/sage/combinat/cluster_algebra_quiver/cluster_seed.py | 2 +- src/sage/combinat/cluster_algebra_quiver/mutation_class.py | 2 +- src/sage/combinat/cluster_algebra_quiver/mutation_type.py | 2 +- src/sage/combinat/cluster_algebra_quiver/quiver.py | 2 +- .../combinat/cluster_algebra_quiver/quiver_mutation_type.py | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/sage/combinat/cluster_algebra_quiver/cluster_seed.py b/src/sage/combinat/cluster_algebra_quiver/cluster_seed.py index 72da7c2eff7..3564594e370 100644 --- a/src/sage/combinat/cluster_algebra_quiver/cluster_seed.py +++ b/src/sage/combinat/cluster_algebra_quiver/cluster_seed.py @@ -1,4 +1,4 @@ -# sage.doctest: optional - sage.graphs sage.modules +# sage.doctest: needs sage.graphs sage.modules r""" ClusterSeed diff --git a/src/sage/combinat/cluster_algebra_quiver/mutation_class.py b/src/sage/combinat/cluster_algebra_quiver/mutation_class.py index 6b3cd757464..33b33087899 100644 --- a/src/sage/combinat/cluster_algebra_quiver/mutation_class.py +++ b/src/sage/combinat/cluster_algebra_quiver/mutation_class.py @@ -1,4 +1,4 @@ -# sage.doctest: optional - sage.graphs +# sage.doctest: needs sage.graphs r""" mutation_class diff --git a/src/sage/combinat/cluster_algebra_quiver/mutation_type.py b/src/sage/combinat/cluster_algebra_quiver/mutation_type.py index 0f149348d0e..fc414b8f8fb 100644 --- a/src/sage/combinat/cluster_algebra_quiver/mutation_type.py +++ b/src/sage/combinat/cluster_algebra_quiver/mutation_type.py @@ -1,4 +1,4 @@ -# sage.doctest: optional - sage.graphs +# sage.doctest: needs sage.graphs r""" Helper functions for mutation types of quivers diff --git a/src/sage/combinat/cluster_algebra_quiver/quiver.py b/src/sage/combinat/cluster_algebra_quiver/quiver.py index 53a4e61d011..b6c5509eff0 100644 --- a/src/sage/combinat/cluster_algebra_quiver/quiver.py +++ b/src/sage/combinat/cluster_algebra_quiver/quiver.py @@ -1,4 +1,4 @@ -# sage.doctest: optional - sage.graphs sage.modules +# sage.doctest: needs sage.graphs sage.modules r""" Quiver diff --git a/src/sage/combinat/cluster_algebra_quiver/quiver_mutation_type.py b/src/sage/combinat/cluster_algebra_quiver/quiver_mutation_type.py index 3e91c58e50d..60e9e78c3bf 100644 --- a/src/sage/combinat/cluster_algebra_quiver/quiver_mutation_type.py +++ b/src/sage/combinat/cluster_algebra_quiver/quiver_mutation_type.py @@ -1,4 +1,4 @@ -# sage.doctest: optional - sage.graphs +# sage.doctest: needs sage.graphs r""" Quiver mutation types From 711b983410214b6023f2e9022f982ff36733fbe3 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sat, 3 Jun 2023 16:39:11 -0700 Subject: [PATCH 8/8] sage.combinat.cluster_algebra_quiver: Modularization fixes for imports --- src/sage/combinat/cluster_algebra_quiver/all.py | 3 +++ src/sage/combinat/cluster_algebra_quiver/quiver.py | 9 ++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/sage/combinat/cluster_algebra_quiver/all.py b/src/sage/combinat/cluster_algebra_quiver/all.py index 40b86813ba0..5b28d09d1c6 100644 --- a/src/sage/combinat/cluster_algebra_quiver/all.py +++ b/src/sage/combinat/cluster_algebra_quiver/all.py @@ -15,3 +15,6 @@ lazy_import("sage.combinat.cluster_algebra_quiver.quiver_mutation_type", "QuiverMutationType") lazy_import("sage.combinat.cluster_algebra_quiver.quiver", "ClusterQuiver") lazy_import("sage.combinat.cluster_algebra_quiver.cluster_seed", "ClusterSeed") + +del install_doc +del lazy_import diff --git a/src/sage/combinat/cluster_algebra_quiver/quiver.py b/src/sage/combinat/cluster_algebra_quiver/quiver.py index b6c5509eff0..7b2ad09b1b2 100644 --- a/src/sage/combinat/cluster_algebra_quiver/quiver.py +++ b/src/sage/combinat/cluster_algebra_quiver/quiver.py @@ -37,18 +37,18 @@ # https://www.gnu.org/licenses/ # **************************************************************************** -from sage.structure.sage_object import SageObject from copy import copy + +from sage.structure.sage_object import SageObject from sage.rings.integer_ring import ZZ from sage.rings.infinity import infinity from sage.graphs.digraph import DiGraph from sage.graphs.graph import Graph from sage.graphs.views import EdgesView from sage.arith.misc import gcd -from sage.modules.free_module_element import vector -from sage.matrix.constructor import matrix from sage.categories.cartesian_product import cartesian_product from sage.misc.misc_c import prod +from sage.misc.lazy_import import lazy_import from sage.rings.rational_field import QQ from sage.rings.polynomial.polynomial_ring import polygen from sage.combinat.cluster_algebra_quiver.quiver_mutation_type import QuiverMutationType, QuiverMutationType_Irreducible, QuiverMutationType_Reducible, _edge_list_to_matrix @@ -57,6 +57,9 @@ from sage.combinat.cluster_algebra_quiver.interact import cluster_interact +lazy_import('sage.modules.free_module_element', 'vector') +lazy_import('sage.matrix.constructor', 'matrix') + class ClusterQuiver(SageObject): """