Skip to content

Commit 1ac73d8

Browse files
author
Release Manager
committed
gh-37245: a few details in combinat folder namely - use ruff to fix some containement tests - add links to some error codes in the doc ### 📝 Checklist - [x] The title is concise, informative, and self-explanatory. - [x] The description explains in detail what this PR is about. URL: #37245 Reported by: Frédéric Chapoton Reviewer(s): David Coudert, Frédéric Chapoton
2 parents 46ef3fd + 0a56fbf commit 1ac73d8

13 files changed

+35
-32
lines changed

src/sage/combinat/cluster_algebra_quiver/mutation_type.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1045,7 +1045,7 @@ def _connected_mutation_type_AAtildeD(dg, ret_conn_vert=False):
10451045
# if one edge appearing in exactly two oriented triangles, test that it is not a double-edge and then
10461046
# test that either the third or fourth vertices (from the oriented triangles) is of degree 2.
10471047
# Then initializes the long_cycle as this triangle including the degree 2 vertex, as long as no other long_cycles.
1048-
elif count == 1 and not dg.has_multiple_edges() and not multiple_trian_edges[0] in dg.multiple_edges():
1048+
elif count == 1 and not dg.has_multiple_edges() and multiple_trian_edges[0] not in dg.multiple_edges():
10491049
multiple_trian_edge = multiple_trian_edges[0]
10501050
neighbors = list(set(dg.neighbors( multiple_trian_edge[0] )).intersection(dg.neighbors( multiple_trian_edge[1] )))
10511051
if dg.degree( neighbors[0] ) == 2:

src/sage/combinat/designs/bibd.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -879,7 +879,7 @@ def BIBD_from_PBD(PBD, v, k, check=True, base_cases=None):
879879
for X in PBD:
880880
n = len(X)
881881
N = (k-1)*n+1
882-
if not (n,k) in base_cases:
882+
if (n,k) not in base_cases:
883883
base_cases[n,k] = _relabel_bibd(balanced_incomplete_block_design(N,k), N)
884884

885885
for XX in base_cases[n,k]:

src/sage/combinat/designs/database.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2469,7 +2469,7 @@ def QDM_57_9_1_1_8():
24692469
((45,7,1,1,9), QDM_45_7_1_1_9),
24702470
((54,7,1,1,8), QDM_54_7_1_1_8),
24712471
((57,9,1,1,8), QDM_57_9_1_1_8)]:
2472-
if not (n+u,lmbda) in QDM:
2472+
if (n+u,lmbda) not in QDM:
24732473
QDM[n+u,lmbda] = {}
24742474
QDM[n+u,lmbda][n,lmbda,mu,u] = (k,f)
24752475

@@ -2701,7 +2701,7 @@ def QDM_57_9_1_1_8():
27012701
# Translate all V(m,t) into (mt+1,m+2;1,0;t)-QDM constructors
27022702
for (m,t),(vec,source) in Vmt_vectors.items():
27032703
n,k,lmbda,mu,u = (m*t+1,m+2,1,0,t)
2704-
if not (n+u,lmbda) in QDM:
2704+
if (n+u,lmbda) not in QDM:
27052705
QDM[n+u,lmbda] = {}
27062706
QDM[n+u,lmbda][n,lmbda,mu,u] = (k,lambda m=m,t=t,vec=vec:QDM_from_Vmt(m,t,vec))
27072707

