Skip to content

Commit 25eb671

Browse files
author
Release Manager
committed
gh-35951: `sage.combinat.cluster_algebra_quiver`: Modularization fixes, update `# needs` <!-- ^^^^^ Please provide a concise, informative and self-explanatory title. Don't put issue numbers in there, do this in the PR body below. For example, instead of "Fixes #1234" use "Introduce new method to calculate 1+1" --> <!-- Describe your changes here in detail --> - `# optional` with standard features are replaced by `# needs` - Some import fixes needed for separate testing of **sagemath-graphs** from #35095 <!-- Why is this change required? What problem does it solve? --> <!-- If this PR resolves an open issue, please link to it here. For example "Fixes #12345". --> This is: - done with the help of `sage -fixdoctests` from #35749 - Part of: #29705 - Cherry-picked from: #35095 ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> <!-- If your change requires a documentation PR, please link it appropriately --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> <!-- Feel free to remove irrelevant items. --> - [x] The title is concise, informative, and self-explanatory. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [ ] I have updated the documentation accordingly. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on - #12345: short description why this is a dependency - #34567: ... --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> URL: #35951 Reported by: Matthias Köppe Reviewer(s): David Coudert
2 parents 67e9079 + 711b983 commit 25eb671

File tree

7 files changed

+73
-60
lines changed

7 files changed

+73
-60
lines changed

src/sage/combinat/cluster_algebra_quiver/all.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,6 @@
1515
lazy_import("sage.combinat.cluster_algebra_quiver.quiver_mutation_type", "QuiverMutationType")
1616
lazy_import("sage.combinat.cluster_algebra_quiver.quiver", "ClusterQuiver")
1717
lazy_import("sage.combinat.cluster_algebra_quiver.cluster_seed", "ClusterSeed")
18+
19+
del install_doc
20+
del lazy_import

