Skip to content

Commit bb0ea98

Browse files
author
Release Manager
committed
gh-35719: `sage.matroids`: Modularization fixes <!-- Please provide a concise, informative and self-explanatory title. --> <!-- Don't put issue numbers in the title. Put it in the Description below. --> <!-- For example, instead of "Fixes #12345", use "Add a new method to multiply two integers" --> ### 📚 Description <!-- Describe your changes here in detail. --> Fixes for imports and adding `# optional`. Also some `# optional` updates in other modules. <!-- 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". --> - Part of: #29705 - Cherry-picked from: #35095 <!-- If your change requires a documentation PR, please link it appropriately. --> ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. It should be `[x]` not `[x ]`. --> - [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: #35719 Reported by: Matthias Köppe Reviewer(s): David Coudert
2 parents ad35d8c + 4d507c7 commit bb0ea98

22 files changed

+1867
-1801
lines changed

src/sage/docs/instancedoc.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
For a Cython ``cdef class``, a decorator cannot be used. Instead, call
3737
:func:`instancedoc` as a function after defining the class::
3838
39-
sage: cython( # optional - sage.misc.cython
39+
sage: cython( # optional - sage.misc.cython
4040
....: '''
4141
....: from sage.misc.instancedoc import instancedoc
4242
....: cdef class Y:
@@ -45,9 +45,9 @@
4545
....: return "Instance docstring"
4646
....: instancedoc(Y)
4747
....: ''')
48-
sage: Y.__doc__
48+
sage: Y.__doc__ # optional - sage.misc.cython
4949
'File:...\nClass docstring'
50-
sage: Y().__doc__
50+
sage: Y().__doc__ # optional - sage.misc.cython
5151
'Instance docstring'
5252
5353
One can still add a custom ``__doc__`` attribute on a particular
@@ -60,7 +60,7 @@
6060
6161
This normally does not work on extension types::
6262
63-
sage: Y().__doc__ = "Very special doc"
63+
sage: Y().__doc__ = "Very special doc" # optional - sage.misc.cython
6464
Traceback (most recent call last):
6565
...
6666
AttributeError: attribute '__doc__' of 'Y' objects is not writable

src/sage/dynamics/arithmetic_dynamics/projective_ds.py

Lines changed: 387 additions & 339 deletions
Large diffs are not rendered by default.

src/sage/ext/fast_callable.pyx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1772,18 +1772,18 @@ cpdef generate_code(Expression expr, InstructionStream stream):
17721772
25
17731773
sage: fc.op_list()
17741774
[('load_arg', 0), ('load_arg', 1), ('py_call', <function my_norm at 0x...>, 2), 'return']
1775-
sage: fc = fast_callable(expr)
1776-
sage: fc(3.0r)
1775+
sage: fc = fast_callable(expr) # optional - sage.symbolic
1776+
sage: fc(3.0r) # optional - sage.symbolic
17771777
4.0*pi + 12.0
1778-
sage: fc = fast_callable(x+3, domain=ZZ)
1779-
sage: fc(4)
1778+
sage: fc = fast_callable(x+3, domain=ZZ) # optional - sage.symbolic
1779+
sage: fc(4) # optional - sage.symbolic
17801780
7
1781-
sage: fc = fast_callable(x/3, domain=ZZ)
1782-
sage: fc(4)
1781+
sage: fc = fast_callable(x/3, domain=ZZ) # optional - sage.symbolic
1782+
sage: fc(4) # optional - sage.symbolic
17831783
Traceback (most recent call last):
17841784
...
17851785
TypeError: no conversion of this rational to integer
1786-
sage: fc(6)
1786+
sage: fc(6) # optional - sage.symbolic
17871787
2
17881788
sage: fc = fast_callable(etb.call(sin, x), domain=ZZ)
17891789
sage: fc(0)

src/sage/matroids/basis_exchange_matroid.pyx

Lines changed: 96 additions & 96 deletions
Large diffs are not rendered by default.

src/sage/matroids/basis_matroid.pyx

Lines changed: 66 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ AUTHORS:
5555
5656
TESTS::
5757
58-
sage: F = matroids.named_matroids.Fano()
59-
sage: M = Matroid(bases=F.bases())
60-
sage: TestSuite(M).run()
58+
sage: F = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings
59+
sage: M = Matroid(bases=F.bases()) # optional - sage.rings.finite_rings
60+
sage: TestSuite(M).run() # optional - sage.rings.finite_rings
6161
6262
Methods
6363
=======
@@ -110,11 +110,11 @@ cdef class BasisMatroid(BasisExchangeMatroid):
110110
Create a BasisMatroid instance out of any other matroid::
111111
112112
sage: from sage.matroids.advanced import *
113-
sage: F = matroids.named_matroids.Fano()
114-
sage: M = BasisMatroid(F)
115-
sage: F.groundset() == M.groundset()
113+
sage: F = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings
114+
sage: M = BasisMatroid(F) # optional - sage.rings.finite_rings
115+
sage: F.groundset() == M.groundset() # optional - sage.rings.finite_rings
116116
True
117-
sage: len(set(F.bases()).difference(M.bases()))
117+
sage: len(set(F.bases()).difference(M.bases())) # optional - sage.rings.finite_rings
118118
0
119119
120120
It is possible to provide either bases or nonbases::
@@ -150,11 +150,11 @@ cdef class BasisMatroid(BasisExchangeMatroid):
150150
EXAMPLES::
151151
152152
sage: from sage.matroids.advanced import *
153-
sage: F = matroids.named_matroids.Fano()
154-
sage: M = BasisMatroid(F)
155-
sage: F.groundset() == M.groundset()
153+
sage: F = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings
154+
sage: M = BasisMatroid(F) # optional - sage.rings.finite_rings
155+
sage: F.groundset() == M.groundset() # optional - sage.rings.finite_rings
156156
True
157-
sage: len(set(F.bases()).difference(M.bases()))
157+
sage: len(set(F.bases()).difference(M.bases())) # optional - sage.rings.finite_rings
158158
0
159159
"""
160160
cdef SetSystem NB
@@ -254,8 +254,8 @@ cdef class BasisMatroid(BasisExchangeMatroid):
254254
EXAMPLES::
255255
256256
sage: from sage.matroids.advanced import *
257-
sage: M = BasisMatroid(matroids.named_matroids.Fano())
258-
sage: repr(M) # indirect doctest
257+
sage: M = BasisMatroid(matroids.named_matroids.Fano()) # optional - sage.rings.finite_rings
258+
sage: repr(M) # indirect doctest # optional - sage.rings.finite_rings
259259
'Matroid of rank 3 on 7 elements with 28 bases'
260260
261261
"""
@@ -429,12 +429,12 @@ cdef class BasisMatroid(BasisExchangeMatroid):
429429
430430
EXAMPLES::
431431
432-
sage: M = Matroid(bases=matroids.named_matroids.N2().bases())
433-
sage: M.truncation()
432+
sage: M = Matroid(bases=matroids.named_matroids.N2().bases()) # optional - sage.rings.finite_rings
433+
sage: M.truncation() # optional - sage.rings.finite_rings
434434
Matroid of rank 5 on 12 elements with 702 bases
435-
sage: M.f_vector()
435+
sage: M.f_vector() # optional - sage.rings.finite_rings
436436
[1, 12, 66, 190, 258, 99, 1]
437-
sage: M.truncation().f_vector()
437+
sage: M.truncation().f_vector() # optional - sage.rings.finite_rings
438438
[1, 12, 66, 190, 258, 1]
439439
440440
"""
@@ -511,10 +511,10 @@ cdef class BasisMatroid(BasisExchangeMatroid):
511511
EXAMPLES::
512512
513513
sage: from sage.matroids.advanced import *
514-
sage: M = BasisMatroid(matroids.named_matroids.Fano())
515-
sage: M
514+
sage: M = BasisMatroid(matroids.named_matroids.Fano()) # optional - sage.rings.finite_rings
515+
sage: M # optional - sage.rings.finite_rings
516516
Matroid of rank 3 on 7 elements with 28 bases
517-
sage: M._with_coloop('x')
517+
sage: M._with_coloop('x') # optional - sage.rings.finite_rings
518518
Matroid of rank 4 on 8 elements with 28 bases
519519
520520
"""
@@ -548,11 +548,11 @@ cdef class BasisMatroid(BasisExchangeMatroid):
548548
EXAMPLES::
549549
550550
sage: from sage.matroids.advanced import *
551-
sage: M = BasisMatroid(matroids.named_matroids.Fano())
552-
sage: sorted(M.groundset())
551+
sage: M = BasisMatroid(matroids.named_matroids.Fano()) # optional - sage.rings.finite_rings
552+
sage: sorted(M.groundset()) # optional - sage.rings.finite_rings
553553
['a', 'b', 'c', 'd', 'e', 'f', 'g']
554-
sage: N = M.relabel({'g':'x'})
555-
sage: sorted(N.groundset())
554+
sage: N = M.relabel({'g':'x'}) # optional - sage.rings.finite_rings
555+
sage: sorted(N.groundset()) # optional - sage.rings.finite_rings
556556
['a', 'b', 'c', 'd', 'e', 'f', 'x']
557557
558558
"""
@@ -572,10 +572,10 @@ cdef class BasisMatroid(BasisExchangeMatroid):
572572
573573
EXAMPLES::
574574
575-
sage: M = Matroid(bases=matroids.named_matroids.Fano().bases())
576-
sage: M
575+
sage: M = Matroid(bases=matroids.named_matroids.Fano().bases()) # optional - sage.rings.finite_rings
576+
sage: M # optional - sage.rings.finite_rings
577577
Matroid of rank 3 on 7 elements with 28 bases
578-
sage: M.bases_count()
578+
sage: M.bases_count() # optional - sage.rings.finite_rings
579579
28
580580
"""
581581
if self._bcount is None:
@@ -594,10 +594,10 @@ cdef class BasisMatroid(BasisExchangeMatroid):
594594
595595
EXAMPLES::
596596
597-
sage: M = Matroid(bases=matroids.named_matroids.Fano().bases())
598-
sage: M
597+
sage: M = Matroid(bases=matroids.named_matroids.Fano().bases()) # optional - sage.rings.finite_rings
598+
sage: M # optional - sage.rings.finite_rings
599599
Matroid of rank 3 on 7 elements with 28 bases
600-
sage: len(M.bases())
600+
sage: len(M.bases()) # optional - sage.rings.finite_rings
601601
28
602602
"""
603603
cdef long r, n
@@ -630,10 +630,10 @@ cdef class BasisMatroid(BasisExchangeMatroid):
630630
631631
EXAMPLES::
632632
633-
sage: M = Matroid(bases=matroids.named_matroids.Fano().bases())
634-
sage: M
633+
sage: M = Matroid(bases=matroids.named_matroids.Fano().bases()) # optional - sage.rings.finite_rings
634+
sage: M # optional - sage.rings.finite_rings
635635
Matroid of rank 3 on 7 elements with 28 bases
636-
sage: len(M.nonbases())
636+
sage: len(M.nonbases()) # optional - sage.rings.finite_rings
637637
7
638638
"""
639639
if self._nonbases is not None:
@@ -674,9 +674,9 @@ cdef class BasisMatroid(BasisExchangeMatroid):
674674
EXAMPLES::
675675
676676
sage: from sage.matroids.advanced import *
677-
sage: M = BasisMatroid(matroids.named_matroids.Fano())
678-
sage: N = BasisMatroid(matroids.named_matroids.Fano())
679-
sage: M._bases_invariant() == N._bases_invariant()
677+
sage: M = BasisMatroid(matroids.named_matroids.Fano()) # optional - sage.rings.finite_rings
678+
sage: N = BasisMatroid(matroids.named_matroids.Fano()) # optional - sage.rings.finite_rings
679+
sage: M._bases_invariant() == N._bases_invariant() # optional - sage.rings.finite_rings
680680
True
681681
"""
682682
if self._bases_invariant_var is not None:
@@ -733,9 +733,9 @@ cdef class BasisMatroid(BasisExchangeMatroid):
733733
EXAMPLES::
734734
735735
sage: from sage.matroids.advanced import *
736-
sage: M = BasisMatroid(matroids.named_matroids.Fano())
737-
sage: N = BasisMatroid(matroids.named_matroids.NonFano())
738-
sage: M._bases_invariant2() == N._bases_invariant2()
736+
sage: M = BasisMatroid(matroids.named_matroids.Fano()) # optional - sage.rings.finite_rings
737+
sage: N = BasisMatroid(matroids.named_matroids.NonFano()) # optional - sage.rings.finite_rings
738+
sage: M._bases_invariant2() == N._bases_invariant2() # optional - sage.rings.finite_rings
739739
False
740740
"""
741741
if self._bases_invariant2_var is None:
@@ -844,8 +844,8 @@ cdef class BasisMatroid(BasisExchangeMatroid):
844844
EXAMPLES::
845845
846846
sage: from sage.matroids.advanced import *
847-
sage: M = BasisMatroid(matroids.named_matroids.N1())
848-
sage: sorted([e for e in M.groundset() if M.is_distinguished(e)])
847+
sage: M = BasisMatroid(matroids.named_matroids.N1()) # optional - sage.rings.finite_rings
848+
sage: sorted([e for e in M.groundset() if M.is_distinguished(e)]) # optional - sage.rings.finite_rings
849849
['c', 'g', 'h', 'j']
850850
851851
"""
@@ -886,12 +886,12 @@ cdef class BasisMatroid(BasisExchangeMatroid):
886886
EXAMPLES::
887887
888888
sage: from sage.matroids.advanced import *
889-
sage: M = BasisMatroid(matroids.named_matroids.NonFano())
890-
sage: N = BasisMatroid(matroids.named_matroids.Fano())
891-
sage: m = {e:e for e in M.groundset()}
892-
sage: M._is_relaxation(N, m)
889+
sage: M = BasisMatroid(matroids.named_matroids.NonFano()) # optional - sage.rings.finite_rings
890+
sage: N = BasisMatroid(matroids.named_matroids.Fano()) # optional - sage.rings.finite_rings
891+
sage: m = {e:e for e in M.groundset()} # optional - sage.rings.finite_rings
892+
sage: M._is_relaxation(N, m) # optional - sage.rings.finite_rings
893893
True
894-
sage: N._is_relaxation(M, m)
894+
sage: N._is_relaxation(M, m) # optional - sage.rings.finite_rings
895895
False
896896
"""
897897
cdef long i, j
@@ -941,12 +941,12 @@ cdef class BasisMatroid(BasisExchangeMatroid):
941941
EXAMPLES::
942942
943943
sage: from sage.matroids.advanced import *
944-
sage: M = BasisMatroid(matroids.named_matroids.NonFano())
945-
sage: N = BasisMatroid(matroids.named_matroids.Fano())
946-
sage: m = {e:e for e in M.groundset()}
947-
sage: M._is_relaxation(N, m)
944+
sage: M = BasisMatroid(matroids.named_matroids.NonFano()) # optional - sage.rings.finite_rings
945+
sage: N = BasisMatroid(matroids.named_matroids.Fano()) # optional - sage.rings.finite_rings
946+
sage: m = {e:e for e in M.groundset()} # optional - sage.rings.finite_rings
947+
sage: M._is_relaxation(N, m) # optional - sage.rings.finite_rings
948948
True
949-
sage: M._is_isomorphism(N, m)
949+
sage: M._is_isomorphism(N, m) # optional - sage.rings.finite_rings
950950
False
951951
"""
952952
if not isinstance(other, BasisMatroid):
@@ -975,13 +975,13 @@ cdef class BasisMatroid(BasisExchangeMatroid):
975975
976976
sage: from sage.matroids.advanced import *
977977
sage: M = BasisMatroid(matroids.Wheel(3))
978-
sage: N = BasisMatroid(matroids.CompleteGraphic(4))
979-
sage: morphism = M._isomorphism(N)
980-
sage: M._is_isomorphism(N, morphism)
978+
sage: N = BasisMatroid(matroids.CompleteGraphic(4)) # optional - sage.graphs
979+
sage: morphism = M._isomorphism(N) # optional - sage.graphs
980+
sage: M._is_isomorphism(N, morphism) # optional - sage.graphs
981981
True
982-
sage: M = BasisMatroid(matroids.named_matroids.NonFano())
983-
sage: N = BasisMatroid(matroids.named_matroids.Fano())
984-
sage: M._isomorphism(N) is not None
982+
sage: M = BasisMatroid(matroids.named_matroids.NonFano()) # optional - sage.rings.finite_rings
983+
sage: N = BasisMatroid(matroids.named_matroids.Fano()) # optional - sage.rings.finite_rings
984+
sage: M._isomorphism(N) is not None # optional - sage.rings.finite_rings
985985
False
986986
"""
987987
if not isinstance(other, BasisMatroid):
@@ -1055,11 +1055,11 @@ cdef class BasisMatroid(BasisExchangeMatroid):
10551055
EXAMPLES::
10561056
10571057
sage: from sage.matroids.advanced import *
1058-
sage: M = BasisMatroid(matroids.named_matroids.NonFano())
1059-
sage: N = BasisMatroid(matroids.named_matroids.Fano())
1060-
sage: M._is_isomorphic(N)
1058+
sage: M = BasisMatroid(matroids.named_matroids.NonFano()) # optional - sage.rings.finite_rings
1059+
sage: N = BasisMatroid(matroids.named_matroids.Fano()) # optional - sage.rings.finite_rings
1060+
sage: M._is_isomorphic(N) # optional - sage.rings.finite_rings
10611061
False
1062-
sage: M._is_isomorphic(N, certificate=True)
1062+
sage: M._is_isomorphic(N, certificate=True) # optional - sage.rings.finite_rings
10631063
(False, None)
10641064
"""
10651065
if certificate:
@@ -1127,12 +1127,12 @@ cdef class BasisMatroid(BasisExchangeMatroid):
11271127
EXAMPLES::
11281128
11291129
sage: from sage.matroids.advanced import *
1130-
sage: M = BasisMatroid(matroids.named_matroids.Fano())
1131-
sage: N = BasisMatroid(matroids.named_matroids.Fano().dual()).dual()
1132-
sage: O = BasisMatroid(matroids.named_matroids.NonFano())
1133-
sage: hash(M) == hash(N)
1130+
sage: M = BasisMatroid(matroids.named_matroids.Fano()) # optional - sage.rings.finite_rings
1131+
sage: N = BasisMatroid(matroids.named_matroids.Fano().dual()).dual() # optional - sage.rings.finite_rings
1132+
sage: O = BasisMatroid(matroids.named_matroids.NonFano()) # optional - sage.rings.finite_rings
1133+
sage: hash(M) == hash(N) # optional - sage.rings.finite_rings
11341134
True
1135-
sage: hash(M) == hash(O)
1135+
sage: hash(M) == hash(O) # optional - sage.rings.finite_rings
11361136
False
11371137
"""
11381138
return hash((self.groundset(), self.bases_count(), self._weak_invariant()))

0 commit comments

Comments
 (0)