src/sage/combinat/designs/difference_family.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3138,8 +3138,9 @@ def difference_family(v, k, l=1, existence=False, explain_construction=False, ch
31383138
31393139
See also :wikipedia:`Difference_set`.
31403140
3141-
If there is no such difference family, an ``EmptySetError`` is raised and if
3142-
there is no construction at the moment ``NotImplementedError`` is raised.
3141+
If there is no such difference family, an ``EmptySetError`` is raised and
3142+
if there is no construction at the moment :class:`NotImplementedError`
3143+
is raised.
31433144
31443145
INPUT:
31453146

src/sage/combinat/designs/latin_squares.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ def mutually_orthogonal_latin_squares(k, n, partitions=False, check=True):
299299
Unknown
300300
301301
If you ask for such a MOLS then you will respectively get an informative
302-
``EmptySetError`` or ``NotImplementedError``::
302+
``EmptySetError`` or :class:`NotImplementedError`::
303303
304304
sage: designs.mutually_orthogonal_latin_squares(5, 5)
305305
Traceback (most recent call last):

src/sage/combinat/designs/orthogonal_arrays.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ def transversal_design(k, n, resolvable=False, check=True, existence=False):
190190
Unknown
191191
192192
If you ask for a transversal design that Sage is not able to build then an
193-
``EmptySetError`` or a ``NotImplementedError`` is raised::
193+
``EmptySetError`` or a :class:`NotImplementedError` is raised::
194194
195195
sage: designs.transversal_design(47, 100)
196196
Traceback (most recent call last):
@@ -1359,7 +1359,7 @@ def incomplete_orthogonal_array(k,n,holes,resolvable=False, existence=False):
13591359
return True
13601360
independent_set = OA_find_disjoint_blocks(OA,k,n,number_of_holes)
13611361

1362-
elif max_hole == 1 and not orthogonal_array(k,n,existence=True) is True:
1362+
elif max_hole == 1 and orthogonal_array(k,n,existence=True) is not True:
13631363
return orthogonal_array(k,n,existence=existence)
13641364

13651365
# From a quasi-difference matrix
@@ -2117,8 +2117,8 @@ class OAMainFunctions:
21172117
6
21182118
21192119
If you ask for an orthogonal array that does not exist, then you will
2120-
either obtain an ``EmptySetError`` (if it knows that such an orthogonal array
2121-
does not exist) or a ``NotImplementedError``::
2120+
either obtain an ``EmptySetError`` (if it knows that such an orthogonal
2121+
array does not exist) or a :class:`NotImplementedError`::
21222122
21232123
sage: designs.orthogonal_arrays.build(4,2)
21242124
Traceback (most recent call last):

src/sage/combinat/designs/resolvable_bibd.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -738,7 +738,7 @@ def PBD_4_7_from_Y(gdd,check=True):
738738
"but there are other: {}".format(txt))
739739

740740
for gs in group_sizes:
741-
if not PBD_4_7(3*gs+1,existence=True) is True:
741+
if PBD_4_7(3*gs+1,existence=True) is not True:
742742
raise RuntimeError("A group has size {} but I do not know how to "
743743
"build a ({},[4,7])-PBD".format(gs,3*gs+1))
744744

src/sage/combinat/designs/steiner_quadruple_systems.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,7 @@ def steiner_quadruple_system(n, check=False):
709709
....: sqs = designs.steiner_quadruple_system(n, check=True)
710710
"""
711711
n = int(n)
712-
if not ((n % 6) in [2, 4]):
712+
if (n % 6) not in [2, 4]:
713713
raise ValueError("n mod 6 must be equal to 2 or 4")
714714
elif n == 4:
715715
sqs = IncidenceStructure(4, [[0,1,2,3]], copy=False, check=False)

src/sage/combinat/finite_state_machine.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -591,8 +591,7 @@
591591
...
592592
ValueError: Invalid input sequence.
593593

594-
The raised ``ValueError``
595-
means `13` is not divisible by `3`.
594+
The raised :class:`ValueError` means `13` is not divisible by `3`.
596595

597596
.. _finite_state_machine_gray_code_example:
598597

@@ -2120,7 +2119,7 @@ def _epsilon_cycle_output_empty_(self, fsm=None):
21202119

21212120
``True`` or ``False``
21222121

2123-
A ``ValueError`` is raised when ``self`` is not in an epsilon
2122+
A :class:`ValueError` is raised when ``self`` is not in an epsilon
21242123
cycle.
21252124

21262125
TESTS::
@@ -2537,7 +2536,9 @@ def duplicate_transition_ignore(old_transition, new_transition):
25372536
def duplicate_transition_raise_error(old_transition, new_transition):
25382537
"""
25392538
Alternative function for handling duplicate transitions in finite
2540-
state machines. This implementation raises a ``ValueError``.
2539+
state machines.
2540+
2541+
This implementation raises a :class:`ValueError`.
25412542

25422543
See the documentation of the ``on_duplicate_transition`` parameter
25432544
of :class:`FiniteStateMachine`.
@@ -2551,7 +2552,7 @@ def duplicate_transition_raise_error(old_transition, new_transition):
25512552

