Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sage.matroids: Modularization fixes #35719

Merged
merged 14 commits into from
Jun 21, 2023
Merged
8 changes: 4 additions & 4 deletions src/sage/docs/instancedoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
For a Cython ``cdef class``, a decorator cannot be used. Instead, call
:func:`instancedoc` as a function after defining the class::
sage: cython( # optional - sage.misc.cython
sage: cython( # optional - sage.misc.cython
....: '''
....: from sage.misc.instancedoc import instancedoc
....: cdef class Y:
Expand All @@ -45,9 +45,9 @@
....: return "Instance docstring"
....: instancedoc(Y)
....: ''')
sage: Y.__doc__
sage: Y.__doc__ # optional - sage.misc.cython
'File:...\nClass docstring'
sage: Y().__doc__
sage: Y().__doc__ # optional - sage.misc.cython
'Instance docstring'
One can still add a custom ``__doc__`` attribute on a particular
Expand All @@ -60,7 +60,7 @@
This normally does not work on extension types::
sage: Y().__doc__ = "Very special doc"
sage: Y().__doc__ = "Very special doc" # optional - sage.misc.cython
Traceback (most recent call last):
...
AttributeError: attribute '__doc__' of 'Y' objects is not writable
Expand Down
726 changes: 387 additions & 339 deletions src/sage/dynamics/arithmetic_dynamics/projective_ds.py

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions src/sage/ext/fast_callable.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1772,18 +1772,18 @@ cpdef generate_code(Expression expr, InstructionStream stream):
25
sage: fc.op_list()
[('load_arg', 0), ('load_arg', 1), ('py_call', <function my_norm at 0x...>, 2), 'return']
sage: fc = fast_callable(expr)
sage: fc(3.0r)
sage: fc = fast_callable(expr) # optional - sage.symbolic
sage: fc(3.0r) # optional - sage.symbolic
4.0*pi + 12.0
sage: fc = fast_callable(x+3, domain=ZZ)
sage: fc(4)
sage: fc = fast_callable(x+3, domain=ZZ) # optional - sage.symbolic
sage: fc(4) # optional - sage.symbolic
7
sage: fc = fast_callable(x/3, domain=ZZ)
sage: fc(4)
sage: fc = fast_callable(x/3, domain=ZZ) # optional - sage.symbolic
sage: fc(4) # optional - sage.symbolic
Traceback (most recent call last):
...
TypeError: no conversion of this rational to integer
sage: fc(6)
sage: fc(6) # optional - sage.symbolic
2
sage: fc = fast_callable(etb.call(sin, x), domain=ZZ)
sage: fc(0)
Expand Down
192 changes: 96 additions & 96 deletions src/sage/matroids/basis_exchange_matroid.pyx

Large diffs are not rendered by default.

132 changes: 66 additions & 66 deletions src/sage/matroids/basis_matroid.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ AUTHORS:
TESTS::
sage: F = matroids.named_matroids.Fano()
sage: M = Matroid(bases=F.bases())
sage: TestSuite(M).run()
sage: F = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings
sage: M = Matroid(bases=F.bases()) # optional - sage.rings.finite_rings
sage: TestSuite(M).run() # optional - sage.rings.finite_rings
Methods
=======
Expand Down Expand Up @@ -110,11 +110,11 @@ cdef class BasisMatroid(BasisExchangeMatroid):
Create a BasisMatroid instance out of any other matroid::
sage: from sage.matroids.advanced import *
sage: F = matroids.named_matroids.Fano()
sage: M = BasisMatroid(F)
sage: F.groundset() == M.groundset()
sage: F = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings
sage: M = BasisMatroid(F) # optional - sage.rings.finite_rings
sage: F.groundset() == M.groundset() # optional - sage.rings.finite_rings
True
sage: len(set(F.bases()).difference(M.bases()))
sage: len(set(F.bases()).difference(M.bases())) # optional - sage.rings.finite_rings
0
It is possible to provide either bases or nonbases::
Expand Down Expand Up @@ -150,11 +150,11 @@ cdef class BasisMatroid(BasisExchangeMatroid):
EXAMPLES::
sage: from sage.matroids.advanced import *
sage: F = matroids.named_matroids.Fano()
sage: M = BasisMatroid(F)
sage: F.groundset() == M.groundset()
sage: F = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings
sage: M = BasisMatroid(F) # optional - sage.rings.finite_rings
sage: F.groundset() == M.groundset() # optional - sage.rings.finite_rings
True
sage: len(set(F.bases()).difference(M.bases()))
sage: len(set(F.bases()).difference(M.bases())) # optional - sage.rings.finite_rings
0
"""
cdef SetSystem NB
Expand Down Expand Up @@ -254,8 +254,8 @@ cdef class BasisMatroid(BasisExchangeMatroid):
EXAMPLES::
sage: from sage.matroids.advanced import *
sage: M = BasisMatroid(matroids.named_matroids.Fano())
sage: repr(M) # indirect doctest
sage: M = BasisMatroid(matroids.named_matroids.Fano()) # optional - sage.rings.finite_rings
sage: repr(M) # indirect doctest # optional - sage.rings.finite_rings
'Matroid of rank 3 on 7 elements with 28 bases'
"""
Expand Down Expand Up @@ -429,12 +429,12 @@ cdef class BasisMatroid(BasisExchangeMatroid):
EXAMPLES::
sage: M = Matroid(bases=matroids.named_matroids.N2().bases())
sage: M.truncation()
sage: M = Matroid(bases=matroids.named_matroids.N2().bases()) # optional - sage.rings.finite_rings
sage: M.truncation() # optional - sage.rings.finite_rings
Matroid of rank 5 on 12 elements with 702 bases
sage: M.f_vector()
sage: M.f_vector() # optional - sage.rings.finite_rings
[1, 12, 66, 190, 258, 99, 1]
sage: M.truncation().f_vector()
sage: M.truncation().f_vector() # optional - sage.rings.finite_rings
[1, 12, 66, 190, 258, 1]
"""
Expand Down Expand Up @@ -511,10 +511,10 @@ cdef class BasisMatroid(BasisExchangeMatroid):
EXAMPLES::
sage: from sage.matroids.advanced import *
sage: M = BasisMatroid(matroids.named_matroids.Fano())
sage: M
sage: M = BasisMatroid(matroids.named_matroids.Fano()) # optional - sage.rings.finite_rings
sage: M # optional - sage.rings.finite_rings
Matroid of rank 3 on 7 elements with 28 bases
sage: M._with_coloop('x')
sage: M._with_coloop('x') # optional - sage.rings.finite_rings
Matroid of rank 4 on 8 elements with 28 bases
"""
Expand Down Expand Up @@ -548,11 +548,11 @@ cdef class BasisMatroid(BasisExchangeMatroid):
EXAMPLES::
sage: from sage.matroids.advanced import *
sage: M = BasisMatroid(matroids.named_matroids.Fano())
sage: sorted(M.groundset())
sage: M = BasisMatroid(matroids.named_matroids.Fano()) # optional - sage.rings.finite_rings
sage: sorted(M.groundset()) # optional - sage.rings.finite_rings
['a', 'b', 'c', 'd', 'e', 'f', 'g']
sage: N = M.relabel({'g':'x'})
sage: sorted(N.groundset())
sage: N = M.relabel({'g':'x'}) # optional - sage.rings.finite_rings
sage: sorted(N.groundset()) # optional - sage.rings.finite_rings
['a', 'b', 'c', 'd', 'e', 'f', 'x']
"""
Expand All @@ -572,10 +572,10 @@ cdef class BasisMatroid(BasisExchangeMatroid):
EXAMPLES::
sage: M = Matroid(bases=matroids.named_matroids.Fano().bases())
sage: M
sage: M = Matroid(bases=matroids.named_matroids.Fano().bases()) # optional - sage.rings.finite_rings
sage: M # optional - sage.rings.finite_rings
Matroid of rank 3 on 7 elements with 28 bases
sage: M.bases_count()
sage: M.bases_count() # optional - sage.rings.finite_rings
28
"""
if self._bcount is None:
Expand All @@ -594,10 +594,10 @@ cdef class BasisMatroid(BasisExchangeMatroid):
EXAMPLES::
sage: M = Matroid(bases=matroids.named_matroids.Fano().bases())
sage: M
sage: M = Matroid(bases=matroids.named_matroids.Fano().bases()) # optional - sage.rings.finite_rings
sage: M # optional - sage.rings.finite_rings
Matroid of rank 3 on 7 elements with 28 bases
sage: len(M.bases())
sage: len(M.bases()) # optional - sage.rings.finite_rings
28
"""
cdef long r, n
Expand Down Expand Up @@ -630,10 +630,10 @@ cdef class BasisMatroid(BasisExchangeMatroid):
EXAMPLES::
sage: M = Matroid(bases=matroids.named_matroids.Fano().bases())
sage: M
sage: M = Matroid(bases=matroids.named_matroids.Fano().bases()) # optional - sage.rings.finite_rings
sage: M # optional - sage.rings.finite_rings
Matroid of rank 3 on 7 elements with 28 bases
sage: len(M.nonbases())
sage: len(M.nonbases()) # optional - sage.rings.finite_rings
7
"""
if self._nonbases is not None:
Expand Down Expand Up @@ -674,9 +674,9 @@ cdef class BasisMatroid(BasisExchangeMatroid):
EXAMPLES::
sage: from sage.matroids.advanced import *
sage: M = BasisMatroid(matroids.named_matroids.Fano())
sage: N = BasisMatroid(matroids.named_matroids.Fano())
sage: M._bases_invariant() == N._bases_invariant()
sage: M = BasisMatroid(matroids.named_matroids.Fano()) # optional - sage.rings.finite_rings
sage: N = BasisMatroid(matroids.named_matroids.Fano()) # optional - sage.rings.finite_rings
sage: M._bases_invariant() == N._bases_invariant() # optional - sage.rings.finite_rings
True
"""
if self._bases_invariant_var is not None:
Expand Down Expand Up @@ -733,9 +733,9 @@ cdef class BasisMatroid(BasisExchangeMatroid):
EXAMPLES::
sage: from sage.matroids.advanced import *
sage: M = BasisMatroid(matroids.named_matroids.Fano())
sage: N = BasisMatroid(matroids.named_matroids.NonFano())
sage: M._bases_invariant2() == N._bases_invariant2()
sage: M = BasisMatroid(matroids.named_matroids.Fano()) # optional - sage.rings.finite_rings
sage: N = BasisMatroid(matroids.named_matroids.NonFano()) # optional - sage.rings.finite_rings
sage: M._bases_invariant2() == N._bases_invariant2() # optional - sage.rings.finite_rings
False
"""
if self._bases_invariant2_var is None:
Expand Down Expand Up @@ -844,8 +844,8 @@ cdef class BasisMatroid(BasisExchangeMatroid):
EXAMPLES::
sage: from sage.matroids.advanced import *
sage: M = BasisMatroid(matroids.named_matroids.N1())
sage: sorted([e for e in M.groundset() if M.is_distinguished(e)])
sage: M = BasisMatroid(matroids.named_matroids.N1()) # optional - sage.rings.finite_rings
sage: sorted([e for e in M.groundset() if M.is_distinguished(e)]) # optional - sage.rings.finite_rings
['c', 'g', 'h', 'j']
"""
Expand Down Expand Up @@ -886,12 +886,12 @@ cdef class BasisMatroid(BasisExchangeMatroid):
EXAMPLES::
sage: from sage.matroids.advanced import *
sage: M = BasisMatroid(matroids.named_matroids.NonFano())
sage: N = BasisMatroid(matroids.named_matroids.Fano())
sage: m = {e:e for e in M.groundset()}
sage: M._is_relaxation(N, m)
sage: M = BasisMatroid(matroids.named_matroids.NonFano()) # optional - sage.rings.finite_rings
sage: N = BasisMatroid(matroids.named_matroids.Fano()) # optional - sage.rings.finite_rings
sage: m = {e:e for e in M.groundset()} # optional - sage.rings.finite_rings
sage: M._is_relaxation(N, m) # optional - sage.rings.finite_rings
True
sage: N._is_relaxation(M, m)
sage: N._is_relaxation(M, m) # optional - sage.rings.finite_rings
False
"""
cdef long i, j
Expand Down Expand Up @@ -941,12 +941,12 @@ cdef class BasisMatroid(BasisExchangeMatroid):
EXAMPLES::
sage: from sage.matroids.advanced import *
sage: M = BasisMatroid(matroids.named_matroids.NonFano())
sage: N = BasisMatroid(matroids.named_matroids.Fano())
sage: m = {e:e for e in M.groundset()}
sage: M._is_relaxation(N, m)
sage: M = BasisMatroid(matroids.named_matroids.NonFano()) # optional - sage.rings.finite_rings
sage: N = BasisMatroid(matroids.named_matroids.Fano()) # optional - sage.rings.finite_rings
sage: m = {e:e for e in M.groundset()} # optional - sage.rings.finite_rings
sage: M._is_relaxation(N, m) # optional - sage.rings.finite_rings
True
sage: M._is_isomorphism(N, m)
sage: M._is_isomorphism(N, m) # optional - sage.rings.finite_rings
False
"""
if not isinstance(other, BasisMatroid):
Expand Down Expand Up @@ -975,13 +975,13 @@ cdef class BasisMatroid(BasisExchangeMatroid):
sage: from sage.matroids.advanced import *
sage: M = BasisMatroid(matroids.Wheel(3))
sage: N = BasisMatroid(matroids.CompleteGraphic(4))
sage: morphism = M._isomorphism(N)
sage: M._is_isomorphism(N, morphism)
sage: N = BasisMatroid(matroids.CompleteGraphic(4)) # optional - sage.graphs
sage: morphism = M._isomorphism(N) # optional - sage.graphs
sage: M._is_isomorphism(N, morphism) # optional - sage.graphs
True
sage: M = BasisMatroid(matroids.named_matroids.NonFano())
sage: N = BasisMatroid(matroids.named_matroids.Fano())
sage: M._isomorphism(N) is not None
sage: M = BasisMatroid(matroids.named_matroids.NonFano()) # optional - sage.rings.finite_rings
sage: N = BasisMatroid(matroids.named_matroids.Fano()) # optional - sage.rings.finite_rings
sage: M._isomorphism(N) is not None # optional - sage.rings.finite_rings
False
"""
if not isinstance(other, BasisMatroid):
Expand Down Expand Up @@ -1055,11 +1055,11 @@ cdef class BasisMatroid(BasisExchangeMatroid):
EXAMPLES::
sage: from sage.matroids.advanced import *
sage: M = BasisMatroid(matroids.named_matroids.NonFano())
sage: N = BasisMatroid(matroids.named_matroids.Fano())
sage: M._is_isomorphic(N)
sage: M = BasisMatroid(matroids.named_matroids.NonFano()) # optional - sage.rings.finite_rings
sage: N = BasisMatroid(matroids.named_matroids.Fano()) # optional - sage.rings.finite_rings
sage: M._is_isomorphic(N) # optional - sage.rings.finite_rings
False
sage: M._is_isomorphic(N, certificate=True)
sage: M._is_isomorphic(N, certificate=True) # optional - sage.rings.finite_rings
(False, None)
"""
if certificate:
Expand Down Expand Up @@ -1127,12 +1127,12 @@ cdef class BasisMatroid(BasisExchangeMatroid):
EXAMPLES::
sage: from sage.matroids.advanced import *
sage: M = BasisMatroid(matroids.named_matroids.Fano())
sage: N = BasisMatroid(matroids.named_matroids.Fano().dual()).dual()
sage: O = BasisMatroid(matroids.named_matroids.NonFano())
sage: hash(M) == hash(N)
sage: M = BasisMatroid(matroids.named_matroids.Fano()) # optional - sage.rings.finite_rings
sage: N = BasisMatroid(matroids.named_matroids.Fano().dual()).dual() # optional - sage.rings.finite_rings
sage: O = BasisMatroid(matroids.named_matroids.NonFano()) # optional - sage.rings.finite_rings
sage: hash(M) == hash(N) # optional - sage.rings.finite_rings
True
sage: hash(M) == hash(O)
sage: hash(M) == hash(O) # optional - sage.rings.finite_rings
False
"""
return hash((self.groundset(), self.bases_count(), self._weak_invariant()))
Expand Down
Loading