src/sage/combinat/cluster_algebra_quiver/cluster_seed.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# -*- coding: utf-8 -*-
1+
# sage.doctest: needs sage.graphs sage.modules
22
r"""
33
ClusterSeed
44
@@ -44,10 +44,10 @@
4444
from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing
4545
from sage.rings.fraction_field_element import FractionFieldElement
4646
from sage.sets.set import Set
47-
from sage.graphs.digraph import DiGraph
4847
from sage.combinat.cluster_algebra_quiver.quiver_mutation_type import QuiverMutationType_Irreducible, QuiverMutationType_Reducible
4948
from sage.combinat.cluster_algebra_quiver.mutation_type import is_mutation_finite
5049
from random import randint
50+
from sage.misc.lazy_import import lazy_import
5151
from sage.misc.misc_c import prod
5252
from sage.matrix.special import identity_matrix
5353
from sage.matrix.constructor import matrix
@@ -57,6 +57,8 @@
5757

5858
from sage.combinat.cluster_algebra_quiver.interact import cluster_interact
5959

60+
lazy_import('sage.graphs.digraph', 'DiGraph')
61+
6062

6163
class ClusterSeed(SageObject):
6264
r"""
@@ -1040,11 +1042,11 @@ def plot(self, circular=False, mark=None, save_pos=False, force_c=False, with_gr
10401042
EXAMPLES::
10411043
10421044
sage: S = ClusterSeed(['A',5])
1043-
sage: S.plot() # optional - sage.plot sage.symbolic
1045+
sage: S.plot() # needs sage.plot sage.symbolic
10441046
Graphics object consisting of 15 graphics primitives
1045-
sage: S.plot(circular=True) # optional - sage.plot sage.symbolic
1047+
sage: S.plot(circular=True) # needs sage.plot sage.symbolic
10461048
Graphics object consisting of 15 graphics primitives
1047-
sage: S.plot(circular=True, mark=1) # optional - sage.plot sage.symbolic
1049+
sage: S.plot(circular=True, mark=1) # needs sage.plot sage.symbolic
10481050
Graphics object consisting of 15 graphics primitives
10491051
"""
10501052
greens = []
@@ -1086,7 +1088,7 @@ def show(self, fig_size=1, circular=False, mark=None, save_pos=False, force_c=Fa
10861088
TESTS::
10871089
10881090
sage: S = ClusterSeed(['A',5])
1089-
sage: S.show() # long time # optional - sage.plot sage.symbolic
1091+
sage: S.show() # long time # needs sage.plot sage.symbolic
10901092
"""
10911093
greens = []
10921094
if with_greens:
@@ -1120,7 +1122,7 @@ def interact(self, fig_size=1, circular=True):
11201122
TESTS::
11211123
11221124
sage: S = ClusterSeed(['A',4])
1123-
sage: S.interact() # optional - sage.plot sage.symbolic
1125+
sage: S.interact() # needs sage.plot sage.symbolic
11241126
...VBox(children=...
11251127
"""
11261128
return cluster_interact(self, fig_size, circular, kind='seed')
@@ -1142,7 +1144,7 @@ def save_image(self, filename, circular=False, mark=None, save_pos=False):
11421144
11431145
sage: S = ClusterSeed(['F',4,[1,2]])
11441146
sage: import tempfile
1145-
sage: with tempfile.NamedTemporaryFile(suffix=".png") as f: # optional - sage.plot sage.symbolic
1147+
sage: with tempfile.NamedTemporaryFile(suffix=".png") as f: # needs sage.plot sage.symbolic
11461148
....: S.save_image(f.name)
11471149
"""
11481150
graph_plot = self.plot(circular=circular, mark=mark, save_pos=save_pos)

src/sage/combinat/cluster_algebra_quiver/interact.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ def cluster_interact(self, fig_size=1, circular=True, kind='seed'):
2525
2626
TESTS::
2727
28-
sage: S = ClusterSeed(['A',4]) # optional - sage.graphs
29-
sage: S.interact() # indirect doctest # optional - sage.graphs sage.symbolic
28+
sage: S = ClusterSeed(['A',4]) # needs sage.graphs sage.modules
29+
sage: S.interact() # indirect doctest # needs sage.graphs sage.modules sage.symbolic
3030
...VBox(children=...
3131
"""
3232
if kind not in ['seed', 'quiver']:

src/sage/combinat/cluster_algebra_quiver/mutation_class.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# sage.doctest: needs sage.graphs
12
r"""
23
mutation_class
34
@@ -41,11 +42,11 @@ def _principal_part(mat):
4142
EXAMPLES::
4243
4344
sage: from sage.combinat.cluster_algebra_quiver.mutation_class import _principal_part
44-
sage: M = Matrix([[1,2],[3,4],[5,6]]); M
45+
sage: M = Matrix([[1,2],[3,4],[5,6]]); M # needs sage.modules
4546
[1 2]
4647
[3 4]
4748
[5 6]
48-
sage: _principal_part(M)
49+
sage: _principal_part(M) # needs sage.modules
4950
[1 2]
5051
[3 4]
5152
"""
@@ -159,7 +160,7 @@ def _matrix_to_digraph( M ):
159160
EXAMPLES::
160161
161162
sage: from sage.combinat.cluster_algebra_quiver.mutation_class import _matrix_to_digraph
162-
sage: _matrix_to_digraph(matrix(3,[0,1,0,-1,0,-1,0,1,0]))
163+
sage: _matrix_to_digraph(matrix(3,[0,1,0,-1,0,-1,0,1,0])) # needs sage.modules
163164
Digraph on 3 vertices
164165
"""
165166
n = M.ncols()
@@ -452,7 +453,7 @@ def _dig6_to_matrix( dig6 ):
452453
sage: from sage.combinat.cluster_algebra_quiver.quiver import ClusterQuiver
453454
sage: dg = ClusterQuiver(['A',4]).digraph()
454455
sage: data = _digraph_to_dig6(dg)
455-
sage: _dig6_to_matrix(data)
456+
sage: _dig6_to_matrix(data) # needs sage.modules
456457
[ 0 1 0 0]
457458
[-1 0 -1 0]
458459
[ 0 1 0 1]

src/sage/combinat/cluster_algebra_quiver/mutation_type.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# sage.doctest: needs sage.graphs
12
r"""
23
Helper functions for mutation types of quivers
34
@@ -55,20 +56,20 @@ def is_mutation_finite(M, nr_of_checks=None):
5556
sage: from sage.combinat.cluster_algebra_quiver.mutation_type import is_mutation_finite
5657
5758
sage: Q = ClusterQuiver(['A',10])
58-
sage: M = Q.b_matrix()
59-
sage: is_mutation_finite(M)
59+
sage: M = Q.b_matrix() # needs sage.modules
60+
sage: is_mutation_finite(M) # needs sage.modules
6061
(True, None)
6162
6263
sage: Q = ClusterQuiver([(0,1),(1,2),(2,3),(3,4),(4,5),(5,6),(6,7),(7,8),(2,9)])
63-
sage: M = Q.b_matrix()
64-
sage: is_mutation_finite(M) # random
64+
sage: M = Q.b_matrix() # needs sage.modules
65+
sage: is_mutation_finite(M) # random # needs sage.modules
6566
(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])
6667
6768
Check that :trac:`19495` is fixed::
6869
69-
sage: dg = DiGraph(); dg.add_vertex(0); S = ClusterSeed(dg); S
70+
sage: dg = DiGraph(); dg.add_vertex(0); S = ClusterSeed(dg); S # needs sage.modules
7071
A seed for a cluster algebra of rank 1
71-
sage: S.is_mutation_finite()
72+
sage: S.is_mutation_finite() # needs sage.modules
7273
True
7374
"""
7475
import random
@@ -1428,7 +1429,7 @@ def _random_tests(mt, k, mut_class=None, nr_mut=5):
14281429
TESTS::
14291430
14301431
sage: from sage.combinat.cluster_algebra_quiver.mutation_type import _random_tests
1431-
sage: _random_tests( ['A',3], 1)
1432+
sage: _random_tests( ['A',3], 1) # needs sage.modules
14321433
testing ['A', 3]
14331434
"""
14341435
from sage.combinat.cluster_algebra_quiver.quiver import ClusterQuiver

src/sage/combinat/cluster_algebra_quiver/quiver.py

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# -*- coding: utf-8 -*-
1+
# sage.doctest: needs sage.graphs sage.modules
22
r"""
33
Quiver
44
@@ -37,19 +37,18 @@
3737
# https://www.gnu.org/licenses/
3838
# ****************************************************************************
3939

40-
from sage.structure.sage_object import SageObject
4140
from copy import copy
41+
42+
from sage.structure.sage_object import SageObject
4243
from sage.rings.integer_ring import ZZ
43-
from sage.rings.cc import CC
4444
from sage.rings.infinity import infinity
4545
from sage.graphs.digraph import DiGraph
4646
from sage.graphs.graph import Graph
4747
from sage.graphs.views import EdgesView
4848
from sage.arith.misc import gcd
49-
from sage.modules.free_module_element import vector
50-
from sage.matrix.constructor import matrix
5149
from sage.categories.cartesian_product import cartesian_product
5250
from sage.misc.misc_c import prod
51+
from sage.misc.lazy_import import lazy_import
5352
from sage.rings.rational_field import QQ
5453
from sage.rings.polynomial.polynomial_ring import polygen
5554
from sage.combinat.cluster_algebra_quiver.quiver_mutation_type import QuiverMutationType, QuiverMutationType_Irreducible, QuiverMutationType_Reducible, _edge_list_to_matrix
@@ -58,6 +57,9 @@
5857

5958
from sage.combinat.cluster_algebra_quiver.interact import cluster_interact
6059

60+
lazy_import('sage.modules.free_module_element', 'vector')
61+
lazy_import('sage.matrix.constructor', 'matrix')
62+
6163

6264
class ClusterQuiver(SageObject):
6365
"""
@@ -67,14 +69,14 @@ class ClusterQuiver(SageObject):
6769
6870
- ``data`` -- can be any of the following::
6971
70-
* QuiverMutationType
71-
* str - a string representing a QuiverMutationType or a common quiver type (see Examples)
72-
* ClusterQuiver
73-
* Matrix - a skew-symmetrizable matrix
74-
* DiGraph - must be the input data for a quiver
75-
* List of edges - must be the edge list of a digraph for a quiver
72+
* :class:`QuiverMutationType`
73+
* :class:`str` -- a string representing a :class:`QuiverMutationType` or a common quiver type (see Examples)
74+
* :class:`ClusterQuiver`
75+
* :class:`Matrix` -- a skew-symmetrizable matrix
76+
* :class:`DiGraph` -- must be the input data for a quiver
77+
* List of edges -- must be the edge list of a digraph for a quiver
7678
77-
- ``frozen`` -- (default:``None``) sets the list of frozen variables
79+
- ``frozen`` -- (default: ``None``) sets the list of frozen variables
7880
if the input type is a :class:`DiGraph`, it is ignored otherwise
7981
8082
- ``user_labels`` -- (default:``None``) sets the names of the labels for
@@ -549,16 +551,17 @@ def plot(self, circular=True, center=(0, 0), directed=True, mark=None,
549551
EXAMPLES::
550552
551553
sage: Q = ClusterQuiver(['A',5])
552-
sage: Q.plot() # optional - sage.plot sage.symbolic
554+
sage: Q.plot() # needs sage.plot sage.symbolic
553555
Graphics object consisting of 15 graphics primitives
554-
sage: Q.plot(circular=True) # optional - sage.plot sage.symbolic
556+
sage: Q.plot(circular=True) # needs sage.plot sage.symbolic
555557
Graphics object consisting of 15 graphics primitives
556-
sage: Q.plot(circular=True, mark=1) # optional - sage.plot sage.symbolic
558+
sage: Q.plot(circular=True, mark=1) # needs sage.plot sage.symbolic
557559
Graphics object consisting of 15 graphics primitives
558560
"""
559561
from sage.plot.colors import rainbow
560562
from sage.graphs.graph_generators import GraphGenerators
561563
from sage.symbolic.constants import e, pi
564+
from sage.rings.cc import CC
562565
from sage.rings.imaginary_unit import I
563566
graphs = GraphGenerators()
564567
# returns positions for graph vertices on two concentric cycles with radius 1 and 2
@@ -699,7 +702,7 @@ def interact(self, fig_size=1, circular=True):
699702
TESTS::
700703
701704
sage: S = ClusterQuiver(['A',4])
702-
sage: S.interact() # optional - sage.plot sage.symbolic
705+
sage: S.interact() # needs sage.plot sage.symbolic
703706
...VBox(children=...
704707
"""
705708
return cluster_interact(self, fig_size, circular, kind="quiver")
@@ -717,7 +720,7 @@ def save_image(self, filename, circular=False):
717720
718721
sage: Q = ClusterQuiver(['F',4,[1,2]])
719722
sage: import tempfile
720-
sage: with tempfile.NamedTemporaryFile(suffix=".png") as f: # optional - sage.plot sage.symbolic
723+
sage: with tempfile.NamedTemporaryFile(suffix=".png") as f: # needs sage.plot sage.symbolic
721724
....: Q.save_image(f.name)
722725
"""
723726
graph_plot = self.plot(circular=circular)
@@ -742,7 +745,7 @@ def qmu_save(self, filename=None):
742745
743746
sage: Q = ClusterQuiver(['F',4,[1,2]])
744747
sage: import tempfile
745-
sage: with tempfile.NamedTemporaryFile(suffix=".qmu") as f: # optional - sage.plot sage.symbolic
748+
sage: with tempfile.NamedTemporaryFile(suffix=".qmu") as f: # needs sage.plot sage.symbolic
746749
....: Q.qmu_save(f.name)
747750
748751
Make sure we can save quivers with `m != n` frozen variables, see :trac:`14851`::
@@ -751,7 +754,7 @@ def qmu_save(self, filename=None):
751754
sage: T1 = S.principal_extension()
752755
sage: Q = T1.quiver()
753756
sage: import tempfile
754-
sage: with tempfile.NamedTemporaryFile(suffix=".qmu") as f: # optional - sage.plot sage.symbolic
757+
sage: with tempfile.NamedTemporaryFile(suffix=".qmu") as f: # needs sage.plot sage.symbolic
755758
....: Q.qmu_save(f.name)
756759
"""
757760
M = self.b_matrix()

0 commit comments

Comments
 (0)