25522553
OUTPUT:
25532554

2554-
Nothing. A ``ValueError`` is raised.
2555+
Nothing. A :class:`ValueError` is raised.
25552556

25562557
EXAMPLES::
25572558

@@ -2812,7 +2813,7 @@ class FiniteStateMachine(SageObject):
28122813
non-deterministic).
28132814

28142815
If the transition does not exist, the function should raise a
2815-
``LookupError`` or return an empty list.
2816+
:class:`LookupError` or return an empty list.
28162817

28172818
When constructing a finite state machine in this way, some
28182819
initial states and an input alphabet have to be specified.
@@ -5507,7 +5508,7 @@ def state(self, state):
55075508

55085509
The state of the finite state machine corresponding to ``state``.
55095510

5510-
If no state is found, then a ``LookupError`` is thrown.
5511+
If no state is found, then a :class:`LookupError` is thrown.
55115512

55125513
EXAMPLES::
55135514

@@ -5553,7 +5554,7 @@ def transition(self, transition):
55535554
The transition of the finite state machine corresponding
55545555
to ``transition``.
55555556

5556-
If no transition is found, then a ``LookupError`` is thrown.
5557+
If no transition is found, then a :class:`LookupError` is thrown.
55575558

55585559
EXAMPLES::
55595560

@@ -7622,7 +7623,7 @@ def product_FiniteStateMachine(self, other, function,
76227623
for `j\in\{1, \ldots, d\}` and returns a pair ``(word_in, word_out)``
76237624
which is the label of the transition `A=(A_1, \ldots, A_d)` to `B=(B_1,
76247625
\ldots, B_d)`. If there is no transition from `A` to `B`,
7625-
then ``function`` should raise a ``LookupError``.
7626+
then ``function`` should raise a :class:`LookupError`.
76267627

76277628
- ``new_input_alphabet`` (optional) -- the new input alphabet
76287629
as a list.
@@ -7637,7 +7638,7 @@ def product_FiniteStateMachine(self, other, function,
76377638
the corresponding state in the new finite state machine. By
76387639
default, the final output is the empty word if both final
76397640
outputs of the constituent states are empty; otherwise, a
7640-
``ValueError`` is raised.
7641+
:class:`ValueError` is raised.
76417642

76427643
- ``new_class`` -- Class of the new finite state machine. By
76437644
default (``None``), the class of ``self`` is used.
@@ -12685,7 +12686,7 @@ def process(self, *args, **kwargs):
1268512686
- ``full_output`` -- (default: ``True``) a boolean. If set,
1268612687
then the full output is given, otherwise only the generated
1268712688
output (the third entry below only). If the input is not
12688-
accepted, a ``ValueError`` is raised.
12689+
accepted, a :class:`ValueError` is raised.
1268912690

1269012691
- ``always_include_output`` -- if set (not by default), always
1269112692
include the output. This is inconsequential for a

src/sage/combinat/partition.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3017,7 +3017,7 @@ def arm_length(self, i, j):
30173017
30183018
OUTPUT:
30193019
3020-
An integer or a ``ValueError``
3020+
An integer or a :class:`ValueError`
30213021
30223022
EXAMPLES::
30233023
@@ -3111,7 +3111,7 @@ def leg_length(self, i, j):
31113111
31123112
OUTPUT:
31133113
3114-
An integer or a ``ValueError``
3114+
An integer or a :class:`ValueError`
31153115
31163116
EXAMPLES::
31173117
@@ -6201,8 +6201,9 @@ def __contains__(self, x):
62016201

62026202
def subset(self, *args, **kwargs):
62036203
r"""
6204-
Return ``self`` if no arguments are given, otherwise raises a
6205-
``ValueError``.
6204+
Return ``self`` if no arguments are given.
6205+
6206+
Otherwise, it raises a :class:`ValueError`.
62066207
62076208
EXAMPLES::
62086209
@@ -9017,7 +9018,7 @@ def number_of_partitions(n, algorithm='default'):
90179018
sage: len(v)
90189019
7
90199020
9020-
The input must be a nonnegative integer or a ``ValueError`` is raised.
9021+
The input must be a nonnegative integer or a :class:`ValueError` is raised.
90219022
90229023
::
90239024

0 commit comments

Comments
 (0)