diff --git a/src/sage/docs/instancedoc.py b/src/sage/docs/instancedoc.py index 5b03886ef02..111c09461e3 100644 --- a/src/sage/docs/instancedoc.py +++ b/src/sage/docs/instancedoc.py @@ -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: @@ -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 @@ -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 diff --git a/src/sage/dynamics/arithmetic_dynamics/projective_ds.py b/src/sage/dynamics/arithmetic_dynamics/projective_ds.py index a6220f27801..534cca093af 100644 --- a/src/sage/dynamics/arithmetic_dynamics/projective_ds.py +++ b/src/sage/dynamics/arithmetic_dynamics/projective_ds.py @@ -196,7 +196,7 @@ class DynamicalSystem_projective(SchemeMorphism_polynomial_projective_space, Symbolic Ring elements are not allowed:: sage: x,y = var('x,y') - sage: DynamicalSystem_projective([x^2,y^2]) + sage: DynamicalSystem_projective([x^2, y^2]) Traceback (most recent call last): ... ValueError: [x^2, y^2] must be elements of a polynomial ring @@ -224,7 +224,7 @@ class DynamicalSystem_projective(SchemeMorphism_polynomial_projective_space, When elements of the quotient ring are used, they are reduced:: sage: P. = ProjectiveSpace(CC, 2) - sage: X = P.subscheme([x-y]) + sage: X = P.subscheme([x - y]) sage: u,v,w = X.coordinate_ring().gens() sage: DynamicalSystem_projective([u^2, v^2, w*u], domain=X) Dynamical System of Closed subscheme of Projective Space of dimension @@ -241,7 +241,7 @@ class DynamicalSystem_projective(SchemeMorphism_polynomial_projective_space, sage: P. = ProjectiveSpace(QQ, 2) sage: f = DynamicalSystem_projective([(x-2*y)^2, (x-2*z)^2, x^2]) - sage: X = P.subscheme(y-z) + sage: X = P.subscheme(y - z) sage: f(f(f(X))) Closed subscheme of Projective Space of dimension 2 over Rational Field defined by: @@ -251,7 +251,7 @@ class DynamicalSystem_projective(SchemeMorphism_polynomial_projective_space, sage: P. = ProjectiveSpace(QQ, 3) sage: f = DynamicalSystem_projective([(x-2*y)^2, (x-2*z)^2, (x-2*w)^2, x^2]) - sage: f(P.subscheme([x,y,z])) + sage: f(P.subscheme([x, y, z])) Closed subscheme of Projective Space of dimension 3 over Rational Field defined by: w, @@ -285,18 +285,18 @@ def __classcall_private__(cls, morphism_or_polys, domain=None, names=None): sage: R. = QQ[] sage: P1 = ProjectiveSpace(R) - sage: f = DynamicalSystem_projective([x-y, x*y]) + sage: f = DynamicalSystem_projective([x - y, x*y]) Traceback (most recent call last): ... ValueError: polys (=[x - y, x*y]) must be of the same degree - sage: DynamicalSystem_projective([x-1, x*y+x]) + sage: DynamicalSystem_projective([x - 1, x*y + x]) Traceback (most recent call last): ... ValueError: polys (=[x - 1, x*y + x]) must be homogeneous :: - sage: DynamicalSystem_projective([exp(x),exp(y)]) + sage: DynamicalSystem_projective([exp(x), exp(y)]) Traceback (most recent call last): ... ValueError: [e^x, e^y] must be elements of a polynomial ring @@ -313,7 +313,7 @@ def __classcall_private__(cls, morphism_or_polys, domain=None, names=None): :: sage: A. = AffineSpace(ZZ, 2) - sage: DynamicalSystem_projective([x^2,y^2], A) + sage: DynamicalSystem_projective([x^2, y^2], A) Traceback (most recent call last): ... ValueError: "domain" must be a projective scheme @@ -505,7 +505,8 @@ def _number_field_from_algebraics(self): sage: P. = ProjectiveSpace(QQbar,1) sage: f = DynamicalSystem_projective([x^2 + QQbar(sqrt(2)) * y^2, y^2]) sage: f._number_field_from_algebraics() - Dynamical System of Projective Space of dimension 1 over Number Field in a with defining polynomial y^2 - 2 with a = 1.414213562373095? + Dynamical System of Projective Space of dimension 1 over Number Field in a + with defining polynomial y^2 - 2 with a = 1.414213562373095? Defn: Defined on coordinates by sending (x : y) to (x^2 + a*y^2 : y^2) """ @@ -528,7 +529,7 @@ def dehomogenize(self, n): If the dehomogenizing indices are the same for the domain and codomain, then a :class:`DynamicalSystem_affine` given by - dehomogenizing the source and target of `self` with respect to + dehomogenizing the source and target of ``self`` with respect to the given indices is returned. If the dehomogenizing indices for the domain and codomain are different then the resulting affine patches are different and a scheme morphism is returned. @@ -536,7 +537,7 @@ def dehomogenize(self, n): EXAMPLES:: sage: P. = ProjectiveSpace(ZZ,1) - sage: f = DynamicalSystem_projective([x^2+y^2, y^2]) + sage: f = DynamicalSystem_projective([x^2 + y^2, y^2]) sage: f.dehomogenize(0) Dynamical System of Affine Space of dimension 1 over Integer Ring Defn: Defined on coordinates by sending (y) to @@ -569,7 +570,7 @@ def dynatomic_polynomial(self, period): ALGORITHM: - For a positive integer `n`, let `[F_n,G_n]` be the coordinates of the `nth` + For a positive integer `n`, let `[F_n,G_n]` be the coordinates of the `n`-th iterate of `f`. Then construct .. MATH:: @@ -676,8 +677,7 @@ def dynatomic_polynomial(self, period): sage: P. = ProjectiveSpace(Qp(5),1) sage: f = DynamicalSystem_projective([x^2 + y^2, y^2]) sage: f.dynatomic_polynomial(2) - (x^4*y + (2 + O(5^20))*x^2*y^3 - x*y^4 + (2 + O(5^20))*y^5)/(x^2*y - - x*y^2 + y^3) + (x^4*y + (2 + O(5^20))*x^2*y^3 - x*y^4 + (2 + O(5^20))*y^5)/(x^2*y - x*y^2 + y^3) :: @@ -728,20 +728,22 @@ def dynatomic_polynomial(self, period): sage: P. = ProjectiveSpace(CC, 1) sage: f = DynamicalSystem_projective([x^2 - CC.0/3*y^2, y^2]) sage: f.dynatomic_polynomial(2) - (x^4*y + (-0.666666666666667*I)*x^2*y^3 - x*y^4 + (-0.111111111111111 - 0.333333333333333*I)*y^5)/(x^2*y - x*y^2 + (-0.333333333333333*I)*y^3) + (x^4*y + (-0.666666666666667*I)*x^2*y^3 - x*y^4 + + (-0.111111111111111 - 0.333333333333333*I)*y^5)/(x^2*y - x*y^2 + + (-0.333333333333333*I)*y^3) :: sage: P. = ProjectiveSpace(CC, 1) - sage: f = DynamicalSystem_projective([x^2-CC.0/5*y^2, y^2]) + sage: f = DynamicalSystem_projective([x^2 - CC.0/5*y^2, y^2]) sage: f.dynatomic_polynomial(2) x^2 + x*y + (1.00000000000000 - 0.200000000000000*I)*y^2 :: sage: L. = PolynomialRing(QuadraticField(2).maximal_order()) - sage: P. = ProjectiveSpace(L.fraction_field() , 1) - sage: f = DynamicalSystem_projective([x^2 + (t^2 + 1)*y^2 , y^2]) + sage: P. = ProjectiveSpace(L.fraction_field(), 1) + sage: f = DynamicalSystem_projective([x^2 + (t^2 + 1)*y^2, y^2]) sage: f.dynatomic_polynomial(2) x^2 + x*y + (t^2 + 2)*y^2 @@ -813,7 +815,7 @@ def dynatomic_polynomial(self, period): sage: R. = QQ[] sage: P. = ProjectiveSpace(R,1) - sage: f = DynamicalSystem_projective([x^2 + c*y^2,y^2]) + sage: f = DynamicalSystem_projective([x^2 + c*y^2, y^2]) sage: f.dynatomic_polynomial([1,2]).parent() Multivariate Polynomial Ring in x, y over Univariate Polynomial Ring in c over Rational Field @@ -913,24 +915,23 @@ def nth_iterate_map(self, n, normalize=False): EXAMPLES:: sage: P. = ProjectiveSpace(QQ,1) - sage: f = DynamicalSystem_projective([x^2+y^2, y^2]) + sage: f = DynamicalSystem_projective([x^2 + y^2, y^2]) sage: f.nth_iterate_map(2) - Dynamical System of Projective Space of dimension 1 over Rational - Field + Dynamical System of Projective Space of dimension 1 over Rational Field Defn: Defined on coordinates by sending (x : y) to (x^4 + 2*x^2*y^2 + 2*y^4 : y^4) :: sage: P. = ProjectiveSpace(CC,1) - sage: f = DynamicalSystem_projective([x^2-y^2, x*y]) + sage: f = DynamicalSystem_projective([x^2 - y^2, x*y]) sage: f.nth_iterate_map(3) - Dynamical System of Projective Space of dimension 1 over Complex - Field with 53 bits of precision + Dynamical System of Projective Space of dimension 1 + over Complex Field with 53 bits of precision Defn: Defined on coordinates by sending (x : y) to - (x^8 + (-7.00000000000000)*x^6*y^2 + 13.0000000000000*x^4*y^4 + - (-7.00000000000000)*x^2*y^6 + y^8 : x^7*y + (-4.00000000000000)*x^5*y^3 - + 4.00000000000000*x^3*y^5 - x*y^7) + (x^8 + (-7.00000000000000)*x^6*y^2 + 13.0000000000000*x^4*y^4 + + (-7.00000000000000)*x^2*y^6 + y^8 + : x^7*y + (-4.00000000000000)*x^5*y^3 + 4.00000000000000*x^3*y^5 - x*y^7) :: @@ -939,8 +940,8 @@ def nth_iterate_map(self, n, normalize=False): sage: f.nth_iterate_map(2) Dynamical System of Projective Space of dimension 2 over Integer Ring Defn: Defined on coordinates by sending (x : y : z) to - (x^4 - 3*x^2*y^2 + y^4 : x^3*y - x*y^3 : 2*x^4 - 2*x^2*y^2 + y^4 - + 2*x^2*z^2 + z^4) + (x^4 - 3*x^2*y^2 + y^4 : x^3*y - x*y^3 + : 2*x^4 - 2*x^2*y^2 + y^4 + 2*x^2*z^2 + z^4) :: @@ -959,8 +960,7 @@ def nth_iterate_map(self, n, normalize=False): sage: P. = ProjectiveSpace(QQ, 2) sage: f = DynamicalSystem_projective([y^2 * z^3, y^3 * z^2, x^5]) sage: f.nth_iterate_map( 5, normalize=True) - Dynamical System of Projective Space of dimension 2 over Rational - Field + Dynamical System of Projective Space of dimension 2 over Rational Field Defn: Defined on coordinates by sending (x : y : z) to (y^202*z^443 : x^140*y^163*z^342 : x^645) """ @@ -1014,7 +1014,7 @@ def nth_iterate(self, P, n, **kwds): EXAMPLES:: sage: P. = ProjectiveSpace(ZZ,1) - sage: f = DynamicalSystem_projective([x^2+y^2, 2*y^2]) + sage: f = DynamicalSystem_projective([x^2 + y^2, 2*y^2]) sage: Q = P(1,1) sage: f.nth_iterate(Q,4) (32768 : 32768) @@ -1022,7 +1022,7 @@ def nth_iterate(self, P, n, **kwds): :: sage: P. = ProjectiveSpace(ZZ,1) - sage: f = DynamicalSystem_projective([x^2+y^2, 2*y^2]) + sage: f = DynamicalSystem_projective([x^2 + y^2, 2*y^2]) sage: Q = P(1,1) sage: f.nth_iterate(Q, 4, normalize=True) (1 : 1) @@ -1030,7 +1030,7 @@ def nth_iterate(self, P, n, **kwds): :: sage: P. = ProjectiveSpace(QQ,2) - sage: f = DynamicalSystem_projective([x^2, 2*y^2, z^2-x^2]) + sage: f = DynamicalSystem_projective([x^2, 2*y^2, z^2 - x^2]) sage: Q = P(2,7,1) sage: f.nth_iterate(Q,2) (-16/7 : -2744 : 1) @@ -1039,11 +1039,11 @@ def nth_iterate(self, P, n, **kwds): sage: R. = PolynomialRing(QQ) sage: P. = ProjectiveSpace(R,2) - sage: f = DynamicalSystem_projective([x^2+t*y^2, (2-t)*y^2, z^2]) - sage: Q = P(2+t,7,t) + sage: f = DynamicalSystem_projective([x^2 + t*y^2, (2-t)*y^2, z^2]) + sage: Q = P(2 + t, 7, t) sage: f.nth_iterate(Q,2) - (t^4 + 2507*t^3 - 6787*t^2 + 10028*t + 16 : -2401*t^3 + 14406*t^2 - - 28812*t + 19208 : t^4) + (t^4 + 2507*t^3 - 6787*t^2 + 10028*t + 16 + : -2401*t^3 + 14406*t^2 - 28812*t + 19208 : t^4) :: @@ -1062,7 +1062,7 @@ def nth_iterate(self, P, n, **kwds): ((c^6 - 9*c^4 + 25*c^2 - c - 21)/(c^2 - 3) : 1) sage: P. = ProjectiveSpace(QQ,2) - sage: f = DynamicalSystem_projective([x^2+3*y^2, 2*y^2,z^2]) + sage: f = DynamicalSystem_projective([x^2 + 3*y^2, 2*y^2, z^2]) sage: f.nth_iterate(P(2, 7, 1), -2) Traceback (most recent call last): ... @@ -1077,7 +1077,8 @@ def nth_iterate(self, P, n, **kwds): sage: f.nth_iterate(P(0, 1), 3) Traceback (most recent call last): ... - ValueError: [0, 0] does not define a point in Projective Space of dimension 1 over Rational Field since all entries are zero + ValueError: [0, 0] does not define a point in Projective Space of + dimension 1 over Rational Field since all entries are zero :: @@ -1091,7 +1092,7 @@ def nth_iterate(self, P, n, **kwds): :: sage: P. = ProjectiveSpace(QQ,1) - sage: f = DynamicalSystem([x+y,y]) + sage: f = DynamicalSystem([x + y, y]) sage: Q = (3,1) sage: f.nth_iterate(Q,0) (3 : 1) @@ -1099,7 +1100,7 @@ def nth_iterate(self, P, n, **kwds): TESTS:: sage: P. = ProjectiveSpace(QQ,1) - sage: f = DynamicalSystem([x^2+y^2,y^2]) + sage: f = DynamicalSystem([x^2 + y^2, y^2]) sage: f.nth_iterate(0,0) (0 : 1) """ @@ -1480,14 +1481,14 @@ def dynamical_degree(self, N=3, prec=53): EXAMPLES:: sage: P. = ProjectiveSpace(QQ, 1) - sage: f = DynamicalSystem_projective([x^2 + (x*y), y^2]) + sage: f = DynamicalSystem_projective([x^2 + x*y, y^2]) sage: f.dynamical_degree() 2.00000000000000 :: sage: P2. = ProjectiveSpace(ZZ, 2) - sage: f = DynamicalSystem_projective([X*Y, Y*Z+Z^2, Z^2]) + sage: f = DynamicalSystem_projective([X*Y, Y*Z + Z^2, Z^2]) sage: f.dynamical_degree(N=5, prec=100) 1.4309690811052555010452244131 """ @@ -1529,21 +1530,21 @@ def orbit(self, P, N, **kwds): EXAMPLES:: sage: P. = ProjectiveSpace(ZZ,2) - sage: f = DynamicalSystem_projective([x^2+y^2, y^2-z^2, 2*z^2]) + sage: f = DynamicalSystem_projective([x^2 + y^2, y^2 - z^2, 2*z^2]) sage: f.orbit(P(1,2,1), 3) [(1 : 2 : 1), (5 : 3 : 2), (34 : 5 : 8), (1181 : -39 : 128)] :: sage: P. = ProjectiveSpace(ZZ,2) - sage: f = DynamicalSystem_projective([x^2+y^2, y^2-z^2, 2*z^2]) + sage: f = DynamicalSystem_projective([x^2 + y^2, y^2 - z^2, 2*z^2]) sage: f.orbit(P(1,2,1), [2,4]) [(34 : 5 : 8), (1181 : -39 : 128), (1396282 : -14863 : 32768)] :: sage: P. = ProjectiveSpace(ZZ,2) - sage: X = P.subscheme(x^2-y^2) + sage: X = P.subscheme(x^2 - y^2) sage: f = DynamicalSystem_projective([x^2, y^2, x*z], domain=X) sage: f.orbit(X(2,2,3), 3, normalize=True) [(2 : 2 : 3), (2 : 2 : 3), (2 : 2 : 3), (2 : 2 : 3)] @@ -1551,22 +1552,22 @@ def orbit(self, P, N, **kwds): :: sage: P. = ProjectiveSpace(QQ,1) - sage: f = DynamicalSystem_projective([x^2+y^2, y^2]) - sage: f.orbit(P.point([1,2],False), 4, check=False) + sage: f = DynamicalSystem_projective([x^2 + y^2, y^2]) + sage: f.orbit(P.point([1,2], False), 4, check=False) [(1 : 2), (5 : 4), (41 : 16), (1937 : 256), (3817505 : 65536)] :: sage: K. = FunctionField(QQ) sage: P. = ProjectiveSpace(K,1) - sage: f = DynamicalSystem_projective([x^2+c*y^2, y^2]) + sage: f = DynamicalSystem_projective([x^2 + c*y^2, y^2]) sage: f.orbit(P(0,1), 3) [(0 : 1), (c : 1), (c^2 + c : 1), (c^4 + 2*c^3 + c^2 + c : 1)] :: sage: P. = ProjectiveSpace(QQ,1) - sage: f = DynamicalSystem_projective([x^2+y^2,y^2], domain=P) + sage: f = DynamicalSystem_projective([x^2 + y^2, y^2], domain=P) sage: f.orbit(P.point([1, 2], False), 4, check=False) [(1 : 2), (5 : 4), (41 : 16), (1937 : 256), (3817505 : 65536)] @@ -1590,7 +1591,8 @@ def orbit(self, P, N, **kwds): sage: f.orbit(P(0, 1), 3) Traceback (most recent call last): ... - ValueError: [0, 0] does not define a point in Projective Space of dimension 1 over Rational Field since all entries are zero + ValueError: [0, 0] does not define a point in Projective Space of + dimension 1 over Rational Field since all entries are zero sage: f.orbit(P(0, 1), 3, check=False) [(0 : 1), (0 : 0), (0 : 0), (0 : 0)] @@ -1607,20 +1609,20 @@ def orbit(self, P, N, **kwds): sage: P. = ProjectiveSpace(QQ,2) sage: f = DynamicalSystem_projective([x^2, y^2, x*z]) - sage: f.orbit((2/3,1/3), 3) + sage: f.orbit((2/3, 1/3), 3) [(2/3 : 1/3 : 1), (2/3 : 1/6 : 1), (2/3 : 1/24 : 1), (2/3 : 1/384 : 1)] TESTS:: sage: P. = ProjectiveSpace(QQ,1) - sage: f = DynamicalSystem([x^2+y^2,y^2]) + sage: f = DynamicalSystem([x^2 + y^2, y^2]) sage: f.orbit(0, 0) [(0 : 1)] :: sage: P. = ProjectiveSpace(QQ,1) - sage: f = DynamicalSystem([x^2-y^2,y^2]) + sage: f = DynamicalSystem([x^2 - y^2, y^2]) sage: f.orbit(0,2) [(0 : 1), (-1 : 1), (0 : 1)] """ @@ -1656,7 +1658,7 @@ def orbit(self, P, N, **kwds): def resultant(self, normalize=False): r""" - Computes the resultant of the defining polynomials of + Compute the resultant of the defining polynomials of this dynamical system. If ``normalize`` is ``True``, then first normalize the coordinate @@ -1671,7 +1673,7 @@ def resultant(self, normalize=False): EXAMPLES:: sage: P. = ProjectiveSpace(QQ,1) - sage: f = DynamicalSystem_projective([x^2+y^2, 6*y^2]) + sage: f = DynamicalSystem_projective([x^2 + y^2, 6*y^2]) sage: f.resultant() 36 @@ -1679,7 +1681,7 @@ def resultant(self, normalize=False): sage: R. = PolynomialRing(GF(17)) sage: P. = ProjectiveSpace(R,1) - sage: f = DynamicalSystem_projective([t*x^2+t*y^2, 6*y^2]) + sage: f = DynamicalSystem_projective([t*x^2 + t*y^2, 6*y^2]) sage: f.resultant() 2*t^2 @@ -1687,23 +1689,23 @@ def resultant(self, normalize=False): sage: R. = PolynomialRing(GF(17)) sage: P. = ProjectiveSpace(R,2) - sage: f = DynamicalSystem_projective([t*x^2+t*y^2, 6*y^2, 2*t*z^2]) + sage: f = DynamicalSystem_projective([t*x^2 + t*y^2, 6*y^2, 2*t*z^2]) sage: f.resultant() 13*t^8 :: sage: P. = ProjectiveSpace(QQ,2) - sage: F = DynamicalSystem_projective([x^2+y^2,6*y^2,10*x*z+z^2+y^2]) + sage: F = DynamicalSystem_projective([x^2 + y^2, 6*y^2, 10*x*z + z^2 + y^2]) sage: F.resultant() 1296 :: - sage: R.=PolynomialRing(QQ) - sage: s = (t^3+t+1).roots(QQbar)[0][0] - sage: P.=ProjectiveSpace(QQbar,1) - sage: f = DynamicalSystem_projective([s*x^3-13*y^3, y^3-15*y^3]) + sage: R. = PolynomialRing(QQ) + sage: s = (t^3 + t + 1).roots(QQbar)[0][0] + sage: P. = ProjectiveSpace(QQbar, 1) + sage: f = DynamicalSystem_projective([s*x^3 - 13*y^3, y^3 - 15*y^3]) sage: f.resultant() 871.6925062959149? """ @@ -1764,14 +1766,15 @@ def primes_of_bad_reduction(self, check=True): EXAMPLES:: sage: P. = ProjectiveSpace(QQ,1) - sage: f = DynamicalSystem_projective([1/3*x^2+1/2*y^2, y^2]) + sage: f = DynamicalSystem_projective([1/3*x^2 + 1/2*y^2, y^2]) sage: f.primes_of_bad_reduction() [2, 3] :: sage: P. = ProjectiveSpace(QQ,3) - sage: f = DynamicalSystem_projective([12*x*z-7*y^2, 31*x^2-y^2, 26*z^2, 3*w^2-z*w]) + sage: f = DynamicalSystem_projective([12*x*z - 7*y^2, 31*x^2 - y^2, + ....: 26*z^2, 3*w^2 - z*w]) sage: f.primes_of_bad_reduction() [2, 3, 7, 13, 31] @@ -1784,7 +1787,7 @@ def primes_of_bad_reduction(self, check=True): sage: f.primes_of_bad_reduction() [Fractional ideal (a), Fractional ideal (3)] - This is an example where check = False returns extra primes:: + This is an example where ``check=False`` returns extra primes:: sage: P. = ProjectiveSpace(ZZ,2) sage: f = DynamicalSystem_projective([3*x*y^2 + 7*y^3 - 4*y^2*z + 5*z^3, @@ -1866,16 +1869,20 @@ def conjugate(self, M, adjugate=False, normalize=False): - ``M`` -- a square invertible matrix - - ``adjugate`` -- (default: ``False``) boolean, also classically called adjoint, takes a square matrix ``M`` and finds the transpose of its cofactor matrix. Used for conjugation in place of inverse when specified ``'True'``. Functionality is the same in projective space. + - ``adjugate`` -- (default: ``False``) boolean, also classically called + adjoint, takes a square matrix ``M`` and finds the transpose of its + cofactor matrix. Used for conjugation in place of inverse when + specified ``True``. Functionality is the same in projective space. - - ``normalize`` -- (default: ``False``) boolean, if normalize is ``'True'``, then the function ``normalize_coordinates`` is called. + - ``normalize`` -- (default: ``False``) boolean, if ``normalize`` is + ``True``, then the method ``normalize_coordinates`` is called. OUTPUT: a dynamical system EXAMPLES:: sage: P. = ProjectiveSpace(ZZ,1) - sage: f = DynamicalSystem_projective([x^2+y^2, y^2]) + sage: f = DynamicalSystem_projective([x^2 + y^2, y^2]) sage: f.conjugate(matrix([[1,2], [0,1]])) Dynamical System of Projective Space of dimension 1 over Integer Ring Defn: Defined on coordinates by sending (x : y) to @@ -1884,9 +1891,9 @@ def conjugate(self, M, adjugate=False, normalize=False): :: sage: R. = PolynomialRing(QQ) - sage: K. = NumberField(x^2+1) + sage: K. = NumberField(x^2 + 1) sage: P. = ProjectiveSpace(ZZ,1) - sage: f = DynamicalSystem_projective([x^3+y^3, y^3]) + sage: f = DynamicalSystem_projective([x^3 + y^3, y^3]) sage: f.conjugate(matrix([[i,0], [0,-i]])) Dynamical System of Projective Space of dimension 1 over Integer Ring Defn: Defined on coordinates by sending (x : y) to @@ -1895,7 +1902,7 @@ def conjugate(self, M, adjugate=False, normalize=False): :: sage: P. = ProjectiveSpace(ZZ,2) - sage: f = DynamicalSystem_projective([x^2+y^2 ,y^2, y*z]) + sage: f = DynamicalSystem_projective([x^2 + y^2, y^2, y*z]) sage: f.conjugate(matrix([[1,2,3], [0,1,2], [0,0,1]])) Dynamical System of Projective Space of dimension 2 over Integer Ring Defn: Defined on coordinates by sending (x : y : z) to @@ -1913,25 +1920,26 @@ def conjugate(self, M, adjugate=False, normalize=False): :: sage: R. = PolynomialRing(QQ) - sage: K. = NumberField(x^2+1) + sage: K. = NumberField(x^2 + 1) sage: P. = ProjectiveSpace(QQ,1) - sage: f = DynamicalSystem_projective([1/3*x^2+1/2*y^2, y^2]) + sage: f = DynamicalSystem_projective([1/3*x^2 + 1/2*y^2, y^2]) sage: f.conjugate(matrix([[i,0], [0,-i]])) - Dynamical System of Projective Space of dimension 1 over Number Field in i with defining polynomial x^2 + 1 + Dynamical System of Projective Space of dimension 1 + over Number Field in i with defining polynomial x^2 + 1 Defn: Defined on coordinates by sending (x : y) to ((1/3*i)*x^2 + (1/2*i)*y^2 : (-i)*y^2) TESTS:: sage: R = ZZ - sage: P.=ProjectiveSpace(R,1) - sage: f=DynamicalSystem_projective([x^2 + y^2,y^2]) - sage: m=matrix(R,2,[4, 3, 2, 1]) - sage: f.conjugate(m,normalize=False) + sage: P. = ProjectiveSpace(R,1) + sage: f = DynamicalSystem_projective([x^2 + y^2, y^2]) + sage: m = matrix(R, 2, [4, 3, 2, 1]) + sage: f.conjugate(m, normalize=False) Dynamical System of Projective Space of dimension 1 over Rational Field Defn: Defined on coordinates by sending (x : y) to (-4*x^2 - 8*x*y - 7/2*y^2 : 12*x^2 + 20*x*y + 8*y^2) - sage: f.conjugate(m,adjugate=True) + sage: f.conjugate(m, adjugate=True) Dynamical System of Projective Space of dimension 1 over Integer Ring Defn: Defined on coordinates by sending (x : y) to (8*x^2 + 16*x*y + 7*y^2 : -24*x^2 - 40*x*y - 16*y^2) @@ -2005,7 +2013,7 @@ def green_function(self, P, v, **kwds): EXAMPLES:: sage: P. = ProjectiveSpace(QQ,1) - sage: f = DynamicalSystem_projective([x^2+y^2, x*y]); + sage: f = DynamicalSystem_projective([x^2 + y^2, x*y]); sage: Q = P(5, 1) sage: f.green_function(Q, 0, N=30) 1.6460930159932946233759277576 @@ -2013,7 +2021,7 @@ def green_function(self, P, v, **kwds): :: sage: P. = ProjectiveSpace(QQ,1) - sage: f = DynamicalSystem_projective([x^2+y^2, x*y]); + sage: f = DynamicalSystem_projective([x^2 + y^2, x*y]); sage: Q = P(5, 1) sage: f.green_function(Q, 0, N=200, prec=200) 1.6460930160038721802875250367738355497198064992657997569827 @@ -2022,7 +2030,7 @@ def green_function(self, P, v, **kwds): sage: K. = QuadraticField(3) sage: P. = ProjectiveSpace(K,1) - sage: f = DynamicalSystem_projective([17*x^2+1/7*y^2, 17*w*x*y]) + sage: f = DynamicalSystem_projective([17*x^2 + 1/7*y^2, 17*w*x*y]) sage: f.green_function(P.point([w, 2], False), K.places()[1]) 1.7236334013785676107373093775 sage: f.green_function(P([2, 1]), K.ideal(7), N=7) @@ -2033,7 +2041,7 @@ def green_function(self, P, v, **kwds): :: sage: P. = ProjectiveSpace(QQ,1) - sage: f = DynamicalSystem_projective([x^2+y^2, x*y]) + sage: f = DynamicalSystem_projective([x^2 + y^2, x*y]) sage: f.green_function(P.point([5,2], False), 0, N=30) 1.7315451844777407992085512000 sage: f.green_function(P.point([2,1], False), 0, N=30) @@ -2196,7 +2204,7 @@ def canonical_height(self, P, **kwds): EXAMPLES:: sage: P. = ProjectiveSpace(ZZ,1) - sage: f = DynamicalSystem_projective([x^2+y^2, 2*x*y]); + sage: f = DynamicalSystem_projective([x^2 + y^2, 2*x*y]); sage: f.canonical_height(P.point([5,4]), error_bound=0.001) 2.1970553519503404898926835324 sage: f.canonical_height(P.point([2,1]), error_bound=0.001) @@ -2207,18 +2215,18 @@ def canonical_height(self, P, **kwds): sage: R. = PolynomialRing(QQ) sage: K. = NumberField(X^2 + X - 1) sage: P. = ProjectiveSpace(K,1) - sage: f = DynamicalSystem_projective([x^2-2*y^2, y^2]) + sage: f = DynamicalSystem_projective([x^2 - 2*y^2, y^2]) sage: Q = P.point([a,1]) - sage: f.canonical_height(Q, error_bound=0.000001) # Answer only within error_bound of 0 + sage: f.canonical_height(Q, error_bound=0.000001) # Answer only within error_bound of 0 5.7364919788790160119266380480e-8 - sage: f.nth_iterate(Q,2) == Q # but it is indeed preperiodic + sage: f.nth_iterate(Q, 2) == Q # but it is indeed preperiodic True :: sage: P. = ProjectiveSpace(QQ,2) - sage: X = P.subscheme(x^2-y^2); - sage: f = DynamicalSystem_projective([x^2,y^2, 4*z^2], domain=X); + sage: X = P.subscheme(x^2 - y^2); + sage: f = DynamicalSystem_projective([x^2, y^2, 4*z^2], domain=X); sage: Q = X([4,4,1]) sage: f.canonical_height(Q, badprimes=[2]) 0.0013538030870311431824555314882 @@ -2226,8 +2234,8 @@ def canonical_height(self, P, **kwds): :: sage: P. = ProjectiveSpace(QQ,2) - sage: X = P.subscheme(x^2-y^2); - sage: f = DynamicalSystem_projective([x^2,y^2, 30*z^2], domain=X) + sage: X = P.subscheme(x^2 - y^2); + sage: f = DynamicalSystem_projective([x^2, y^2, 30*z^2], domain=X) sage: Q = X([4, 4, 1]) sage: f.canonical_height(Q, badprimes=[2,3,5], prec=200) 2.7054056208276961889784303469356774912979228770208655455481 @@ -2235,7 +2243,7 @@ def canonical_height(self, P, **kwds): :: sage: P. = ProjectiveSpace(QQ, 1) - sage: f = DynamicalSystem_projective([1000*x^2-29*y^2, 1000*y^2]) + sage: f = DynamicalSystem_projective([1000*x^2 - 29*y^2, 1000*y^2]) sage: Q = P(-1/4, 1) sage: f.canonical_height(Q, error_bound=0.01) 3.7996079979254623065837411853 @@ -2255,7 +2263,7 @@ def canonical_height(self, P, **kwds): :: sage: P.=ProjectiveSpace(QQ, 1) - sage: f = DynamicalSystem([2*( -2*x^3 + 3*(x^2*y)) + 3*y^3,3*y^3]) + sage: f = DynamicalSystem([2*(-2*x^3 + 3*(x^2*y)) + 3*y^3, 3*y^3]) sage: f.canonical_height(P(1,0)) 0.00000000000000000000000000000 """ @@ -2430,7 +2438,8 @@ def height_difference_bound(self, prec=None): :: sage: P. = ProjectiveSpace(QQbar, 2) - sage: f = DynamicalSystem_projective([x^2, QQbar(sqrt(-1))*y^2, QQbar(sqrt(3))*z^2]) + sage: f = DynamicalSystem_projective([x^2, QQbar(sqrt(-1))*y^2, + ....: QQbar(sqrt(3))*z^2]) sage: f.height_difference_bound() 2.89037175789616 @@ -2494,8 +2503,8 @@ def multiplier(self, P, n, check=True): EXAMPLES:: sage: P. = ProjectiveSpace(QQ,2) - sage: f = DynamicalSystem_projective([x^2,y^2, 4*z^2]); - sage: Q = P.point([4,4,1], False); + sage: f = DynamicalSystem_projective([x^2, y^2, 4*z^2]) + sage: Q = P.point([4,4,1], False) sage: f.multiplier(Q,1) [2 0] [0 2] @@ -2517,23 +2526,23 @@ def multiplier(self, P, n, check=True): :: sage: P. = ProjectiveSpace(RR,1) - sage: f = DynamicalSystem_projective([x^2-2*y^2, y^2]) + sage: f = DynamicalSystem_projective([x^2 - 2*y^2, y^2]) sage: f.multiplier(P(2,1), 1) [4.00000000000000] :: sage: P. = ProjectiveSpace(Qp(13),1) - sage: f = DynamicalSystem_projective([x^2-29/16*y^2, y^2]) + sage: f = DynamicalSystem_projective([x^2 - 29/16*y^2, y^2]) sage: f.multiplier(P(5,4), 3) [6 + 8*13 + 13^2 + 8*13^3 + 13^4 + 8*13^5 + 13^6 + 8*13^7 + 13^8 + - 8*13^9 + 13^10 + 8*13^11 + 13^12 + 8*13^13 + 13^14 + 8*13^15 + 13^16 + - 8*13^17 + 13^18 + 8*13^19 + O(13^20)] + 8*13^9 + 13^10 + 8*13^11 + 13^12 + 8*13^13 + 13^14 + 8*13^15 + 13^16 + + 8*13^17 + 13^18 + 8*13^19 + O(13^20)] :: sage: P. = ProjectiveSpace(QQ,1) - sage: f = DynamicalSystem_projective([x^2-y^2, y^2]) + sage: f = DynamicalSystem_projective([x^2 - y^2, y^2]) sage: f.multiplier(P(0,1), 1) Traceback (most recent call last): ... @@ -2596,14 +2605,14 @@ def _multipliermod(self, P, n, p, k): EXAMPLES:: sage: P. = ProjectiveSpace(QQ,1) - sage: f = DynamicalSystem_projective([x^2-29/16*y^2, y^2]) + sage: f = DynamicalSystem_projective([x^2 - 29/16*y^2, y^2]) sage: f._multipliermod(P(5,4), 3, 11, 1) [3] :: sage: P. = ProjectiveSpace(QQ,1) - sage: f = DynamicalSystem_projective([x^2-29/16*y^2, y^2]) + sage: f = DynamicalSystem_projective([x^2 - 29/16*y^2, y^2]) sage: f._multipliermod(P(5,4), 3, 11, 2) [80] """ @@ -2715,34 +2724,41 @@ def nth_preimage_tree(self, Q, n, **kwds): kwds: - - ``return_points`` -- (default: ``False``) boolean; if ``True``, return a list of lists - where the index ``i`` is the level of the tree and the elements of the list at that - index are the ``i``-th preimage points as an algebraic element of the splitting field - of the polynomial ``f^n - Q = 0`` + - ``return_points`` -- (default: ``False``) boolean; if ``True``, + return a list of lists where the index `i` is the level of the tree + and the elements of the list at that index are the `i`-th preimage + points as an algebraic element of the splitting field of the + polynomial `f^n - Q = 0` - - ``numerical`` -- (default: ``False``) boolean; calculate pre-images numerically. Note if this - is set to ``True``, preimage points are displayed as complex numbers + - ``numerical`` -- (default: ``False``) boolean; calculate pre-images + numerically. Note if this is set to ``True``, preimage points are + displayed as complex numbers - - ``prec`` -- (default: 100) positive integer; the precision of the ``ComplexField`` if - we compute the preimage points numerically + - ``prec`` -- (default: 100) positive integer; the precision of the + ``ComplexField`` if we compute the preimage points numerically - - ``display_labels`` -- (default: ``True``) boolean; whether to display vertex labels. Since labels - can be very cluttered, can set ``display_labels`` to ``False`` and use ``return_points`` to get a + - ``display_labels`` -- (default: ``True``) boolean; whether to display + vertex labels. Since labels can be very cluttered, can set + ``display_labels`` to ``False`` and use ``return_points`` to get a hold of the points themselves, either as algebraic or complex numbers - - ``display_complex`` -- (default: ``False``) boolean; display vertex labels as - complex numbers. Note if this option is chosen that we must choose an embedding - from the splitting field ``field_def`` of the nth-preimage equation into C. We make - the choice of the first embedding returned by ``field_def.embeddings(ComplexField())`` + - ``display_complex`` -- (default: ``False``) boolean; display vertex + labels as complex numbers. Note if this option is chosen that we must + choose an embedding from the splitting field ``field_def`` of the + `n`-th-preimage equation into `\CC`. We make the choice of the first + embedding returned by ``field_def.embeddings(ComplexField())`` - - ``digits`` -- a positive integer, the number of decimal digits to display for complex - numbers. This only applies if ``display_complex`` is set to ``True`` + - ``digits`` -- a positive integer, the number of decimal digits to + display for complex numbers. This only applies if ``display_complex`` + is set to ``True`` OUTPUT: - If ``return_points`` is ``False``, a ``GraphPlot`` object representing the ``n``-th pre-image tree. - If ``return_points`` is ``True``, a tuple ``(GP, points)``, where ``GP`` is a ``GraphPlot`` object, - and ``points`` is a list of lists as described above under ``return_points``. + If ``return_points`` is ``False``, a :class:`GraphPlot` object representing + the `n`-th pre-image tree. If ``return_points`` is ``True``, a tuple + ``(GP, points)``, where ``GP`` is a :class:`GraphPlot` object, and + ``points`` is a list of lists as described above under + ``return_points``. EXAMPLES:: @@ -2754,7 +2770,7 @@ def nth_preimage_tree(self, Q, n, **kwds): :: - sage: P. = ProjectiveSpace(GF(3),1) + sage: P. = ProjectiveSpace(GF(3), 1) sage: f = DynamicalSystem_projective([x^2 + x*y + y^2, y^2]) sage: Q = P(0,1) sage: f.nth_preimage_tree(Q, 2, return_points=True) @@ -2857,7 +2873,7 @@ def possible_periods(self, **kwds): EXAMPLES:: sage: P. = ProjectiveSpace(QQ,1) - sage: f = DynamicalSystem_projective([x^2-29/16*y^2, y^2]) + sage: f = DynamicalSystem_projective([x^2 - 29/16*y^2, y^2]) sage: f.possible_periods(ncpus=1) [1, 3] @@ -2956,7 +2972,7 @@ def _preperiodic_points_to_cyclegraph(self, preper): EXAMPLES:: sage: P. = ProjectiveSpace(QQ,1) - sage: f = DynamicalSystem_projective([x^2-2*y^2, y^2]) + sage: f = DynamicalSystem_projective([x^2 - 2*y^2, y^2]) sage: preper = [P(-2, 1), P(1, 0), P(0, 1), P(1, 1), P(2, 1), P(-1, 1)] sage: f._preperiodic_points_to_cyclegraph(preper) Looped digraph on 6 vertices @@ -3001,21 +3017,21 @@ def is_PGL_minimal(self, prime_list=None): EXAMPLES:: sage: PS. = ProjectiveSpace(QQ,1) - sage: f = DynamicalSystem_projective([X^2+3*Y^2, X*Y]) + sage: f = DynamicalSystem_projective([X^2 + 3*Y^2, X*Y]) sage: f.is_PGL_minimal() True :: sage: PS. = ProjectiveSpace(QQ,1) - sage: f = DynamicalSystem_projective([6*x^2+12*x*y+7*y^2, 12*x*y]) + sage: f = DynamicalSystem_projective([6*x^2 + 12*x*y + 7*y^2, 12*x*y]) sage: f.is_PGL_minimal() False :: sage: PS. = ProjectiveSpace(QQ,1) - sage: f = DynamicalSystem_projective([6*x^2+12*x*y+7*y^2, y^2]) + sage: f = DynamicalSystem_projective([6*x^2 + 12*x*y + 7*y^2, y^2]) sage: f.is_PGL_minimal() False """ @@ -3061,7 +3077,7 @@ def minimal_model(self, return_transformation=False, prime_list=None, algorithm= - ``algorithm`` -- (optional) string; can be one of the following: - ``check_primes`` -- (optional) boolean: this signals whether to - check whether each element in prime_list is a prime + check whether each element in ``prime_list`` is a prime * ``'BM'`` - the Bruin-Molnar algorithm [BM2012]_ * ``'HS'`` - the Hutz-Stoll algorithm [HS2018]_ @@ -3076,7 +3092,7 @@ def minimal_model(self, return_transformation=False, prime_list=None, algorithm= EXAMPLES:: sage: PS. = ProjectiveSpace(QQ,1) - sage: f = DynamicalSystem_projective([X^2+3*Y^2, X*Y]) + sage: f = DynamicalSystem_projective([X^2 + 3*Y^2, X*Y]) sage: f.minimal_model(return_transformation=True) ( Dynamical System of Projective Space of dimension 1 over Rational @@ -3091,8 +3107,10 @@ def minimal_model(self, return_transformation=False, prime_list=None, algorithm= :: sage: PS. = ProjectiveSpace(QQ,1) - sage: f = DynamicalSystem_projective([7365/2*X^4 + 6282*X^3*Y + 4023*X^2*Y^2 + 1146*X*Y^3 + 245/2*Y^4, - ....: -12329/2*X^4 - 10506*X^3*Y - 6723*X^2*Y^2 - 1914*X*Y^3 - 409/2*Y^4]) + sage: f = DynamicalSystem_projective([7365/2*X^4 + 6282*X^3*Y + 4023*X^2*Y^2 + ....: + 1146*X*Y^3 + 245/2*Y^4, + ....: -12329/2*X^4 - 10506*X^3*Y - 6723*X^2*Y^2 + ....: - 1914*X*Y^3 - 409/2*Y^4]) sage: f.minimal_model(return_transformation=True) ( Dynamical System of Projective Space of dimension 1 over Rational Field @@ -3107,17 +3125,16 @@ def minimal_model(self, return_transformation=False, prime_list=None, algorithm= :: sage: PS. = ProjectiveSpace(QQ,1) - sage: f = DynamicalSystem_projective([6*x^2+12*x*y+7*y^2, 12*x*y]) + sage: f = DynamicalSystem_projective([6*x^2 + 12*x*y + 7*y^2, 12*x*y]) sage: f.minimal_model() - Dynamical System of Projective Space of dimension 1 over Rational - Field + Dynamical System of Projective Space of dimension 1 over Rational Field Defn: Defined on coordinates by sending (x : y) to (x^2 + 12*x*y + 42*y^2 : 2*x*y) :: sage: PS. = ProjectiveSpace(ZZ,1) - sage: f = DynamicalSystem_projective([6*x^2+12*x*y+7*y^2, 12*x*y + 42*y^2]) + sage: f = DynamicalSystem_projective([6*x^2 + 12*x*y + 7*y^2, 12*x*y + 42*y^2]) sage: g,M = f.minimal_model(return_transformation=True, algorithm='BM') sage: f.conjugate(M) == g True @@ -3142,7 +3159,7 @@ def minimal_model(self, return_transformation=False, prime_list=None, algorithm= TESTS:: sage: PS. = ProjectiveSpace(QQ,1) - sage: f = DynamicalSystem_projective([X+Y, X-3*Y]) + sage: f = DynamicalSystem_projective([X + Y, X - 3*Y]) sage: f.minimal_model() Traceback (most recent call last): ... @@ -3151,7 +3168,7 @@ def minimal_model(self, return_transformation=False, prime_list=None, algorithm= :: sage: PS. = ProjectiveSpace(QQ,1) - sage: f = DynamicalSystem_projective([X^2-Y^2, X^2+X*Y]) + sage: f = DynamicalSystem_projective([X^2 - Y^2, X^2 + X*Y]) sage: f.minimal_model() Traceback (most recent call last): ... @@ -3161,10 +3178,11 @@ def minimal_model(self, return_transformation=False, prime_list=None, algorithm= sage: P. = ProjectiveSpace(QQ,1) sage: f = DynamicalSystem([2*x^2, y^2]) - sage: f.minimal_model(algorithm = 'BM') + sage: f.minimal_model(algorithm='BM') Traceback (most recent call last): ... - TypeError: affine minimality is only considered for maps not of the form f or 1/f for a polynomial f + TypeError: affine minimality is only considered for + maps not of the form f or 1/f for a polynomial f :: @@ -3382,34 +3400,35 @@ def affine_preperiodic_model(self, m, n, return_conjugation=False): sage: g.periodic_points(1) [(-1 : -1 : 1), - (-1/2 : -1 : 1), - (-1/2 : -1/2 : 1), - (-1/3 : -2/3 : 1), - (0 : -1 : 1), - (0 : -1/2 : 1), - (0 : 0 : 1)] + (-1/2 : -1 : 1), + (-1/2 : -1/2 : 1), + (-1/3 : -2/3 : 1), + (0 : -1 : 1), + (0 : -1/2 : 1), + (0 : 0 : 1)] :: sage: P. = ProjectiveSpace(GF(9), 2) sage: f = DynamicalSystem_projective([x^2, y^2, z^2]) sage: f.affine_preperiodic_model(0, 1) - Dynamical System of Projective Space of dimension 2 over Finite Field in z2 of size 3^2 - Defn: Defined on coordinates by sending (x : y : z) to - ((-z2)*x^2 : z2*x^2 + (-z2)*x*y + (-z2)*y^2 : - (-z2)*x^2 + z2*x*y + (z2 + 1)*y^2 - y*z + z^2) + Dynamical System of Projective Space of dimension 2 + over Finite Field in z2 of size 3^2 + Defn: Defined on coordinates by sending (x : y : z) to + ((-z2)*x^2 : z2*x^2 + (-z2)*x*y + (-z2)*y^2 : + (-z2)*x^2 + z2*x*y + (z2 + 1)*y^2 - y*z + z^2) :: sage: R. = GF(3)[] sage: P. = ProjectiveSpace(R, 2) sage: f = DynamicalSystem_projective([x^2, y^2, z^2]) - sage: f.affine_preperiodic_model(0, 1) # long time + sage: f.affine_preperiodic_model(0, 1) # long time Dynamical System of Projective Space of dimension 2 over - Univariate Polynomial Ring in c over Finite Field of size 3 + Univariate Polynomial Ring in c over Finite Field of size 3 Defn: Defined on coordinates by sending (x : y : z) to (2*c^3*x^2 : c^3*x^2 + 2*c^3*x*y + 2*c^3*y^2 : - 2*c^3*x^2 + c^3*x*y + (c^3 + c^2)*y^2 + 2*c^2*y*z + c^2*z^2) + 2*c^3*x^2 + c^3*x*y + (c^3 + c^2)*y^2 + 2*c^2*y*z + c^2*z^2) :: @@ -3418,7 +3437,7 @@ def affine_preperiodic_model(self, m, n, return_conjugation=False): sage: f = DynamicalSystem_projective([x^2 + k*x*y + y^2, z^2, y^2]) sage: f.affine_preperiodic_model(1, 1) Dynamical System of Projective Space of dimension 2 - over Cyclotomic Field of order 3 and degree 2 + over Cyclotomic Field of order 3 and degree 2 Defn: Defined on coordinates by sending (x : y : z) to (-y^2 : x^2 : x^2 + (-k)*x*z + z^2) @@ -3436,8 +3455,8 @@ def affine_preperiodic_model(self, m, n, return_conjugation=False): sage: X = P.subscheme(2*y - z) sage: f = DynamicalSystem_projective([x^2 + y^2, z^2 + y^2, z^2], domain=X) sage: f.affine_preperiodic_model(0, 1) - Dynamical System of Closed subscheme of Projective Space of dimension 2 over Rational Field defined by: - 2*y - z + Dynamical System of Closed subscheme of Projective Space of dimension 2 + over Rational Field defined by: 2*y - z Defn: Defined on coordinates by sending (x : y : z) to (-x^2 - y^2 : y^2 : x^2 + z^2) @@ -3583,7 +3602,7 @@ def automorphism_group(self, **kwds): EXAMPLES:: sage: R. = ProjectiveSpace(QQ, 1) - sage: f = DynamicalSystem_projective([x^2-y^2, x*y]) + sage: f = DynamicalSystem_projective([x^2 - y^2, x*y]) sage: f.automorphism_group(return_functions=True) [x, -x] @@ -3607,7 +3626,7 @@ def automorphism_group(self, **kwds): :: sage: R. = ProjectiveSpace(QQ, 1) - sage: f = DynamicalSystem_projective([x^2-2*x*y-2*y^2, -2*x^2-2*x*y+y^2]) + sage: f = DynamicalSystem_projective([x^2 - 2*x*y - 2*y^2, -2*x^2 - 2*x*y + y^2]) sage: f.automorphism_group(return_functions=True) [x, 1/x, -x - 1, -x/(x + 1), (-x - 1)/x, -1/(x + 1)] @@ -3615,10 +3634,12 @@ def automorphism_group(self, **kwds): sage: R. = ProjectiveSpace(QQ, 1) sage: f = DynamicalSystem_projective([3*x^2*y - y^3, x^3 - 3*x*y^2]) - sage: lst, label = f.automorphism_group(algorithm='CRT', return_functions=True, iso_type=True) + sage: lst, label = f.automorphism_group(algorithm='CRT', return_functions=True, + ....: iso_type=True) sage: sorted(lst), label ([-1/x, 1/x, (-x - 1)/(x - 1), (-x + 1)/(x + 1), (x - 1)/(x + 1), - (x + 1)/(x - 1), -x, x], 'Dihedral of order 8') + (x + 1)/(x - 1), -x, x], + 'Dihedral of order 8') :: @@ -3646,7 +3667,7 @@ def automorphism_group(self, **kwds): sage: K. = CyclotomicField(3) sage: P. = ProjectiveSpace(K, 1) - sage: D6 = DynamicalSystem_projective([y^2,x^2]) + sage: D6 = DynamicalSystem_projective([y^2, x^2]) sage: sorted(D6.automorphism_group()) [ [-w - 1 0] [ 0 -w - 1] [w 0] [0 w] [0 1] [1 0] @@ -3689,35 +3710,35 @@ def critical_subscheme(self): sage: set_verbose(None) sage: P. = ProjectiveSpace(QQ,1) - sage: f = DynamicalSystem_projective([x^3-2*x*y^2 + 2*y^3, y^3]) + sage: f = DynamicalSystem_projective([x^3 - 2*x*y^2 + 2*y^3, y^3]) sage: f.critical_subscheme() Closed subscheme of Projective Space of dimension 1 over Rational Field defined by: - 9*x^2*y^2 - 6*y^4 + 9*x^2*y^2 - 6*y^4 :: sage: set_verbose(None) sage: P. = ProjectiveSpace(QQ,1) - sage: f = DynamicalSystem_projective([2*x^2-y^2, x*y]) + sage: f = DynamicalSystem_projective([2*x^2 - y^2, x*y]) sage: f.critical_subscheme() Closed subscheme of Projective Space of dimension 1 over Rational Field defined by: - 4*x^2 + 2*y^2 + 4*x^2 + 2*y^2 :: sage: P. = ProjectiveSpace(QQ,2) - sage: f = DynamicalSystem_projective([2*x^2-y^2, x*y, z^2]) + sage: f = DynamicalSystem_projective([2*x^2 - y^2, x*y, z^2]) sage: f.critical_subscheme() Closed subscheme of Projective Space of dimension 2 over Rational Field defined by: - 8*x^2*z + 4*y^2*z + 8*x^2*z + 4*y^2*z :: - sage: P. = ProjectiveSpace(GF(81),3) - sage: g = DynamicalSystem_projective([x^3+y^3, y^3+z^3, z^3+x^3, w^3]) + sage: P. = ProjectiveSpace(GF(81), 3) + sage: g = DynamicalSystem_projective([x^3 + y^3, y^3 + z^3, z^3 + x^3, w^3]) sage: g.critical_subscheme() Closed subscheme of Projective Space of dimension 3 over Finite Field in z4 of size 3^4 defined by: @@ -3726,7 +3747,7 @@ def critical_subscheme(self): :: sage: P. = ProjectiveSpace(QQ,1) - sage: f = DynamicalSystem_projective([x^2,x*y]) + sage: f = DynamicalSystem_projective([x^2, x*y]) sage: f.critical_subscheme() Traceback (most recent call last): ... @@ -3758,7 +3779,7 @@ def critical_points(self, R=None): sage: set_verbose(None) sage: P. = ProjectiveSpace(QQ,1) - sage: f = DynamicalSystem_projective([x^3-2*x*y^2 + 2*y^3, y^3]) + sage: f = DynamicalSystem_projective([x^3 - 2*x*y^2 + 2*y^3, y^3]) sage: f.critical_points() [(1 : 0)] sage: K. = QuadraticField(6) @@ -3769,7 +3790,7 @@ def critical_points(self, R=None): sage: set_verbose(None) sage: P. = ProjectiveSpace(QQ,1) - sage: f = DynamicalSystem_projective([2*x^2-y^2, x*y]) + sage: f = DynamicalSystem_projective([2*x^2 - y^2, x*y]) sage: f.critical_points(QQbar) [(-0.7071067811865475?*I : 1), (0.7071067811865475?*I : 1)] """ @@ -3834,7 +3855,7 @@ def ramification_type(self, R=None, stable=True): sage: F.ramification_type() [[3], [3], [3]] - sage: F = DynamicalSystem_projective([x^3-2*x*y^2 + 2*y^3, y^3]) + sage: F = DynamicalSystem_projective([x^3 - 2*x*y^2 + 2*y^3, y^3]) sage: F.ramification_type() [[2], [2], [3]] sage: F.ramification_type(R=F.base_ring()) @@ -3868,7 +3889,7 @@ def is_postcritically_finite(self, err=0.01, use_algebraic_closure=True): Only for endomorphisms of `\mathbb{P}^1`. It checks if each critical point is preperiodic. The optional parameter ``err`` is passed into - ``is_preperiodic()`` as part of the preperiodic check. + :meth:`is_preperiodic` as part of the preperiodic check. The computations can be done either over the algebraic closure of the base field or over the minimal extension of the base field that @@ -3878,8 +3899,8 @@ def is_postcritically_finite(self, err=0.01, use_algebraic_closure=True): - ``err`` -- (default: 0.01) positive real number - - ``use_algebraic_closure`` -- boolean (default: True) -- If True uses the - algebraic closure. If False, uses the smallest extension of the base field + - ``use_algebraic_closure`` -- boolean (default: ``True``) -- If ``True``, uses the + algebraic closure. If ``False``, uses the smallest extension of the base field containing all the critical points. OUTPUT: boolean @@ -3903,14 +3924,15 @@ def is_postcritically_finite(self, err=0.01, use_algebraic_closure=True): sage: R. = QQ[] sage: K. = NumberField(z^8 + 3*z^6 + 3*z^4 + z^2 + 1) sage: PS. = ProjectiveSpace(K,1) - sage: f = DynamicalSystem_projective([x^3+v*y^3, y^3]) + sage: f = DynamicalSystem_projective([x^3 + v*y^3, y^3]) sage: f.is_postcritically_finite() # long time True :: sage: P. = ProjectiveSpace(QQ,1) - sage: f = DynamicalSystem_projective([6*x^2+16*x*y+16*y^2, -3*x^2-4*x*y-4*y^2]) + sage: f = DynamicalSystem_projective([6*x^2 + 16*x*y + 16*y^2, + ....: -3*x^2 - 4*x*y - 4*y^2]) sage: f.is_postcritically_finite() True @@ -3926,7 +3948,7 @@ def is_postcritically_finite(self, err=0.01, use_algebraic_closure=True): sage: P. = ProjectiveSpace(QQ,1) sage: f = DynamicalSystem_projective([8*x^4 - 8*x^2*y^2 + y^4, y^4]) - sage: f.is_postcritically_finite(use_algebraic_closure=False) #long time + sage: f.is_postcritically_finite(use_algebraic_closure=False) # long time True :: @@ -3985,7 +4007,7 @@ def is_dynamical_belyi_map(self): EXAMPLES:: sage: P.=ProjectiveSpace(QQ, 1) - sage: f=DynamicalSystem_projective([-2*x^3 - 9*x^2*y - 12*x*y^2 - 6*y^3, y^3]) + sage: f = DynamicalSystem_projective([-2*x^3 - 9*x^2*y - 12*x*y^2 - 6*y^3, y^3]) sage: f.is_dynamical_belyi_map() True @@ -3999,7 +4021,7 @@ def is_dynamical_belyi_map(self): :: sage: P. = ProjectiveSpace(QQ, 1) - sage: f = DynamicalSystem_projective([x^2 + y^2,y^2]) + sage: f = DynamicalSystem_projective([x^2 + y^2, y^2]) sage: f.is_dynamical_belyi_map() False @@ -4030,7 +4052,7 @@ def is_dynamical_belyi_map(self): :: sage: P. = ProjectiveSpace(GF(7), 1) - sage: f = DynamicalSystem_projective([x^3 + 6*y^3, y^3]) + sage: f = DynamicalSystem_projective([x^3 + 6*y^3, y^3]) sage: f.is_dynamical_belyi_map() False """ @@ -4066,8 +4088,8 @@ def critical_point_portrait(self, check=True, use_algebraic_closure=True): - ``check`` -- boolean (default: True) - - ``use_algebraic_closure`` -- boolean (default: True) -- If True uses the - algebraic closure. If False, uses the smallest extension of the base field + - ``use_algebraic_closure`` -- boolean (default: ``True``) -- If ``True``, uses the + algebraic closure. If ``False``, uses the smallest extension of the base field containing all the critical points. OUTPUT: a digraph @@ -4077,8 +4099,8 @@ def critical_point_portrait(self, check=True, use_algebraic_closure=True): sage: R. = QQ[] sage: K. = NumberField(z^6 + 2*z^5 + 2*z^4 + 2*z^3 + z^2 + 1) sage: PS. = ProjectiveSpace(K,1) - sage: f = DynamicalSystem_projective([x^2+v*y^2, y^2]) - sage: f.critical_point_portrait(check=False) # long time + sage: f = DynamicalSystem_projective([x^2 + v*y^2, y^2]) + sage: f.critical_point_portrait(check=False) # long time Looped digraph on 6 vertices :: @@ -4111,7 +4133,7 @@ def critical_point_portrait(self, check=True, use_algebraic_closure=True): sage: P. = ProjectiveSpace(QQ,1) sage: f = DynamicalSystem_projective([8*x^4 - 8*x^2*y^2 + y^4, y^4]) - sage: f.critical_point_portrait(use_algebraic_closure=False) #long time + sage: f.critical_point_portrait(use_algebraic_closure=False) # long time Looped digraph on 6 vertices :: @@ -4189,8 +4211,8 @@ def critical_height(self, **kwds): - ``error_bound`` -- (optional) a positive real number - - ``use_algebraic_closure`` -- boolean (default: True) -- If True uses the - algebraic closure. If False, uses the smallest extension of the base field + - ``use_algebraic_closure`` -- boolean (default: ``True``) -- If ``True``, uses the + algebraic closure. If ``False``, uses the smallest extension of the base field containing all the critical points. OUTPUT: real number @@ -4198,7 +4220,7 @@ def critical_height(self, **kwds): EXAMPLES:: sage: P. = ProjectiveSpace(QQ,1) - sage: f = DynamicalSystem_projective([x^3+7*y^3, 11*y^3]) + sage: f = DynamicalSystem_projective([x^3 + 7*y^3, 11*y^3]) sage: f.critical_height() 1.1989273321156851418802151128 @@ -4206,21 +4228,21 @@ def critical_height(self, **kwds): sage: K. = QuadraticField(2) sage: P. = ProjectiveSpace(K,1) - sage: f = DynamicalSystem_projective([x^2+w*y^2, y^2]) + sage: f = DynamicalSystem_projective([x^2 + w*y^2, y^2]) sage: f.critical_height() 0.16090842452312941163719755472 Postcritically finite maps have critical height 0:: sage: P. = ProjectiveSpace(QQ,1) - sage: f = DynamicalSystem_projective([x^3-3/4*x*y^2 + 3/4*y^3, y^3]) + sage: f = DynamicalSystem_projective([x^3 - 3/4*x*y^2 + 3/4*y^3, y^3]) sage: f.critical_height(error_bound=0.0001) 0.00000000000000000000000000000 :: sage: P. = ProjectiveSpace(QQ,1) - sage: f = DynamicalSystem_projective([x^3+3*x*y^2, y^3]) + sage: f = DynamicalSystem_projective([x^3 + 3*x*y^2, y^3]) sage: f.critical_height(use_algebraic_closure=False) 0.000023477016733897112886491967991 sage: f.critical_height() @@ -4375,7 +4397,8 @@ def preperiodic_points(self, m, n, **kwds): sage: P. = ProjectiveSpace(QQ, 2) sage: X = P.subscheme(2*x - y) - sage: f = DynamicalSystem_projective([x^2 - y^2, 2*(x^2 - y^2), y^2 - z^2], domain=X) + sage: f = DynamicalSystem_projective([x^2 - y^2, 2*(x^2 - y^2), y^2 - z^2], + ....: domain=X) sage: f.preperiodic_points(1, 1) [(-1/4 : -1/2 : 1), (1 : 2 : 1)] @@ -4401,7 +4424,8 @@ def preperiodic_points(self, m, n, **kwds): sage: P. = ProjectiveSpace(GF(5), 2) sage: f = DynamicalSystem_projective([x^2, x*y, z^2]) sage: f.preperiodic_points(2, 1, return_scheme=True, minimal=False) - Closed subscheme of Projective Space of dimension 2 over Finite Field of size 5 defined by: + Closed subscheme of + Projective Space of dimension 2 over Finite Field of size 5 defined by: 0, x^8*z^4 - x^4*z^8, x^7*y*z^4 - x^3*y*z^8 @@ -4432,7 +4456,7 @@ def preperiodic_points(self, m, n, **kwds): sage: f = DynamicalSystem_projective([x^2 + c*y^2, y^2]) sage: f.preperiodic_points(1, 2, return_scheme=True) Closed subscheme of Projective Space of dimension 1 over Univariate - Polynomial Ring in c over Rational Field defined by: + Polynomial Ring in c over Rational Field defined by: x^2 - x*y + (c + 1)*y^2 TESTS:: @@ -4460,7 +4484,7 @@ def preperiodic_points(self, m, n, **kwds): :: sage: P. = ProjectiveSpace(QQ, 2) - sage: f=DynamicalSystem([x^2 - z^2, y^2 - 21/16*z^2, z^2]) + sage: f = DynamicalSystem([x^2 - z^2, y^2 - 21/16*z^2, z^2]) sage: len(f.preperiodic_points(1, 2, minimal=True, formal=False)) == 16 True @@ -4471,7 +4495,8 @@ def preperiodic_points(self, m, n, **kwds): sage: f.preperiodic_points(2, 2) Traceback (most recent call last): ... - ValueError: dynamical system is not a morphism, cannot calculate minimal or formal preperiodic points + ValueError: dynamical system is not a morphism, + cannot calculate minimal or formal preperiodic points """ n = ZZ(n) m = ZZ(m) @@ -4757,7 +4782,8 @@ def periodic_points(self, n, minimal=True, formal=False, R=None, algorithm='vari sage: K. = NumberField(x^2 - x + 3) sage: P. = ProjectiveSpace(K, 2) sage: X = P.subscheme(2*x - y) - sage: f = DynamicalSystem_projective([x^2 - y^2, 2*(x^2 - y^2), y^2 - z^2], domain=X) + sage: f = DynamicalSystem_projective([x^2 - y^2, 2*(x^2 - y^2), y^2 - z^2], + ....: domain=X) sage: f.periodic_points(2) [(-1/5*u - 1/5 : -2/5*u - 2/5 : 1), (1/5*u - 2/5 : 2/5*u - 4/5 : 1)] @@ -5032,21 +5058,23 @@ def multiplier_spectra(self, n, formal=False, type='point', use_algebraic_closur :: sage: P. = ProjectiveSpace(QQ, 1) - sage: f = DynamicalSystem_projective([4608*x^10 - 2910096*x^9*y + 325988068*x^8*y^2 + 31825198932*x^7*y^3 - 4139806626613*x^6*y^4\ - - 44439736715486*x^5*y^5 + 2317935971590902*x^4*y^6 - 15344764859590852*x^3*y^7 + 2561851642765275*x^2*y^8\ - + 113578270285012470*x*y^9 - 150049940203963800*y^10, 4608*y^10]) + sage: f = DynamicalSystem_projective([4608*x^10 - 2910096*x^9*y + 325988068*x^8*y^2 + ....: + 31825198932*x^7*y^3 - 4139806626613*x^6*y^4 - 44439736715486*x^5*y^5 + ....: + 2317935971590902*x^4*y^6 - 15344764859590852*x^3*y^7 + ....: + 2561851642765275*x^2*y^8 + 113578270285012470*x*y^9 + ....: - 150049940203963800*y^10, 4608*y^10]) sage: sorted(f.multiplier_spectra(1)) [-119820502365680843999, - -7198147681176255644585/256, - -3086380435599991/9, - -3323781962860268721722583135/35184372088832, - -4290991994944936653/2097152, - 0, - 529278480109921/256, - 1061953534167447403/19683, - 848446157556848459363/19683, - 82911372672808161930567/8192, - 3553497751559301575157261317/8192] + -7198147681176255644585/256, + -3086380435599991/9, + -3323781962860268721722583135/35184372088832, + -4290991994944936653/2097152, + 0, + 529278480109921/256, + 1061953534167447403/19683, + 848446157556848459363/19683, + 82911372672808161930567/8192, + 3553497751559301575157261317/8192] :: @@ -5494,9 +5522,10 @@ def sigma_invariants(self, n, formal=False, embedding=None, type='point', sage: P. = ProjectiveSpace(QQ, 2) sage: f = DynamicalSystem_projective([x^2, z^2, y^2]) sage: f.sigma_invariants(1, chow=True) - [1, 7, -6, -12, 21, -36, -60, 72, 48, 35, -90, -120, 352, 96, -288, -64, 35, -120, -120, 688, -96, - -1056, 320, 384, 0, 21, -90, -60, 672, -384, -1440, 1344, 768, -768, 0, 0, 7, -36, -12, 328, -336, - -864, 1472, 384, -1536, 512, 0, 0, 0, 1, -6, 0, 64, -96, -192, 512, 0, -768, 512, 0, 0, 0, 0, 0] + [1, 7, -6, -12, 21, -36, -60, 72, 48, 35, -90, -120, 352, 96, -288, -64, 35, + -120, -120, 688, -96, -1056, 320, 384, 0, 21, -90, -60, 672, -384, -1440, 1344, + 768, -768, 0, 0, 7, -36, -12, 328, -336, -864, 1472, 384, -1536, 512, 0, 0, 0, + 1, -6, 0, 64, -96, -192, 512, 0, -768, 512, 0, 0, 0, 0, 0] When calculating the sigma invariants for `\mathbb{P}^N`, with `N > 1`, the default algorithm loses information about multiplicities. Note that @@ -5560,13 +5589,13 @@ def sigma_invariants(self, n, formal=False, embedding=None, type='point', :: sage: P. = ProjectiveSpace(QQ, 1) - sage: f = DynamicalSystem_projective([512*x^5 - 378128*x^4*y + 76594292*x^3*y^2 - 4570550136*x^2*y^3 - 2630045017*x*y^4\ - + 28193217129*y^5, 512*y^5]) + sage: f = DynamicalSystem_projective([512*x^5 - 378128*x^4*y + 76594292*x^3*y^2 + ....: - 4570550136*x^2*y^3 - 2630045017*x*y^4 + 28193217129*y^5, 512*y^5]) sage: f.sigma_invariants(1) [19575526074450617/1048576, -9078122048145044298567432325/2147483648, - -2622661114909099878224381377917540931367/1099511627776, - -2622661107937102104196133701280271632423/549755813888, - 338523204830161116503153209450763500631714178825448006778305/72057594037927936, 0] + -2622661114909099878224381377917540931367/1099511627776, + -2622661107937102104196133701280271632423/549755813888, + 338523204830161116503153209450763500631714178825448006778305/72057594037927936, 0] :: @@ -5979,15 +6008,15 @@ def reduced_form(self, **kwds): sage: f = DynamicalSystem_projective([x^3 + x*y^2, y^3]) sage: m = matrix(QQ, 2, 2, [-201221, -1, 1, 0]) sage: f = f.conjugate(m) - sage: f.reduced_form(prec=50, smallest_coeffs=False) #needs 2 periodic + sage: f.reduced_form(prec=50, smallest_coeffs=False) # needs 2 periodic Traceback (most recent call last): ... - ValueError: accuracy of Newton's root not within tolerance(0.000066... > 1e-06), increase precision + ValueError: accuracy of Newton's root not within tolerance(0.000066... > 1e-06), + increase precision sage: f.reduced_form(smallest_coeffs=False) ( Dynamical System of Projective Space of dimension 1 over Rational Field - Defn: Defined on coordinates by sending (x : y) to - (x^3 + x*y^2 : y^3) + Defn: Defined on coordinates by sending (x : y) to (x^3 + x*y^2 : y^3) , [ 0 -1] @@ -5997,14 +6026,13 @@ def reduced_form(self, **kwds): :: sage: PS. = ProjectiveSpace(ZZ, 1) - sage: f = DynamicalSystem_projective([x^2+ x*y, y^2]) #needs 3 periodic + sage: f = DynamicalSystem_projective([x^2 + x*y, y^2]) # needs 3 periodic sage: m = matrix(QQ, 2, 2, [-221, -1, 1, 0]) sage: f = f.conjugate(m) sage: f.reduced_form(prec=200, smallest_coeffs=False) ( Dynamical System of Projective Space of dimension 1 over Integer Ring - Defn: Defined on coordinates by sending (x : y) to - (-x^2 + x*y - y^2 : -y^2) + Defn: Defined on coordinates by sending (x : y) to (-x^2 + x*y - y^2 : -y^2) , [ 0 -1] [ 1 220] @@ -6017,8 +6045,7 @@ def reduced_form(self, **kwds): sage: f.reduced_form(smallest_coeffs=False) ( Dynamical System of Projective Space of dimension 1 over Rational Field - Defn: Defined on coordinates by sending (x : y) to - (x^3 : y^3) + Defn: Defined on coordinates by sending (x : y) to (x^3 : y^3) , [1 0] @@ -6028,8 +6055,10 @@ def reduced_form(self, **kwds): :: sage: PS. = ProjectiveSpace(QQ,1) - sage: f = DynamicalSystem_projective([7365*X^4 + 12564*X^3*Y + 8046*X^2*Y^2 + 2292*X*Y^3 + 245*Y^4,\ - -12329*X^4 - 21012*X^3*Y - 13446*X^2*Y^2 - 3828*X*Y^3 - 409*Y^4]) + sage: f = DynamicalSystem_projective([7365*X^4 + 12564*X^3*Y + 8046*X^2*Y^2 + ....: + 2292*X*Y^3 + 245*Y^4, + ....: -12329*X^4 - 21012*X^3*Y - 13446*X^2*Y^2 + ....: - 3828*X*Y^3 - 409*Y^4]) sage: f.reduced_form(prec=30, smallest_coeffs=False) Traceback (most recent call last): ... @@ -6038,7 +6067,8 @@ def reduced_form(self, **kwds): ( Dynamical System of Projective Space of dimension 1 over Rational Field Defn: Defined on coordinates by sending (X : Y) to - (-7*X^4 - 12*X^3*Y - 42*X^2*Y^2 - 12*X*Y^3 - 7*Y^4 : -X^4 - 4*X^3*Y - 6*X^2*Y^2 - 4*X*Y^3 - Y^4), + (-7*X^4 - 12*X^3*Y - 42*X^2*Y^2 - 12*X*Y^3 - 7*Y^4 + : -X^4 - 4*X^3*Y - 6*X^2*Y^2 - 4*X*Y^3 - Y^4), [-1 2] [ 2 -5] @@ -6073,9 +6103,9 @@ def reduced_form(self, **kwds): sage: f = f.conjugate(m) sage: f.reduced_form(smallest_coeffs=False) ( - Dynamical System of Projective Space of dimension 1 over Number Field in w with defining polynomial x^2 - 2 with w = 1.414213562373095? - Defn: Defined on coordinates by sending (x : y) to - (x^3 : w*y^3) , + Dynamical System of Projective Space of dimension 1 over Number Field in w + with defining polynomial x^2 - 2 with w = 1.414213562373095? + Defn: Defined on coordinates by sending (x : y) to (x^3 : w*y^3) , [ 1 -12] [ 0 1] @@ -6084,16 +6114,18 @@ def reduced_form(self, **kwds): :: sage: R. = QQ[] - sage: K. = NumberField(x^5+x-3, embedding=(x^5+x-3).roots(ring=CC)[0][0]) + sage: K. = NumberField(x^5 + x - 3, + ....: embedding=(x^5 + x - 3).roots(ring=CC)[0][0]) sage: P. = ProjectiveSpace(K, 1) sage: f = DynamicalSystem_projective([12*x^3, 2334*w*y^3]) sage: m = matrix(K, 2, 2, [-12,1,1,0]) sage: f = f.conjugate(m) sage: f.reduced_form(smallest_coeffs=False) ( - Dynamical System of Projective Space of dimension 1 over Number Field in w with defining polynomial x^5 + x - 3 with w = 1.132997565885066? + Dynamical System of Projective Space of dimension 1 over Number Field in w + with defining polynomial x^5 + x - 3 with w = 1.132997565885066? Defn: Defined on coordinates by sending (x : y) to - (12*x^3 : (2334*w)*y^3) , + (12*x^3 : (2334*w)*y^3) , [ 0 -1] [ 1 -12] @@ -6148,7 +6180,7 @@ def reduced_form(self, **kwds): sage: P. = QQ[] sage: f = DynamicalSystem([4*x^2 + y^2, 4*y^2]) - sage: f.reduced_form() #long time + sage: f.reduced_form() # long time ( Dynamical System of Projective Space of dimension 1 over Rational Field Defn: Defined on coordinates by sending (x : y) to @@ -6268,7 +6300,7 @@ def _is_preperiodic(self, P, err=0.1, return_period=False): EXAMPLES:: sage: P. = ProjectiveSpace(QQ,1) - sage: f = DynamicalSystem_projective([x^3-3*x*y^2, y^3], domain=P) + sage: f = DynamicalSystem_projective([x^3 - 3*x*y^2, y^3], domain=P) sage: Q = P(-1, 1) sage: f._is_preperiodic(Q) True @@ -6278,7 +6310,7 @@ def _is_preperiodic(self, P, err=0.1, return_period=False): sage: R. = PolynomialRing(QQ) sage: K. = NumberField(X^2 + X - 1) sage: P. = ProjectiveSpace(K,1) - sage: f = DynamicalSystem_projective([x^2-2*y^2, y^2]) + sage: f = DynamicalSystem_projective([x^2 - 2*y^2, y^2]) sage: Q = P.point([a,1]) sage: Q.is_preperiodic(f) True @@ -6494,7 +6526,7 @@ def lift_to_rational_periodic(self, points_modp, B=None): There may be multiple points in the lift. sage: P. = ProjectiveSpace(QQ,1) sage: f = DynamicalSystem_projective([-5*x^2 + 4*y^2, 4*x*y]) - sage: f.lift_to_rational_periodic([[P(1,0).change_ring(GF(3)), 1]]) # long time + sage: f.lift_to_rational_periodic([[P(1,0).change_ring(GF(3)), 1]]) # long time [[(1 : 0), 1], [(2/3 : 1), 1], [(-2/3 : 1), 1]] :: @@ -6507,8 +6539,11 @@ def lift_to_rational_periodic(self, points_modp, B=None): :: sage: P. = ProjectiveSpace(QQ, 2) - sage: f = DynamicalSystem_projective([76*x^2 - 180*x*y + 45*y^2 + 14*x*z + 45*y*z - 90*z^2, 67*x^2 - 180*x*y - 157*x*z + 90*y*z, -90*z^2]) - sage: f.lift_to_rational_periodic([[P(14,19,1).change_ring(GF(23)), 9]]) # long time + sage: f = DynamicalSystem_projective([76*x^2 - 180*x*y + 45*y^2 + ....: + 14*x*z + 45*y*z - 90*z^2, + ....: 67*x^2 - 180*x*y - 157*x*z + 90*y*z, + ....: -90*z^2]) + sage: f.lift_to_rational_periodic([[P(14,19,1).change_ring(GF(23)), 9]]) # long time [[(-9 : -4 : 1), 9]] """ if not points_modp: @@ -6721,8 +6756,8 @@ def all_periodic_points(self, **kwds): EXAMPLES:: sage: P. = ProjectiveSpace(QQ,1) - sage: f = DynamicalSystem_projective([x^2-3/4*y^2, y^2]) - sage: sorted(f.all_periodic_points(prime_bound=20, lifting_prime=7)) # long time + sage: f = DynamicalSystem_projective([x^2 - 3/4*y^2, y^2]) + sage: sorted(f.all_periodic_points(prime_bound=20, lifting_prime=7)) # long time [(-1/2 : 1), (1 : 0), (3/2 : 1)] :: @@ -6741,28 +6776,29 @@ def all_periodic_points(self, **kwds): sage: P. = ProjectiveSpace(QQ,1) sage: f = DynamicalSystem_projective([-5*x^2 + 4*y^2, 4*x*y]) - sage: sorted(f.all_periodic_points()) # long time + sage: sorted(f.all_periodic_points()) # long time [(-2 : 1), (-2/3 : 1), (2/3 : 1), (1 : 0), (2 : 1)] :: sage: R. = QQ[] - sage: K. = NumberField(x^2-x+1) + sage: K. = NumberField(x^2 - x + 1) sage: P. = ProjectiveSpace(K,1) - sage: f = DynamicalSystem_projective([u^2 + v^2,v^2]) + sage: f = DynamicalSystem_projective([u^2 + v^2, v^2]) sage: sorted(f.all_periodic_points()) [(-w + 1 : 1), (w : 1), (1 : 0)] :: sage: R. = QQ[] - sage: K. = NumberField(x^2-x+1) + sage: K. = NumberField(x^2 - x + 1) sage: P. = ProjectiveSpace(K,1) - sage: f = DynamicalSystem_projective([u^2+v^2,u*v]) + sage: f = DynamicalSystem_projective([u^2 + v^2, u*v]) sage: f.all_periodic_points() Traceback (most recent call last): ... - NotImplementedError: rational periodic points for number fields only implemented for polynomials + NotImplementedError: rational periodic points for number fields + only implemented for polynomials :: @@ -6776,7 +6812,8 @@ def all_periodic_points(self, **kwds): :: sage: P. = ProjectiveSpace(QQ, 3) - sage: f = DynamicalSystem_projective([x^2 - (3/4)*w^2, y^2 - 3/4*w^2, z^2 - 3/4*w^2, w^2]) + sage: f = DynamicalSystem_projective([x^2 - (3/4)*w^2, y^2 - 3/4*w^2, + ....: z^2 - 3/4*w^2, w^2]) sage: sorted(f.all_periodic_points(algorithm="dynatomic")) [(-1/2 : -1/2 : -1/2 : 1), (-1/2 : -1/2 : 3/2 : 1), @@ -6804,7 +6841,7 @@ def all_periodic_points(self, **kwds): TESTS:: sage: P. = ProjectiveSpace(QQ, 1) - sage: f = DynamicalSystem([x^2+ y^2, x*y]) + sage: f = DynamicalSystem([x^2 + y^2, x*y]) sage: f.all_periodic_points(algorithm="banana") Traceback (most recent call last): ... @@ -6934,7 +6971,7 @@ def all_rational_preimages(self, points): In others words, all the rational points which have some iterate in the set points. This function repeatedly calls - ``rational_preimages``. If the degree is at least two, + :meth:`rational_preimages`. If the degree is at least two, by Northocott, this is always a finite set. The map must be defined over number fields and be an endomorphism. @@ -6950,12 +6987,15 @@ def all_rational_preimages(self, points): sage: f = DynamicalSystem_projective([16*x^2 - 29*y^2, 16*y^2]) sage: sorted(f.all_rational_preimages([P(-1,4)])) [(-7/4 : 1), (-5/4 : 1), (-3/4 : 1), (-1/4 : 1), (1/4 : 1), (3/4 : 1), - (5/4 : 1), (7/4 : 1)] + (5/4 : 1), (7/4 : 1)] :: sage: P. = ProjectiveSpace(QQ,2) - sage: f = DynamicalSystem_projective([76*x^2 - 180*x*y + 45*y^2 + 14*x*z + 45*y*z - 90*z^2, 67*x^2 - 180*x*y - 157*x*z + 90*y*z, -90*z^2]) + sage: f = DynamicalSystem_projective([76*x^2 - 180*x*y + 45*y^2 + 14*x*z + ....: + 45*y*z - 90*z^2, + ....: 67*x^2 - 180*x*y - 157*x*z + 90*y*z, + ....: -90*z^2]) sage: sorted(f.all_rational_preimages([P(-9,-4,1)])) [(-9 : -4 : 1), (0 : -1 : 1), (0 : 0 : 1), (0 : 1 : 1), (0 : 4 : 1), (1 : 0 : 1), (1 : 1 : 1), (1 : 2 : 1), (1 : 3 : 1)] @@ -6970,10 +7010,10 @@ def all_rational_preimages(self, points): A number field example:: sage: z = QQ['z'].0 - sage: K. = NumberField(z^3 + (z^2)/4 - (41/16)*z + 23/64); + sage: K. = NumberField(z^3 + (z^2)/4 - (41/16)*z + 23/64) sage: P. = ProjectiveSpace(K,1) sage: f = DynamicalSystem_projective([16*x^2 - 29*y^2, 16*y^2]) - sage: sorted(f.all_rational_preimages([P(16*w^2 - 29,16)]), key=str) + sage: sorted(f.all_rational_preimages([P(16*w^2 - 29, 16)]), key=str) [(-w - 1/2 : 1), (-w : 1), (-w^2 + 21/16 : 1), @@ -6991,7 +7031,7 @@ def all_rational_preimages(self, points): sage: K. = QuadraticField(3) sage: P. = ProjectiveSpace(K,1) - sage: f = DynamicalSystem_projective([u^2+v^2, v^2]) + sage: f = DynamicalSystem_projective([u^2 + v^2, v^2]) sage: f.all_rational_preimages(P(4)) [(-w : 1), (w : 1)] """ @@ -7070,10 +7110,9 @@ def all_preperiodic_points(self, **kwds): EXAMPLES:: sage: PS. = ProjectiveSpace(1,QQ) - sage: f = DynamicalSystem_projective([x^2 -y^2, 3*x*y]) + sage: f = DynamicalSystem_projective([x^2 - y^2, 3*x*y]) sage: sorted(f.all_preperiodic_points()) - [(-2 : 1), (-1 : 1), (-1/2 : 1), (0 : 1), (1/2 : 1), (1 : 0), (1 : 1), - (2 : 1)] + [(-2 : 1), (-1 : 1), (-1/2 : 1), (0 : 1), (1/2 : 1), (1 : 0), (1 : 1), (2 : 1)] :: @@ -7085,20 +7124,20 @@ def all_preperiodic_points(self, **kwds): :: sage: PS. = ProjectiveSpace(2,QQ) - sage: f = DynamicalSystem_projective([x^2 - 21/16*z^2, y^2-2*z^2, z^2]) - sage: sorted(f.all_preperiodic_points(prime_bound=[1,8], lifting_prime=7, periods=[2])) # long time - [(-5/4 : -2 : 1), (-5/4 : -1 : 1), (-5/4 : 0 : 1), (-5/4 : 1 : 1), (-5/4 - : 2 : 1), (-1/4 : -2 : 1), (-1/4 : -1 : 1), (-1/4 : 0 : 1), (-1/4 : 1 : - 1), (-1/4 : 2 : 1), (1/4 : -2 : 1), (1/4 : -1 : 1), (1/4 : 0 : 1), (1/4 - : 1 : 1), (1/4 : 2 : 1), (5/4 : -2 : 1), (5/4 : -1 : 1), (5/4 : 0 : 1), - (5/4 : 1 : 1), (5/4 : 2 : 1)] + sage: f = DynamicalSystem_projective([x^2 - 21/16*z^2, y^2 - 2*z^2, z^2]) + sage: sorted(f.all_preperiodic_points(prime_bound=[1,8], # long time + ....: lifting_prime=7, periods=[2])) + [(-5/4 : -2 : 1), (-5/4 : -1 : 1), (-5/4 : 0 : 1), (-5/4 : 1 : 1), (-5/4 : 2 : 1), + (-1/4 : -2 : 1), (-1/4 : -1 : 1), (-1/4 : 0 : 1), (-1/4 : 1 : 1), (-1/4 : 2 : 1), + (1/4 : -2 : 1), (1/4 : -1 : 1), (1/4 : 0 : 1), (1/4 : 1 : 1), (1/4 : 2 : 1), + (5/4 : -2 : 1), (5/4 : -1 : 1), (5/4 : 0 : 1), (5/4 : 1 : 1), (5/4 : 2 : 1)] :: sage: K. = QuadraticField(33) sage: PS. = ProjectiveSpace(K,1) - sage: f = DynamicalSystem_projective([x^2-71/48*y^2, y^2]) - sage: sorted(f.all_preperiodic_points()) # long time + sage: f = DynamicalSystem_projective([x^2 - 71/48*y^2, y^2]) + sage: sorted(f.all_preperiodic_points()) # long time [(-1/12*w - 1 : 1), (-1/6*w - 1/4 : 1), (-1/12*w - 1/2 : 1), @@ -7239,7 +7278,7 @@ def rational_preperiodic_graph(self, **kwds): :: sage: PS. = ProjectiveSpace(1,QQ) - sage: f = DynamicalSystem_projective([-3/2*x^3 +19/6*x*y^2, y^3]) + sage: f = DynamicalSystem_projective([-3/2*x^3 + 19/6*x*y^2, y^3]) sage: f.rational_preperiodic_graph(prime_bound=[1,8]) Looped digraph on 12 vertices @@ -7248,15 +7287,16 @@ def rational_preperiodic_graph(self, **kwds): sage: PS. = ProjectiveSpace(2,QQ) sage: f = DynamicalSystem_projective([2*x^3 - 50*x*z^2 + 24*z^3, ....: 5*y^3 - 53*y*z^2 + 24*z^3, 24*z^3]) - sage: f.rational_preperiodic_graph(prime_bound=[1,11], lifting_prime=13) # long time + sage: f.rational_preperiodic_graph(prime_bound=[1,11], # long time + ....: lifting_prime=13) Looped digraph on 30 vertices :: sage: K. = QuadraticField(-3) sage: P. = ProjectiveSpace(K,1) - sage: f = DynamicalSystem_projective([x^2+y^2, y^2]) - sage: f.rational_preperiodic_graph() # long time + sage: f = DynamicalSystem_projective([x^2 + y^2, y^2]) + sage: f.rational_preperiodic_graph() # long time Looped digraph on 5 vertices """ #input checking done in .rational_preperiodic_points() @@ -7286,7 +7326,7 @@ def connected_rational_component(self, P, n=0): EXAMPLES:: sage: R. = PolynomialRing(QQ) - sage: K. = NumberField(x^3+1/4*x^2-41/16*x+23/64) + sage: K. = NumberField(x^3 + 1/4*x^2 - 41/16*x + 23/64) sage: PS. = ProjectiveSpace(1,K) sage: f = DynamicalSystem_projective([x^2 - 29/16*y^2, y^2]) sage: P = PS([w,1]) @@ -7307,9 +7347,9 @@ def connected_rational_component(self, P, n=0): :: sage: PS. = ProjectiveSpace(2,QQ) - sage: f = DynamicalSystem_projective([x^2 - 21/16*z^2, y^2-2*z^2, z^2]) - sage: P = PS([17/16,7/4,1]) - sage: f.connected_rational_component(P,3) + sage: f = DynamicalSystem_projective([x^2 - 21/16*z^2, y^2 - 2*z^2, z^2]) + sage: P = PS([17/16, 7/4, 1]) + sage: f.connected_rational_component(P, 3) [(17/16 : 7/4 : 1), (-47/256 : 17/16 : 1), (-83807/65536 : -223/256 : 1), @@ -7463,7 +7503,8 @@ def conjugating_set(self, other, R=None, num_cpus=2): sage: D8.conjugating_set(D8) Traceback (most recent call last): ... - ValueError: no more rational preimages; try extending the base field and trying again + ValueError: no more rational preimages; + try extending the base field and trying again :: @@ -7508,7 +7549,7 @@ def conjugating_set(self, other, R=None, num_cpus=2): note that only one possible conjugation is returned:: sage: P. = ProjectiveSpace(GF(11), 2) - sage: f = DynamicalSystem_projective([2*x + 12*y, 11*y+2*z, x+z]) + sage: f = DynamicalSystem_projective([2*x + 12*y, 11*y + 2*z, x + z]) sage: m1 = matrix(GF(11), 3, 3, [1,4,1,0,2,1,1,1,1]) sage: g = f.conjugate(m1) sage: f.conjugating_set(g) @@ -7522,7 +7563,7 @@ def conjugating_set(self, other, R=None, num_cpus=2): sage: L. = CyclotomicField(8) sage: P. = ProjectiveSpace(L, 2) - sage: f = DynamicalSystem_projective([2*x + 12*y, 11*y+2*z, x+z]) + sage: f = DynamicalSystem_projective([2*x + 12*y, 11*y + 2*z, x + z]) sage: m1 = matrix(L, 3, 3, [1,4,v^2,0,2,1,1,1,1]) sage: g = f.conjugate(m1) sage: m = f.conjugating_set(g)[0] # long time @@ -7717,7 +7758,7 @@ def is_conjugate(self, other, R=None, num_cpus=2): sage: f.is_conjugate(g) True - conjugation is only checked over the base field by default:: + Conjugation is only checked over the base field by default:: sage: P. = ProjectiveSpace(QQ, 1) sage: f = DynamicalSystem_projective([-3*y^2, 3*x^2]) @@ -7728,7 +7769,7 @@ def is_conjugate(self, other, R=None, num_cpus=2): :: sage: P. = ProjectiveSpace(QQ, 2) - sage: f = DynamicalSystem_projective([7*x + 12*y, 8*y+2*z, x+z]) + sage: f = DynamicalSystem_projective([7*x + 12*y, 8*y + 2*z, x + z]) sage: m1 = matrix(QQ, 3, 3, [1,4,1,0,2,1,1,1,1]) sage: g = f.conjugate(m1) sage: f.is_conjugate(g) @@ -7737,7 +7778,7 @@ def is_conjugate(self, other, R=None, num_cpus=2): :: sage: P. = ProjectiveSpace(GF(7), 2) - sage: f = DynamicalSystem_projective([2*x + 12*y, 11*y+2*z, x+z]) + sage: f = DynamicalSystem_projective([2*x + 12*y, 11*y + 2*z, x + z]) sage: m1 = matrix(GF(7), 3, 3, [1,4,1,0,2,1,1,1,1]) sage: g = f.conjugate(m1) sage: f.is_conjugate(g) @@ -7746,7 +7787,7 @@ def is_conjugate(self, other, R=None, num_cpus=2): :: sage: P. = ProjectiveSpace(QQ, 2) - sage: f = DynamicalSystem_projective([2*x^2 + 12*y*x, 11*y*x+2*y^2, x^2+z^2]) + sage: f = DynamicalSystem_projective([2*x^2 + 12*y*x, 11*y*x + 2*y^2, x^2 + z^2]) sage: m1 = matrix(QQ, 3, 3, [1,4,1,0,2,1,1,1,1]) sage: g = f.conjugate(m1) sage: f.is_conjugate(g) @@ -7848,7 +7889,7 @@ def is_polynomial(self): sage: K. = QuadraticField(4/27) sage: P. = ProjectiveSpace(K,1) - sage: f = DynamicalSystem_projective([x**3 + w*y^3,x*y**2]) + sage: f = DynamicalSystem_projective([x**3 + w*y^3, x*y**2]) sage: f.is_polynomial() False @@ -7863,7 +7904,7 @@ def is_polynomial(self): :: sage: PS. = ProjectiveSpace(QQ, 1) - sage: f = DynamicalSystem_projective([6*x^2+12*x*y+7*y^2, 12*x*y + 42*y^2]) + sage: f = DynamicalSystem_projective([6*x^2 + 12*x*y + 7*y^2, 12*x*y + 42*y^2]) sage: f.is_polynomial() False @@ -7872,7 +7913,7 @@ def is_polynomial(self): See :trac:`25242`:: sage: P. = ProjectiveSpace(QQ, 1) - sage: F = DynamicalSystem([x^2+ y^2, x*y]) + sage: F = DynamicalSystem([x^2 + y^2, x*y]) sage: F2 = F.conjugate(matrix(QQ,2,2, [1,2,3,5])) sage: F2.is_polynomial() False @@ -7996,13 +8037,14 @@ def normal_form(self, return_conjugation=False): :: - sage: K = GF(3^3, prefix = 'w') + sage: K = GF(3^3, prefix='w') sage: P. = ProjectiveSpace(K,1) sage: f = DynamicalSystem_projective([x^3 + 2*x^2*y + 2*x*y^2 + K.gen()*y^3, y^3]) sage: f.normal_form() - Dynamical System of Projective Space of dimension 1 over Finite Field in w3 of size 3^3 - Defn: Defined on coordinates by sending (x : y) to - (x^3 + x^2*y + x*y^2 + (-w3)*y^3 : y^3) + Dynamical System of Projective Space of dimension 1 + over Finite Field in w3 of size 3^3 + Defn: Defined on coordinates by sending (x : y) to + (x^3 + x^2*y + x*y^2 + (-w3)*y^3 : y^3) :: @@ -8165,24 +8207,26 @@ def potential_good_reduction(self, prime, return_conjugation=False): A tuple: - The first element is: - - ``False`` if this dynamical system does not have potential good reduction. - - ``True`` if this dynamical system does have potential good reduction. + - ``False`` if this dynamical system does not have potential good reduction. + - ``True`` if this dynamical system does have potential good reduction. + - The second element is: - - ``None`` if this dynamical system does not have potential good reduction. - - A dynamical system with good reduction at ``prime`` otherwise. + - ``None`` if this dynamical system does not have potential good reduction. + - A dynamical system with good reduction at ``prime`` otherwise. + - If ``return_conjugation`` is ``True``, then the tuple will have a third element, which is: - - ``None`` if this dynamical system does not have potential good reduction. - - The `PGL_2` map used to achieve good reduction otherwise. + - ``None`` if this dynamical system does not have potential good reduction. + - The `PGL_2` map used to achieve good reduction otherwise. EXAMPLES:: sage: P. = ProjectiveSpace(QQ, 1) - sage: system = DynamicalSystem_projective([x^2-y^2, 2*x*y]) + sage: system = DynamicalSystem_projective([x^2 - y^2, 2*x*y]) sage: prime = system.field_of_definition_periodic(1).prime_above(2) sage: new_system = system.potential_good_reduction(prime)[1] sage: new_system Dynamical System of Projective Space of dimension 1 over Number Field - in a with defining polynomial x^2 + 1 + in a with defining polynomial x^2 + 1 Defn: Defined on coordinates by sending (x : y) to ((-1/2*a)*x^2 + (-5/2*a)*y^2 : (-a)*x*y + y^2) @@ -8205,7 +8249,7 @@ def potential_good_reduction(self, prime, return_conjugation=False): :: sage: P. = ProjectiveSpace(QQ, 1) - sage: system = DynamicalSystem_projective([3^4*x^3+3*x*y^2+y^3, 3^6*y^3]) + sage: system = DynamicalSystem_projective([3^4*x^3 + 3*x*y^2 + y^3, 3^6*y^3]) sage: prime = system.field_of_definition_periodic(1).prime_above(3) sage: system.potential_good_reduction(prime) (False, None) @@ -8213,7 +8257,7 @@ def potential_good_reduction(self, prime, return_conjugation=False): :: sage: P. = ProjectiveSpace(QQ, 1) - sage: system = DynamicalSystem_projective([x^5-x*y^4, 5*y^5]) + sage: system = DynamicalSystem_projective([x^5 - x*y^4, 5*y^5]) sage: prime = system.field_of_definition_periodic(1).prime_above(5) sage: system.potential_good_reduction(prime) (False, None) @@ -8227,15 +8271,16 @@ def potential_good_reduction(self, prime, return_conjugation=False): sage: system = DynamicalSystem_projective([x^2 - y^2, 2*x*y]) sage: system.potential_good_reduction(prime) (True, - Dynamical System of Projective Space of dimension 1 over - Number Field in a with defining polynomial x^2 + 1 - Defn: Defined on coordinates by sending (x : y) to - ((-1/2*a)*x^2 + (-5/2*a)*y^2 : (-a)*x*y + y^2)) + Dynamical System of Projective Space of dimension 1 over + Number Field in a with defining polynomial x^2 + 1 + Defn: Defined on coordinates by sending (x : y) to + ((-1/2*a)*x^2 + (-5/2*a)*y^2 : (-a)*x*y + y^2)) :: sage: P. = ProjectiveSpace(QQ, 1) - sage: system = DynamicalSystem_projective([3^5*x^3 + x^2*y - 3^5*x*y^2, -3^5*x^2*y + x*y^2 + 3^5*y^3]) + sage: system = DynamicalSystem_projective([3^5*x^3 + x^2*y - 3^5*x*y^2, + ....: -3^5*x^2*y + x*y^2 + 3^5*y^3]) sage: system.potential_good_reduction(3, return_conjugation=True) # long time (False, None, None) @@ -8252,7 +8297,7 @@ def potential_good_reduction(self, prime, return_conjugation=False): :: sage: P. = ProjectiveSpace(QQ, 1) - sage: system = DynamicalSystem_projective([3*x^2 + x*y+y^2, 9*y^2]) + sage: system = DynamicalSystem_projective([3*x^2 + x*y + y^2, 9*y^2]) sage: prime = system.field_of_definition_periodic(1).prime_above(3) sage: system.potential_good_reduction(prime) (False, None) @@ -8359,20 +8404,22 @@ def reduce_base_field(self): :: sage: P. = ProjectiveSpace(QQbar, 2) - sage: f = DynamicalSystem_projective([x^2 + QQbar(sqrt(3))*y^2, y^2, QQbar(sqrt(2))*z^2]) + sage: f = DynamicalSystem_projective([x^2 + QQbar(sqrt(3))*y^2, + ....: y^2, QQbar(sqrt(2))*z^2]) sage: f.reduce_base_field() Dynamical System of Projective Space of dimension 2 over Number Field in a with - defining polynomial y^4 - 4*y^2 + 1 with a = -0.5176380902050415? + defining polynomial y^4 - 4*y^2 + 1 with a = -0.5176380902050415? Defn: Defined on coordinates by sending (x : y : z) to (x^2 + (-a^2 + 2)*y^2 : y^2 : (a^3 - 3*a)*z^2) :: sage: R. = QQ[] - sage: K. = NumberField(x^3-2, embedding=(x^3-2).roots(ring=CC)[0][0]) + sage: K. = NumberField(x^3 - 2, embedding=(x^3 - 2).roots(ring=CC)[0][0]) sage: R. = QQ[] - sage: L. = NumberField(x^6 + 9*x^4 - 4*x^3 + 27*x^2 + 36*x + 31, \ - ....: embedding=(x^6 + 9*x^4 - 4*x^3 + 27*x^2 + 36*x + 31).roots(ring=CC)[0][0]) + sage: L. = NumberField(x^6 + 9*x^4 - 4*x^3 + 27*x^2 + 36*x + 31, + ....: embedding=(x^6 + 9*x^4 - 4*x^3 + ....: + 27*x^2 + 36*x + 31).roots(ring=CC)[0][0]) sage: P. = ProjectiveSpace(L,1) sage: f = DynamicalSystem([L(v)*x^2 + y^2, x*y]) sage: f.reduce_base_field().base_ring().is_isomorphic(K) @@ -8420,7 +8467,7 @@ def is_newton(self, return_conjugation=False): sage: F = f.homogenize(1) sage: F.is_newton(return_conjugation=True) ( - [1 0] + [1 0] True, [0 1] ) @@ -8510,7 +8557,7 @@ def is_postcritically_finite(self, **kwds): EXAMPLES:: sage: P. = ProjectiveSpace(GF(5),2) - sage: f = DynamicalSystem_projective([x^2 + y^2,y^2, z^2 + y*z], domain=P) + sage: f = DynamicalSystem_projective([x^2 + y^2, y^2, z^2 + y*z], domain=P) sage: f.is_postcritically_finite() True @@ -8541,14 +8588,14 @@ def _is_preperiodic(self, P, **kwds): EXAMPLES:: sage: P. = ProjectiveSpace(GF(5),2) - sage: f = DynamicalSystem_projective([x^2 + y^2,y^2, z^2 + y*z], domain=P) + sage: f = DynamicalSystem_projective([x^2 + y^2, y^2, z^2 + y*z], domain=P) sage: f._is_preperiodic(P(2,1,2)) True :: sage: P. = ProjectiveSpace(GF(5),2) - sage: f = DynamicalSystem_projective([x^2 + y^2,y^2, z^2 + y*z], domain=P) + sage: f = DynamicalSystem_projective([x^2 + y^2, y^2, z^2 + y*z], domain=P) sage: f._is_preperiodic(P(2,1,2), return_period=True) (0, 6) """ @@ -8575,14 +8622,14 @@ def orbit_structure(self, P): EXAMPLES:: sage: P. = ProjectiveSpace(GF(5),2) - sage: f = DynamicalSystem_projective([x^2 + y^2,y^2, z^2 + y*z], domain=P) + sage: f = DynamicalSystem_projective([x^2 + y^2, y^2, z^2 + y*z], domain=P) sage: f.orbit_structure(P(2,1,2)) (0, 6) :: sage: P. = ProjectiveSpace(GF(7),2) - sage: X = P.subscheme(x^2-y^2) + sage: X = P.subscheme(x^2 - y^2) sage: f = DynamicalSystem_projective([x^2, y^2, z^2], domain=X) sage: f.orbit_structure(X(1,1,2)) (0, 2) @@ -8628,21 +8675,21 @@ def cyclegraph(self): EXAMPLES:: sage: P. = ProjectiveSpace(GF(13),1) - sage: f = DynamicalSystem_projective([x^2-y^2, y^2]) + sage: f = DynamicalSystem_projective([x^2 - y^2, y^2]) sage: f.cyclegraph() Looped digraph on 14 vertices :: sage: P. = ProjectiveSpace(GF(3^2,'t'),2) - sage: f = DynamicalSystem_projective([x^2+y^2, y^2, z^2+y*z]) + sage: f = DynamicalSystem_projective([x^2 + y^2, y^2, z^2 + y*z]) sage: f.cyclegraph() Looped digraph on 91 vertices :: sage: P. = ProjectiveSpace(GF(7),2) - sage: X = P.subscheme(x^2-y^2) + sage: X = P.subscheme(x^2 - y^2) sage: f = DynamicalSystem_projective([x^2, y^2, z^2], domain=X) sage: f.cyclegraph() Looped digraph on 15 vertices @@ -8650,15 +8697,15 @@ def cyclegraph(self): :: sage: P. = ProjectiveSpace(GF(3),2) - sage: f = DynamicalSystem_projective([x*z-y^2, x^2-y^2, y^2-z^2]) + sage: f = DynamicalSystem_projective([x*z - y^2, x^2 - y^2, y^2 - z^2]) sage: f.cyclegraph() Looped digraph on 13 vertices :: sage: P. = ProjectiveSpace(GF(3),2) - sage: X = P.subscheme([x-y]) - sage: f = DynamicalSystem_projective([x^2-y^2, x^2-y^2, y^2-z^2], domain=X) + sage: X = P.subscheme([x - y]) + sage: f = DynamicalSystem_projective([x^2 - y^2, x^2 - y^2, y^2 - z^2], domain=X) sage: f.cyclegraph() Looped digraph on 4 vertices """ @@ -8720,7 +8767,7 @@ def possible_periods(self, return_points=False): :: sage: P. = ProjectiveSpace(GF(13),1) - sage: f = DynamicalSystem_projective([x^2-y^2, y^2]) + sage: f = DynamicalSystem_projective([x^2 - y^2, y^2]) sage: sorted(f.possible_periods(True)) [[(0 : 1), 2], [(1 : 0), 1], [(3 : 1), 3], [(3 : 1), 36]] @@ -8784,7 +8831,7 @@ def automorphism_group(self, **kwds): EXAMPLES:: sage: R. = ProjectiveSpace(GF(7^3,'t'),1) - sage: f = DynamicalSystem_projective([x^2-y^2, x*y]) + sage: f = DynamicalSystem_projective([x^2 - y^2, x*y]) sage: f.automorphism_group() [ [1 0] [6 0] @@ -8794,9 +8841,10 @@ def automorphism_group(self, **kwds): :: sage: R. = ProjectiveSpace(GF(3^2,'t'),1) - sage: f = DynamicalSystem_projective([x^3,y^3]) - sage: lst, label = f.automorphism_group(return_functions=True, iso_type=True) # long time - sage: sorted(lst, key=str), label # long time + sage: f = DynamicalSystem_projective([x^3, y^3]) + sage: lst, label = f.automorphism_group(return_functions=True, # long time + ....: iso_type=True) + sage: sorted(lst, key=str), label # long time ([(2*x + 1)/(x + 1), (2*x + 1)/x, (2*x + 2)/(x + 2), @@ -8826,14 +8874,14 @@ def automorphism_group(self, **kwds): :: sage: R. = ProjectiveSpace(GF(2^5,'t'),1) - sage: f = DynamicalSystem_projective([x^5,y^5]) + sage: f = DynamicalSystem_projective([x^5, y^5]) sage: f.automorphism_group(return_functions=True, iso_type=True) ([x, 1/x], 'Cyclic of order 2') :: sage: R. = ProjectiveSpace(GF(3^4,'t'),1) - sage: f = DynamicalSystem_projective([x^2+25*x*y+y^2, x*y+3*y^2]) + sage: f = DynamicalSystem_projective([x^2 + 25*x*y + y^2, x*y + 3*y^2]) sage: f.automorphism_group(absolute=True) [Univariate Polynomial Ring in w over Finite Field in b of size 3^4, [ @@ -8882,14 +8930,14 @@ def all_periodic_points(self, **kwds): EXAMPLES:: sage: P. = ProjectiveSpace(GF(5^2),1) - sage: f = DynamicalSystem_projective([x^2+y^2, x*y]) + sage: f = DynamicalSystem_projective([x^2 + y^2, x*y]) sage: f.all_periodic_points() [(1 : 0), (z2 + 2 : 1), (4*z2 + 3 : 1)] :: sage: P. = ProjectiveSpace(GF(5),2) - sage: f = DynamicalSystem_projective([x^2+y^2+z^2, x*y+x*z, z^2]) + sage: f = DynamicalSystem_projective([x^2 + y^2 + z^2, x*y + x*z, z^2]) sage: f.all_periodic_points() [(1 : 0 : 0), (0 : 0 : 1), diff --git a/src/sage/ext/fast_callable.pyx b/src/sage/ext/fast_callable.pyx index d21bddd5deb..27ed329e75e 100644 --- a/src/sage/ext/fast_callable.pyx +++ b/src/sage/ext/fast_callable.pyx @@ -1772,18 +1772,18 @@ cpdef generate_code(Expression expr, InstructionStream stream): 25 sage: fc.op_list() [('load_arg', 0), ('load_arg', 1), ('py_call', , 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) diff --git a/src/sage/matroids/basis_exchange_matroid.pyx b/src/sage/matroids/basis_exchange_matroid.pyx index 8555ff67152..6501c592662 100644 --- a/src/sage/matroids/basis_exchange_matroid.pyx +++ b/src/sage/matroids/basis_exchange_matroid.pyx @@ -473,8 +473,8 @@ cdef class BasisExchangeMatroid(Matroid): EXAMPLES:: - sage: M = matroids.named_matroids.Fano() - sage: sorted(M.groundset()) + sage: M = 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'] """ return self._groundset @@ -495,17 +495,17 @@ cdef class BasisExchangeMatroid(Matroid): EXAMPLES:: - sage: M = matroids.named_matroids.Fano() - sage: type(M.groundset()) + sage: M = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings + sage: type(M.groundset()) # optional - sage.rings.finite_rings <... 'frozenset'> - sage: type(M.groundset_list()) + sage: type(M.groundset_list()) # optional - sage.rings.finite_rings <... 'list'> - sage: sorted(M.groundset_list()) + sage: sorted(M.groundset_list()) # optional - sage.rings.finite_rings ['a', 'b', 'c', 'd', 'e', 'f', 'g'] - sage: E = M.groundset_list() - sage: E.remove('a') - sage: sorted(M.groundset_list()) + sage: E = M.groundset_list() # optional - sage.rings.finite_rings + sage: E.remove('a') # optional - sage.rings.finite_rings + sage: sorted(M.groundset_list()) # optional - sage.rings.finite_rings ['a', 'b', 'c', 'd', 'e', 'f', 'g'] """ return list(self._E) @@ -516,10 +516,10 @@ cdef class BasisExchangeMatroid(Matroid): EXAMPLES:: - sage: M = matroids.named_matroids.Fano() - sage: len(M) + sage: M = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings + sage: len(M) # optional - sage.rings.finite_rings 7 - sage: len(M.groundset()) + sage: len(M.groundset()) # optional - sage.rings.finite_rings 7 """ @@ -538,10 +538,10 @@ cdef class BasisExchangeMatroid(Matroid): EXAMPLES:: - sage: M = matroids.named_matroids.Fano() - sage: M.full_rank() + sage: M = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings + sage: M.full_rank() # optional - sage.rings.finite_rings 3 - sage: M.dual().full_rank() + sage: M.dual().full_rank() # optional - sage.rings.finite_rings 4 """ return self._matroid_rank @@ -564,10 +564,10 @@ cdef class BasisExchangeMatroid(Matroid): EXAMPLES:: - sage: M = matroids.named_matroids.Fano() - sage: M.full_corank() + sage: M = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings + sage: M.full_corank() # optional - sage.rings.finite_rings 4 - sage: M.dual().full_corank() + sage: M.dual().full_corank() # optional - sage.rings.finite_rings 3 """ return self._groundset_size - self._matroid_rank @@ -592,12 +592,12 @@ cdef class BasisExchangeMatroid(Matroid): EXAMPLES:: - sage: M = matroids.named_matroids.Fano() - sage: sorted(M.basis()) + sage: M = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings + sage: sorted(M.basis()) # optional - sage.rings.finite_rings ['a', 'b', 'c'] - sage: M.rank('cd') + sage: M.rank('cd') # optional - sage.rings.finite_rings 2 - sage: sorted(M.basis()) + sage: sorted(M.basis()) # optional - sage.rings.finite_rings ['a', 'c', 'd'] """ @@ -750,8 +750,8 @@ cdef class BasisExchangeMatroid(Matroid): EXAMPLES:: - sage: M = matroids.named_matroids.P8() - sage: sorted(M._fundamental_circuit('abcd', 'e')) + sage: M = matroids.named_matroids.P8() # optional - sage.rings.finite_rings + sage: sorted(M._fundamental_circuit('abcd', 'e')) # optional - sage.rings.finite_rings ['a', 'b', 'c', 'e'] """ self.__pack(self._input, B) @@ -906,8 +906,8 @@ cdef class BasisExchangeMatroid(Matroid): EXAMPLES:: - sage: M = matroids.named_matroids.P8() - sage: sorted(M._fundamental_cocircuit('efgh', 'e')) + sage: M = matroids.named_matroids.P8() # optional - sage.rings.finite_rings + sage: sorted(M._fundamental_cocircuit('efgh', 'e')) # optional - sage.rings.finite_rings ['b', 'c', 'd', 'e'] """ self.__pack(self._input, B) @@ -1255,8 +1255,8 @@ cdef class BasisExchangeMatroid(Matroid): EXAMPLES:: - sage: M = matroids.named_matroids.S8() - sage: M.f_vector() + sage: M = matroids.named_matroids.S8() # optional - sage.rings.finite_rings + sage: M.f_vector() # optional - sage.rings.finite_rings [1, 8, 22, 14, 1] """ @@ -1321,14 +1321,14 @@ cdef class BasisExchangeMatroid(Matroid): EXAMPLES:: - sage: M = matroids.named_matroids.S8() - sage: M.f_vector() + sage: M = matroids.named_matroids.S8() # optional - sage.rings.finite_rings + sage: M.f_vector() # optional - sage.rings.finite_rings [1, 8, 22, 14, 1] - sage: len(M.flats(2)) + sage: len(M.flats(2)) # optional - sage.rings.finite_rings 22 - sage: len(M.flats(8)) + sage: len(M.flats(8)) # optional - sage.rings.finite_rings 0 - sage: len(M.flats(4)) + sage: len(M.flats(4)) # optional - sage.rings.finite_rings 1 """ cdef bitset_t *flats @@ -1396,14 +1396,14 @@ cdef class BasisExchangeMatroid(Matroid): EXAMPLES:: - sage: M = matroids.named_matroids.S8().dual() - sage: M.f_vector() + sage: M = matroids.named_matroids.S8().dual() # optional - sage.rings.finite_rings + sage: M.f_vector() # optional - sage.rings.finite_rings [1, 8, 22, 14, 1] - sage: len(M.coflats(2)) + sage: len(M.coflats(2)) # optional - sage.rings.finite_rings 22 - sage: len(M.coflats(8)) + sage: len(M.coflats(8)) # optional - sage.rings.finite_rings 0 - sage: len(M.coflats(4)) + sage: len(M.coflats(4)) # optional - sage.rings.finite_rings 1 """ cdef bitset_t *coflats @@ -1529,8 +1529,8 @@ cdef class BasisExchangeMatroid(Matroid): EXAMPLES:: - sage: M = matroids.named_matroids.N1() - sage: M.bases_count() + sage: M = matroids.named_matroids.N1() # optional - sage.rings.finite_rings + sage: M.bases_count() # optional - sage.rings.finite_rings 184 """ if self._bcount is not None: @@ -1556,9 +1556,9 @@ cdef class BasisExchangeMatroid(Matroid): EXAMPLES:: - sage: M = matroids.named_matroids.Fano() - sage: I = M.independent_sets() - sage: len(I) + sage: M = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings + sage: I = M.independent_sets() # optional - sage.rings.finite_rings + sage: len(I) # optional - sage.rings.finite_rings 57 """ cdef bitset_t *I @@ -1617,10 +1617,10 @@ cdef class BasisExchangeMatroid(Matroid): EXAMPLES:: - sage: M = matroids.named_matroids.N1() - sage: M.bases_count() + sage: M = matroids.named_matroids.N1() # optional - sage.rings.finite_rings + sage: M.bases_count() # optional - sage.rings.finite_rings 184 - sage: [len(M.independent_r_sets(r)) for r in range(M.full_rank() + 1)] + sage: [len(M.independent_r_sets(r)) for r in range(M.full_rank() + 1)] # optional - sage.rings.finite_rings [1, 10, 45, 120, 201, 184] """ @@ -1649,10 +1649,10 @@ cdef class BasisExchangeMatroid(Matroid): EXAMPLES:: - sage: M = matroids.named_matroids.N1() - sage: M.bases_count() + sage: M = matroids.named_matroids.N1() # optional - sage.rings.finite_rings + sage: M.bases_count() # optional - sage.rings.finite_rings 184 - sage: len([B for B in M.bases()]) + sage: len([B for B in M.bases()]) # optional - sage.rings.finite_rings 184 """ return self.independent_r_sets(self.full_rank()) @@ -1671,10 +1671,10 @@ cdef class BasisExchangeMatroid(Matroid): EXAMPLES:: - sage: M = matroids.named_matroids.N1() - sage: len(M.nonbases()) + sage: M = matroids.named_matroids.N1() # optional - sage.rings.finite_rings + sage: len(M.nonbases()) # optional - sage.rings.finite_rings 68 - sage: [len(M.dependent_r_sets(r)) for r in range(M.full_rank() + 1)] + sage: [len(M.dependent_r_sets(r)) for r in range(M.full_rank() + 1)] # optional - sage.rings.finite_rings [0, 0, 0, 0, 9, 68] """ @@ -1714,10 +1714,10 @@ cdef class BasisExchangeMatroid(Matroid): EXAMPLES:: - sage: M = matroids.named_matroids.N1() - sage: binomial(M.size(), M.full_rank())-M.bases_count() + sage: M = matroids.named_matroids.N1() # optional - sage.rings.finite_rings + sage: binomial(M.size(), M.full_rank())-M.bases_count() # optional - sage.rings.finite_rings 68 - sage: len([B for B in M.nonbases()]) + sage: len([B for B in M.nonbases()]) # optional - sage.rings.finite_rings 68 """ return self.dependent_r_sets(self.full_rank()) @@ -1740,8 +1740,8 @@ cdef class BasisExchangeMatroid(Matroid): EXAMPLES:: - sage: M = matroids.named_matroids.N1() - sage: len(M.nonspanning_circuits()) + sage: M = matroids.named_matroids.N1() # optional - sage.rings.finite_rings + sage: len(M.nonspanning_circuits()) # optional - sage.rings.finite_rings 23 """ cdef SetSystem NSC @@ -1789,8 +1789,8 @@ cdef class BasisExchangeMatroid(Matroid): EXAMPLES:: - sage: M = matroids.named_matroids.N1() - sage: len(M.noncospanning_cocircuits()) + sage: M = matroids.named_matroids.N1() # optional - sage.rings.finite_rings + sage: len(M.noncospanning_cocircuits()) # optional - sage.rings.finite_rings 23 """ cdef SetSystem NSC @@ -1835,8 +1835,8 @@ cdef class BasisExchangeMatroid(Matroid): EXAMPLES:: - sage: M = Matroid(bases=matroids.named_matroids.NonFano().bases()) - sage: sorted([sorted(C) for C in M.cocircuits()]) + sage: M = Matroid(bases=matroids.named_matroids.NonFano().bases()) # optional - sage.rings.finite_rings + sage: sorted([sorted(C) for C in M.cocircuits()]) # optional - sage.rings.finite_rings [['a', 'b', 'c', 'd', 'g'], ['a', 'b', 'c', 'e', 'g'], ['a', 'b', 'c', 'f', 'g'], ['a', 'b', 'd', 'e'], ['a', 'c', 'd', 'f'], ['a', 'e', 'f', 'g'], ['b', 'c', 'e', 'f'], @@ -1883,8 +1883,8 @@ cdef class BasisExchangeMatroid(Matroid): EXAMPLES:: - sage: M = Matroid(matroids.named_matroids.NonFano().bases()) - sage: sorted([sorted(C) for C in M.circuits()]) + sage: M = Matroid(matroids.named_matroids.NonFano().bases()) # optional - sage.rings.finite_rings + sage: sorted([sorted(C) for C in M.circuits()]) # optional - sage.rings.finite_rings [['a', 'b', 'c', 'g'], ['a', 'b', 'd', 'e'], ['a', 'b', 'f'], ['a', 'c', 'd', 'f'], ['a', 'c', 'e'], ['a', 'd', 'e', 'f'], ['a', 'd', 'g'], ['a', 'e', 'f', 'g'], ['b', 'c', 'd'], @@ -1932,10 +1932,10 @@ cdef class BasisExchangeMatroid(Matroid): EXAMPLES:: - sage: M = matroids.named_matroids.N1() - sage: M._characteristic_setsystem() + sage: M = matroids.named_matroids.N1() # optional - sage.rings.finite_rings + sage: M._characteristic_setsystem() # optional - sage.rings.finite_rings Iterator over a system of subsets - sage: len(M._characteristic_setsystem()) + sage: len(M._characteristic_setsystem()) # optional - sage.rings.finite_rings 23 """ if 2 * self._matroid_rank > self._groundset_size: @@ -1958,9 +1958,9 @@ cdef class BasisExchangeMatroid(Matroid): EXAMPLES:: - sage: M = Matroid(bases=matroids.named_matroids.Fano().bases()) - sage: N = Matroid(matroids.named_matroids.NonFano().bases()) - sage: M._weak_invariant() == N._weak_invariant() + sage: M = Matroid(bases=matroids.named_matroids.Fano().bases()) # optional - sage.rings.finite_rings + sage: N = Matroid(matroids.named_matroids.NonFano().bases()) # optional - sage.rings.finite_rings + sage: M._weak_invariant() == N._weak_invariant() # optional - sage.rings.finite_rings False """ if self._weak_invariant_var is None: @@ -2003,9 +2003,9 @@ cdef class BasisExchangeMatroid(Matroid): EXAMPLES:: - sage: M = Matroid(matroids.named_matroids.Fano().bases()) - sage: N = Matroid(matroids.named_matroids.NonFano().bases()) - sage: M._strong_invariant() == N._strong_invariant() + sage: M = Matroid(matroids.named_matroids.Fano().bases()) # optional - sage.rings.finite_rings + sage: N = Matroid(matroids.named_matroids.NonFano().bases()) # optional - sage.rings.finite_rings + sage: M._strong_invariant() == N._strong_invariant() # optional - sage.rings.finite_rings False """ if self._strong_invariant_var is None: @@ -2132,10 +2132,10 @@ cdef class BasisExchangeMatroid(Matroid): sage: N._is_isomorphism(M, {e:e for e in M.groundset()}) False - sage: M = matroids.named_matroids.Fano() \ ['g'] - sage: N = matroids.Wheel(3) - sage: morphism = {'a':0, 'b':1, 'c': 2, 'd':4, 'e':5, 'f':3} - sage: M._is_isomorphism(N, morphism) + sage: M = matroids.named_matroids.Fano() \ ['g'] # optional - sage.rings.finite_rings + sage: N = matroids.Wheel(3) # optional - sage.rings.finite_rings + sage: morphism = {'a':0, 'b':1, 'c': 2, 'd':4, 'e':5, 'f':3} # optional - sage.rings.finite_rings + sage: M._is_isomorphism(N, morphism) # optional - sage.rings.finite_rings True TESTS: @@ -2146,8 +2146,8 @@ cdef class BasisExchangeMatroid(Matroid): ....: return min(len(X), 2) ....: sage: M = Matroid(groundset='abcd', rank_function=f) - sage: N = Matroid(field=GF(3), reduced_matrix=[[1,1],[1,-1]]) - sage: N._is_isomorphism(M, {0:'a', 1:'b', 2:'c', 3:'d'}) + sage: N = Matroid(field=GF(3), reduced_matrix=[[1,1],[1,-1]]) # optional - sage.rings.finite_rings + sage: N._is_isomorphism(M, {0:'a', 1:'b', 2:'c', 3:'d'}) # optional - sage.rings.finite_rings True """ if not isinstance(other, BasisExchangeMatroid): @@ -2195,13 +2195,13 @@ cdef class BasisExchangeMatroid(Matroid): sage: from sage.matroids.advanced import * sage: M1 = matroids.Wheel(3) - sage: M2 = matroids.CompleteGraphic(4) - sage: morphism = M1._isomorphism(M2) - sage: M1._is_isomorphism(M2, morphism) + sage: M2 = matroids.CompleteGraphic(4) # optional - sage.graphs + sage: morphism = M1._isomorphism(M2) # optional - sage.graphs + sage: M1._is_isomorphism(M2, morphism) # optional - sage.graphs True - sage: M1 = matroids.named_matroids.Fano() - sage: M2 = matroids.named_matroids.NonFano() - sage: M1._isomorphism(M2) is None + sage: M1 = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings + sage: M2 = matroids.named_matroids.NonFano() # optional - sage.rings.finite_rings + sage: M1._isomorphism(M2) is None # optional - sage.rings.finite_rings True TESTS: @@ -2212,8 +2212,8 @@ cdef class BasisExchangeMatroid(Matroid): ....: return min(len(X), 2) ....: sage: M = Matroid(groundset='abcd', rank_function=f) - sage: N = Matroid(field=GF(3), reduced_matrix=[[1,1],[1,-1]]) - sage: N._isomorphism(M) is not None + sage: N = Matroid(field=GF(3), reduced_matrix=[[1,1],[1,-1]]) # optional - sage.rings.finite_rings + sage: N._isomorphism(M) is not None # optional - sage.rings.finite_rings True """ if not isinstance(other, BasisExchangeMatroid): @@ -2289,16 +2289,16 @@ cdef class BasisExchangeMatroid(Matroid): sage: from sage.matroids.advanced import * sage: M1 = BasisMatroid(matroids.Wheel(3)) - sage: M2 = matroids.CompleteGraphic(4) - sage: M1._is_isomorphic(M2) + sage: M2 = matroids.CompleteGraphic(4) # optional - sage.graphs + sage: M1._is_isomorphic(M2) # optional - sage.graphs True - sage: M1._is_isomorphic(M2, certificate=True) + sage: M1._is_isomorphic(M2, certificate=True) # optional - sage.graphs (True, {0: 0, 1: 1, 2: 2, 3: 3, 4: 5, 5: 4}) - sage: M1 = BasisMatroid(matroids.named_matroids.Fano()) - sage: M2 = matroids.named_matroids.NonFano() - sage: M1._is_isomorphic(M2) + sage: M1 = BasisMatroid(matroids.named_matroids.Fano()) # optional - sage.rings.finite_rings + sage: M2 = matroids.named_matroids.NonFano() # optional - sage.rings.finite_rings + sage: M1._is_isomorphic(M2) # optional - sage.rings.finite_rings False - sage: M1._is_isomorphic(M2, certificate=True) + sage: M1._is_isomorphic(M2, certificate=True) # optional - sage.rings.finite_rings (False, None) """ @@ -2370,8 +2370,8 @@ cdef class BasisExchangeMatroid(Matroid): EXAMPLES:: sage: from sage.matroids.advanced import * - sage: M = BasisMatroid(matroids.named_matroids.Fano()) - sage: M.is_valid() + sage: M = BasisMatroid(matroids.named_matroids.Fano()) # optional - sage.rings.finite_rings + sage: M.is_valid() # optional - sage.rings.finite_rings True sage: M = Matroid(groundset='abcd', bases=['ab', 'cd']) sage: M.is_valid() @@ -2381,7 +2381,7 @@ cdef class BasisExchangeMatroid(Matroid): Verify that :trac:`20172` was fixed:: - sage: M=Matroid(groundset='1234',bases=['12','13','23','34']) + sage: M = Matroid(groundset='1234', bases=['12','13','23','34']) sage: M.is_valid() False """ diff --git a/src/sage/matroids/basis_matroid.pyx b/src/sage/matroids/basis_matroid.pyx index 85f09fd8f97..e9ac791d729 100644 --- a/src/sage/matroids/basis_matroid.pyx +++ b/src/sage/matroids/basis_matroid.pyx @@ -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 ======= @@ -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:: @@ -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 @@ -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' """ @@ -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] """ @@ -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 """ @@ -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'] """ @@ -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: @@ -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 @@ -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: @@ -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: @@ -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: @@ -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'] """ @@ -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 @@ -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): @@ -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): @@ -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: @@ -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())) diff --git a/src/sage/matroids/catalog.py b/src/sage/matroids/catalog.py index 769ef123923..0397436a5f8 100644 --- a/src/sage/matroids/catalog.py +++ b/src/sage/matroids/catalog.py @@ -39,8 +39,6 @@ from sage.graphs.graph_generators import graphs from sage.rings.integer_ring import ZZ -from sage.rings.finite_rings.finite_field_constructor import GF -from sage.schemes.projective.projective_space import ProjectiveSpace import sage.matroids.matroid import sage.matroids.basis_exchange_matroid @@ -51,6 +49,11 @@ QuaternaryMatroid) from sage.matroids.rank_matroid import RankMatroid from sage.matroids.constructor import Matroid +from sage.misc.lazy_import import lazy_import + +lazy_import('sage.rings.finite_rings.finite_field_constructor', 'GF') +lazy_import('sage.schemes.projective.projective_space', 'ProjectiveSpace') + # The order is the same as in Oxley. @@ -67,13 +70,13 @@ def Q6(): EXAMPLES:: sage: from sage.matroids.advanced import setprint - sage: M = matroids.named_matroids.Q6(); M + sage: M = matroids.named_matroids.Q6(); M # optional - sage.rings.finite_rings Q6: Quaternary matroid of rank 3 on 6 elements - sage: setprint(M.hyperplanes()) + sage: setprint(M.hyperplanes()) # optional - sage.rings.finite_rings [{'a', 'b', 'd'}, {'a', 'c'}, {'a', 'e'}, {'a', 'f'}, {'b', 'c', 'e'}, {'b', 'f'}, {'c', 'd'}, {'c', 'f'}, {'d', 'e'}, {'d', 'f'}, {'e', 'f'}] - sage: M.nonspanning_circuits() == M.noncospanning_cocircuits() + sage: M.nonspanning_circuits() == M.noncospanning_cocircuits() # optional - sage.rings.finite_rings False """ F = GF(4, 'x') @@ -106,10 +109,10 @@ def P6(): {2: {{'a', 'b', 'c'}}, 3: {{'a', 'b', 'c', 'd', 'e', 'f'}}} sage: len(set(M.nonspanning_circuits()).difference(M.nonbases())) == 0 True - sage: Matroid(matrix=random_matrix(GF(4, 'a'), ncols=5, + sage: Matroid(matrix=random_matrix(GF(4, 'a'), ncols=5, # optional - sage.rings.finite_rings ....: nrows=5)).has_minor(M) False - sage: M.is_valid() + sage: M.is_valid() # optional - sage.rings.finite_rings True """ E = 'abcdef' @@ -134,13 +137,13 @@ def R6(): EXAMPLES:: - sage: M = matroids.named_matroids.R6(); M + sage: M = matroids.named_matroids.R6(); M # optional - sage.rings.finite_rings R6: Ternary matroid of rank 3 on 6 elements, type 2+ - sage: M.equals(M.dual()) + sage: M.equals(M.dual()) # optional - sage.rings.finite_rings True - sage: M.is_connected() + sage: M.is_connected() # optional - sage.rings.finite_rings True - sage: M.is_3connected() + sage: M.is_3connected() # optional - sage.rings.finite_rings False """ A = Matrix(GF(3), [ @@ -167,12 +170,12 @@ def Fano(): EXAMPLES:: sage: from sage.matroids.advanced import setprint - sage: M = matroids.named_matroids.Fano(); M + sage: M = matroids.named_matroids.Fano(); M # optional - sage.rings.finite_rings Fano: Binary matroid of rank 3 on 7 elements, type (3, 0) - sage: setprint(sorted(M.nonspanning_circuits())) + sage: setprint(sorted(M.nonspanning_circuits())) # optional - sage.rings.finite_rings [{'a', 'b', 'f'}, {'a', 'c', 'e'}, {'a', 'd', 'g'}, {'b', 'c', 'd'}, {'b', 'e', 'g'}, {'c', 'f', 'g'}, {'d', 'e', 'f'}] - sage: M.delete(M.groundset_list()[randrange(0, + sage: M.delete(M.groundset_list()[randrange(0, # optional - sage.rings.finite_rings ....: 7)]).is_isomorphic(matroids.CompleteGraphic(4)) True """ @@ -198,14 +201,14 @@ def NonFano(): EXAMPLES:: sage: from sage.matroids.advanced import setprint - sage: M = matroids.named_matroids.NonFano(); M + sage: M = matroids.named_matroids.NonFano(); M # optional - sage.rings.finite_rings NonFano: Ternary matroid of rank 3 on 7 elements, type 0- - sage: setprint(M.nonbases()) + sage: setprint(M.nonbases()) # optional - sage.rings.finite_rings [{'a', 'b', 'f'}, {'a', 'c', 'e'}, {'a', 'd', 'g'}, {'b', 'c', 'd'}, {'b', 'e', 'g'}, {'c', 'f', 'g'}] - sage: M.delete('f').is_isomorphic(matroids.CompleteGraphic(4)) + sage: M.delete('f').is_isomorphic(matroids.CompleteGraphic(4)) # optional - sage.rings.finite_rings True - sage: M.delete('g').is_isomorphic(matroids.CompleteGraphic(4)) + sage: M.delete('g').is_isomorphic(matroids.CompleteGraphic(4)) # optional - sage.rings.finite_rings False """ A = Matrix(GF(3), [ @@ -230,11 +233,11 @@ def O7(): EXAMPLES:: - sage: M = matroids.named_matroids.O7(); M + sage: M = matroids.named_matroids.O7(); M # optional - sage.rings.finite_rings O7: Ternary matroid of rank 3 on 7 elements, type 0+ - sage: M.delete('e').is_isomorphic(matroids.CompleteGraphic(4)) + sage: M.delete('e').is_isomorphic(matroids.CompleteGraphic(4)) # optional - sage.rings.finite_rings True - sage: M.tutte_polynomial() + sage: M.tutte_polynomial() # optional - sage.rings.finite_rings y^4 + x^3 + x*y^2 + 3*y^3 + 4*x^2 + 5*x*y + 5*y^2 + 4*x + 4*y """ A = Matrix(GF(3), [ @@ -259,13 +262,13 @@ def P7(): EXAMPLES:: - sage: M = matroids.named_matroids.P7(); M + sage: M = matroids.named_matroids.P7(); M # optional - sage.rings.finite_rings P7: Ternary matroid of rank 3 on 7 elements, type 1+ - sage: M.f_vector() + sage: M.f_vector() # optional - sage.rings.finite_rings [1, 7, 11, 1] - sage: M.has_minor(matroids.CompleteGraphic(4)) + sage: M.has_minor(matroids.CompleteGraphic(4)) # optional - sage.rings.finite_rings False - sage: M.is_valid() + sage: M.is_valid() # optional - sage.rings.finite_rings True """ A = Matrix(GF(3), [ @@ -299,15 +302,15 @@ def AG32prime(): {'b', 'e', 'g', 'h'}, {'c', 'd', 'e', 'h'}, {'c', 'f', 'g', 'h'}, {'d', 'e', 'f', 'g'}}, 4: {{'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'}}} - sage: M.contract('c').is_isomorphic(matroids.named_matroids.Fano()) + sage: M.contract('c').is_isomorphic(matroids.named_matroids.Fano()) # optional - sage.rings.finite_rings True - sage: setprint(M.noncospanning_cocircuits()) + sage: setprint(M.noncospanning_cocircuits()) # optional - sage.rings.finite_rings [{'a', 'b', 'c', 'h'}, {'a', 'b', 'd', 'e'}, {'a', 'b', 'f', 'g'}, {'a', 'c', 'd', 'f'}, {'a', 'd', 'g', 'h'}, {'a', 'e', 'f', 'h'}, {'b', 'c', 'd', 'g'}, {'b', 'c', 'e', 'f'}, {'b', 'd', 'f', 'h'}, {'b', 'e', 'g', 'h'}, {'c', 'd', 'e', 'h'}, {'c', 'f', 'g', 'h'}, {'d', 'e', 'f', 'g'}] - sage: M.is_valid() # long time + sage: M.is_valid() # long time # optional - sage.rings.finite_rings True """ E = 'abcdefgh' @@ -332,14 +335,14 @@ def R8(): EXAMPLES:: - sage: M = matroids.named_matroids.R8(); M + sage: M = matroids.named_matroids.R8(); M # optional - sage.rings.finite_rings R8: Ternary matroid of rank 4 on 8 elements, type 0+ - sage: M.contract(M.groundset_list()[randrange(0, + sage: M.contract(M.groundset_list()[randrange(0, # optional - sage.rings.finite_rings ....: 8)]).is_isomorphic(matroids.named_matroids.NonFano()) True - sage: M.equals(M.dual()) + sage: M.equals(M.dual()) # optional - sage.rings.finite_rings True - sage: M.has_minor(matroids.named_matroids.Fano()) + sage: M.has_minor(matroids.named_matroids.Fano()) # optional - sage.rings.finite_rings False """ A = Matrix(GF(3), [ @@ -374,11 +377,11 @@ def F8(): ....: for i in M.groundset()]) sage: len(D) 3 - sage: [N.is_isomorphic(matroids.named_matroids.Fano()) for N in D] + sage: [N.is_isomorphic(matroids.named_matroids.Fano()) for N in D] # optional - sage.rings.finite_rings [...True...] - sage: [N.is_isomorphic(matroids.named_matroids.NonFano()) for N in D] + sage: [N.is_isomorphic(matroids.named_matroids.NonFano()) for N in D] # optional - sage.rings.finite_rings [...True...] - sage: M.is_valid() # long time + sage: M.is_valid() # long time # optional - sage.rings.finite_rings True """ E = 'abcdefgh' @@ -477,21 +480,21 @@ def S8(): EXAMPLES:: sage: from sage.matroids.advanced import * - sage: M = matroids.named_matroids.S8(); M + sage: M = matroids.named_matroids.S8(); M # optional - sage.rings.finite_rings S8: Binary matroid of rank 4 on 8 elements, type (2, 0) - sage: M.contract('d').is_isomorphic(matroids.named_matroids.Fano()) + sage: M.contract('d').is_isomorphic(matroids.named_matroids.Fano()) # optional - sage.rings.finite_rings True - sage: M.delete('d').is_isomorphic( + sage: M.delete('d').is_isomorphic( # optional - sage.rings.finite_rings ....: matroids.named_matroids.Fano().dual()) False - sage: M.is_graphic() + sage: M.is_graphic() # optional - sage.rings.finite_rings False - sage: D = get_nonisomorphic_matroids( + sage: D = get_nonisomorphic_matroids( # optional - sage.rings.finite_rings ....: list(matroids.named_matroids.Fano().linear_coextensions( ....: cosimple=True))) - sage: len(D) + sage: len(D) # optional - sage.rings.finite_rings 2 - sage: [N.is_isomorphic(M) for N in D] + sage: [N.is_isomorphic(M) for N in D] # optional - sage.rings.finite_rings [...True...] """ @@ -553,13 +556,13 @@ def T8(): EXAMPLES:: - sage: M = matroids.named_matroids.T8(); M + sage: M = matroids.named_matroids.T8(); M # optional - sage.rings.finite_rings T8: Ternary matroid of rank 4 on 8 elements, type 0- - sage: M.truncation().is_isomorphic(matroids.Uniform(3, 8)) + sage: M.truncation().is_isomorphic(matroids.Uniform(3, 8)) # optional - sage.rings.finite_rings True - sage: M.contract('e').is_isomorphic(matroids.named_matroids.P7()) + sage: M.contract('e').is_isomorphic(matroids.named_matroids.P7()) # optional - sage.rings.finite_rings True - sage: M.has_minor(matroids.Uniform(3, 8)) + sage: M.has_minor(matroids.Uniform(3, 8)) # optional - sage.rings.finite_rings False """ @@ -585,15 +588,15 @@ def J(): EXAMPLES:: sage: from sage.matroids.advanced import setprint - sage: M = matroids.named_matroids.J(); M + sage: M = matroids.named_matroids.J(); M # optional - sage.rings.finite_rings J: Ternary matroid of rank 4 on 8 elements, type 0- - sage: setprint(M.truncation().nonbases()) + sage: setprint(M.truncation().nonbases()) # optional - sage.rings.finite_rings [{'a', 'b', 'f'}, {'a', 'c', 'g'}, {'a', 'd', 'h'}] - sage: M.is_isomorphic(M.dual()) + sage: M.is_isomorphic(M.dual()) # optional - sage.rings.finite_rings True - sage: M.has_minor(matroids.CompleteGraphic(4)) + sage: M.has_minor(matroids.CompleteGraphic(4)) # optional - sage.rings.finite_rings False - sage: M.is_valid() + sage: M.is_valid() # optional - sage.rings.finite_rings True """ A = Matrix(GF(3), [ @@ -619,14 +622,14 @@ def P8(): EXAMPLES:: - sage: M = matroids.named_matroids.P8(); M + sage: M = matroids.named_matroids.P8(); M # optional - sage.rings.finite_rings P8: Ternary matroid of rank 4 on 8 elements, type 2+ - sage: M.is_isomorphic(M.dual()) + sage: M.is_isomorphic(M.dual()) # optional - sage.rings.finite_rings True - sage: Matroid(matrix=random_matrix(GF(4, 'a'), ncols=5, + sage: Matroid(matrix=random_matrix(GF(4, 'a'), ncols=5, # optional - sage.rings.finite_rings ....: nrows=5)).has_minor(M) False - sage: M.bicycle_dimension() + sage: M.bicycle_dimension() # optional - sage.rings.finite_rings 2 """ @@ -690,12 +693,12 @@ def K33dual(): EXAMPLES:: - sage: M = matroids.named_matroids.K33dual(); M + sage: M = matroids.named_matroids.K33dual(); M # optional - sage.graphs M*(K3, 3): Regular matroid of rank 4 on 9 elements with 81 bases - sage: any(N.is_3connected() + sage: any(N.is_3connected() # optional - sage.graphs ....: for N in M.linear_extensions(simple=True)) False - sage: M.is_valid() # long time + sage: M.is_valid() # long time # optional - sage.graphs True """ E = 'abcdefghi' @@ -719,11 +722,11 @@ def TernaryDowling3(): EXAMPLES:: - sage: M = matroids.named_matroids.TernaryDowling3(); M + sage: M = matroids.named_matroids.TernaryDowling3(); M # optional - sage.rings.finite_rings Q3(GF(3)x): Ternary matroid of rank 3 on 9 elements, type 0- - sage: len(list(M.linear_subclasses())) + sage: len(list(M.linear_subclasses())) # optional - sage.rings.finite_rings 72 - sage: M.fundamental_cycle('abc', 'd') + sage: M.fundamental_cycle('abc', 'd') # optional - sage.rings.finite_rings {'a': 2, 'b': 1, 'd': 1} """ @@ -756,16 +759,16 @@ def CompleteGraphic(n): EXAMPLES:: sage: from sage.matroids.advanced import setprint - sage: M = matroids.CompleteGraphic(5); M + sage: M = matroids.CompleteGraphic(5); M # optional - sage.graphs M(K5): Graphic matroid of rank 4 on 10 elements - sage: M.has_minor(matroids.Uniform(2, 4)) + sage: M.has_minor(matroids.Uniform(2, 4)) # optional - sage.graphs False - sage: simplify(M.contract(randrange(0, + sage: simplify(M.contract(randrange(0, # optional - sage.graphs ....: 10))).is_isomorphic(matroids.CompleteGraphic(4)) True - sage: setprint(M.closure([0, 2, 4, 5])) + sage: setprint(M.closure([0, 2, 4, 5])) # optional - sage.graphs {0, 1, 2, 4, 5, 7} - sage: M.is_valid() + sage: M.is_valid() # optional - sage.graphs True """ M = Matroid(groundset=list(range((n * (n - 1)) // 2)), @@ -802,11 +805,11 @@ def Wheel(n, field=None, ring=None): sage: M.is_valid() True sage: M = matroids.Wheel(3) - sage: M.is_isomorphic(matroids.CompleteGraphic(4)) + sage: M.is_isomorphic(matroids.CompleteGraphic(4)) # optional - sage.graphs True - sage: M.is_isomorphic(matroids.Wheel(3,field=GF(3))) + sage: M.is_isomorphic(matroids.Wheel(3, field=GF(3))) # optional - sage.rings.finite_rings True - sage: M = matroids.Wheel(3,field=GF(3)); M + sage: M = matroids.Wheel(3, field=GF(3)); M # optional - sage.rings.finite_rings Wheel(3): Ternary matroid of rank 3 on 6 elements, type 0+ """ base_ring = ZZ @@ -853,17 +856,17 @@ def Whirl(n): EXAMPLES:: - sage: M = matroids.Whirl(5); M + sage: M = matroids.Whirl(5); M # optional - sage.rings.finite_rings Whirl(5): Ternary matroid of rank 5 on 10 elements, type 0- - sage: M.is_valid() + sage: M.is_valid() # optional - sage.rings.finite_rings True - sage: M.tutte_polynomial() + sage: M.tutte_polynomial() # optional - sage.rings.finite_rings x^5 + y^5 + 5*x^4 + 5*x^3*y + 5*x^2*y^2 + 5*x*y^3 + 5*y^4 + 10*x^3 + 15*x^2*y + 15*x*y^2 + 10*y^3 + 10*x^2 + 15*x*y + 10*y^2 + 5*x + 5*y - sage: M.is_isomorphic(matroids.Wheel(5)) + sage: M.is_isomorphic(matroids.Wheel(5)) # optional - sage.rings.finite_rings False - sage: M = matroids.Whirl(3) - sage: M.is_isomorphic(matroids.CompleteGraphic(4)) + sage: M = matroids.Whirl(3) # optional - sage.rings.finite_rings + sage: M.is_isomorphic(matroids.CompleteGraphic(4)) # optional - sage.rings.finite_rings False .. TODO:: @@ -960,12 +963,12 @@ def PG(n, q, x=None): EXAMPLES:: - sage: M = matroids.PG(2, 2) - sage: M.is_isomorphic(matroids.named_matroids.Fano()) + sage: M = matroids.PG(2, 2) # optional - sage.rings.finite_rings + sage: M.is_isomorphic(matroids.named_matroids.Fano()) # optional - sage.rings.finite_rings True - sage: matroids.PG(5, 4, 'z').size() == (4^6 - 1) / (4 - 1) + sage: matroids.PG(5, 4, 'z').size() == (4^6 - 1) / (4 - 1) # optional - sage.rings.finite_rings True - sage: M = matroids.PG(4, 7); M + sage: M = matroids.PG(4, 7); M # optional - sage.rings.finite_rings PG(4, 7): Linear matroid of rank 5 on 2801 elements represented over the Finite Field of size 7 """ @@ -1003,13 +1006,13 @@ def AG(n, q, x=None): EXAMPLES:: - sage: M = matroids.AG(2, 3) \ 8 - sage: M.is_isomorphic(matroids.named_matroids.AG23minus()) + sage: M = matroids.AG(2, 3) \ 8 # optional - sage.rings.finite_rings + sage: M.is_isomorphic(matroids.named_matroids.AG23minus()) # optional - sage.rings.finite_rings True - sage: matroids.AG(5, 4, 'z').size() == ((4 ^ 6 - 1) / (4 - 1) - + sage: matroids.AG(5, 4, 'z').size() == ((4 ^ 6 - 1) / (4 - 1) - # optional - sage.rings.finite_rings ....: (4 ^ 5 - 1)/(4 - 1)) True - sage: M = matroids.AG(4, 2); M + sage: M = matroids.AG(4, 2); M # optional - sage.rings.finite_rings AG(4, 2): Binary matroid of rank 5 on 16 elements, type (5, 0) """ @@ -1045,7 +1048,7 @@ def R10(): {4, 6} sage: M.equals(M.dual()) False - sage: M.is_isomorphic(M.dual()) + sage: M.is_isomorphic(M.dual()) # optional - sage.graphs True sage: M.is_valid() True @@ -1083,7 +1086,7 @@ def R12(): R12: Regular matroid of rank 6 on 12 elements with 441 bases sage: M.equals(M.dual()) False - sage: M.is_isomorphic(M.dual()) + sage: M.is_isomorphic(M.dual()) # optional - sage.graphs True sage: M.is_valid() True @@ -1243,10 +1246,10 @@ def Q10(): EXAMPLES:: - sage: M = matroids.named_matroids.Q10() - sage: M.is_isomorphic(M.dual()) + sage: M = matroids.named_matroids.Q10() # optional - sage.rings.finite_rings + sage: M.is_isomorphic(M.dual()) # optional - sage.rings.finite_rings True - sage: M.is_valid() + sage: M.is_valid() # optional - sage.rings.finite_rings True Check the splitter property. By Seymour's Theorem, and using self-duality, @@ -1255,8 +1258,8 @@ def Q10(): are quaternary are `U_{2, 5}, U_{3, 5}, F_7, F_7^*`. As it happens, it suffices to check for `U_{2, 5}`: - sage: S = matroids.named_matroids.Q10().linear_extensions(simple=True) - sage: [M for M in S if not M.has_line_minor(5)] # long time + sage: S = matroids.named_matroids.Q10().linear_extensions(simple=True) # optional - sage.rings.finite_rings + sage: [M for M in S if not M.has_line_minor(5)] # long time # optional - sage.rings.finite_rings [] """ F = GF(4, 'x') @@ -1281,10 +1284,10 @@ def N1(): EXAMPLES:: - sage: M = matroids.named_matroids.N1() - sage: M.is_field_isomorphic(M.dual()) + sage: M = matroids.named_matroids.N1() # optional - sage.rings.finite_rings + sage: M.is_field_isomorphic(M.dual()) # optional - sage.rings.finite_rings True - sage: M.is_valid() + sage: M.is_valid() # optional - sage.rings.finite_rings True """ @@ -1308,10 +1311,10 @@ def N2(): EXAMPLES:: - sage: M = matroids.named_matroids.N2() - sage: M.is_field_isomorphic(M.dual()) + sage: M = matroids.named_matroids.N2() # optional - sage.rings.finite_rings + sage: M.is_field_isomorphic(M.dual()) # optional - sage.rings.finite_rings True - sage: M.is_valid() + sage: M.is_valid() # optional - sage.rings.finite_rings True """ @@ -1422,11 +1425,11 @@ def ExtendedBinaryGolayCode(): EXAMPLES:: - sage: M = matroids.named_matroids.ExtendedBinaryGolayCode() - sage: C = LinearCode(M.representation()) - sage: C.is_permutation_equivalent(codes.GolayCode(GF(2))) # long time + sage: M = matroids.named_matroids.ExtendedBinaryGolayCode() # optional - sage.rings.finite_rings + sage: C = LinearCode(M.representation()) # optional - sage.rings.finite_rings + sage: C.is_permutation_equivalent(codes.GolayCode(GF(2))) # long time # optional - sage.rings.finite_rings True - sage: M.is_valid() + sage: M.is_valid() # optional - sage.rings.finite_rings True """ A = Matrix(GF(2), [ @@ -1457,11 +1460,11 @@ def ExtendedTernaryGolayCode(): EXAMPLES:: - sage: M = matroids.named_matroids.ExtendedTernaryGolayCode() - sage: C = LinearCode(M.representation()) - sage: C.is_permutation_equivalent(codes.GolayCode(GF(3))) # long time + sage: M = matroids.named_matroids.ExtendedTernaryGolayCode() # optional - sage.rings.finite_rings + sage: C = LinearCode(M.representation()) # optional - sage.rings.finite_rings + sage: C.is_permutation_equivalent(codes.GolayCode(GF(3))) # long time # optional - sage.rings.finite_rings True - sage: M.is_valid() + sage: M.is_valid() # optional - sage.rings.finite_rings True """ A = Matrix(GF(3), [ @@ -1509,11 +1512,11 @@ def NotP8(): EXAMPLES:: - sage: M = matroids.named_matroids.P8() - sage: N = matroids.named_matroids.NotP8() - sage: M.is_isomorphic(N) + sage: M = matroids.named_matroids.P8() # optional - sage.rings.finite_rings + sage: N = matroids.named_matroids.NotP8() # optional - sage.rings.finite_rings + sage: M.is_isomorphic(N) # optional - sage.rings.finite_rings False - sage: M.is_valid() + sage: M.is_valid() # optional - sage.rings.finite_rings True """ A = Matrix(GF(3), [ @@ -1538,10 +1541,10 @@ def D16(): # A.K.A. the Carolyn Chun Matroid EXAMPLES:: - sage: M = matroids.named_matroids.D16() - sage: M + sage: M = matroids.named_matroids.D16() # optional - sage.rings.finite_rings + sage: M # optional - sage.rings.finite_rings D16: Binary matroid of rank 8 on 16 elements, type (0, 0) - sage: M.is_valid() + sage: M.is_valid() # optional - sage.rings.finite_rings True """ @@ -1569,10 +1572,10 @@ def Terrahawk(): # A.K.A. the Dillon Mayhew Matroid EXAMPLES:: - sage: M = matroids.named_matroids.Terrahawk() - sage: M + sage: M = matroids.named_matroids.Terrahawk() # optional - sage.rings.finite_rings + sage: M # optional - sage.rings.finite_rings Terrahawk: Binary matroid of rank 8 on 16 elements, type (0, 4) - sage: M.is_valid() + sage: M.is_valid() # optional - sage.rings.finite_rings True """ @@ -1653,10 +1656,10 @@ def T12(): EXAMPLES:: - sage: M = matroids.named_matroids.T12() - sage: M + sage: M = matroids.named_matroids.T12() # optional - sage.rings.finite_rings + sage: M # optional - sage.rings.finite_rings T12: Binary matroid of rank 6 on 12 elements, type (2, None) - sage: M.is_valid() + sage: M.is_valid() # optional - sage.rings.finite_rings True """ A = Matrix(GF(2), [ @@ -1681,10 +1684,10 @@ def P9(): EXAMPLES:: - sage: M = matroids.named_matroids.P9() - sage: M + sage: M = matroids.named_matroids.P9() # optional - sage.rings.finite_rings + sage: M # optional - sage.rings.finite_rings P9: Binary matroid of rank 4 on 9 elements, type (1, 1) - sage: M.is_valid() + sage: M.is_valid() # optional - sage.rings.finite_rings True """ A = Matrix(GF(2), [ diff --git a/src/sage/matroids/circuit_closures_matroid.pyx b/src/sage/matroids/circuit_closures_matroid.pyx index 679445a6a62..3c6200bb48b 100644 --- a/src/sage/matroids/circuit_closures_matroid.pyx +++ b/src/sage/matroids/circuit_closures_matroid.pyx @@ -50,8 +50,8 @@ AUTHORS: TESTS:: sage: from sage.matroids.advanced import * - sage: M = CircuitClosuresMatroid(matroids.named_matroids.Fano()) - sage: TestSuite(M).run() + sage: M = CircuitClosuresMatroid(matroids.named_matroids.Fano()) # optional - sage.rings.finite_rings + sage: TestSuite(M).run() # optional - sage.rings.finite_rings Methods ======= @@ -117,8 +117,8 @@ cdef class CircuitClosuresMatroid(Matroid): EXAMPLES:: sage: from sage.matroids.advanced import * - sage: M = CircuitClosuresMatroid(matroids.named_matroids.Fano()) - sage: M + sage: M = CircuitClosuresMatroid(matroids.named_matroids.Fano()) # optional - sage.rings.finite_rings + sage: M # optional - sage.rings.finite_rings Matroid of rank 3 on 7 elements with circuit-closures {2: {{'a', 'b', 'f'}, {'a', 'c', 'e'}, {'a', 'd', 'g'}, {'b', 'c', 'd'}, {'b', 'e', 'g'}, {'c', 'f', 'g'}, @@ -127,7 +127,7 @@ cdef class CircuitClosuresMatroid(Matroid): ....: circuit_closures={3: ['edfg', 'acdg', 'bcfg', 'cefh', ....: 'afgh', 'abce', 'abdf', 'begh', 'bcdh', 'adeh'], ....: 4: ['abcdefgh']}) - sage: M.equals(matroids.named_matroids.P8()) + sage: M.equals(matroids.named_matroids.P8()) # optional - sage.rings.finite_rings True """ @@ -140,8 +140,8 @@ cdef class CircuitClosuresMatroid(Matroid): EXAMPLES:: sage: from sage.matroids.advanced import * - sage: M = CircuitClosuresMatroid(matroids.named_matroids.Fano()) - sage: M + sage: M = CircuitClosuresMatroid(matroids.named_matroids.Fano()) # optional - sage.rings.finite_rings + sage: M # optional - sage.rings.finite_rings Matroid of rank 3 on 7 elements with circuit-closures {2: {{'a', 'b', 'f'}, {'a', 'c', 'e'}, {'a', 'd', 'g'}, {'b', 'c', 'd'}, {'b', 'e', 'g'}, {'c', 'f', 'g'}, @@ -152,7 +152,7 @@ cdef class CircuitClosuresMatroid(Matroid): ....: circuit_closures={3: ['edfg', 'acdg', 'bcfg', 'cefh', ....: 'afgh', 'abce', 'abdf', 'begh', 'bcdh', 'adeh'], ....: 4: ['abcdefgh']}) - sage: M.equals(matroids.named_matroids.P8()) + sage: M.equals(matroids.named_matroids.P8()) # optional - sage.rings.finite_rings True """ if M is not None: @@ -348,17 +348,17 @@ cdef class CircuitClosuresMatroid(Matroid): EXAMPLES:: sage: from sage.matroids.advanced import * - sage: M = CircuitClosuresMatroid(matroids.named_matroids.Fano()) - sage: CC = M.circuit_closures() - sage: len(CC[2]) + sage: M = CircuitClosuresMatroid(matroids.named_matroids.Fano()) # optional - sage.rings.finite_rings + sage: CC = M.circuit_closures() # optional - sage.rings.finite_rings + sage: len(CC[2]) # optional - sage.rings.finite_rings 7 - sage: len(CC[3]) + sage: len(CC[3]) # optional - sage.rings.finite_rings 1 - sage: len(CC[1]) + sage: len(CC[1]) # optional - sage.rings.finite_rings Traceback (most recent call last): ... KeyError: 1 - sage: [sorted(X) for X in CC[3]] + sage: [sorted(X) for X in CC[3]] # optional - sage.rings.finite_rings [['a', 'b', 'c', 'd', 'e', 'f', 'g']] """ return self._circuit_closures @@ -387,16 +387,16 @@ cdef class CircuitClosuresMatroid(Matroid): sage: from sage.matroids.advanced import * sage: M1 = CircuitClosuresMatroid(matroids.Wheel(3)) - sage: M2 = matroids.CompleteGraphic(4) - sage: M1._is_isomorphic(M2) + sage: M2 = matroids.CompleteGraphic(4) # optional - sage.graphs + sage: M1._is_isomorphic(M2) # optional - sage.graphs True - sage: M1._is_isomorphic(M2, certificate=True) + sage: M1._is_isomorphic(M2, certificate=True) # optional - sage.graphs (True, {0: 0, 1: 1, 2: 2, 3: 3, 4: 5, 5: 4}) - sage: M1 = CircuitClosuresMatroid(matroids.named_matroids.Fano()) - sage: M2 = matroids.named_matroids.NonFano() - sage: M1._is_isomorphic(M2) + sage: M1 = CircuitClosuresMatroid(matroids.named_matroids.Fano()) # optional - sage.rings.finite_rings + sage: M2 = matroids.named_matroids.NonFano() # optional - sage.rings.finite_rings + sage: M1._is_isomorphic(M2) # optional - sage.rings.finite_rings False - sage: M1._is_isomorphic(M2, certificate=True) + sage: M1._is_isomorphic(M2, certificate=True) # optional - sage.rings.finite_rings (False, None) diff --git a/src/sage/matroids/constructor.py b/src/sage/matroids/constructor.py index 99580562e96..12ca5ec2873 100644 --- a/src/sage/matroids/constructor.py +++ b/src/sage/matroids/constructor.py @@ -53,8 +53,8 @@ A number of special matroids are collected under a ``named_matroids`` submenu. To see which, type ``matroids.named_matroids.`` as above:: - sage: F7 = matroids.named_matroids.Fano() - sage: len(F7.nonspanning_circuits()) + sage: F7 = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings + sage: len(F7.nonspanning_circuits()) # optional - sage.rings.finite_rings 7 Constructing matroids @@ -68,15 +68,15 @@ EXAMPLES:: - sage: A = Matrix(GF(2), [[1, 0, 0, 0, 1, 1, 1], + sage: A = Matrix(GF(2), [[1, 0, 0, 0, 1, 1, 1], # optional - sage.rings.finite_rings ....: [0, 1, 0, 1, 0, 1, 1], ....: [0, 0, 1, 1, 1, 0, 1]]) - sage: M = Matroid(A) - sage: M.is_isomorphic(matroids.named_matroids.Fano()) + sage: M = Matroid(A) # optional - sage.rings.finite_rings + sage: M.is_isomorphic(matroids.named_matroids.Fano()) # optional - sage.rings.finite_rings True - sage: M = Matroid(graphs.PetersenGraph()) - sage: M.rank() + sage: M = Matroid(graphs.PetersenGraph()) # optional - sage.graphs + sage: M.rank() # optional - sage.graphs 9 AUTHORS: @@ -148,8 +148,8 @@ def Matroid(groundset=None, data=None, **kwds): You will see a list of methods which will construct matroids. For example:: - sage: F7 = matroids.named_matroids.Fano() - sage: len(F7.nonspanning_circuits()) + sage: F7 = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings + sage: len(F7.nonspanning_circuits()) # optional - sage.rings.finite_rings 7 or:: @@ -335,54 +335,54 @@ def Matroid(groundset=None, data=None, **kwds): :: - sage: G = graphs.PetersenGraph() - sage: Matroid(G) + sage: G = graphs.PetersenGraph() # optional - sage.graphs + sage: Matroid(G) # optional - sage.graphs Graphic matroid of rank 9 on 15 elements If each edge has a unique label, then those are used as the ground set labels:: - sage: G = Graph([(0, 1, 'a'), (0, 2, 'b'), (1, 2, 'c')]) - sage: M = Matroid(G) - sage: sorted(M.groundset()) + sage: G = Graph([(0, 1, 'a'), (0, 2, 'b'), (1, 2, 'c')]) # optional - sage.graphs + sage: M = Matroid(G) # optional - sage.graphs + sage: sorted(M.groundset()) # optional - sage.graphs ['a', 'b', 'c'] If there are parallel edges, then integers are used for the ground set. If there are no edges in parallel, and is not a complete list of labels, or the labels are not unique, then vertex tuples are used:: - sage: G = Graph([(0, 1, 'a'), (0, 2, 'b'), (1, 2, 'b')]) - sage: M = Matroid(G) - sage: sorted(M.groundset()) + sage: G = Graph([(0, 1, 'a'), (0, 2, 'b'), (1, 2, 'b')]) # optional - sage.graphs + sage: M = Matroid(G) # optional - sage.graphs + sage: sorted(M.groundset()) # optional - sage.graphs [(0, 1), (0, 2), (1, 2)] - sage: H = Graph([(0, 1, 'a'), (0, 2, 'b'), (1, 2, 'b'), (1, 2, 'c')], multiedges=True) - sage: N = Matroid(H) - sage: sorted(N.groundset()) + sage: H = Graph([(0, 1, 'a'), (0, 2, 'b'), (1, 2, 'b'), (1, 2, 'c')], # optional - sage.graphs + ....: multiedges=True) + sage: N = Matroid(H) # optional - sage.graphs + sage: sorted(N.groundset()) # optional - sage.graphs [0, 1, 2, 3] The GraphicMatroid object forces its graph to be connected. If a disconnected graph is used as input, it will connect the components:: - sage: G1 = graphs.CycleGraph(3); G2 = graphs.DiamondGraph() - sage: G = G1.disjoint_union(G2) - sage: M = Matroid(G) - sage: M + sage: G1 = graphs.CycleGraph(3); G2 = graphs.DiamondGraph() # optional - sage.graphs + sage: G = G1.disjoint_union(G2) # optional - sage.graphs + sage: M = Matroid(G); M # optional - sage.graphs Graphic matroid of rank 5 on 8 elements - sage: M.graph() + sage: M.graph() # optional - sage.graphs Looped multi-graph on 6 vertices - sage: M.graph().is_connected() + sage: M.graph().is_connected() # optional - sage.graphs True - sage: M.is_connected() + sage: M.is_connected() # optional - sage.graphs False If the keyword ``regular`` is set to ``True``, the output will instead - be an instance of ``RegularMatroid``. + be an instance of :class:`RegularMatroid`. :: - sage: G = Graph([(0, 1), (0, 2), (1, 2)]) - sage: M = Matroid(G, regular=True); M + sage: G = Graph([(0, 1), (0, 2), (1, 2)]) # optional - sage.graphs + sage: M = Matroid(G, regular=True); M # optional - sage.graphs Regular matroid of rank 2 on 3 elements with 3 bases Note: if a groundset is specified, we assume it is in the same order @@ -390,9 +390,9 @@ def Matroid(groundset=None, data=None, **kwds): :meth:`G.edge_iterator() ` provides:: - sage: G = Graph([(0, 1), (0, 2), (0, 2), (1, 2)], multiedges=True) - sage: M = Matroid('abcd', G) - sage: M.rank(['b', 'c']) + sage: G = Graph([(0, 1), (0, 2), (0, 2), (1, 2)], multiedges=True) # optional - sage.graphs + sage: M = Matroid('abcd', G) # optional - sage.graphs + sage: M.rank(['b', 'c']) # optional - sage.graphs 1 As before, @@ -400,14 +400,14 @@ def Matroid(groundset=None, data=None, **kwds): tuples ``(i, j)`` of endpoints. If that fails, we simply use a list ``[0..m-1]`` :: - sage: G = Graph([(0, 1), (0, 2), (1, 2)]) - sage: M = Matroid(G, regular=True) - sage: sorted(M.groundset()) + sage: G = Graph([(0, 1), (0, 2), (1, 2)]) # optional - sage.graphs + sage: M = Matroid(G, regular=True) # optional - sage.graphs + sage: sorted(M.groundset()) # optional - sage.graphs [(0, 1), (0, 2), (1, 2)] - sage: G = Graph([(0, 1), (0, 2), (0, 2), (1, 2)], multiedges=True) - sage: M = Matroid(G, regular=True) - sage: sorted(M.groundset()) + sage: G = Graph([(0, 1), (0, 2), (0, 2), (1, 2)], multiedges=True) # optional - sage.graphs + sage: M = Matroid(G, regular=True) # optional - sage.graphs + sage: sorted(M.groundset()) # optional - sage.graphs [0, 1, 2, 3] When the ``graph`` keyword is used, a variety of inputs can be @@ -415,12 +415,12 @@ def Matroid(groundset=None, data=None, **kwds): (see the :class:`Graph ` method's documentation):: - sage: Matroid(graph=':I`AKGsaOs`cI]Gb~') + sage: Matroid(graph=':I`AKGsaOs`cI]Gb~') # optional - sage.graphs Graphic matroid of rank 9 on 17 elements However, this method is no more clever than ``Graph()``:: - sage: Matroid(graph=41/2) + sage: Matroid(graph=41/2) # optional - sage.graphs Traceback (most recent call last): ... ValueError: This input cannot be turned into a graph @@ -430,31 +430,31 @@ def Matroid(groundset=None, data=None, **kwds): The basic input is a :mod:`Sage matrix `:: - sage: A = Matrix(GF(2), [[1, 0, 0, 1, 1, 0], + sage: A = Matrix(GF(2), [[1, 0, 0, 1, 1, 0], # optional - sage.rings.finite_rings ....: [0, 1, 0, 1, 0, 1], ....: [0, 0, 1, 0, 1, 1]]) - sage: M = Matroid(matrix=A) - sage: M.is_isomorphic(matroids.CompleteGraphic(4)) + sage: M = Matroid(matrix=A) # optional - sage.rings.finite_rings + sage: M.is_isomorphic(matroids.CompleteGraphic(4)) # optional - sage.graphs sage.rings.finite_rings True Various shortcuts are possible:: - sage: M1 = Matroid(matrix=[[1, 0, 0, 1, 1, 0], + sage: M1 = Matroid(matrix=[[1, 0, 0, 1, 1, 0], # optional - sage.rings.finite_rings ....: [0, 1, 0, 1, 0, 1], ....: [0, 0, 1, 0, 1, 1]], ring=GF(2)) - sage: M2 = Matroid(reduced_matrix=[[1, 1, 0], + sage: M2 = Matroid(reduced_matrix=[[1, 1, 0], # optional - sage.rings.finite_rings ....: [1, 0, 1], ....: [0, 1, 1]], ring=GF(2)) - sage: M3 = Matroid(groundset=[0, 1, 2, 3, 4, 5], + sage: M3 = Matroid(groundset=[0, 1, 2, 3, 4, 5], # optional - sage.rings.finite_rings ....: matrix=[[1, 1, 0], [1, 0, 1], [0, 1, 1]], ....: ring=GF(2)) - sage: A = Matrix(GF(2), [[1, 1, 0], [1, 0, 1], [0, 1, 1]]) - sage: M4 = Matroid([0, 1, 2, 3, 4, 5], A) - sage: M1 == M2 + sage: A = Matrix(GF(2), [[1, 1, 0], [1, 0, 1], [0, 1, 1]]) # optional - sage.rings.finite_rings + sage: M4 = Matroid([0, 1, 2, 3, 4, 5], A) # optional - sage.rings.finite_rings + sage: M1 == M2 # optional - sage.rings.finite_rings True - sage: M1 == M3 + sage: M1 == M3 # optional - sage.rings.finite_rings True - sage: M1 == M4 + sage: M1 == M4 # optional - sage.rings.finite_rings True However, with unnamed arguments the input has to be a ``Matrix`` @@ -469,36 +469,36 @@ def Matroid(groundset=None, data=None, **kwds): identity matrix is prepended. Otherwise the groundset size must equal the number of columns:: - sage: A = Matrix(GF(2), [[1, 1, 0], [1, 0, 1], [0, 1, 1]]) - sage: M = Matroid([0, 1, 2], A) - sage: N = Matroid([0, 1, 2, 3, 4, 5], A) - sage: M.rank() + sage: A = Matrix(GF(2), [[1, 1, 0], [1, 0, 1], [0, 1, 1]]) # optional - sage.rings.finite_rings + sage: M = Matroid([0, 1, 2], A) # optional - sage.rings.finite_rings + sage: N = Matroid([0, 1, 2, 3, 4, 5], A) # optional - sage.rings.finite_rings + sage: M.rank() # optional - sage.rings.finite_rings 2 - sage: N.rank() + sage: N.rank() # optional - sage.rings.finite_rings 3 We automatically create an optimized subclass, if available:: - sage: Matroid([0, 1, 2, 3, 4, 5], + sage: Matroid([0, 1, 2, 3, 4, 5], # optional - sage.rings.finite_rings ....: matrix=[[1, 1, 0], [1, 0, 1], [0, 1, 1]], ....: field=GF(2)) Binary matroid of rank 3 on 6 elements, type (2, 7) - sage: Matroid([0, 1, 2, 3, 4, 5], + sage: Matroid([0, 1, 2, 3, 4, 5], # optional - sage.rings.finite_rings ....: matrix=[[1, 1, 0], [1, 0, 1], [0, 1, 1]], ....: field=GF(3)) Ternary matroid of rank 3 on 6 elements, type 0- - sage: Matroid([0, 1, 2, 3, 4, 5], + sage: Matroid([0, 1, 2, 3, 4, 5], # optional - sage.rings.finite_rings ....: matrix=[[1, 1, 0], [1, 0, 1], [0, 1, 1]], ....: field=GF(4, 'x')) Quaternary matroid of rank 3 on 6 elements - sage: Matroid([0, 1, 2, 3, 4, 5], + sage: Matroid([0, 1, 2, 3, 4, 5], # optional - sage.rings.finite_rings ....: matrix=[[1, 1, 0], [1, 0, 1], [0, 1, 1]], ....: field=GF(2), regular=True) Regular matroid of rank 3 on 6 elements with 16 bases Otherwise the generic LinearMatroid class is used:: - sage: Matroid([0, 1, 2, 3, 4, 5], + sage: Matroid([0, 1, 2, 3, 4, 5], # optional - sage.rings.finite_rings ....: matrix=[[1, 1, 0], [1, 0, 1], [0, 1, 1]], ....: field=GF(83)) Linear matroid of rank 3 on 6 elements represented over the Finite @@ -592,9 +592,9 @@ def Matroid(groundset=None, data=None, **kwds): Most of the time, the matroid itself is returned:: - sage: M = matroids.named_matroids.Fano() - sage: N = Matroid(M) - sage: N is M + sage: M = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings + sage: N = Matroid(M) # optional - sage.rings.finite_rings + sage: N is M # optional - sage.rings.finite_rings True But it can be useful with the ``regular`` option:: @@ -615,10 +615,9 @@ def Matroid(groundset=None, data=None, **kwds): The ``regular`` option:: - sage: M = Matroid(reduced_matrix=[[1, 1, 0], + sage: M = Matroid(reduced_matrix=[[1, 1, 0], # optional - sage.graphs ....: [1, 0, 1], - ....: [0, 1, 1]], regular=True) - sage: M + ....: [0, 1, 1]], regular=True); M Regular matroid of rank 3 on 6 elements with 16 bases sage: M.is_isomorphic(matroids.CompleteGraphic(4)) @@ -627,27 +626,26 @@ def Matroid(groundset=None, data=None, **kwds): By default we check if the resulting matroid is actually regular. To increase speed, this check can be skipped:: - sage: M = matroids.named_matroids.Fano() - sage: N = Matroid(M, regular=True) + sage: M = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings + sage: N = Matroid(M, regular=True) # optional - sage.rings.finite_rings Traceback (most recent call last): ... ValueError: input is not a valid regular matroid - sage: N = Matroid(M, regular=True, check=False) - sage: N + sage: N = Matroid(M, regular=True, check=False); N # optional - sage.rings.finite_rings Regular matroid of rank 3 on 7 elements with 32 bases - sage: N.is_valid() + sage: N.is_valid() # optional - sage.rings.finite_rings False Sometimes the output is regular, but represents a different matroid from the one you intended:: - sage: M = Matroid(Matrix(GF(3), [[1, 0, 1, 1], [0, 1, 1, 2]])) - sage: N = Matroid(Matrix(GF(3), [[1, 0, 1, 1], [0, 1, 1, 2]]), + sage: M = Matroid(Matrix(GF(3), [[1, 0, 1, 1], [0, 1, 1, 2]])) # optional - sage.rings.finite_rings + sage: N = Matroid(Matrix(GF(3), [[1, 0, 1, 1], [0, 1, 1, 2]]), # optional - sage.rings.finite_rings ....: regular=True) - sage: N.is_valid() + sage: N.is_valid() # optional - sage.rings.finite_rings True - sage: N.is_isomorphic(M) + sage: N.is_isomorphic(M) # optional - sage.rings.finite_rings False TESTS:: diff --git a/src/sage/matroids/dual_matroid.py b/src/sage/matroids/dual_matroid.py index 804e43f035b..87dfdda88d0 100644 --- a/src/sage/matroids/dual_matroid.py +++ b/src/sage/matroids/dual_matroid.py @@ -10,13 +10,13 @@ EXAMPLES:: - sage: M = matroids.named_matroids.Fano() - sage: N = M.dual() - sage: M.is_basis('abc') + sage: M = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings + sage: N = M.dual() # optional - sage.rings.finite_rings + sage: M.is_basis('abc') # optional - sage.rings.finite_rings True - sage: N.is_basis('defg') + sage: N.is_basis('defg') # optional - sage.rings.finite_rings True - sage: M.dual().dual() == M + sage: M.dual().dual() == M # optional - sage.rings.finite_rings True Implementation @@ -455,17 +455,17 @@ def __eq__(self, other): EXAMPLES:: sage: from sage.matroids.advanced import * - sage: M1 = matroids.named_matroids.Fano() - sage: M2 = CircuitClosuresMatroid(M1.dual()) - sage: M3 = CircuitClosuresMatroid(M1).dual() + sage: M1 = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings + sage: M2 = CircuitClosuresMatroid(M1.dual()) # optional - sage.rings.finite_rings + sage: M3 = CircuitClosuresMatroid(M1).dual() # optional - sage.rings.finite_rings sage: M4 = CircuitClosuresMatroid(groundset='abcdefg', ....: circuit_closures={3: ['abcdefg'], 2: ['beg', 'cdb', 'cfg', ....: 'ace', 'fed', 'gad', 'fab']}).dual() - sage: M1.dual() == M2 # indirect doctest + sage: M1.dual() == M2 # indirect doctest # optional - sage.rings.finite_rings False - sage: M2 == M3 + sage: M2 == M3 # optional - sage.rings.finite_rings False - sage: M3 == M4 + sage: M3 == M4 # optional - sage.rings.finite_rings True """ if not isinstance(other, DualMatroid): @@ -487,17 +487,17 @@ def __ne__(self, other): EXAMPLES:: sage: from sage.matroids.advanced import * - sage: M1 = matroids.named_matroids.Fano() - sage: M2 = CircuitClosuresMatroid(M1.dual()) - sage: M3 = CircuitClosuresMatroid(M1).dual() + sage: M1 = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings + sage: M2 = CircuitClosuresMatroid(M1.dual()) # optional - sage.rings.finite_rings + sage: M3 = CircuitClosuresMatroid(M1).dual() # optional - sage.rings.finite_rings sage: M4 = CircuitClosuresMatroid(groundset='abcdefg', ....: circuit_closures={3: ['abcdefg'], 2: ['beg', 'cdb', 'cfg', ....: 'ace', 'fed', 'gad', 'fab']}).dual() - sage: M1.dual() != M2 # indirect doctest + sage: M1.dual() != M2 # indirect doctest # optional - sage.rings.finite_rings True - sage: M2 != M3 + sage: M2 != M3 # optional - sage.rings.finite_rings True - sage: M3 != M4 + sage: M3 != M4 # optional - sage.rings.finite_rings False """ return not self == other diff --git a/src/sage/matroids/extension.pyx b/src/sage/matroids/extension.pyx index d762526d2fa..dae24e2be8b 100644 --- a/src/sage/matroids/extension.pyx +++ b/src/sage/matroids/extension.pyx @@ -59,7 +59,7 @@ cdef class CutNode: EXAMPLES:: - sage: len(list(matroids.named_matroids.Fano().linear_subclasses())) # indirect doctest + sage: len(list(matroids.named_matroids.Fano().linear_subclasses())) # indirect doctest # optional - sage.rings.finite_rings 16 """ cdef CutNode node diff --git a/src/sage/matroids/graphic_matroid.py b/src/sage/matroids/graphic_matroid.py index 9bafa6dc0c7..b20d538030e 100644 --- a/src/sage/matroids/graphic_matroid.py +++ b/src/sage/matroids/graphic_matroid.py @@ -1,3 +1,4 @@ +# sage.doctest: optional - sage.graphs r""" Graphic Matroids @@ -1334,6 +1335,8 @@ def _subgraph_from_set(self, X): sage: M._subgraph_from_set([0,1,2]) Looped multi-graph on 3 vertices """ + from sage.graphs.graph import Graph + edge_list = self._groundset_to_edges(X) return Graph(edge_list, loops=True, multiedges=True) diff --git a/src/sage/matroids/lean_matrix.pyx b/src/sage/matroids/lean_matrix.pyx index 145bdd47544..d202f2d91d2 100644 --- a/src/sage/matroids/lean_matrix.pyx +++ b/src/sage/matroids/lean_matrix.pyx @@ -1,3 +1,4 @@ +# sage.doctest: optional - sage.rings.finite_rings # cython: profile=True """ Lean matrices diff --git a/src/sage/matroids/linear_matroid.pyx b/src/sage/matroids/linear_matroid.pyx index cd7416c986e..baa8aae6f15 100644 --- a/src/sage/matroids/linear_matroid.pyx +++ b/src/sage/matroids/linear_matroid.pyx @@ -21,25 +21,25 @@ See also :mod:`sage.matroids.advanced`. In both cases, it is possible to provide a reduced matrix `B`, to create the matroid induced by `A = [ I B ]`:: sage: from sage.matroids.advanced import * - sage: A = Matrix(GF(2), [[1, 0, 0, 1, 1, 0, 1], [0, 1, 0, 1, 0, 1, 1], + sage: A = Matrix(GF(2), [[1, 0, 0, 1, 1, 0, 1], [0, 1, 0, 1, 0, 1, 1], # optional - sage.rings.finite_rings ....: [0, 0, 1, 0, 1, 1, 1]]) - sage: B = Matrix(GF(2), [[1, 1, 0, 1], [1, 0, 1, 1], [0, 1, 1, 1]]) - sage: M1 = Matroid(A) - sage: M2 = LinearMatroid(A) - sage: M3 = BinaryMatroid(A) - sage: M4 = Matroid(reduced_matrix=B) - sage: M5 = LinearMatroid(reduced_matrix=B) - sage: isinstance(M1, BinaryMatroid) + sage: B = Matrix(GF(2), [[1, 1, 0, 1], [1, 0, 1, 1], [0, 1, 1, 1]]) # optional - sage.rings.finite_rings + sage: M1 = Matroid(A) # optional - sage.rings.finite_rings + sage: M2 = LinearMatroid(A) # optional - sage.rings.finite_rings + sage: M3 = BinaryMatroid(A) # optional - sage.rings.finite_rings + sage: M4 = Matroid(reduced_matrix=B) # optional - sage.rings.finite_rings + sage: M5 = LinearMatroid(reduced_matrix=B) # optional - sage.rings.finite_rings + sage: isinstance(M1, BinaryMatroid) # optional - sage.rings.finite_rings True - sage: M1.equals(M2) + sage: M1.equals(M2) # optional - sage.rings.finite_rings True - sage: M1.equals(M3) + sage: M1.equals(M3) # optional - sage.rings.finite_rings True - sage: M1 == M4 + sage: M1 == M4 # optional - sage.rings.finite_rings True - sage: M1.is_field_isomorphic(M5) + sage: M1.is_field_isomorphic(M5) # optional - sage.rings.finite_rings True - sage: M2 == M3 # comparing LinearMatroid and BinaryMatroid always yields False + sage: M2 == M3 # comparing LinearMatroid and BinaryMatroid always yields False # optional - sage.rings.finite_rings False Class methods @@ -241,22 +241,22 @@ cdef class LinearMatroid(BasisExchangeMatroid): EXAMPLES:: sage: from sage.matroids.advanced import * - sage: A = Matrix(GF(3), 2, 4, [[1, 0, 1, 1], [0, 1, 1, 2]]) - sage: M = LinearMatroid(A) - sage: M + sage: A = Matrix(GF(3), 2, 4, [[1, 0, 1, 1], [0, 1, 1, 2]]) # optional - sage.rings.finite_rings + sage: M = LinearMatroid(A) # optional - sage.rings.finite_rings + sage: M # optional - sage.rings.finite_rings Linear matroid of rank 2 on 4 elements represented over the Finite Field of size 3 - sage: sorted(M.groundset()) + sage: sorted(M.groundset()) # optional - sage.rings.finite_rings [0, 1, 2, 3] - sage: Matrix(M) + sage: Matrix(M) # optional - sage.rings.finite_rings [1 0 1 1] [0 1 1 2] - sage: M = LinearMatroid(A, 'abcd') - sage: sorted(M.groundset()) + sage: M = LinearMatroid(A, 'abcd') # optional - sage.rings.finite_rings + sage: sorted(M.groundset()) # optional - sage.rings.finite_rings ['a', 'b', 'c', 'd'] - sage: B = Matrix(GF(3), 2, 2, [[1, 1], [1, 2]]) - sage: N = LinearMatroid(reduced_matrix=B, groundset='abcd') - sage: M == N + sage: B = Matrix(GF(3), 2, 2, [[1, 1], [1, 2]]) # optional - sage.rings.finite_rings + sage: N = LinearMatroid(reduced_matrix=B, groundset='abcd') # optional - sage.rings.finite_rings + sage: M == N # optional - sage.rings.finite_rings True """ def __init__(self, matrix=None, groundset=None, reduced_matrix=None, ring=None, keep_initial_representation=True): @@ -266,7 +266,7 @@ cdef class LinearMatroid(BasisExchangeMatroid): EXAMPLES:: sage: from sage.matroids.advanced import * - sage: LinearMatroid(matrix=Matrix(GF(5), [[1, 0, 1, 1, 1], # indirect doctest + sage: LinearMatroid(matrix=Matrix(GF(5), [[1, 0, 1, 1, 1], # indirect doctest, optional - sage.rings.finite_rings ....: [0, 1, 1, 2, 3]])) Linear matroid of rank 2 on 5 elements represented over the Finite Field of size 5 @@ -289,7 +289,7 @@ cdef class LinearMatroid(BasisExchangeMatroid): EXAMPLES:: sage: from sage.matroids.advanced import * - sage: M = LinearMatroid(matrix=Matrix(GF(5), [[1, 0, 1, 1, 1], # indirect doctest + sage: M = LinearMatroid(matrix=Matrix(GF(5), [[1, 0, 1, 1, 1], # indirect doctest, optional - sage.rings.finite_rings ....: [0, 1, 1, 2, 3]])) sage: M = None """ @@ -355,11 +355,11 @@ cdef class LinearMatroid(BasisExchangeMatroid): EXAMPLES:: sage: from sage.matroids.advanced import * - sage: M = LinearMatroid(matrix=Matrix(GF(5), [[1, 1, 0, 1, 1], + sage: M = LinearMatroid(matrix=Matrix(GF(5), [[1, 1, 0, 1, 1], # optional - sage.rings.finite_rings ....: [0, 1, 1, 2, 3]])) - sage: A = Matrix(M) - sage: M._forget() - sage: A == Matrix(M) + sage: A = Matrix(M) # optional - sage.rings.finite_rings + sage: M._forget() # optional - sage.rings.finite_rings + sage: A == Matrix(M) # optional - sage.rings.finite_rings False """ self._representation = None @@ -370,9 +370,9 @@ cdef class LinearMatroid(BasisExchangeMatroid): EXAMPLES:: - sage: M = Matroid(matrix=Matrix(GF(5), [[1, 0, 1, 1, 1], + sage: M = Matroid(matrix=Matrix(GF(5), [[1, 0, 1, 1, 1], # optional - sage.rings.finite_rings ....: [0, 1, 1, 2, 3]])) - sage: M.base_ring() + sage: M.base_ring() # optional - sage.rings.finite_rings Finite Field of size 5 """ return self._A.base_ring() @@ -384,9 +384,9 @@ cdef class LinearMatroid(BasisExchangeMatroid): EXAMPLES:: - sage: M = Matroid(matrix=Matrix(GF(5), [[1, 0, 1, 1, 1], + sage: M = Matroid(matrix=Matrix(GF(5), [[1, 0, 1, 1, 1], # optional - sage.rings.finite_rings ....: [0, 1, 1, 2, 3]])) - sage: M.characteristic() + sage: M.characteristic() # optional - sage.rings.finite_rings 5 """ return characteristic(self._A) @@ -442,13 +442,13 @@ cdef class LinearMatroid(BasisExchangeMatroid): EXAMPLES:: - sage: M = Matroid(matrix=Matrix(GF(5), [[1, 1, 0, 1, 1], + sage: M = Matroid(matrix=Matrix(GF(5), [[1, 1, 0, 1, 1], # optional - sage.rings.finite_rings ....: [0, 1, 1, 2, 3]])) - sage: M._matrix_() + sage: M._matrix_() # optional - sage.rings.finite_rings [1 1 0 1 1] [0 1 1 2 3] - sage: M._forget() - sage: M._matrix_() + sage: M._forget() # optional - sage.rings.finite_rings + sage: M._matrix_() # optional - sage.rings.finite_rings [1 0 4 4 3] [0 1 1 2 3] """ @@ -460,9 +460,9 @@ cdef class LinearMatroid(BasisExchangeMatroid): EXAMPLES:: - sage: M = Matroid(matrix=Matrix(GF(5), [[1, 1, 0, 1, 1], + sage: M = Matroid(matrix=Matrix(GF(5), [[1, 1, 0, 1, 1], # optional - sage.rings.finite_rings ....: [0, 1, 1, 2, 3]])) - sage: repr(M) # indirect doctest + sage: repr(M) # indirect doctest # optional - sage.rings.finite_rings 'Linear matroid of rank 2 on 5 elements represented over the Finite Field of size 5' """ @@ -538,44 +538,44 @@ cdef class LinearMatroid(BasisExchangeMatroid): EXAMPLES:: - sage: M = matroids.named_matroids.Fano() - sage: M.representation() + sage: M = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings + sage: M.representation() # optional - sage.rings.finite_rings [1 0 0 0 1 1 1] [0 1 0 1 0 1 1] [0 0 1 1 1 0 1] - sage: Matrix(M) == M.representation() + sage: Matrix(M) == M.representation() # optional - sage.rings.finite_rings True - sage: M.representation(labels=True) + sage: M.representation(labels=True) # optional - sage.rings.finite_rings ( [1 0 0 0 1 1 1] [0 1 0 1 0 1 1] [0 0 1 1 1 0 1], ['a', 'b', 'c', 'd', 'e', 'f', 'g'] ) - sage: M.representation(B='efg') + sage: M.representation(B='efg') # optional - sage.rings.finite_rings [1 1 0 1 1 0 0] [1 0 1 1 0 1 0] [1 1 1 0 0 0 1] - sage: M.representation(B='efg', order='efgabcd') + sage: M.representation(B='efg', order='efgabcd') # optional - sage.rings.finite_rings [1 0 0 1 1 0 1] [0 1 0 1 0 1 1] [0 0 1 1 1 1 0] - sage: M.representation(B='abc', reduced=True) + sage: M.representation(B='abc', reduced=True) # optional - sage.rings.finite_rings ( [0 1 1 1] [1 0 1 1] [1 1 0 1], ['a', 'b', 'c'], ['d', 'e', 'f', 'g'] ) - sage: M.representation(B='efg', reduced=True, labels=False, + sage: M.representation(B='efg', reduced=True, labels=False, # optional - sage.rings.finite_rings ....: order='gfeabcd') [1 1 1 0] [1 0 1 1] [1 1 0 1] sage: from sage.matroids.advanced import lift_cross_ratios, lift_map, LinearMatroid - sage: R = GF(7) - sage: A = Matrix(R, [[1, 0, 6, 1, 2],[6, 1, 0, 0, 1],[0, 6, 3, 6, 0]]) - sage: M = LinearMatroid(reduced_matrix = A) - sage: M.representation(lift_map=lift_map('sru')) + sage: R = GF(7) # optional - sage.rings.finite_rings + sage: A = Matrix(R, [[1, 0, 6, 1, 2],[6, 1, 0, 0, 1],[0, 6, 3, 6, 0]]) # optional - sage.rings.finite_rings + sage: M = LinearMatroid(reduced_matrix=A) # optional - sage.rings.finite_rings + sage: M.representation(lift_map=lift_map('sru')) # optional - sage.rings.finite_rings [ 1 0 0 1 0 1 1 1] [ 0 1 0 -z + 1 1 0 0 1] [ 0 0 1 0 -z z 1 0] @@ -667,13 +667,13 @@ cdef class LinearMatroid(BasisExchangeMatroid): EXAMPLES:: - sage: M = matroids.named_matroids.Fano() - sage: A = M._reduced_representation('efg') - sage: R, C = M._current_rows_cols() - sage: (sorted(R), sorted(C)) + sage: M = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings + sage: A = M._reduced_representation('efg') # optional - sage.rings.finite_rings + sage: R, C = M._current_rows_cols() # optional - sage.rings.finite_rings + sage: (sorted(R), sorted(C)) # optional - sage.rings.finite_rings (['e', 'f', 'g'], ['a', 'b', 'c', 'd']) - sage: R, C = M._current_rows_cols(B='abg') - sage: (sorted(R), sorted(C)) + sage: R, C = M._current_rows_cols(B='abg') # optional - sage.rings.finite_rings + sage: (sorted(R), sorted(C)) # optional - sage.rings.finite_rings (['a', 'b', 'g'], ['c', 'd', 'e', 'f']) """ @@ -712,12 +712,12 @@ cdef class LinearMatroid(BasisExchangeMatroid): EXAMPLES:: - sage: M = Matroid(reduced_matrix=Matrix(GF(7), [[1, 1, 1], + sage: M = Matroid(reduced_matrix=Matrix(GF(7), [[1, 1, 1], # optional - sage.rings.finite_rings ....: [1, 2, 3]])) - sage: M._basic_representation() + sage: M._basic_representation() # optional - sage.rings.finite_rings LeanMatrix instance with 2 rows and 5 columns over Finite Field of size 7 - sage: matrix(M._basic_representation([3, 4])) + sage: matrix(M._basic_representation([3, 4])) # optional - sage.rings.finite_rings [3 6 2 1 0] [5 1 6 0 1] @@ -748,9 +748,9 @@ cdef class LinearMatroid(BasisExchangeMatroid): EXAMPLES:: - sage: M = matroids.named_matroids.Fano() - sage: E = M.groundset_list() - sage: [M.representation_vectors()[e] for e in E] + sage: M = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings + sage: E = M.groundset_list() # optional - sage.rings.finite_rings + sage: [M.representation_vectors()[e] for e in E] # optional - sage.rings.finite_rings [(1, 0, 0), (0, 1, 0), (0, 0, 1), (0, 1, 1), (1, 0, 1), (1, 1, 0), (1, 1, 1)] """ @@ -781,12 +781,12 @@ cdef class LinearMatroid(BasisExchangeMatroid): EXAMPLES:: - sage: M = Matroid(reduced_matrix=Matrix(GF(7), [[1, 1, 1], + sage: M = Matroid(reduced_matrix=Matrix(GF(7), [[1, 1, 1], # optional - sage.rings.finite_rings ....: [1, 2, 3]])) - sage: M._reduced_representation() + sage: M._reduced_representation() # optional - sage.rings.finite_rings LeanMatrix instance with 2 rows and 3 columns over Finite Field of size 7 - sage: matrix(M._reduced_representation([3, 4])) + sage: matrix(M._reduced_representation([3, 4])) # optional - sage.rings.finite_rings [2 3 6] [6 5 1] """ @@ -819,19 +819,13 @@ cdef class LinearMatroid(BasisExchangeMatroid): EXAMPLES:: sage: from sage.matroids.advanced import * - sage: M = matroids.named_matroids.Fano() \ ['g'] - sage: N = BinaryMatroid(Matrix(matroids.Wheel(3))) - sage: morphism = {'a':0, 'b':1, 'c': 2, 'd':4, 'e':5, 'f':3} - sage: M._is_field_isomorphism(N, morphism) + sage: M = matroids.named_matroids.Fano() \ ['g'] # optional - sage.rings.finite_rings + sage: N = BinaryMatroid(Matrix(matroids.Wheel(3))) # optional - sage.rings.finite_rings + sage: morphism = {'a':0, 'b':1, 'c': 2, 'd':4, 'e':5, 'f':3} # optional - sage.rings.finite_rings + sage: M._is_field_isomorphism(N, morphism) # optional - sage.rings.finite_rings True """ # TODO: ensure this is safe for noncommutative rings - global GF2, GF2_zero, GF2_one, GF2_not_defined - if GF2_not_defined: - GF2 = GF(2) - GF2_zero = GF2(0) - GF2_one = GF2(1) - GF2_not_defined = False B = self.basis() N = self.groundset() - B Bo = frozenset([morphism[e] for e in B]) @@ -845,8 +839,18 @@ cdef class LinearMatroid(BasisExchangeMatroid): if other._cocircuit(No | set([morphism[e]])) != frozenset([morphism[f] for f in C[e]]): return False - if self.base_ring() == GF2: - return True + global GF2, GF2_zero, GF2_one, GF2_not_defined + try: + if GF2_not_defined: + GF2 = GF(2) + GF2_zero = GF2(0) + GF2_one = GF2(1) + GF2_not_defined = False + except ImportError: + pass + else: + if self.base_ring() == GF2: + return True self._set_current_basis(B) other._set_current_basis(Bo) @@ -907,48 +911,48 @@ cdef class LinearMatroid(BasisExchangeMatroid): yields ``False``, even if the matroids are equal:: sage: from sage.matroids.advanced import * - sage: M = matroids.named_matroids.Fano() - sage: M1 = LinearMatroid(Matrix(M), groundset=M.groundset_list()) - sage: M2 = Matroid(groundset='abcdefg', + sage: M = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings + sage: M1 = LinearMatroid(Matrix(M), groundset=M.groundset_list()) # optional - sage.rings.finite_rings + sage: M2 = Matroid(groundset='abcdefg', # optional - sage.rings.finite_rings ....: reduced_matrix=[[0, 1, 1, 1], ....: [1, 0, 1, 1], ....: [1, 1, 0, 1]], field=GF(2)) - sage: M.equals(M1) + sage: M.equals(M1) # optional - sage.rings.finite_rings True - sage: M.equals(M2) + sage: M.equals(M2) # optional - sage.rings.finite_rings True - sage: M.is_field_equivalent(M1) + sage: M.is_field_equivalent(M1) # optional - sage.rings.finite_rings True - sage: M.is_field_equivalent(M2) + sage: M.is_field_equivalent(M2) # optional - sage.rings.finite_rings True - sage: M == M1 + sage: M == M1 # optional - sage.rings.finite_rings False - sage: M == M2 + sage: M == M2 # optional - sage.rings.finite_rings True ``LinearMatroid`` instances ``M`` and ``N`` satisfy ``M == N`` if the representations are equivalent up to row operations and column scaling:: - sage: M1 = Matroid(groundset='abcd', + sage: M1 = Matroid(groundset='abcd', # optional - sage.rings.finite_rings ....: matrix=Matrix(GF(7), [[1, 0, 1, 1], [0, 1, 1, 2]])) - sage: M2 = Matroid(groundset='abcd', + sage: M2 = Matroid(groundset='abcd', # optional - sage.rings.finite_rings ....: matrix=Matrix(GF(7), [[1, 0, 1, 1], [0, 1, 1, 3]])) - sage: M3 = Matroid(groundset='abcd', + sage: M3 = Matroid(groundset='abcd', # optional - sage.rings.finite_rings ....: matrix=Matrix(GF(7), [[2, 6, 1, 0], [6, 1, 0, 1]])) - sage: M1.equals(M2) + sage: M1.equals(M2) # optional - sage.rings.finite_rings True - sage: M1.equals(M3) + sage: M1.equals(M3) # optional - sage.rings.finite_rings True - sage: M1 == M2 + sage: M1 == M2 # optional - sage.rings.finite_rings False - sage: M1 == M3 + sage: M1 == M3 # optional - sage.rings.finite_rings True - sage: M1.is_field_equivalent(M2) + sage: M1.is_field_equivalent(M2) # optional - sage.rings.finite_rings False - sage: M1.is_field_equivalent(M3) + sage: M1.is_field_equivalent(M3) # optional - sage.rings.finite_rings True - sage: M1.is_field_equivalent(M1) + sage: M1.is_field_equivalent(M1) # optional - sage.rings.finite_rings True """ if self is other: @@ -994,28 +998,28 @@ cdef class LinearMatroid(BasisExchangeMatroid): EXAMPLES:: - sage: M = matroids.named_matroids.Fano() - sage: N = matroids.named_matroids.NonFano() - sage: N.is_field_isomorphism(M, {e:e for e in M.groundset()}) + sage: M = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings + sage: N = matroids.named_matroids.NonFano() # optional - sage.rings.finite_rings + sage: N.is_field_isomorphism(M, {e:e for e in M.groundset()}) # optional - sage.rings.finite_rings False - sage: from sage.matroids.advanced import * - sage: M = matroids.named_matroids.Fano() \ ['g'] - sage: N = LinearMatroid(reduced_matrix=Matrix(GF(2), + sage: from sage.matroids.advanced import * # optional - sage.rings.finite_rings + sage: M = matroids.named_matroids.Fano() \ ['g'] # optional - sage.rings.finite_rings + sage: N = LinearMatroid(reduced_matrix=Matrix(GF(2), # optional - sage.rings.finite_rings ....: [[-1, 0, 1], [1, -1, 0], [0, 1, -1]])) - sage: morphism = {'a':0, 'b':1, 'c': 2, 'd':4, 'e':5, 'f':3} - sage: M.is_field_isomorphism(N, morphism) + sage: morphism = {'a':0, 'b':1, 'c': 2, 'd':4, 'e':5, 'f':3} # optional - sage.rings.finite_rings + sage: M.is_field_isomorphism(N, morphism) # optional - sage.rings.finite_rings True - sage: M1 = Matroid(groundset=[0, 1, 2, 3], matrix=Matrix(GF(7), + sage: M1 = Matroid(groundset=[0, 1, 2, 3], matrix=Matrix(GF(7), # optional - sage.rings.finite_rings ....: [[1, 0, 1, 1], [0, 1, 1, 2]])) - sage: M2 = Matroid(groundset=[0, 1, 2, 3], matrix=Matrix(GF(7), + sage: M2 = Matroid(groundset=[0, 1, 2, 3], matrix=Matrix(GF(7), # optional - sage.rings.finite_rings ....: [[1, 0, 1, 1], [0, 1, 2, 1]])) - sage: mf1 = {0:0, 1:1, 2:2, 3:3} - sage: mf2 = {0:0, 1:1, 2:3, 3:2} - sage: M1.is_field_isomorphism(M2, mf1) + sage: mf1 = {0:0, 1:1, 2:2, 3:3} # optional - sage.rings.finite_rings + sage: mf2 = {0:0, 1:1, 2:3, 3:2} # optional - sage.rings.finite_rings + sage: M1.is_field_isomorphism(M2, mf1) # optional - sage.rings.finite_rings False - sage: M1.is_field_isomorphism(M2, mf2) + sage: M1.is_field_isomorphism(M2, mf2) # optional - sage.rings.finite_rings True """ from copy import copy @@ -1072,22 +1076,22 @@ cdef class LinearMatroid(BasisExchangeMatroid): EXAMPLES:: sage: from sage.matroids.advanced import * - sage: M1 = BinaryMatroid(reduced_matrix=Matrix(GF(2), + sage: M1 = BinaryMatroid(reduced_matrix=Matrix(GF(2), # optional - sage.rings.finite_rings ....: [[1, 1, 0, 1], [1, 0, 1, 1], [0, 1, 1, 1]])) - sage: M2 = LinearMatroid(reduced_matrix=Matrix(GF(2), + sage: M2 = LinearMatroid(reduced_matrix=Matrix(GF(2), # optional - sage.rings.finite_rings ....: [[1, 1, 0, 1], [1, 0, 1, 1], [1, 1, 0, 1]])) - sage: M3 = BinaryMatroid(reduced_matrix=Matrix(GF(2), + sage: M3 = BinaryMatroid(reduced_matrix=Matrix(GF(2), # optional - sage.rings.finite_rings ....: [[1, 1, 0, 1], [1, 0, 1, 1], [1, 1, 1, 0]])) - sage: M2._fast_isom_test(M1) is None + sage: M2._fast_isom_test(M1) is None # optional - sage.rings.finite_rings True - sage: M1._fast_isom_test(M2) + sage: M1._fast_isom_test(M2) # optional - sage.rings.finite_rings Traceback (most recent call last): ... AttributeError: 'sage.matroids.linear_matroid.LinearMatroid' object has no attribute '_invariant' - sage: M1._fast_isom_test(M3) is None + sage: M1._fast_isom_test(M3) is None # optional - sage.rings.finite_rings True - sage: Matroid(graphs.WheelGraph(6), regular = True)._fast_isom_test( + sage: Matroid(graphs.WheelGraph(6), regular=True)._fast_isom_test( # optional - sage.graphs ....: matroids.Wheel(5)) True """ @@ -1122,8 +1126,8 @@ cdef class LinearMatroid(BasisExchangeMatroid): EXAMPLES:: sage: M1 = matroids.Wheel(3) - sage: M2 = Matroid(graphs.CompleteGraph(4), regular = True) - sage: M1.is_field_isomorphic(M2) + sage: M2 = Matroid(graphs.CompleteGraph(4), regular=True) # optional - sage.graphs + sage: M1.is_field_isomorphic(M2) # optional - sage.graphs True sage: M3 = Matroid(bases=M1.bases()) sage: M1.is_field_isomorphic(M3) @@ -1132,19 +1136,19 @@ cdef class LinearMatroid(BasisExchangeMatroid): AttributeError: 'sage.matroids.basis_matroid.BasisMatroid' object has no attribute 'base_ring' sage: from sage.matroids.advanced import * - sage: M4 = BinaryMatroid(Matrix(M1)) - sage: M5 = LinearMatroid(reduced_matrix=Matrix(GF(2), [[-1, 0, 1], + sage: M4 = BinaryMatroid(Matrix(M1)) # optional - sage.rings.finite_rings + sage: M5 = LinearMatroid(reduced_matrix=Matrix(GF(2), [[-1, 0, 1], # optional - sage.rings.finite_rings ....: [1, -1, 0], [0, 1, -1]])) - sage: M4.is_field_isomorphic(M5) + sage: M4.is_field_isomorphic(M5) # optional - sage.rings.finite_rings True - sage: M1 = Matroid(groundset=[0, 1, 2, 3], matrix=Matrix(GF(7), + sage: M1 = Matroid(groundset=[0, 1, 2, 3], matrix=Matrix(GF(7), # optional - sage.rings.finite_rings ....: [[1, 0, 1, 1], [0, 1, 1, 2]])) - sage: M2 = Matroid(groundset=[0, 1, 2, 3], matrix=Matrix(GF(7), + sage: M2 = Matroid(groundset=[0, 1, 2, 3], matrix=Matrix(GF(7), # optional - sage.rings.finite_rings ....: [[1, 0, 1, 1], [0, 1, 2, 1]])) - sage: M1.is_field_isomorphic(M2) + sage: M1.is_field_isomorphic(M2) # optional - sage.rings.finite_rings True - sage: M1.is_field_equivalent(M2) + sage: M1.is_field_equivalent(M2) # optional - sage.rings.finite_rings False """ @@ -1220,19 +1224,19 @@ cdef class LinearMatroid(BasisExchangeMatroid): See docstring for :meth:`LinearMatroid.equals>` for more:: - sage: M1 = Matroid(groundset='abcd', matrix=Matrix(GF(7), + sage: M1 = Matroid(groundset='abcd', matrix=Matrix(GF(7), # optional - sage.rings.finite_rings ....: [[1, 0, 1, 1], [0, 1, 1, 2]])) - sage: M2 = Matroid(groundset='abcd', matrix=Matrix(GF(7), + sage: M2 = Matroid(groundset='abcd', matrix=Matrix(GF(7), # optional - sage.rings.finite_rings ....: [[1, 0, 1, 1], [0, 1, 1, 3]])) - sage: M3 = Matroid(groundset='abcd', matrix=Matrix(GF(7), + sage: M3 = Matroid(groundset='abcd', matrix=Matrix(GF(7), # optional - sage.rings.finite_rings ....: [[2, 6, 1, 0], [6, 1, 0, 1]])) - sage: M1.equals(M2) + sage: M1.equals(M2) # optional - sage.rings.finite_rings True - sage: M1.equals(M3) + sage: M1.equals(M3) # optional - sage.rings.finite_rings True - sage: M1 != M2 # indirect doctest + sage: M1 != M2 # indirect doctest # optional - sage.rings.finite_rings True - sage: M1 == M3 # indirect doctest + sage: M1 == M3 # indirect doctest # optional - sage.rings.finite_rings True """ if op not in [Py_EQ, Py_NE]: @@ -1260,14 +1264,14 @@ cdef class LinearMatroid(BasisExchangeMatroid): EXAMPLES:: - sage: M1 = Matroid(groundset='abcde', matrix=Matrix(GF(7), + sage: M1 = Matroid(groundset='abcde', matrix=Matrix(GF(7), # optional - sage.rings.finite_rings ....: [[1, 0, 1, 1, 1], [0, 1, 1, 2, 3]])) - sage: M2 = Matroid(groundset='abcde', matrix=Matrix(GF(7), + sage: M2 = Matroid(groundset='abcde', matrix=Matrix(GF(7), # optional - sage.rings.finite_rings ....: [[0, 1, 1, 2, 3], [1, 0, 1, 1, 1]])) - sage: hash(M1) == hash(M2) + sage: hash(M1) == hash(M2) # optional - sage.rings.finite_rings True - sage: M2 = M1.dual() - sage: hash(M1) == hash(M2) + sage: M2 = M1.dual() # optional - sage.rings.finite_rings + sage: hash(M1) == hash(M2) # optional - sage.rings.finite_rings False """ return hash((self.groundset(), self.full_rank(), self._weak_invariant())) @@ -1300,11 +1304,11 @@ cdef class LinearMatroid(BasisExchangeMatroid): EXAMPLES:: - sage: M = Matroid(groundset='abcdefgh', ring=GF(5), + sage: M = Matroid(groundset='abcdefgh', ring=GF(5), # optional - sage.rings.finite_rings ....: reduced_matrix=[[2, 1, 1, 0], ....: [1, 1, 0, 1], [1, 0, 1, 1], [0, 1, 1, 2]]) - sage: N = M._minor(contractions=set(['a']), deletions=set([])) - sage: N._minor(contractions=set([]), deletions=set(['b', 'c'])) + sage: N = M._minor(contractions=set(['a']), deletions=set([])) # optional - sage.rings.finite_rings + sage: N._minor(contractions=set([]), deletions=set(['b', 'c'])) # optional - sage.rings.finite_rings Linear matroid of rank 3 on 5 elements represented over the Finite Field of size 5 """ @@ -1336,11 +1340,11 @@ cdef class LinearMatroid(BasisExchangeMatroid): EXAMPLES:: - sage: A = Matrix(GF(7), [[1, 1, 0, 1], + sage: A = Matrix(GF(7), [[1, 1, 0, 1], # optional - sage.rings.finite_rings ....: [1, 0, 1, 1], ....: [0, 1, 1, 1]]) - sage: B = - A.transpose() - sage: Matroid(reduced_matrix=A).dual() == Matroid( + sage: B = - A.transpose() # optional - sage.rings.finite_rings + sage: Matroid(reduced_matrix=A).dual() == Matroid( # optional - sage.rings.finite_rings ....: reduced_matrix=B, ....: groundset=[3, 4, 5, 6, 0, 1, 2]) True @@ -1377,21 +1381,21 @@ cdef class LinearMatroid(BasisExchangeMatroid): EXAMPLES:: - sage: M = matroids.named_matroids.N1() - sage: M.has_line_minor(4) + sage: M = matroids.named_matroids.N1() # optional - sage.rings.finite_rings + sage: M.has_line_minor(4) # optional - sage.rings.finite_rings True - sage: M.has_line_minor(5) + sage: M.has_line_minor(5) # optional - sage.rings.finite_rings False - sage: M.has_line_minor(k=4, hyperlines=[['a', 'b', 'c']]) + sage: M.has_line_minor(k=4, hyperlines=[['a', 'b', 'c']]) # optional - sage.rings.finite_rings False - sage: M.has_line_minor(k=4, hyperlines=[['a', 'b', 'c'], + sage: M.has_line_minor(k=4, hyperlines=[['a', 'b', 'c'], # optional - sage.rings.finite_rings ....: ['a', 'b', 'd' ]]) True - sage: M.has_line_minor(4, certificate=True) + sage: M.has_line_minor(4, certificate=True) # optional - sage.rings.finite_rings (True, frozenset({'a', 'b', 'd'})) - sage: M.has_line_minor(5, certificate=True) + sage: M.has_line_minor(5, certificate=True) # optional - sage.rings.finite_rings (False, None) - sage: M.has_line_minor(k=4, hyperlines=[['a', 'b', 'c'], + sage: M.has_line_minor(k=4, hyperlines=[['a', 'b', 'c'], # optional - sage.rings.finite_rings ....: ['a', 'b', 'd' ]], certificate=True) (True, frozenset({'a', 'b', 'd'})) @@ -1429,10 +1433,10 @@ cdef class LinearMatroid(BasisExchangeMatroid): EXAMPLES:: - sage: M = matroids.Whirl(3) - sage: matroids.named_matroids.Fano().has_field_minor(M) + sage: M = matroids.Whirl(3) # optional - sage.rings.finite_rings + sage: matroids.named_matroids.Fano().has_field_minor(M) # optional - sage.rings.finite_rings False - sage: matroids.named_matroids.NonFano().has_field_minor(M) + sage: matroids.named_matroids.NonFano().has_field_minor(M) # optional - sage.rings.finite_rings True """ if self is N: @@ -1485,8 +1489,8 @@ cdef class LinearMatroid(BasisExchangeMatroid): EXAMPLES:: - sage: M = Matroid(Matrix(GF(7), [[1, 0, 1, 1], [0, 1, 1, 4]])) - sage: M._exchange_value(1, 3) + sage: M = Matroid(Matrix(GF(7), [[1, 0, 1, 1], [0, 1, 1, 4]])) # optional - sage.rings.finite_rings + sage: M._exchange_value(1, 3) # optional - sage.rings.finite_rings 4 """ return self.__exchange_value(self._idx[e], self._idx[f]) @@ -1518,11 +1522,11 @@ cdef class LinearMatroid(BasisExchangeMatroid): EXAMPLES:: - sage: M = Matroid(Matrix(GF(7), [[1, 0, 1, 1], [0, 1, 1, 4]])) - sage: v = M.fundamental_cycle([0, 1], 3) - sage: [v[0], v[1], v[3]] + sage: M = Matroid(Matrix(GF(7), [[1, 0, 1, 1], [0, 1, 1, 4]])) # optional - sage.rings.finite_rings + sage: v = M.fundamental_cycle([0, 1], 3) # optional - sage.rings.finite_rings + sage: [v[0], v[1], v[3]] # optional - sage.rings.finite_rings [6, 3, 1] - sage: frozenset(v.keys()) == M.fundamental_circuit([0, 1], 3) + sage: frozenset(v.keys()) == M.fundamental_circuit([0, 1], 3) # optional - sage.rings.finite_rings True """ if e in B or not self._is_basis(B): @@ -1564,11 +1568,11 @@ cdef class LinearMatroid(BasisExchangeMatroid): EXAMPLES:: - sage: M = Matroid(Matrix(GF(7), [[1, 0, 1, 1], [0, 1, 1, 4]])) - sage: v = M.fundamental_cocycle([0, 1], 0) - sage: [v[0], v[2], v[3]] + sage: M = Matroid(Matrix(GF(7), [[1, 0, 1, 1], [0, 1, 1, 4]])) # optional - sage.rings.finite_rings + sage: v = M.fundamental_cocycle([0, 1], 0) # optional - sage.rings.finite_rings + sage: [v[0], v[2], v[3]] # optional - sage.rings.finite_rings [1, 1, 1] - sage: frozenset(v.keys()) == M.fundamental_cocircuit([0, 1], 0) + sage: frozenset(v.keys()) == M.fundamental_cocircuit([0, 1], 0) # optional - sage.rings.finite_rings True """ if e not in B or not self._is_basis(B): @@ -1593,11 +1597,11 @@ cdef class LinearMatroid(BasisExchangeMatroid): EXAMPLES:: - sage: M = Matroid(Matrix(GF(7), [[1, 0, 0, 1, 1, 1], + sage: M = Matroid(Matrix(GF(7), [[1, 0, 0, 1, 1, 1], # optional - sage.rings.finite_rings ....: [0, 1, 0, 1, 2, 4], [0, 0, 1, 3, 2, 5]])) - sage: sorted(M._line_ratios(set([2]))) + sage: sorted(M._line_ratios(set([2]))) # optional - sage.rings.finite_rings [1, 2, 4] - sage: sorted(M._line_ratios([0])) + sage: sorted(M._line_ratios([0])) # optional - sage.rings.finite_rings [1, 5] """ self._move_current_basis(F, set()) @@ -1624,11 +1628,11 @@ cdef class LinearMatroid(BasisExchangeMatroid): EXAMPLES:: - sage: M = Matroid(Matrix(GF(7), [[1, 0, 0, 1, 1, 1], + sage: M = Matroid(Matrix(GF(7), [[1, 0, 0, 1, 1, 1], # optional - sage.rings.finite_rings ....: [0, 1, 0, 1, 2, 4], [0, 0, 1, 3, 2, 5]])) - sage: M._line_length([2]) + sage: M._line_length([2]) # optional - sage.rings.finite_rings 5 - sage: M._line_length([0]) + sage: M._line_length([0]) # optional - sage.rings.finite_rings 4 """ return 2 + len(self._line_ratios(F)) @@ -1646,11 +1650,11 @@ cdef class LinearMatroid(BasisExchangeMatroid): EXAMPLES:: - sage: M = Matroid(Matrix(GF(7), [[1, 0, 0, 1, 1, 1], + sage: M = Matroid(Matrix(GF(7), [[1, 0, 0, 1, 1, 1], # optional - sage.rings.finite_rings ....: [0, 1, 0, 1, 2, 4], [0, 0, 1, 3, 2, 5]])) - sage: sorted(M._line_cross_ratios(set([2]))) + sage: sorted(M._line_cross_ratios(set([2]))) # optional - sage.rings.finite_rings [2, 4] - sage: sorted(M._line_cross_ratios([0])) + sage: sorted(M._line_cross_ratios([0])) # optional - sage.rings.finite_rings [5] """ cr = set() @@ -1697,13 +1701,13 @@ cdef class LinearMatroid(BasisExchangeMatroid): EXAMPLES:: - sage: M = Matroid(Matrix(GF(7), [[1, 0, 0, 1, 1, 1], + sage: M = Matroid(Matrix(GF(7), [[1, 0, 0, 1, 1, 1], # optional - sage.rings.finite_rings ....: [0, 1, 0, 1, 2, 4], ....: [0, 0, 1, 3, 2, 5]])) - sage: sorted(M.cross_ratios()) + sage: sorted(M.cross_ratios()) # optional - sage.rings.finite_rings [2, 3, 4, 5, 6] - sage: M = Matroid(graphs.CompleteGraph(5), regular = True) - sage: M.cross_ratios() + sage: M = Matroid(graphs.CompleteGraph(5), regular=True) # optional - sage.graphs + sage: M.cross_ratios() # optional - sage.graphs set() """ if hyperlines is None: @@ -1750,14 +1754,14 @@ cdef class LinearMatroid(BasisExchangeMatroid): EXAMPLES:: - sage: M = Matroid(Matrix(GF(7), [[1, 0, 0, 1, 1, 1], + sage: M = Matroid(Matrix(GF(7), [[1, 0, 0, 1, 1, 1], # optional - sage.rings.finite_rings ....: [0, 1, 0, 1, 2, 4], ....: [0, 0, 1, 3, 2, 6]])) - sage: M.cross_ratio([0], 1, 2, 3, 5) + sage: M.cross_ratio([0], 1, 2, 3, 5) # optional - sage.rings.finite_rings 4 - sage: M = Matroid(ring=GF(7), matrix=[[1, 0, 1, 1], [0, 1, 1, 1]]) - sage: M.cross_ratio(set(), 0, 1, 2, 3) + sage: M = Matroid(ring=GF(7), matrix=[[1, 0, 1, 1], [0, 1, 1, 1]]) # optional - sage.rings.finite_rings + sage: M.cross_ratio(set(), 0, 1, 2, 3) # optional - sage.rings.finite_rings Traceback (most recent call last): ... ValueError: points a, b, c, d do not form a 4-point line in M/F @@ -1915,16 +1919,16 @@ cdef class LinearMatroid(BasisExchangeMatroid): EXAMPLES:: - sage: M = Matroid(ring=GF(2), matrix=[[1, 1, 0, 1, 0, 0], + sage: M = Matroid(ring=GF(2), matrix=[[1, 1, 0, 1, 0, 0], # optional - sage.rings.finite_rings ....: [1, 0, 1, 0, 1, 0], ....: [0, 1, 1, 0, 0, 1], ....: [0, 0, 0, 1, 1, 1]]) - sage: M.linear_extension(6, {0:1, 5: 1}).representation() + sage: M.linear_extension(6, {0:1, 5: 1}).representation() # optional - sage.rings.finite_rings [1 1 0 1 0 0 1] [1 0 1 0 1 0 1] [0 1 1 0 0 1 1] [0 0 0 1 1 1 1] - sage: M.linear_extension(6, col=[0, 1, 1, 1]).representation() + sage: M.linear_extension(6, col=[0, 1, 1, 1]).representation() # optional - sage.rings.finite_rings [1 1 0 1 0 0 0] [1 0 1 0 1 0 1] [0 1 1 0 0 1 1] @@ -2003,17 +2007,17 @@ cdef class LinearMatroid(BasisExchangeMatroid): EXAMPLES:: - sage: M = Matroid(ring=GF(2), matrix=[[1, 1, 0, 1, 0, 0], + sage: M = Matroid(ring=GF(2), matrix=[[1, 1, 0, 1, 0, 0], # optional - sage.rings.finite_rings ....: [1, 0, 1, 0, 1, 0], ....: [0, 1, 1, 0, 0, 1], ....: [0, 0, 0, 1, 1, 1]]) - sage: M.linear_coextension(6, {0:1, 5: 1}).representation() + sage: M.linear_coextension(6, {0:1, 5: 1}).representation() # optional - sage.rings.finite_rings [1 1 0 1 0 0 0] [1 0 1 0 1 0 0] [0 1 1 0 0 1 0] [0 0 0 1 1 1 0] [1 0 0 0 0 1 1] - sage: M.linear_coextension(6, row=[0,1,1,1,0,1]).representation() + sage: M.linear_coextension(6, row=[0,1,1,1,0,1]).representation() # optional - sage.rings.finite_rings [1 1 0 1 0 0 0] [1 0 1 0 1 0 0] [0 1 1 0 0 1 0] @@ -2022,11 +2026,11 @@ cdef class LinearMatroid(BasisExchangeMatroid): Coextending commutes with dualizing:: - sage: M = matroids.named_matroids.NonFano() - sage: chain = {'a': 1, 'b': -1, 'f': 1} - sage: M1 = M.linear_coextension('x', chain) - sage: M2 = M.dual().linear_extension('x', chain) - sage: M1 == M2.dual() + sage: M = matroids.named_matroids.NonFano() # optional - sage.rings.finite_rings + sage: chain = {'a': 1, 'b': -1, 'f': 1} # optional - sage.rings.finite_rings + sage: M1 = M.linear_coextension('x', chain) # optional - sage.rings.finite_rings + sage: M2 = M.dual().linear_extension('x', chain) # optional - sage.rings.finite_rings + sage: M1 == M2.dual() # optional - sage.rings.finite_rings True """ cdef LeanMatrix col @@ -2078,9 +2082,9 @@ cdef class LinearMatroid(BasisExchangeMatroid): EXAMPLES:: - sage: M = Matroid(ring=GF(2), matrix=[[1, 1, 0, 1, 0, 0], + sage: M = Matroid(ring=GF(2), matrix=[[1, 1, 0, 1, 0, 0], # optional - sage.rings.finite_rings ....: [1, 0, 1, 0, 1, 0], [0, 1, 1, 0, 0, 1], [0, 0, 0, 1, 1, 1]]) - sage: M._linear_extensions(6, [{0:1, 5: 1}])[0].representation() + sage: M._linear_extensions(6, [{0:1, 5: 1}])[0].representation() # optional - sage.rings.finite_rings [1 1 0 1 0 0 1] [1 0 1 0 1 0 1] [0 1 1 0 0 1 1] @@ -2127,9 +2131,9 @@ cdef class LinearMatroid(BasisExchangeMatroid): EXAMPLES:: - sage: M = Matroid(ring=GF(2), matrix=[[1, 1, 0, 1, 0, 0], + sage: M = Matroid(ring=GF(2), matrix=[[1, 1, 0, 1, 0, 0], # optional - sage.rings.finite_rings ....: [1, 0, 1, 0, 1, 0], [0, 1, 1, 0, 0, 1], [0, 0, 0, 1, 1, 1]]) - sage: M._linear_coextensions(6, [{0:1, 5: 1}])[0].representation() + sage: M._linear_coextensions(6, [{0:1, 5: 1}])[0].representation() # optional - sage.rings.finite_rings [1 1 0 1 0 0 0] [1 0 1 0 1 0 0] [0 1 1 0 0 1 0] @@ -2241,15 +2245,15 @@ cdef class LinearMatroid(BasisExchangeMatroid): EXAMPLES:: - sage: M = Matroid(reduced_matrix=Matrix(GF(2), [[1, 1, 0], + sage: M = Matroid(reduced_matrix=Matrix(GF(2), [[1, 1, 0], # optional - sage.rings.finite_rings ....: [1, 0, 1], [0, 1, 1]])) - sage: len(M._linear_extension_chains(F=set([0, 1, 2]))) + sage: len(M._linear_extension_chains(F=set([0, 1, 2]))) # optional - sage.rings.finite_rings 8 - sage: M._linear_extension_chains(F=set()) + sage: M._linear_extension_chains(F=set()) # optional - sage.rings.finite_rings [{}] - sage: M._linear_extension_chains(F=set([1])) + sage: M._linear_extension_chains(F=set([1])) # optional - sage.rings.finite_rings [{}, {1: 1}] - sage: len(M._linear_extension_chains(F=set([0, 1]))) + sage: len(M._linear_extension_chains(F=set([0, 1]))) # optional - sage.rings.finite_rings 4 sage: N = Matroid(ring=QQ, reduced_matrix=[[1, 1, 0], ....: [1, 0, 1], [0, 1, 1]]) @@ -2333,15 +2337,15 @@ cdef class LinearMatroid(BasisExchangeMatroid): EXAMPLES:: - sage: M = Matroid(reduced_matrix=Matrix(GF(2), + sage: M = Matroid(reduced_matrix=Matrix(GF(2), # optional - sage.rings.finite_rings ....: [[1, 1, 0], [1, 0, 1], [0, 1, 1]])) - sage: len(M.linear_extension_chains()) + sage: len(M.linear_extension_chains()) # optional - sage.rings.finite_rings 8 - sage: len(M.linear_extension_chains(F=[0, 1])) + sage: len(M.linear_extension_chains(F=[0, 1])) # optional - sage.rings.finite_rings 4 - sage: len(M.linear_extension_chains(F=[0, 1], simple=True)) + sage: len(M.linear_extension_chains(F=[0, 1], simple=True)) # optional - sage.rings.finite_rings 0 - sage: M.linear_extension_chains(F=[0, 1, 2], simple=True) + sage: M.linear_extension_chains(F=[0, 1, 2], simple=True) # optional - sage.rings.finite_rings [{0: 1, 1: 1, 2: 1}] sage: N = Matroid(ring=QQ, ....: reduced_matrix=[[-1, -1, 0], [1, 0, -1], [0, 1, 1]]) @@ -2433,15 +2437,15 @@ cdef class LinearMatroid(BasisExchangeMatroid): EXAMPLES:: - sage: M = Matroid(reduced_matrix=Matrix(GF(2), + sage: M = Matroid(reduced_matrix=Matrix(GF(2), # optional - sage.rings.finite_rings ....: [[1, 1, 0], [1, 0, 1], [0, 1, 1]])) - sage: len(M.linear_coextension_cochains()) + sage: len(M.linear_coextension_cochains()) # optional - sage.rings.finite_rings 8 - sage: len(M.linear_coextension_cochains(F=[0, 1])) + sage: len(M.linear_coextension_cochains(F=[0, 1])) # optional - sage.rings.finite_rings 4 - sage: len(M.linear_coextension_cochains(F=[0, 1], cosimple=True)) + sage: len(M.linear_coextension_cochains(F=[0, 1], cosimple=True)) # optional - sage.rings.finite_rings 0 - sage: M.linear_coextension_cochains(F=[3, 4, 5], cosimple=True) + sage: M.linear_coextension_cochains(F=[3, 4, 5], cosimple=True) # optional - sage.rings.finite_rings [{3: 1, 4: 1, 5: 1}] sage: N = Matroid(ring=QQ, ....: reduced_matrix=[[-1, -1, 0], [1, 0, -1], [0, 1, 1]]) @@ -2490,26 +2494,25 @@ cdef class LinearMatroid(BasisExchangeMatroid): EXAMPLES:: - sage: M = Matroid(ring=GF(2), - ....: reduced_matrix=[[-1, 0, 1], [1, -1, 0], [0, 1, -1]]) - sage: len(M.linear_extensions()) + sage: M = Matroid(ring=GF(2), # optional - sage.rings.finite_rings + ....: reduced_matrix=[[-1, 0, 1], [1, -1, 0], [0, 1, -1]]) + sage: len(M.linear_extensions()) # optional - sage.rings.finite_rings 8 - sage: S = M.linear_extensions(simple=True) - sage: S + sage: S = M.linear_extensions(simple=True); S # optional - sage.rings.finite_rings [Binary matroid of rank 3 on 7 elements, type (3, 0)] - sage: S[0].is_field_isomorphic(matroids.named_matroids.Fano()) + sage: S[0].is_field_isomorphic(matroids.named_matroids.Fano()) # optional - sage.rings.finite_rings True sage: M = Matroid(ring=QQ, - ....: reduced_matrix=[[1, 0, 1], [1, 1, 0], [0, 1, 1]]) + ....: reduced_matrix=[[1, 0, 1], [1, 1, 0], [0, 1, 1]]) sage: S = M.linear_extensions(simple=True, ....: fundamentals=[1, -1, 1/2, 2]) sage: len(S) 7 - sage: any(N.is_isomorphic(matroids.named_matroids.NonFano()) + sage: any(N.is_isomorphic(matroids.named_matroids.NonFano()) # optional - sage.rings.finite_rings ....: for N in S) True sage: len(M.linear_extensions(simple=True, - ....: fundamentals=[1, -1, 1/2, 2], F=[0, 1])) + ....: fundamentals=[1, -1, 1/2, 2], F=[0, 1])) 1 """ if element is None: @@ -2559,15 +2562,15 @@ cdef class LinearMatroid(BasisExchangeMatroid): EXAMPLES:: - sage: M = Matroid(ring=GF(2), + sage: M = Matroid(ring=GF(2), # optional - sage.rings.finite_rings ....: reduced_matrix=[[-1, 0, 1], [1, -1, 0], [0, 1, -1]]) - sage: len(M.linear_coextensions()) + sage: len(M.linear_coextensions()) # optional - sage.rings.finite_rings 8 - sage: S = M.linear_coextensions(cosimple=True) - sage: S + sage: S = M.linear_coextensions(cosimple=True) # optional - sage.rings.finite_rings + sage: S # optional - sage.rings.finite_rings [Binary matroid of rank 4 on 7 elements, type (3, 7)] - sage: F7 = matroids.named_matroids.Fano() - sage: S[0].is_field_isomorphic(F7.dual()) + sage: F7 = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings + sage: S[0].is_field_isomorphic(F7.dual()) # optional - sage.rings.finite_rings True sage: M = Matroid(ring=QQ, ....: reduced_matrix=[[1, 0, 1], [1, 1, 0], [0, 1, 1]]) @@ -2575,10 +2578,10 @@ cdef class LinearMatroid(BasisExchangeMatroid): ....: fundamentals=[1, -1, 1/2, 2]) sage: len(S) 7 - sage: NF7 = matroids.named_matroids.NonFano() - sage: any(N.is_isomorphic(NF7.dual()) for N in S) + sage: NF7 = matroids.named_matroids.NonFano() # optional - sage.rings.finite_rings + sage: any(N.is_isomorphic(NF7.dual()) for N in S) # optional - sage.rings.finite_rings True - sage: len(M.linear_coextensions(cosimple=True, + sage: len(M.linear_coextensions(cosimple=True, # optional - sage.rings.finite_rings ....: fundamentals=[1, -1, 1/2, 2], ....: F=[3, 4])) 1 @@ -2663,25 +2666,25 @@ cdef class LinearMatroid(BasisExchangeMatroid): EXAMPLES:: - sage: matroids.Uniform(2, 3)._is_3connected_shifting() + sage: matroids.Uniform(2, 3)._is_3connected_shifting() # optional - sage.graphs True - sage: M = Matroid(ring=QQ, matrix=[[1, 0, 0, 1, 1, 0], + sage: M = Matroid(ring=QQ, matrix=[[1, 0, 0, 1, 1, 0], # optional - sage.graphs ....: [0, 1, 0, 1, 2, 0], ....: [0, 0, 1, 0, 0, 1]]) - sage: M._is_3connected_shifting() + sage: M._is_3connected_shifting() # optional - sage.graphs False - sage: N = Matroid(circuit_closures={2: ['abc', 'cdef'], + sage: N = Matroid(circuit_closures={2: ['abc', 'cdef'], # optional - sage.graphs ....: 3: ['abcdef']}, ....: groundset='abcdef') - sage: N._is_3connected_shifting() + sage: N._is_3connected_shifting() # optional - sage.graphs False - sage: matroids.named_matroids.BetsyRoss()._is_3connected_shifting() + sage: matroids.named_matroids.BetsyRoss()._is_3connected_shifting() # optional - sage.graphs True - sage: M = matroids.named_matroids.R6() - sage: M._is_3connected_shifting() + sage: M = matroids.named_matroids.R6() # optional - sage.graphs + sage: M._is_3connected_shifting() # optional - sage.graphs False - sage: B, X = M._is_3connected_shifting(True) - sage: M.connectivity(X)<3 + sage: B, X = M._is_3connected_shifting(True) # optional - sage.graphs + sage: M.connectivity(X) < 3 # optional - sage.graphs True """ if not self.is_connected(): @@ -2742,17 +2745,17 @@ cdef class LinearMatroid(BasisExchangeMatroid): EXAMPLES:: sage: M = matroids.Uniform(2, 6) - sage: B, X = M._is_4connected_shifting(True) - sage: (B, M.connectivity(X)<=3) + sage: B, X = M._is_4connected_shifting(True) # optional - sage.graphs + sage: (B, M.connectivity(X)<=3) # optional - sage.graphs (False, True) - sage: matroids.Uniform(4, 8)._is_4connected_shifting() + sage: matroids.Uniform(4, 8)._is_4connected_shifting() # optional - sage.graphs True - sage: M = Matroid(field=GF(2), matrix=[[1,0,0,1,0,1,1,0,0,1,1,1], + sage: M = Matroid(field=GF(2), matrix=[[1,0,0,1,0,1,1,0,0,1,1,1], # optional - sage.rings.finite_rings ....: [0,1,0,1,0,1,0,1,0,0,0,1], ....: [0,0,1,1,0,0,1,1,0,1,0,1], ....: [0,0,0,0,1,1,1,1,0,0,1,1], ....: [0,0,0,0,0,0,0,0,1,1,1,1]]) - sage: M._is_4connected_shifting() + sage: M._is_4connected_shifting() # optional - sage.graphs sage.rings.finite_rings True """ if self.rank()>self.size()-self.rank(): @@ -2898,10 +2901,10 @@ cdef class LinearMatroid(BasisExchangeMatroid): EXAMPLES:: - sage: M = Matroid(Matrix(GF(7), [[1, 0, 0, 1, 1], [0, 1, 0, 1, 2], + sage: M = Matroid(Matrix(GF(7), [[1, 0, 0, 1, 1], [0, 1, 0, 1, 2], # optional - sage.rings.finite_rings ....: [0, 0, 1, 1, 3]])) - sage: N = copy(M) # indirect doctest - sage: M == N + sage: N = copy(M) # indirect doctest # optional - sage.rings.finite_rings + sage: M == N # optional - sage.rings.finite_rings True """ cdef LinearMatroid N @@ -2919,10 +2922,10 @@ cdef class LinearMatroid(BasisExchangeMatroid): EXAMPLES:: - sage: M = Matroid(Matrix(GF(7), [[1, 0, 0, 1, 1], [0, 1, 0, 1, 2], + sage: M = Matroid(Matrix(GF(7), [[1, 0, 0, 1, 1], [0, 1, 0, 1, 2], # optional - sage.rings.finite_rings ....: [0, 0, 1, 1, 3]])) - sage: N = deepcopy(M) # indirect doctest - sage: M == N + sage: N = deepcopy(M) # indirect doctest # optional - sage.rings.finite_rings + sage: M == N # optional - sage.rings.finite_rings True """ cdef LinearMatroid N @@ -2955,16 +2958,16 @@ cdef class LinearMatroid(BasisExchangeMatroid): EXAMPLES:: - sage: M = Matroid(Matrix(GF(7), [[1, 0, 0, 1, 1], [0, 1, 0, 1, 2], + sage: M = Matroid(Matrix(GF(7), [[1, 0, 0, 1, 1], [0, 1, 0, 1, 2], # optional - sage.rings.finite_rings ....: [0, 0, 1, 1, 3]])) - sage: M == loads(dumps(M)) # indirect doctest + sage: M == loads(dumps(M)) # indirect doctest # optional - sage.rings.finite_rings True - sage: M.rename("U35") - sage: loads(dumps(M)) + sage: M.rename("U35") # optional - sage.rings.finite_rings + sage: loads(dumps(M)) # optional - sage.rings.finite_rings U35 - sage: M = Matroid(Matrix(GF(7), [[1, 0, 1], [1, 0, 1]])) - sage: N = loads(dumps(M)) - sage: N.representation() + sage: M = Matroid(Matrix(GF(7), [[1, 0, 1], [1, 0, 1]])) # optional - sage.rings.finite_rings + sage: N = loads(dumps(M)) # optional - sage.rings.finite_rings + sage: N.representation() # optional - sage.rings.finite_rings [1 0 1] [1 0 1] """ @@ -3038,21 +3041,21 @@ cdef class BinaryMatroid(LinearMatroid): EXAMPLES:: - sage: A = Matrix(GF(2), 2, 4, [[1, 0, 1, 1], [0, 1, 1, 1]]) - sage: M = Matroid(A) - sage: M + sage: A = Matrix(GF(2), 2, 4, [[1, 0, 1, 1], [0, 1, 1, 1]]) # optional - sage.rings.finite_rings + sage: M = Matroid(A) # optional - sage.rings.finite_rings + sage: M # optional - sage.rings.finite_rings Binary matroid of rank 2 on 4 elements, type (0, 6) - sage: sorted(M.groundset()) + sage: sorted(M.groundset()) # optional - sage.rings.finite_rings [0, 1, 2, 3] - sage: Matrix(M) + sage: Matrix(M) # optional - sage.rings.finite_rings [1 0 1 1] [0 1 1 1] - sage: M = Matroid(matrix=A, groundset='abcd') - sage: sorted(M.groundset()) + sage: M = Matroid(matrix=A, groundset='abcd') # optional - sage.rings.finite_rings + sage: sorted(M.groundset()) # optional - sage.rings.finite_rings ['a', 'b', 'c', 'd'] - sage: B = Matrix(GF(2), 2, 2, [[1, 1], [1, 1]]) - sage: N = Matroid(reduced_matrix=B, groundset='abcd') - sage: M == N + sage: B = Matrix(GF(2), 2, 2, [[1, 1], [1, 1]]) # optional - sage.rings.finite_rings + sage: N = Matroid(reduced_matrix=B, groundset='abcd') # optional - sage.rings.finite_rings + sage: M == N # optional - sage.rings.finite_rings True """ def __init__(self, matrix=None, groundset=None, reduced_matrix=None, ring=None, keep_initial_representation=True, basis=None): @@ -3068,7 +3071,7 @@ cdef class BinaryMatroid(LinearMatroid): EXAMPLES:: sage: from sage.matroids.advanced import * - sage: BinaryMatroid(matrix=Matrix(GF(5), [[1, 0, 1, 1, 1], # indirect doctest + sage: BinaryMatroid(matrix=Matrix(GF(5), [[1, 0, 1, 1, 1], # indirect doctest, optional - sage.rings.finite_rings ....: [0, 1, 1, 2, 3]])) Binary matroid of rank 2 on 5 elements, type (1, 7) """ @@ -3133,8 +3136,8 @@ cdef class BinaryMatroid(LinearMatroid): EXAMPLES:: - sage: M = matroids.named_matroids.Fano() - sage: M.base_ring() + sage: M = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings + sage: M.base_ring() # optional - sage.rings.finite_rings Finite Field of size 2 """ global GF2 @@ -3147,8 +3150,8 @@ cdef class BinaryMatroid(LinearMatroid): EXAMPLES:: - sage: M = matroids.named_matroids.Fano() - sage: M.characteristic() + sage: M = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings + sage: M.characteristic() # optional - sage.rings.finite_rings 2 """ return 2 @@ -3215,9 +3218,9 @@ cdef class BinaryMatroid(LinearMatroid): EXAMPLES:: - sage: M = matroids.named_matroids.Fano() - sage: M.rename() - sage: repr(M) # indirect doctest + sage: M = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings + sage: M.rename() # optional - sage.rings.finite_rings + sage: repr(M) # indirect doctest # optional - sage.rings.finite_rings 'Binary matroid of rank 3 on 7 elements, type (3, 0)' """ S = "Binary matroid of rank " + str(self.rank()) + " on " + str(self.size()) + " elements, type (" + str(self.bicycle_dimension()) + ', ' + str(self.brown_invariant()) + ')' @@ -3241,13 +3244,13 @@ cdef class BinaryMatroid(LinearMatroid): EXAMPLES:: - sage: M = matroids.named_matroids.Fano() - sage: A = M._reduced_representation('efg') - sage: R, C = M._current_rows_cols() - sage: (sorted(R), sorted(C)) + sage: M = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings + sage: A = M._reduced_representation('efg') # optional - sage.rings.finite_rings + sage: R, C = M._current_rows_cols() # optional - sage.rings.finite_rings + sage: (sorted(R), sorted(C)) # optional - sage.rings.finite_rings (['e', 'f', 'g'], ['a', 'b', 'c', 'd']) - sage: R, C = M._current_rows_cols(B='abg') - sage: (sorted(R), sorted(C)) + sage: R, C = M._current_rows_cols(B='abg') # optional - sage.rings.finite_rings + sage: (sorted(R), sorted(C)) # optional - sage.rings.finite_rings (['a', 'b', 'g'], ['c', 'd', 'e', 'f']) """ @@ -3289,13 +3292,13 @@ cdef class BinaryMatroid(LinearMatroid): EXAMPLES:: - sage: M = matroids.named_matroids.Fano() - sage: M._basic_representation() + sage: M = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings + sage: M._basic_representation() # optional - sage.rings.finite_rings 3 x 7 BinaryMatrix [1000111] [0101011] [0011101] - sage: matrix(M._basic_representation('efg')) + sage: matrix(M._basic_representation('efg')) # optional - sage.rings.finite_rings [1 1 0 1 1 0 0] [1 0 1 1 0 1 0] [1 1 1 0 0 0 1] @@ -3328,13 +3331,13 @@ cdef class BinaryMatroid(LinearMatroid): EXAMPLES:: - sage: M = matroids.named_matroids.Fano() - sage: M._reduced_representation() + sage: M = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings + sage: M._reduced_representation() # optional - sage.rings.finite_rings 3 x 4 BinaryMatrix [0111] [1011] [1101] - sage: matrix(M._reduced_representation('efg')) + sage: matrix(M._reduced_representation('efg')) # optional - sage.rings.finite_rings [1 1 0 1] [1 0 1 1] [1 1 1 0] @@ -3368,23 +3371,23 @@ cdef class BinaryMatroid(LinearMatroid): EXAMPLES:: - sage: M1 = matroids.named_matroids.Fano() - sage: M2 = Matroid(ring=GF(2), + sage: M1 = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings + sage: M2 = Matroid(ring=GF(2), # optional - sage.rings.finite_rings ....: reduced_matrix=[[1, 0, 1, 1], [0, 1, 1, 1], [1, 1, 0, 1]]) - sage: M1._is_isomorphic(M2) + sage: M1._is_isomorphic(M2) # optional - sage.rings.finite_rings True - sage: M1._is_isomorphic(M2, certificate=True) + sage: M1._is_isomorphic(M2, certificate=True) # optional - sage.rings.finite_rings (True, {'a': 0, 'b': 1, 'c': 2, 'd': 4, 'e': 3, 'f': 5, 'g': 6}) - sage: M1 = matroids.named_matroids.Fano().delete('a') - sage: M2 = matroids.Whirl(3) - sage: M1._is_isomorphic(M2) + sage: M1 = matroids.named_matroids.Fano().delete('a') # optional - sage.rings.finite_rings + sage: M2 = matroids.Whirl(3) # optional - sage.rings.finite_rings + sage: M1._is_isomorphic(M2) # optional - sage.rings.finite_rings False - sage: M1._is_isomorphic(M2, certificate=True) + sage: M1._is_isomorphic(M2, certificate=True) # optional - sage.rings.finite_rings (False, None) - sage: M1._is_isomorphic(matroids.Wheel(3)) + sage: M1._is_isomorphic(matroids.Wheel(3)) # optional - sage.rings.finite_rings True - sage: M1._is_isomorphic(matroids.Wheel(3), certificate=True) + sage: M1._is_isomorphic(matroids.Wheel(3), certificate=True) # optional - sage.rings.finite_rings (True, {'b': 1, 'c': 2, 'd': 4, 'e': 3, 'f': 5, 'g': 0}) """ @@ -3414,10 +3417,10 @@ cdef class BinaryMatroid(LinearMatroid): EXAMPLES:: - sage: M = matroids.named_matroids.Fano() \ ['a'] - sage: N = matroids.named_matroids.Fano() \ ['b'] - sage: morphism = {'b':'a', 'c':'c', 'd':'e', 'e':'d', 'f':'f', 'g':'g'} - sage: M._is_isomorphism(N, morphism) + sage: M = matroids.named_matroids.Fano() \ ['a'] # optional - sage.rings.finite_rings + sage: N = matroids.named_matroids.Fano() \ ['b'] # optional - sage.rings.finite_rings + sage: morphism = {'b':'a', 'c':'c', 'd':'e', 'e':'d', 'f':'f', 'g':'g'} # optional - sage.rings.finite_rings + sage: M._is_isomorphism(N, morphism) # optional - sage.rings.finite_rings True """ if isinstance(other, BinaryMatroid): @@ -3434,8 +3437,8 @@ cdef class BinaryMatroid(LinearMatroid): EXAMPLES:: - sage: M = matroids.named_matroids.Fano() - sage: M._invariant() # indirect doctest + sage: M = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings + sage: M._invariant() # indirect doctest # optional - sage.rings.finite_rings (3, 0, 7, 0, 0, 0, 0, 0) """ cdef BinaryMatrix B @@ -3537,8 +3540,8 @@ cdef class BinaryMatroid(LinearMatroid): EXAMPLES:: sage: from sage.matroids.advanced import * - sage: M = BinaryMatroid(matroids.AG(2, 5).representation()) - sage: M._invariant() + sage: M = BinaryMatroid(matroids.AG(2, 5).representation()) # optional - sage.rings.finite_rings + sage: M._invariant() # optional - sage.rings.finite_rings (2, 1, 24, 0, 1, 0, 0, 1) """ if self._b_invariant is None: @@ -3560,8 +3563,8 @@ cdef class BinaryMatroid(LinearMatroid): EXAMPLES:: - sage: M = matroids.named_matroids.Fano() - sage: M.bicycle_dimension() + sage: M = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings + sage: M.bicycle_dimension() # optional - sage.rings.finite_rings 3 """ if self._b_invariant is None: @@ -3592,13 +3595,13 @@ cdef class BinaryMatroid(LinearMatroid): EXAMPLES:: - sage: M = matroids.named_matroids.Fano() - sage: M.brown_invariant() + sage: M = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings + sage: M.brown_invariant() # optional - sage.rings.finite_rings 0 - sage: M = Matroid(Matrix(GF(2), 3, 8, [[1, 0, 0, 1, 1, 1, 1, 1], + sage: M = Matroid(Matrix(GF(2), 3, 8, [[1, 0, 0, 1, 1, 1, 1, 1], # optional - sage.rings.finite_rings ....: [0, 1, 0, 1, 1, 0, 0, 0], ....: [0, 0, 1, 0, 0, 1, 1, 0]])) - sage: M.brown_invariant() is None + sage: M.brown_invariant() is None # optional - sage.rings.finite_rings True """ if self._b_invariant is None: @@ -3624,14 +3627,16 @@ cdef class BinaryMatroid(LinearMatroid): EXAMPLES:: - sage: M = matroids.named_matroids.S8() - sage: for F in M._principal_tripartition(): print(sorted(F)) + sage: M = matroids.named_matroids.S8() # optional - sage.rings.finite_rings + sage: for F in M._principal_tripartition(): print(sorted(F)) # optional - sage.rings.finite_rings ['a', 'b', 'c', 'e', 'f', 'g'] ['d'] ['h'] - sage: M.bicycle_dimension() + sage: M.bicycle_dimension() # optional - sage.rings.finite_rings 2 - sage: for i in [-1, 0, 1]: print(sorted([e for e in M.groundset() if (M\e).bicycle_dimension() == 2 + i])) + sage: for i in [-1, 0, 1]: # optional - sage.rings.finite_rings + ....: print(sorted(e for e in M.groundset() + ....: if (M\e).bicycle_dimension() == 2 + i)) ['a', 'b', 'c', 'e', 'f', 'g'] ['d'] ['h'] @@ -3662,8 +3667,8 @@ cdef class BinaryMatroid(LinearMatroid): EXAMPLES:: sage: from sage.matroids.advanced import * - sage: M = BinaryMatroid(matrix(matroids.named_matroids.R12())) - sage: M._projection() + sage: M = BinaryMatroid(matrix(matroids.named_matroids.R12())) # optional - sage.rings.finite_rings + sage: M._projection() # optional - sage.rings.finite_rings 12 x 12 BinaryMatrix [001110111000] [001101110100] @@ -3699,14 +3704,14 @@ cdef class BinaryMatroid(LinearMatroid): An ordered partition. sage: from sage.matroids.advanced import * - sage: M = matroids.named_matroids.R12() - sage: N = BinaryMatroid(reduced_matrix=M.representation(reduced=True, + sage: M = matroids.named_matroids.R12() # optional - sage.rings.finite_rings + sage: N = BinaryMatroid(reduced_matrix=M.representation(reduced=True, # optional - sage.rings.finite_rings ....: labels=False), groundset='abcdefghijkl') - sage: Npp = N._projection_partition(); Npp # random + sage: Npp = N._projection_partition(); Npp # random # optional - sage.rings.finite_rings 2 x 12 BinaryMatrix [110011001100] [001100110011] - sage: sorted(Npp._matrix_().rows()) + sage: sorted(Npp._matrix_().rows()) # optional - sage.rings.finite_rings [(1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0), (0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1)] """ if self._eq_part is None: @@ -3734,9 +3739,9 @@ cdef class BinaryMatroid(LinearMatroid): EXAMPLES:: - sage: M = matroids.named_matroids.S8() - sage: N = matroids.named_matroids.S8() - sage: M._fast_isom_test(N) is None + sage: M = matroids.named_matroids.S8() # optional - sage.rings.finite_rings + sage: N = matroids.named_matroids.S8() # optional - sage.rings.finite_rings + sage: M._fast_isom_test(N) is None # optional - sage.rings.finite_rings True """ if self._invariant() != other._invariant(): @@ -3775,9 +3780,9 @@ cdef class BinaryMatroid(LinearMatroid): EXAMPLES:: - sage: M = matroids.named_matroids.Fano() - sage: N = M._minor(contractions=set(['a']), deletions=set([])) - sage: N._minor(contractions=set([]), deletions=set(['b', 'c'])) + sage: M = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings + sage: N = M._minor(contractions=set(['a']), deletions=set([])) # optional - sage.rings.finite_rings + sage: N._minor(contractions=set([]), deletions=set(['b', 'c'])) # optional - sage.rings.finite_rings Binary matroid of rank 2 on 4 elements, type (0, 6) """ self._move_current_basis(contractions, deletions) @@ -3808,16 +3813,16 @@ cdef class BinaryMatroid(LinearMatroid): EXAMPLES:: sage: R10 = matroids.named_matroids.R10() - sage: M = Matroid(ring=GF(2), reduced_matrix=R10.representation( + sage: M = Matroid(ring=GF(2), reduced_matrix=R10.representation( # optional - sage.rings.finite_rings ....: reduced=True, labels=False)) - sage: M.is_graphic() + sage: M.is_graphic() # optional - sage.rings.finite_rings False - sage: K5 = Matroid(graphs.CompleteGraph(5), regular = True) - sage: M = Matroid(ring=GF(2), reduced_matrix=K5.representation( + sage: K5 = Matroid(graphs.CompleteGraph(5), regular=True) # optional - sage.graphs + sage: M = Matroid(ring=GF(2), reduced_matrix=K5.representation( # optional - sage.graphs sage.rings.finite_rings ....: reduced=True, labels=False)) - sage: M.is_graphic() + sage: M.is_graphic() # optional - sage.graphs sage.rings.finite_rings True - sage: M.dual().is_graphic() + sage: M.dual().is_graphic() # optional - sage.graphs sage.rings.finite_rings False ALGORITHM: @@ -3876,8 +3881,8 @@ cdef class BinaryMatroid(LinearMatroid): EXAMPLES:: - sage: M = Matroid(Matrix(GF(2), [[]])) - sage: M.is_valid() + sage: M = Matroid(Matrix(GF(2), [[]])) # optional - sage.rings.finite_rings + sage: M.is_valid() # optional - sage.rings.finite_rings True """ return True @@ -3908,8 +3913,8 @@ cdef class BinaryMatroid(LinearMatroid): EXAMPLES:: - sage: N = matroids.named_matroids.Fano() - sage: N.binary_matroid() is N + sage: N = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings + sage: N.binary_matroid() is N # optional - sage.rings.finite_rings True """ return self @@ -3936,8 +3941,8 @@ cdef class BinaryMatroid(LinearMatroid): EXAMPLES:: - sage: N = matroids.named_matroids.Fano() - sage: N.is_binary() + sage: N = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings + sage: N.is_binary() # optional - sage.rings.finite_rings True """ return True @@ -3948,10 +3953,10 @@ cdef class BinaryMatroid(LinearMatroid): EXAMPLES:: - sage: M = Matroid(Matrix(GF(2), [[1, 0, 0, 1, 1], [0, 1, 0, 1, 2], + sage: M = Matroid(Matrix(GF(2), [[1, 0, 0, 1, 1], [0, 1, 0, 1, 2], # optional - sage.rings.finite_rings ....: [0, 0, 1, 1, 3]])) - sage: N = copy(M) # indirect doctest - sage: M == N + sage: N = copy(M) # indirect doctest # optional - sage.rings.finite_rings + sage: M == N # optional - sage.rings.finite_rings True """ cdef BinaryMatroid N @@ -3972,10 +3977,10 @@ cdef class BinaryMatroid(LinearMatroid): EXAMPLES:: - sage: M = Matroid(Matrix(GF(2), [[1, 0, 0, 1, 1], [0, 1, 0, 1, 2], + sage: M = Matroid(Matrix(GF(2), [[1, 0, 0, 1, 1], [0, 1, 0, 1, 2], # optional - sage.rings.finite_rings ....: [0, 0, 1, 1, 3]])) - sage: N = deepcopy(M) # indirect doctest - sage: M == N + sage: N = deepcopy(M) # indirect doctest # optional - sage.rings.finite_rings + sage: M == N # optional - sage.rings.finite_rings True """ from copy import deepcopy @@ -4011,15 +4016,15 @@ cdef class BinaryMatroid(LinearMatroid): EXAMPLES:: - sage: M = Matroid(Matrix(GF(2), [[1, 0, 0, 1], [0, 1, 0, 1], + sage: M = Matroid(Matrix(GF(2), [[1, 0, 0, 1], [0, 1, 0, 1], # optional - sage.rings.finite_rings ....: [0, 0, 1, 1]])) - sage: M == loads(dumps(M)) # indirect doctest + sage: M == loads(dumps(M)) # indirect doctest # optional - sage.rings.finite_rings True - sage: M.rename("U34") - sage: loads(dumps(M)) + sage: M.rename("U34") # optional - sage.rings.finite_rings + sage: loads(dumps(M)) # optional - sage.rings.finite_rings U34 - sage: M = Matroid(Matrix(GF(2), [[1, 0, 1], [1, 0, 1]])) - sage: loads(dumps(M)).representation() + sage: M = Matroid(Matrix(GF(2), [[1, 0, 1], [1, 0, 1]])) # optional - sage.rings.finite_rings + sage: loads(dumps(M)).representation() # optional - sage.rings.finite_rings [1 0 1] [1 0 1] @@ -4027,12 +4032,12 @@ cdef class BinaryMatroid(LinearMatroid): Check that :trac:`23437` is fixed:: - sage: M = matroids.named_matroids.Fano().dual() - sage: B = list(M.bases()) - sage: N = loads(dumps(M)) - sage: N.closure(frozenset({'d'})) + sage: M = matroids.named_matroids.Fano().dual() # optional - sage.rings.finite_rings + sage: B = list(M.bases()) # optional - sage.rings.finite_rings + sage: N = loads(dumps(M)) # optional - sage.rings.finite_rings + sage: N.closure(frozenset({'d'})) # optional - sage.rings.finite_rings frozenset({'d'}) - sage: N.is_isomorphic(M) + sage: N.is_isomorphic(M) # optional - sage.rings.finite_rings True """ import sage.matroids.unpickling @@ -4103,21 +4108,20 @@ cdef class TernaryMatroid(LinearMatroid): EXAMPLES:: - sage: A = Matrix(GF(3), 2, 4, [[1, 0, 1, 1], [0, 1, 1, 1]]) - sage: M = Matroid(A) - sage: M + sage: A = Matrix(GF(3), 2, 4, [[1, 0, 1, 1], [0, 1, 1, 1]]) # optional - sage.rings.finite_rings + sage: M = Matroid(A); M # optional - sage.rings.finite_rings Ternary matroid of rank 2 on 4 elements, type 0- - sage: sorted(M.groundset()) + sage: sorted(M.groundset()) # optional - sage.rings.finite_rings [0, 1, 2, 3] - sage: Matrix(M) + sage: Matrix(M) # optional - sage.rings.finite_rings [1 0 1 1] [0 1 1 1] - sage: M = Matroid(matrix=A, groundset='abcd') - sage: sorted(M.groundset()) + sage: M = Matroid(matrix=A, groundset='abcd') # optional - sage.rings.finite_rings + sage: sorted(M.groundset()) # optional - sage.rings.finite_rings ['a', 'b', 'c', 'd'] - sage: B = Matrix(GF(2), 2, 2, [[1, 1], [1, 1]]) - sage: N = Matroid(ring=GF(3), reduced_matrix=B, groundset='abcd') - sage: M == N + sage: B = Matrix(GF(2), 2, 2, [[1, 1], [1, 1]]) # optional - sage.rings.finite_rings + sage: N = Matroid(ring=GF(3), reduced_matrix=B, groundset='abcd') # optional - sage.rings.finite_rings + sage: M == N # optional - sage.rings.finite_rings True """ def __init__(self, matrix=None, groundset=None, reduced_matrix=None, ring=None, keep_initial_representation=True, basis=None): @@ -4133,7 +4137,7 @@ cdef class TernaryMatroid(LinearMatroid): EXAMPLES:: sage: from sage.matroids.advanced import * - sage: TernaryMatroid(matrix=Matrix(GF(5), [[1, 0, 1, 1, 1], # indirect doctest + sage: TernaryMatroid(matrix=Matrix(GF(5), [[1, 0, 1, 1, 1], # indirect doctest, optional - sage.rings.finite_rings ....: [0, 1, 1, 2, 3]])) Ternary matroid of rank 2 on 5 elements, type 1+ """ @@ -4200,8 +4204,8 @@ cdef class TernaryMatroid(LinearMatroid): EXAMPLES:: - sage: M = matroids.named_matroids.NonFano() - sage: M.base_ring() + sage: M = matroids.named_matroids.NonFano() # optional - sage.rings.finite_rings + sage: M.base_ring() # optional - sage.rings.finite_rings Finite Field of size 3 """ global GF3 @@ -4214,8 +4218,8 @@ cdef class TernaryMatroid(LinearMatroid): EXAMPLES:: - sage: M = matroids.named_matroids.NonFano() - sage: M.characteristic() + sage: M = matroids.named_matroids.NonFano() # optional - sage.rings.finite_rings + sage: M.characteristic() # optional - sage.rings.finite_rings 3 """ return 3 @@ -4284,9 +4288,9 @@ cdef class TernaryMatroid(LinearMatroid): EXAMPLES:: - sage: M = matroids.named_matroids.NonFano() - sage: M.rename() - sage: repr(M) # indirect doctest + sage: M = matroids.named_matroids.NonFano() # optional - sage.rings.finite_rings + sage: M.rename() # optional - sage.rings.finite_rings + sage: repr(M) # indirect doctest # optional - sage.rings.finite_rings 'Ternary matroid of rank 3 on 7 elements, type 0-' """ S = "Ternary matroid of rank " + str(self.rank()) + " on " + str(self.size()) + " elements, type " + str(self.bicycle_dimension()) @@ -4314,13 +4318,13 @@ cdef class TernaryMatroid(LinearMatroid): EXAMPLES:: - sage: M = matroids.named_matroids.NonFano() - sage: A = M._reduced_representation('efg') - sage: R, C = M._current_rows_cols() - sage: (sorted(R), sorted(C)) + sage: M = matroids.named_matroids.NonFano() # optional - sage.rings.finite_rings + sage: A = M._reduced_representation('efg') # optional - sage.rings.finite_rings + sage: R, C = M._current_rows_cols() # optional - sage.rings.finite_rings + sage: (sorted(R), sorted(C)) # optional - sage.rings.finite_rings (['e', 'f', 'g'], ['a', 'b', 'c', 'd']) - sage: R, C = M._current_rows_cols(B='abg') - sage: (sorted(R), sorted(C)) + sage: R, C = M._current_rows_cols(B='abg') # optional - sage.rings.finite_rings + sage: (sorted(R), sorted(C)) # optional - sage.rings.finite_rings (['a', 'b', 'g'], ['c', 'd', 'e', 'f']) """ @@ -4362,13 +4366,13 @@ cdef class TernaryMatroid(LinearMatroid): EXAMPLES:: - sage: M = matroids.named_matroids.NonFano() - sage: M._basic_representation() + sage: M = matroids.named_matroids.NonFano() # optional - sage.rings.finite_rings + sage: M._basic_representation() # optional - sage.rings.finite_rings 3 x 7 TernaryMatrix [+000+++] [0+0+0++] [00+++0+] - sage: matrix(M._basic_representation('efg')) + sage: matrix(M._basic_representation('efg')) # optional - sage.rings.finite_rings [1 2 0 2 1 0 0] [1 0 2 2 0 1 0] [2 1 1 2 0 0 1] @@ -4401,13 +4405,13 @@ cdef class TernaryMatroid(LinearMatroid): EXAMPLES:: - sage: M = matroids.named_matroids.NonFano() - sage: M._reduced_representation() + sage: M = matroids.named_matroids.NonFano() # optional - sage.rings.finite_rings + sage: M._reduced_representation() # optional - sage.rings.finite_rings 3 x 4 TernaryMatrix [0+++] [+0++] [++0+] - sage: matrix(M._reduced_representation('efg')) + sage: matrix(M._reduced_representation('efg')) # optional - sage.rings.finite_rings [1 2 0 2] [1 0 2 2] [2 1 1 2] @@ -4440,13 +4444,13 @@ cdef class TernaryMatroid(LinearMatroid): EXAMPLES:: - sage: M1 = matroids.named_matroids.NonFano().delete('a') - sage: M2 = matroids.Whirl(3) - sage: M1._is_isomorphic(M2) + sage: M1 = matroids.named_matroids.NonFano().delete('a') # optional - sage.rings.finite_rings + sage: M2 = matroids.Whirl(3) # optional - sage.rings.finite_rings + sage: M1._is_isomorphic(M2) # optional - sage.rings.finite_rings True - sage: M2 = matroids.Wheel(3) - sage: M1._is_isomorphic(M2) + sage: M2 = matroids.Wheel(3) # optional - sage.rings.finite_rings + sage: M1._is_isomorphic(M2) # optional - sage.rings.finite_rings False """ if certificate: @@ -4466,8 +4470,8 @@ cdef class TernaryMatroid(LinearMatroid): EXAMPLES:: - sage: M = matroids.named_matroids.NonFano() - sage: M._invariant() # indirect doctest + sage: M = matroids.named_matroids.NonFano() # optional - sage.rings.finite_rings + sage: M._invariant() # indirect doctest # optional - sage.rings.finite_rings (0, 2, 0, 4, 3, 0, 12, 12, 3, 0, 0, 0) """ cdef TernaryMatrix T @@ -4551,8 +4555,8 @@ cdef class TernaryMatroid(LinearMatroid): EXAMPLES:: - sage: M = matroids.named_matroids.NonFano() - sage: M._invariant() + sage: M = matroids.named_matroids.NonFano() # optional - sage.rings.finite_rings + sage: M._invariant() # optional - sage.rings.finite_rings (0, 2, 0, 4, 3, 0, 12, 12, 3, 0, 0, 0) """ if self._t_invariant is None: @@ -4574,8 +4578,8 @@ cdef class TernaryMatroid(LinearMatroid): EXAMPLES:: - sage: M = matroids.named_matroids.NonFano() - sage: M.bicycle_dimension() + sage: M = matroids.named_matroids.NonFano() # optional - sage.rings.finite_rings + sage: M.bicycle_dimension() # optional - sage.rings.finite_rings 0 """ if self._t_invariant is None: @@ -4600,8 +4604,8 @@ cdef class TernaryMatroid(LinearMatroid): EXAMPLES:: - sage: M = matroids.named_matroids.NonFano() - sage: M.character() + sage: M = matroids.named_matroids.NonFano() # optional - sage.rings.finite_rings + sage: M.character() # optional - sage.rings.finite_rings 2 """ if self._t_invariant is None: @@ -4618,20 +4622,20 @@ cdef class TernaryMatroid(LinearMatroid): EXAMPLES:: - sage: M = matroids.named_matroids.N1() - sage: print(M) + sage: M = matroids.named_matroids.N1() # optional - sage.rings.finite_rings + sage: print(M) # optional - sage.rings.finite_rings N1: Ternary matroid of rank 5 on 10 elements, type 0+ - sage: P = M._principal_quadripartition() - sage: for e in sorted(P[0]): print("{} {}".format(e, M/e)) - sage: for e in sorted(P[1]): print("{} {}".format(e, M/e)) + sage: P = M._principal_quadripartition() # optional - sage.rings.finite_rings + sage: for e in sorted(P[0]): print("{} {}".format(e, M/e)) # optional - sage.rings.finite_rings + sage: for e in sorted(P[1]): print("{} {}".format(e, M/e)) # optional - sage.rings.finite_rings a Ternary matroid of rank 4 on 9 elements, type 1- b Ternary matroid of rank 4 on 9 elements, type 1- e Ternary matroid of rank 4 on 9 elements, type 1- f Ternary matroid of rank 4 on 9 elements, type 1- - sage: for e in sorted(P[2]): print("{} {}".format(e, M/e)) + sage: for e in sorted(P[2]): print("{} {}".format(e, M/e)) # optional - sage.rings.finite_rings d Ternary matroid of rank 4 on 9 elements, type 0- i Ternary matroid of rank 4 on 9 elements, type 0- - sage: for e in sorted(P[3]): print("{} {}".format(e, M/e)) + sage: for e in sorted(P[3]): print("{} {}".format(e, M/e)) # optional - sage.rings.finite_rings c Ternary matroid of rank 4 on 9 elements, type 0+ g Ternary matroid of rank 4 on 9 elements, type 0+ h Ternary matroid of rank 4 on 9 elements, type 0+ @@ -4663,9 +4667,9 @@ cdef class TernaryMatroid(LinearMatroid): EXAMPLES:: - sage: from sage.matroids.advanced import * - sage: M = TernaryMatroid(matrix(matroids.named_matroids.R12())) - sage: M._projection() + sage: from sage.matroids.advanced import * # optional - sage.rings.finite_rings + sage: M = TernaryMatroid(matrix(matroids.named_matroids.R12())) # optional - sage.rings.finite_rings + sage: M._projection() # optional - sage.rings.finite_rings 12 x 12 TernaryMatrix [++00-0--0+++] [+-+000+0+-+0] @@ -4705,9 +4709,9 @@ cdef class TernaryMatroid(LinearMatroid): EXAMPLES:: - sage: M = matroids.named_matroids.T8() - sage: N = matroids.named_matroids.P8() - sage: M._fast_isom_test(N) + sage: M = matroids.named_matroids.T8() # optional - sage.rings.finite_rings + sage: N = matroids.named_matroids.P8() # optional - sage.rings.finite_rings + sage: M._fast_isom_test(N) # optional - sage.rings.finite_rings False """ if self._invariant() != other._invariant(): @@ -4742,9 +4746,9 @@ cdef class TernaryMatroid(LinearMatroid): EXAMPLES:: - sage: M = matroids.named_matroids.P8() - sage: N = M._minor(contractions=set(['a']), deletions=set([])) - sage: N._minor(contractions=set([]), deletions=set(['b', 'c'])) + sage: M = matroids.named_matroids.P8() # optional - sage.rings.finite_rings + sage: N = M._minor(contractions=set(['a']), deletions=set([])) # optional - sage.rings.finite_rings + sage: N._minor(contractions=set([]), deletions=set(['b', 'c'])) # optional - sage.rings.finite_rings Ternary matroid of rank 3 on 5 elements, type 0- """ self._move_current_basis(contractions, deletions) @@ -4771,8 +4775,8 @@ cdef class TernaryMatroid(LinearMatroid): EXAMPLES:: - sage: M = Matroid(Matrix(GF(3), [[]])) - sage: M.is_valid() + sage: M = Matroid(Matrix(GF(3), [[]])) # optional - sage.rings.finite_rings + sage: M.is_valid() # optional - sage.rings.finite_rings True """ return True @@ -4803,8 +4807,8 @@ cdef class TernaryMatroid(LinearMatroid): EXAMPLES:: - sage: N = matroids.named_matroids.NonFano() - sage: N.ternary_matroid() is N + sage: N = matroids.named_matroids.NonFano() # optional - sage.rings.finite_rings + sage: N.ternary_matroid() is N # optional - sage.rings.finite_rings True """ return self @@ -4831,8 +4835,8 @@ cdef class TernaryMatroid(LinearMatroid): EXAMPLES:: - sage: N = matroids.named_matroids.NonFano() - sage: N.is_ternary() + sage: N = matroids.named_matroids.NonFano() # optional - sage.rings.finite_rings + sage: N.is_ternary() # optional - sage.rings.finite_rings True """ return True @@ -4843,10 +4847,10 @@ cdef class TernaryMatroid(LinearMatroid): EXAMPLES:: - sage: M = Matroid(Matrix(GF(3), [[1, 0, 0, 1, 1], [0, 1, 0, 1, 2], + sage: M = Matroid(Matrix(GF(3), [[1, 0, 0, 1, 1], [0, 1, 0, 1, 2], # optional - sage.rings.finite_rings ....: [0, 0, 1, 1, 3]])) - sage: N = copy(M) # indirect doctest - sage: M == N + sage: N = copy(M) # indirect doctest # optional - sage.rings.finite_rings + sage: M == N # optional - sage.rings.finite_rings True """ cdef TernaryMatroid N @@ -4867,10 +4871,10 @@ cdef class TernaryMatroid(LinearMatroid): EXAMPLES:: - sage: M = Matroid(Matrix(GF(3), [[1, 0, 0, 1, 1], [0, 1, 0, 1, 2], + sage: M = Matroid(Matrix(GF(3), [[1, 0, 0, 1, 1], [0, 1, 0, 1, 2], # optional - sage.rings.finite_rings ....: [0, 0, 1, 1, -1]])) - sage: N = deepcopy(M) # indirect doctest - sage: M == N + sage: N = deepcopy(M) # indirect doctest # optional - sage.rings.finite_rings + sage: M == N # optional - sage.rings.finite_rings True """ from copy import deepcopy @@ -4907,15 +4911,15 @@ cdef class TernaryMatroid(LinearMatroid): EXAMPLES:: sage: from sage.matroids.advanced import * - sage: M = TernaryMatroid(Matrix(GF(3), [[1, 0, 0, 1], + sage: M = TernaryMatroid(Matrix(GF(3), [[1, 0, 0, 1], # optional - sage.rings.finite_rings ....: [0, 1, 0, 1], [0, 0, 1, 1]])) - sage: M == loads(dumps(M)) # indirect doctest + sage: M == loads(dumps(M)) # indirect doctest # optional - sage.rings.finite_rings True - sage: M.rename("U34") - sage: loads(dumps(M)) + sage: M.rename("U34") # optional - sage.rings.finite_rings + sage: loads(dumps(M)) # optional - sage.rings.finite_rings U34 - sage: M = TernaryMatroid(Matrix(GF(3), [[1, 0, 1], [1, 0, 1]])) - sage: loads(dumps(M)).representation() + sage: M = TernaryMatroid(Matrix(GF(3), [[1, 0, 1], [1, 0, 1]])) # optional - sage.rings.finite_rings + sage: loads(dumps(M)).representation() # optional - sage.rings.finite_rings [1 0 1] [1 0 1] @@ -4923,15 +4927,15 @@ cdef class TernaryMatroid(LinearMatroid): Check that :trac:`23437` is fixed:: - sage: from sage.matroids.advanced import * - sage: X_bin = matroids.named_matroids.Fano().representation() - sage: X = Matrix(GF(3), X_bin) - sage: M = TernaryMatroid(matrix=X).dual() - sage: B = list(M.bases()) - sage: N = loads(dumps(M)) - sage: N.closure(frozenset({3})) + sage: from sage.matroids.advanced import * # optional - sage.rings.finite_rings + sage: X_bin = matroids.named_matroids.Fano().representation() # optional - sage.rings.finite_rings + sage: X = Matrix(GF(3), X_bin) # optional - sage.rings.finite_rings + sage: M = TernaryMatroid(matrix=X).dual() # optional - sage.rings.finite_rings + sage: B = list(M.bases()) # optional - sage.rings.finite_rings + sage: N = loads(dumps(M)) # optional - sage.rings.finite_rings + sage: N.closure(frozenset({3})) # optional - sage.rings.finite_rings frozenset({3}) - sage: N.is_isomorphic(M) + sage: N.is_isomorphic(M) # optional - sage.rings.finite_rings True """ import sage.matroids.unpickling @@ -5004,25 +5008,25 @@ cdef class QuaternaryMatroid(LinearMatroid): EXAMPLES:: - sage: GF4 = GF(4, 'x') - sage: x = GF4.gens()[0] - sage: A = Matrix(GF4, 2, 4, [[1, 0, 1, 1], [0, 1, 1, x]]) - sage: M = Matroid(A) - sage: M + sage: GF4 = GF(4, 'x') # optional - sage.rings.finite_rings + sage: x = GF4.gens()[0] # optional - sage.rings.finite_rings + sage: A = Matrix(GF4, 2, 4, [[1, 0, 1, 1], [0, 1, 1, x]]) # optional - sage.rings.finite_rings + sage: M = Matroid(A) # optional - sage.rings.finite_rings + sage: M # optional - sage.rings.finite_rings Quaternary matroid of rank 2 on 4 elements - sage: sorted(M.groundset()) + sage: sorted(M.groundset()) # optional - sage.rings.finite_rings [0, 1, 2, 3] - sage: Matrix(M) + sage: Matrix(M) # optional - sage.rings.finite_rings [1 0 1 1] [0 1 1 x] - sage: M = Matroid(matrix=A, groundset='abcd') - sage: sorted(M.groundset()) + sage: M = Matroid(matrix=A, groundset='abcd') # optional - sage.rings.finite_rings + sage: sorted(M.groundset()) # optional - sage.rings.finite_rings ['a', 'b', 'c', 'd'] - sage: GF4p = GF(4, 'y') - sage: y = GF4p.gens()[0] - sage: B = Matrix(GF4p, 2, 2, [[1, 1], [1, y]]) - sage: N = Matroid(reduced_matrix=B, groundset='abcd') - sage: M == N + sage: GF4p = GF(4, 'y') # optional - sage.rings.finite_rings + sage: y = GF4p.gens()[0] # optional - sage.rings.finite_rings + sage: B = Matrix(GF4p, 2, 2, [[1, 1], [1, y]]) # optional - sage.rings.finite_rings + sage: N = Matroid(reduced_matrix=B, groundset='abcd') # optional - sage.rings.finite_rings + sage: M == N # optional - sage.rings.finite_rings False """ def __init__(self, matrix=None, groundset=None, reduced_matrix=None, ring=None, keep_initial_representation=True, basis=None): @@ -5038,7 +5042,7 @@ cdef class QuaternaryMatroid(LinearMatroid): EXAMPLES:: sage: from sage.matroids.advanced import * - sage: QuaternaryMatroid(matrix=Matrix(GF(4, 'x'), # indirect doctest + sage: QuaternaryMatroid(matrix=Matrix(GF(4, 'x'), # indirect doctest, optional - sage.rings.finite_rings ....: [[1, 0, 1, 1, 1], ....: [0, 1, 1, 1, 1]])) Quaternary matroid of rank 2 on 5 elements @@ -5100,9 +5104,9 @@ cdef class QuaternaryMatroid(LinearMatroid): EXAMPLES:: - sage: M = Matroid(ring=GF(4, 'y'), reduced_matrix=[[1, 0, 1], + sage: M = Matroid(ring=GF(4, 'y'), reduced_matrix=[[1, 0, 1], # optional - sage.rings.finite_rings ....: [0, 1, 1]]) - sage: M.base_ring() + sage: M.base_ring() # optional - sage.rings.finite_rings Finite Field in y of size 2^2 """ return (self._A).base_ring() @@ -5114,9 +5118,9 @@ cdef class QuaternaryMatroid(LinearMatroid): EXAMPLES:: - sage: M = Matroid(ring=GF(4, 'y'), reduced_matrix=[[1, 0, 1], + sage: M = Matroid(ring=GF(4, 'y'), reduced_matrix=[[1, 0, 1], # optional - sage.rings.finite_rings ....: [0, 1, 1]]) - sage: M.characteristic() + sage: M.characteristic() # optional - sage.rings.finite_rings 2 """ return 2 @@ -5177,9 +5181,9 @@ cdef class QuaternaryMatroid(LinearMatroid): EXAMPLES:: - sage: M = Matroid(ring=GF(4, 'x'), matrix=[[1, 0, 1], [0, 1, 1]]) - sage: M.rename() - sage: repr(M) # indirect doctest + sage: M = Matroid(ring=GF(4, 'x'), matrix=[[1, 0, 1], [0, 1, 1]]) # optional - sage.rings.finite_rings + sage: M.rename() # optional - sage.rings.finite_rings + sage: repr(M) # indirect doctest # optional - sage.rings.finite_rings 'Quaternary matroid of rank 2 on 3 elements' """ S = "Quaternary matroid of rank " + str(self.rank()) + " on " + str(self.size()) + " elements" @@ -5203,13 +5207,13 @@ cdef class QuaternaryMatroid(LinearMatroid): EXAMPLES:: - sage: M = matroids.named_matroids.Q10() - sage: A = M._reduced_representation('efghi') - sage: R, C = M._current_rows_cols() - sage: (sorted(R), sorted(C)) + sage: M = matroids.named_matroids.Q10() # optional - sage.rings.finite_rings + sage: A = M._reduced_representation('efghi') # optional - sage.rings.finite_rings + sage: R, C = M._current_rows_cols() # optional - sage.rings.finite_rings + sage: (sorted(R), sorted(C)) # optional - sage.rings.finite_rings (['e', 'f', 'g', 'h', 'i'], ['a', 'b', 'c', 'd', 'j']) - sage: R, C = M._current_rows_cols(B='abcde') - sage: (sorted(R), sorted(C)) + sage: R, C = M._current_rows_cols(B='abcde') # optional - sage.rings.finite_rings + sage: (sorted(R), sorted(C)) # optional - sage.rings.finite_rings (['a', 'b', 'c', 'd', 'e'], ['f', 'g', 'h', 'i', 'j']) """ @@ -5251,15 +5255,15 @@ cdef class QuaternaryMatroid(LinearMatroid): EXAMPLES:: - sage: M = matroids.named_matroids.Q10() - sage: M._basic_representation() + sage: M = matroids.named_matroids.Q10() # optional - sage.rings.finite_rings + sage: M._basic_representation() # optional - sage.rings.finite_rings 5 x 10 QuaternaryMatrix [100001x00y] [01000y1x00] [001000y1x0] [0001000y1x] [00001x00y1] - sage: matrix(M._basic_representation('efghi')) + sage: matrix(M._basic_representation('efghi')) # optional - sage.rings.finite_rings [ 1 0 x + 1 1 0 1 0 0 0 1] [ x x + 1 0 0 0 0 0 1 0 1] [ 0 0 x x + 1 0 0 1 0 0 1] @@ -5294,15 +5298,15 @@ cdef class QuaternaryMatroid(LinearMatroid): EXAMPLES:: - sage: M = matroids.named_matroids.Q10() - sage: M._reduced_representation() + sage: M = matroids.named_matroids.Q10() # optional - sage.rings.finite_rings + sage: M._reduced_representation() # optional - sage.rings.finite_rings 5 x 5 QuaternaryMatrix [1x00y] [y1x00] [0y1x0] [00y1x] [x00y1] - sage: matrix(M._reduced_representation('efghi')) + sage: matrix(M._reduced_representation('efghi')) # optional - sage.rings.finite_rings [ 1 0 x + 1 1 1] [ x x + 1 0 0 1] [ 0 0 x x + 1 1] @@ -5322,8 +5326,8 @@ cdef class QuaternaryMatroid(LinearMatroid): EXAMPLES:: - sage: M = matroids.named_matroids.Q10() - sage: M._invariant() # indirect doctest + sage: M = matroids.named_matroids.Q10() # optional - sage.rings.finite_rings + sage: M._invariant() # indirect doctest # optional - sage.rings.finite_rings (0, 0, 5, 5, 20, 10, 25) """ cdef QuaternaryMatrix Q, QT @@ -5401,8 +5405,8 @@ cdef class QuaternaryMatroid(LinearMatroid): EXAMPLES:: - sage: M = matroids.named_matroids.Q10() - sage: M._invariant() + sage: M = matroids.named_matroids.Q10() # optional - sage.rings.finite_rings + sage: M._invariant() # optional - sage.rings.finite_rings (0, 0, 5, 5, 20, 10, 25) """ @@ -5429,8 +5433,8 @@ cdef class QuaternaryMatroid(LinearMatroid): EXAMPLES:: - sage: M = matroids.named_matroids.Q10() - sage: M.bicycle_dimension() + sage: M = matroids.named_matroids.Q10() # optional - sage.rings.finite_rings + sage: M.bicycle_dimension() # optional - sage.rings.finite_rings 0 """ if self._q_invariant is None: @@ -5456,14 +5460,16 @@ cdef class QuaternaryMatroid(LinearMatroid): EXAMPLES:: - sage: M = matroids.named_matroids.Q10()\'a' - sage: for F in M._principal_tripartition(): print(sorted(F)) + sage: M = matroids.named_matroids.Q10()\'a' # optional - sage.rings.finite_rings + sage: for F in M._principal_tripartition(): print(sorted(F)) # optional - sage.rings.finite_rings ['b', 'c', 'd', 'e', 'h', 'i'] ['f', 'g', 'j'] [] - sage: M.bicycle_dimension() + sage: M.bicycle_dimension() # optional - sage.rings.finite_rings 1 - sage: for i in [-1, 0, 1]: print(sorted([e for e in M.groundset() if (M\e).bicycle_dimension() == 1 + i])) + sage: for i in [-1, 0, 1]: # optional - sage.rings.finite_rings + ....: print(sorted(e for e in M.groundset() + ....: if (M\e).bicycle_dimension() == 1 + i)) ['b', 'c', 'd', 'e', 'h', 'i'] ['f', 'g', 'j'] [] @@ -5492,9 +5498,9 @@ cdef class QuaternaryMatroid(LinearMatroid): EXAMPLES:: - sage: M = matroids.named_matroids.Q10()\'a' - sage: N = matroids.named_matroids.Q10()\'b' - sage: M._fast_isom_test(N) is None + sage: M = matroids.named_matroids.Q10()\'a' # optional - sage.rings.finite_rings + sage: N = matroids.named_matroids.Q10()\'b' # optional - sage.rings.finite_rings + sage: M._fast_isom_test(N) is None # optional - sage.rings.finite_rings True """ if self._invariant() != other._invariant(): @@ -5528,9 +5534,9 @@ cdef class QuaternaryMatroid(LinearMatroid): EXAMPLES:: - sage: M = matroids.named_matroids.Q10() - sage: N = M._minor(contractions=set(['a']), deletions=set([])) - sage: N._minor(contractions=set([]), deletions=set(['b', 'c'])) + sage: M = matroids.named_matroids.Q10() # optional - sage.rings.finite_rings + sage: N = M._minor(contractions=set(['a']), deletions=set([])) # optional - sage.rings.finite_rings + sage: N._minor(contractions=set([]), deletions=set(['b', 'c'])) # optional - sage.rings.finite_rings Quaternary matroid of rank 4 on 7 elements """ self._move_current_basis(contractions, deletions) @@ -5557,8 +5563,8 @@ cdef class QuaternaryMatroid(LinearMatroid): EXAMPLES:: - sage: M = Matroid(Matrix(GF(4, 'x'), [[]])) - sage: M.is_valid() + sage: M = Matroid(Matrix(GF(4, 'x'), [[]])) # optional - sage.rings.finite_rings + sage: M.is_valid() # optional - sage.rings.finite_rings True """ return True @@ -5569,10 +5575,10 @@ cdef class QuaternaryMatroid(LinearMatroid): EXAMPLES:: - sage: M = Matroid(Matrix(GF(4, 'x'), [[1, 0, 0, 1, 1], + sage: M = Matroid(Matrix(GF(4, 'x'), [[1, 0, 0, 1, 1], # optional - sage.rings.finite_rings ....: [0, 1, 0, 1, 2], [0, 0, 1, 1, 3]])) - sage: N = copy(M) # indirect doctest - sage: M == N + sage: N = copy(M) # indirect doctest # optional - sage.rings.finite_rings + sage: M == N # optional - sage.rings.finite_rings True """ cdef QuaternaryMatroid N @@ -5593,10 +5599,10 @@ cdef class QuaternaryMatroid(LinearMatroid): EXAMPLES:: - sage: M = Matroid(Matrix(GF(4, 'x'), [[1, 0, 0, 1, 1], + sage: M = Matroid(Matrix(GF(4, 'x'), [[1, 0, 0, 1, 1], # optional - sage.rings.finite_rings ....: [0, 1, 0, 1, 2], [0, 0, 1, 1, -1]])) - sage: N = deepcopy(M) # indirect doctest - sage: M == N + sage: N = deepcopy(M) # indirect doctest # optional - sage.rings.finite_rings + sage: M == N # optional - sage.rings.finite_rings True """ from copy import deepcopy @@ -5632,12 +5638,12 @@ cdef class QuaternaryMatroid(LinearMatroid): EXAMPLES:: - sage: M = Matroid(Matrix(GF(4, 'x'), [[1, 0, 0, 1], [0, 1, 0, 1], + sage: M = Matroid(Matrix(GF(4, 'x'), [[1, 0, 0, 1], [0, 1, 0, 1], # optional - sage.rings.finite_rings ....: [0, 0, 1, 1]])) - sage: M == loads(dumps(M)) # indirect doctest + sage: M == loads(dumps(M)) # indirect doctest # optional - sage.rings.finite_rings True - sage: M.rename("U34") - sage: loads(dumps(M)) + sage: M.rename("U34") # optional - sage.rings.finite_rings + sage: loads(dumps(M)) # optional - sage.rings.finite_rings U34 TESTS: @@ -5645,14 +5651,14 @@ cdef class QuaternaryMatroid(LinearMatroid): Check that :trac:`23437` is fixed:: sage: from sage.matroids.advanced import QuaternaryMatroid - sage: X_bin = matroids.named_matroids.Fano().representation() - sage: X = Matrix(GF(4), X_bin) - sage: M = QuaternaryMatroid(matrix=X).dual() - sage: B = list(M.bases()) - sage: N = loads(dumps(M)) - sage: N.closure(frozenset({3})) + sage: X_bin = matroids.named_matroids.Fano().representation() # optional - sage.rings.finite_rings + sage: X = Matrix(GF(4), X_bin) # optional - sage.rings.finite_rings + sage: M = QuaternaryMatroid(matrix=X).dual() # optional - sage.rings.finite_rings + sage: B = list(M.bases()) # optional - sage.rings.finite_rings + sage: N = loads(dumps(M)) # optional - sage.rings.finite_rings + sage: N.closure(frozenset({3})) # optional - sage.rings.finite_rings frozenset({3}) - sage: N.is_isomorphic(M) + sage: N.is_isomorphic(M) # optional - sage.rings.finite_rings True """ import sage.matroids.unpickling @@ -5733,16 +5739,15 @@ cdef class RegularMatroid(LinearMatroid): EXAMPLES:: sage: A = Matrix(ZZ, 2, 4, [[1, 0, 1, 1], [0, 1, 1, 1]]) - sage: M = Matroid(A, regular=True) - sage: M + sage: M = Matroid(A, regular=True); M # optional - sage.graphs Regular matroid of rank 2 on 4 elements with 5 bases - sage: sorted(M.groundset()) + sage: sorted(M.groundset()) # optional - sage.graphs [0, 1, 2, 3] - sage: Matrix(M) + sage: Matrix(M) # optional - sage.graphs [1 0 1 1] [0 1 1 1] - sage: M = Matroid(matrix=A, groundset='abcd', regular=True) - sage: sorted(M.groundset()) + sage: M = Matroid(matrix=A, groundset='abcd', regular=True) # optional - sage.graphs + sage: sorted(M.groundset()) # optional - sage.graphs ['a', 'b', 'c', 'd'] """ def __init__(self, matrix=None, groundset=None, reduced_matrix=None, ring=None, keep_initial_representation=True): @@ -5758,7 +5763,7 @@ cdef class RegularMatroid(LinearMatroid): EXAMPLES:: sage: from sage.matroids.advanced import * - sage: RegularMatroid(matrix=Matrix(ZZ, [[1, 0, 1, 1, 1], # indirect doctest + sage: RegularMatroid(matrix=Matrix(ZZ, [[1, 0, 1, 1, 1], # indirect doctest, optional - sage.graphs ....: [0, 1, 1, 1, 1]])) Regular matroid of rank 2 on 5 elements with 7 bases """ @@ -5897,8 +5902,8 @@ cdef class RegularMatroid(LinearMatroid): EXAMPLES:: - sage: M = Matroid(graphs.CompleteGraph(5), regular = True) - sage: M.bases_count() + sage: M = Matroid(graphs.CompleteGraph(5), regular=True) # optional - sage.graphs + sage: M.bases_count() # optional - sage.graphs 125 ALGORITHM: @@ -6025,8 +6030,8 @@ cdef class RegularMatroid(LinearMatroid): EXAMPLES:: sage: M = matroids.named_matroids.R10() - sage: PV, tups, G = M._hypergraph() - sage: G + sage: PV, tups, G = M._hypergraph() # optional - sage.graphs + sage: G # optional - sage.graphs Digraph on 55 vertices """ # NEW VERSION, Uses Sage'S Graph Isomorphism @@ -6107,20 +6112,20 @@ cdef class RegularMatroid(LinearMatroid): EXAMPLES:: sage: M1 = matroids.Wheel(3) - sage: M2 = Matroid(groundset = list(range(6)), - ....: graph = graphs.CompleteGraph(4), regular = True) - sage: M1._is_isomorphic(M2) + sage: M2 = Matroid(groundset=list(range(6)), # optional - sage.graphs + ....: graph=graphs.CompleteGraph(4), regular=True) + sage: M1._is_isomorphic(M2) # optional - sage.graphs True - sage: M1._is_isomorphic(M2, certificate=True) + sage: M1._is_isomorphic(M2, certificate=True) # optional - sage.graphs (True, {0: 0, 1: 1, 2: 2, 3: 3, 4: 5, 5: 4}) sage: M1 = matroids.Wheel(3) - sage: M2 = matroids.named_matroids.Fano() - sage: M1._is_isomorphic(M2) + sage: M2 = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings + sage: M1._is_isomorphic(M2) # optional - sage.rings.finite_rings False - sage: M1._is_isomorphic(M2.delete('a')) + sage: M1._is_isomorphic(M2.delete('a')) # optional - sage.rings.finite_rings True - sage: M1._is_isomorphic(M2.delete('a'), certificate=True) + sage: M1._is_isomorphic(M2.delete('a'), certificate=True) # optional - sage.rings.finite_rings (True, {0: 'g', 1: 'b', 2: 'c', 3: 'e', 4: 'd', 5: 'f'}) Check that :trac:`17316` was fixed:: @@ -6179,7 +6184,7 @@ cdef class RegularMatroid(LinearMatroid): sage: M = matroids.named_matroids.R10()\'a' sage: N = matroids.named_matroids.R10()\'b' - sage: M._fast_isom_test(N) + sage: M._fast_isom_test(N) # optional - sage.graphs True """ if self.bases_count() != other.bases_count(): @@ -6210,9 +6215,9 @@ cdef class RegularMatroid(LinearMatroid): Check that :trac:`22263` was fixed:: - sage: m1 = Matroid(graph='H?ABC~}') - sage: m2 = Matroid(graph='H?ACNr}') - sage: m1.is_isomorphic(m2) + sage: m1 = Matroid(graph='H?ABC~}') # optional - sage.graphs + sage: m2 = Matroid(graph='H?ACNr}') # optional - sage.graphs + sage: m1.is_isomorphic(m2) # optional - sage.graphs False """ from sage.groups.perm_gps.partn_ref.refinement_graphs import isomorphic @@ -6331,13 +6336,13 @@ cdef class RegularMatroid(LinearMatroid): EXAMPLES:: - sage: M = matroids.named_matroids.R10() - sage: M.is_graphic() + sage: M = matroids.named_matroids.R10() # optional - sage.rings.finite_rings + sage: M.is_graphic() # optional - sage.rings.finite_rings False - sage: M = Matroid(graphs.CompleteGraph(5), regular = True) - sage: M.is_graphic() + sage: M = Matroid(graphs.CompleteGraph(5), regular=True) # optional - sage.graphs + sage: M.is_graphic() # optional - sage.graphs True - sage: M.dual().is_graphic() + sage: M.dual().is_graphic() # optional - sage.graphs False ALGORITHM: @@ -6363,14 +6368,14 @@ cdef class RegularMatroid(LinearMatroid): EXAMPLES:: - sage: M = Matroid(Matrix(ZZ, [[1, 0, 0, 1, 1, 0, 1], + sage: M = Matroid(Matrix(ZZ, [[1, 0, 0, 1, 1, 0, 1], # optional - sage.graphs ....: [0, 1, 0, 1, 0, 1, 1], ....: [0, 0, 1, 0, 1, 1, 1]]), ....: regular=True, check=False) - sage: M.is_valid() + sage: M.is_valid() # optional - sage.graphs False - sage: M = Matroid(graphs.PetersenGraph()) - sage: M.is_valid() + sage: M = Matroid(graphs.PetersenGraph()) # optional - sage.graphs + sage: M.is_valid() # optional - sage.graphs True """ M = LinearMatroid(ring=QQ, reduced_matrix=self.representation(self.basis(), True, False)) @@ -6403,8 +6408,8 @@ cdef class RegularMatroid(LinearMatroid): EXAMPLES:: - sage: N = matroids.named_matroids.R10() - sage: N.binary_matroid() + sage: N = matroids.named_matroids.R10() # optional - sage.rings.finite_rings + sage: N.binary_matroid() # optional - sage.rings.finite_rings Binary matroid of rank 5 on 10 elements, type (1, None) """ @@ -6433,8 +6438,8 @@ cdef class RegularMatroid(LinearMatroid): EXAMPLES:: - sage: N = matroids.named_matroids.R10() - sage: N.is_binary() + sage: N = matroids.named_matroids.R10() # optional - sage.rings.finite_rings + sage: N.is_binary() # optional - sage.rings.finite_rings True """ return True @@ -6463,8 +6468,8 @@ cdef class RegularMatroid(LinearMatroid): EXAMPLES:: - sage: N = matroids.named_matroids.R10() - sage: N.ternary_matroid() + sage: N = matroids.named_matroids.R10() # optional - sage.rings.finite_rings + sage: N.ternary_matroid() # optional - sage.rings.finite_rings Ternary matroid of rank 5 on 10 elements, type 4+ """ @@ -6493,8 +6498,8 @@ cdef class RegularMatroid(LinearMatroid): EXAMPLES:: - sage: N = matroids.named_matroids.R10() - sage: N.is_ternary() + sage: N = matroids.named_matroids.R10() # optional - sage.rings.finite_rings + sage: N.is_ternary() # optional - sage.rings.finite_rings True """ return True @@ -6507,9 +6512,9 @@ cdef class RegularMatroid(LinearMatroid): EXAMPLES:: - sage: M = matroids.named_matroids.R10() - sage: N = copy(M) # indirect doctest - sage: M == N + sage: M = matroids.named_matroids.R10() # optional - sage.rings.finite_rings + sage: N = copy(M) # indirect doctest # optional - sage.rings.finite_rings + sage: M == N # optional - sage.rings.finite_rings True """ cdef RegularMatroid N @@ -6527,9 +6532,9 @@ cdef class RegularMatroid(LinearMatroid): EXAMPLES:: - sage: M = matroids.named_matroids.R10() - sage: N = deepcopy(M) # indirect doctest - sage: M == N + sage: M = matroids.named_matroids.R10() # optional - sage.rings.finite_rings + sage: N = deepcopy(M) # indirect doctest # optional - sage.rings.finite_rings + sage: M == N # optional - sage.rings.finite_rings True """ cdef RegularMatroid N diff --git a/src/sage/matroids/matroid.pyx b/src/sage/matroids/matroid.pyx index 8d641737a8f..b91539ae82a 100644 --- a/src/sage/matroids/matroid.pyx +++ b/src/sage/matroids/matroid.pyx @@ -216,7 +216,7 @@ in which the partition is specified as a list of lists:: sage: M = PartitionMatroid([[1, 2], [3, 4, 5], [6, 7]]) sage: M.full_rank() 3 - sage: M.tutte_polynomial(var('x'), var('y')) + sage: M.tutte_polynomial(var('x'), var('y')) # optional - sage.symbolic x^2*y^2 + 2*x*y^3 + y^4 + x^3 + 3*x^2*y + 3*x*y^2 + y^3 .. NOTE:: @@ -394,7 +394,7 @@ cdef class Matroid(SageObject): sage: M = PartitionMatroid([[1, 2], [3, 4, 5], [6, 7]]) sage: M.full_rank() 3 - sage: M.tutte_polynomial(var('x'), var('y')) + sage: M.tutte_polynomial(var('x'), var('y')) # optional - sage.symbolic x^2*y^2 + 2*x*y^3 + y^4 + x^3 + 3*x^2*y + 3*x*y^2 + y^3 .. NOTE:: @@ -1133,7 +1133,7 @@ cdef class Matroid(SageObject): EXAMPLES:: sage: M = matroids.named_matroids.Vamos() - sage: M._has_minor(matroids.Whirl(3)) + sage: M._has_minor(matroids.Whirl(3)) # optional - sage.rings.finite_rings False sage: M._has_minor(matroids.Uniform(2, 4)) True @@ -1361,12 +1361,12 @@ cdef class Matroid(SageObject): EXAMPLES:: - sage: M = matroids.named_matroids.Fano() - sage: M.rank() + sage: M = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings + sage: M.rank() # optional - sage.rings.finite_rings 3 - sage: M.rank(['a', 'b', 'f']) + sage: M.rank(['a', 'b', 'f']) # optional - sage.rings.finite_rings 2 - sage: M.rank(['a', 'b', 'x']) + sage: M.rank(['a', 'b', 'x']) # optional - sage.rings.finite_rings Traceback (most recent call last): ... ValueError: ['a', 'b', 'x'] is not a subset of the groundset @@ -1489,7 +1489,7 @@ cdef class Matroid(SageObject): ... ValueError: ['x'] is not a subset of the groundset sage: C = M.circuit() - sage: sorted(C) # random + sage: sorted(C) # random ['a', 'b', 'c', 'd'] sage: M.is_circuit(C) True @@ -1672,12 +1672,12 @@ cdef class Matroid(SageObject): EXAMPLES:: - sage: M = matroids.named_matroids.Fano() - sage: M.corank() + sage: M = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings + sage: M.corank() # optional - sage.rings.finite_rings 4 - sage: M.corank('cdeg') + sage: M.corank('cdeg') # optional - sage.rings.finite_rings 3 - sage: M.rank(['a', 'b', 'x']) + sage: M.rank(['a', 'b', 'x']) # optional - sage.rings.finite_rings Traceback (most recent call last): ... ValueError: ['a', 'b', 'x'] is not a subset of the groundset @@ -1769,7 +1769,7 @@ cdef class Matroid(SageObject): sage: M = matroids.named_matroids.Vamos() sage: X = M.max_coindependent(['a', 'c', 'd', 'e', 'f']) - sage: sorted(X) # random + sage: sorted(X) # random ['a', 'c', 'd', 'f'] sage: M.is_coindependent(X) True @@ -1855,7 +1855,7 @@ cdef class Matroid(SageObject): ... ValueError: ['x'] is not a subset of the groundset sage: C = M.cocircuit() - sage: sorted(C) # random + sage: sorted(C) # random ['e', 'f', 'g', 'h'] sage: M.is_cocircuit(C) True @@ -1914,10 +1914,10 @@ cdef class Matroid(SageObject): EXAMPLES:: - sage: M = matroids.named_matroids.Fano() - sage: M.loops() + sage: M = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings + sage: M.loops() # optional - sage.rings.finite_rings frozenset() - sage: (M / ['a', 'b']).loops() + sage: (M / ['a', 'b']).loops() # optional - sage.rings.finite_rings frozenset({'f'}) """ return self._closure(set()) @@ -2138,10 +2138,10 @@ cdef class Matroid(SageObject): EXAMPLES:: - sage: M = matroids.named_matroids.Fano().dual() - sage: M.coloops() + sage: M = matroids.named_matroids.Fano().dual() # optional - sage.rings.finite_rings + sage: M.coloops() # optional - sage.rings.finite_rings frozenset() - sage: (M \ ['a', 'b']).coloops() + sage: (M \ ['a', 'b']).coloops() # optional - sage.rings.finite_rings frozenset({'f'}) """ return self._coclosure(set()) @@ -2384,8 +2384,8 @@ cdef class Matroid(SageObject): EXAMPLES:: - sage: M = matroids.named_matroids.Fano() - sage: sorted([sorted(C) for C in M.circuits()]) + sage: M = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings + sage: sorted([sorted(C) for C in M.circuits()]) # optional - sage.rings.finite_rings [['a', 'b', 'c', 'g'], ['a', 'b', 'd', 'e'], ['a', 'b', 'f'], ['a', 'c', 'd', 'f'], ['a', 'c', 'e'], ['a', 'd', 'g'], ['a', 'e', 'f', 'g'], ['b', 'c', 'd'], ['b', 'c', 'e', 'f'], @@ -2416,8 +2416,8 @@ cdef class Matroid(SageObject): EXAMPLES:: - sage: M = matroids.named_matroids.Fano() - sage: sorted([sorted(C) for C in M.nonspanning_circuits()]) + sage: M = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings + sage: sorted([sorted(C) for C in M.nonspanning_circuits()]) # optional - sage.rings.finite_rings [['a', 'b', 'f'], ['a', 'c', 'e'], ['a', 'd', 'g'], ['b', 'c', 'd'], ['b', 'e', 'g'], ['c', 'f', 'g'], ['d', 'e', 'f']] @@ -2442,8 +2442,8 @@ cdef class Matroid(SageObject): EXAMPLES:: - sage: M = matroids.named_matroids.Fano() - sage: sorted([sorted(C) for C in M.cocircuits()]) + sage: M = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings + sage: sorted([sorted(C) for C in M.cocircuits()]) # optional - sage.rings.finite_rings [['a', 'b', 'c', 'g'], ['a', 'b', 'd', 'e'], ['a', 'c', 'd', 'f'], ['a', 'e', 'f', 'g'], ['b', 'c', 'e', 'f'], ['b', 'd', 'f', 'g'], ['c', 'd', 'e', 'g']] @@ -2471,8 +2471,8 @@ cdef class Matroid(SageObject): EXAMPLES:: - sage: M = matroids.named_matroids.Fano().dual() - sage: sorted([sorted(C) for C in M.noncospanning_cocircuits()]) + sage: M = matroids.named_matroids.Fano().dual() # optional - sage.rings.finite_rings + sage: sorted([sorted(C) for C in M.noncospanning_cocircuits()]) # optional - sage.rings.finite_rings [['a', 'b', 'f'], ['a', 'c', 'e'], ['a', 'd', 'g'], ['b', 'c', 'd'], ['b', 'e', 'g'], ['c', 'f', 'g'], ['d', 'e', 'f']] @@ -2497,17 +2497,17 @@ cdef class Matroid(SageObject): EXAMPLES:: - sage: M = matroids.named_matroids.Fano() - sage: CC = M.circuit_closures() - sage: len(CC[2]) + sage: M = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings + sage: CC = M.circuit_closures() # optional - sage.rings.finite_rings + sage: len(CC[2]) # optional - sage.rings.finite_rings 7 - sage: len(CC[3]) + sage: len(CC[3]) # optional - sage.rings.finite_rings 1 - sage: len(CC[1]) + sage: len(CC[1]) # optional - sage.rings.finite_rings Traceback (most recent call last): ... KeyError: 1 - sage: [sorted(X) for X in CC[3]] + sage: [sorted(X) for X in CC[3]] # optional - sage.rings.finite_rings [['a', 'b', 'c', 'd', 'e', 'f', 'g']] """ CC = [set([]) for r in xrange(self.rank() + 1)] @@ -2534,11 +2534,11 @@ cdef class Matroid(SageObject): EXAMPLES:: - sage: M = matroids.named_matroids.Fano() - sage: CC = M.nonspanning_circuit_closures() - sage: len(CC[2]) + sage: M = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings + sage: CC = M.nonspanning_circuit_closures() # optional - sage.rings.finite_rings + sage: len(CC[2]) # optional - sage.rings.finite_rings 7 - sage: len(CC[3]) + sage: len(CC[3]) # optional - sage.rings.finite_rings Traceback (most recent call last): ... KeyError: 3 @@ -2737,9 +2737,9 @@ cdef class Matroid(SageObject): EXAMPLES:: - sage: M = matroids.named_matroids.Fano() - sage: F = M._flags(1) - sage: sorted(M._extend_flags(F)) == sorted(M._flags(2)) + sage: M = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings + sage: F = M._flags(1) # optional - sage.rings.finite_rings + sage: sorted(M._extend_flags(F)) == sorted(M._flags(2)) # optional - sage.rings.finite_rings True """ newflags = [] @@ -2777,8 +2777,8 @@ cdef class Matroid(SageObject): EXAMPLES:: - sage: M = matroids.named_matroids.Fano() - sage: sorted([M._flags(1)]) + sage: M = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings + sage: sorted([M._flags(1)]) # optional - sage.rings.finite_rings [[[frozenset({'a'}), {'a'}, frozenset({'b', 'c', 'd', 'e', 'f', 'g'})], [frozenset({'b'}), {'b'}, frozenset({'c', 'd', 'e', 'f', 'g'})], [frozenset({'c'}), {'c'}, frozenset({'d', 'e', 'f', 'g'})], @@ -2815,8 +2815,8 @@ cdef class Matroid(SageObject): EXAMPLES:: - sage: M = matroids.named_matroids.Fano() - sage: sorted([sorted(F) for F in M.flats(2)]) + sage: M = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings + sage: sorted([sorted(F) for F in M.flats(2)]) # optional - sage.rings.finite_rings [['a', 'b', 'f'], ['a', 'c', 'e'], ['a', 'd', 'g'], ['b', 'c', 'd'], ['b', 'e', 'g'], ['c', 'f', 'g'], ['d', 'e', 'f']] @@ -2844,8 +2844,8 @@ cdef class Matroid(SageObject): EXAMPLES:: - sage: M = matroids.named_matroids.Q6() - sage: sorted([sorted(F) for F in M.coflats(2)]) + sage: M = matroids.named_matroids.Q6() # optional - sage.rings.finite_rings + sage: sorted([sorted(F) for F in M.coflats(2)]) # optional - sage.rings.finite_rings [['a', 'b'], ['a', 'c'], ['a', 'd', 'f'], ['a', 'e'], ['b', 'c'], ['b', 'd'], ['b', 'e'], ['b', 'f'], ['c', 'd'], ['c', 'e', 'f'], ['d', 'e']] @@ -2858,8 +2858,8 @@ cdef class Matroid(SageObject): EXAMPLES:: - sage: M = matroids.named_matroids.Fano() - sage: M.lattice_of_flats() + sage: M = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings + sage: M.lattice_of_flats() # optional - sage.rings.finite_rings Finite lattice containing 16 elements """ from sage.combinat.posets.lattices import LatticePoset @@ -3125,13 +3125,13 @@ cdef class Matroid(SageObject): EXAMPLES:: - sage: M = matroids.Whirl(4) - sage: P = M.matroid_polytope(); P + sage: M = matroids.Whirl(4) # optional - sage.rings.finite_rings + sage: P = M.matroid_polytope(); P # optional - sage.geometry.polyhedron sage.rings.finite_rings A 7-dimensional polyhedron in ZZ^8 defined as the convex hull of 46 vertices - sage: M = matroids.named_matroids.NonFano() - sage: M.matroid_polytope() + sage: M = matroids.named_matroids.NonFano() # optional - sage.rings.finite_rings + sage: M.matroid_polytope() # optional - sage.geometry.polyhedron sage.rings.finite_rings A 6-dimensional polyhedron in ZZ^7 defined as the convex hull of 29 vertices @@ -3168,13 +3168,13 @@ cdef class Matroid(SageObject): EXAMPLES:: - sage: M = matroids.Whirl(4) - sage: M.independence_matroid_polytope() + sage: M = matroids.Whirl(4) # optional - sage.rings.finite_rings + sage: M.independence_matroid_polytope() # optional - sage.geometry.polyhedron sage.rings.finite_rings A 8-dimensional polyhedron in ZZ^8 defined as the convex hull of 135 vertices - sage: M = matroids.named_matroids.NonFano() - sage: M.independence_matroid_polytope() + sage: M = matroids.named_matroids.NonFano() # optional - sage.rings.finite_rings + sage: M.independence_matroid_polytope() # optional - sage.geometry.polyhedron sage.rings.finite_rings A 7-dimensional polyhedron in ZZ^7 defined as the convex hull of 58 vertices @@ -3227,11 +3227,11 @@ cdef class Matroid(SageObject): TypeError: can only test for isomorphism between matroids. - sage: M1 = matroids.named_matroids.Fano() - sage: M2 = matroids.named_matroids.NonFano() - sage: M1.is_isomorphic(M2) + sage: M1 = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings + sage: M2 = matroids.named_matroids.NonFano() # optional - sage.rings.finite_rings + sage: M1.is_isomorphic(M2) # optional - sage.rings.finite_rings False - sage: M1.is_isomorphic(M2, certificate=True) + sage: M1.is_isomorphic(M2, certificate=True) # optional - sage.rings.finite_rings (False, None) """ if not isinstance(other, Matroid): @@ -3267,9 +3267,9 @@ cdef class Matroid(SageObject): sage: M1._is_isomorphic(M2, certificate=True) (True, {0: 0, 1: 1, 2: 2, 3: 3, 4: 5, 5: 4}) - sage: M1 = matroids.named_matroids.Fano() - sage: M2 = matroids.named_matroids.NonFano() - sage: M1._is_isomorphic(M2) + sage: M1 = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings + sage: M2 = matroids.named_matroids.NonFano() # optional - sage.rings.finite_rings + sage: M1._is_isomorphic(M2) # optional - sage.rings.finite_rings False """ @@ -3309,9 +3309,9 @@ cdef class Matroid(SageObject): ... TypeError: can only give isomorphism between matroids. - sage: M1 = matroids.named_matroids.Fano() - sage: M2 = matroids.named_matroids.NonFano() - sage: M1.isomorphism(M2) is not None + sage: M1 = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings + sage: M2 = matroids.named_matroids.NonFano() # optional - sage.rings.finite_rings + sage: M1.isomorphism(M2) is not None # optional - sage.rings.finite_rings False """ if not isinstance(other, Matroid): @@ -3339,9 +3339,9 @@ cdef class Matroid(SageObject): sage: morphism=M1.isomorphism(M2) sage: M1.is_isomorphism(M2, morphism) True - sage: M1 = matroids.named_matroids.Fano() - sage: M2 = matroids.named_matroids.NonFano() - sage: M1.isomorphism(M2) is not None + sage: M1 = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings + sage: M2 = matroids.named_matroids.NonFano() # optional - sage.rings.finite_rings + sage: M1.isomorphism(M2) is not None # optional - sage.rings.finite_rings False """ if self is other: @@ -3385,38 +3385,38 @@ cdef class Matroid(SageObject): yields ``False``, even if the matroids are equal:: sage: from sage.matroids.advanced import * - sage: M = matroids.named_matroids.Fano() - sage: M + sage: M = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings + sage: M # optional - sage.rings.finite_rings Fano: Binary matroid of rank 3 on 7 elements, type (3, 0) - sage: M1 = BasisMatroid(M) - sage: M2 = Matroid(groundset='abcdefg', reduced_matrix=[ + sage: M1 = BasisMatroid(M) # optional - sage.rings.finite_rings + sage: M2 = Matroid(groundset='abcdefg', reduced_matrix=[ # optional - sage.rings.finite_rings ....: [0, 1, 1, 1], [1, 0, 1, 1], [1, 1, 0, 1]], field=GF(2)) - sage: M.equals(M1) + sage: M.equals(M1) # optional - sage.rings.finite_rings True - sage: M.equals(M2) + sage: M.equals(M2) # optional - sage.rings.finite_rings True - sage: M == M1 + sage: M == M1 # optional - sage.rings.finite_rings False - sage: M == M2 + sage: M == M2 # optional - sage.rings.finite_rings True :class:`LinearMatroid ` instances ``M`` and ``N`` satisfy ``M == N`` if the representations are equivalent up to row operations and column scaling:: - sage: M1 = LinearMatroid(groundset='abcd', matrix=Matrix(GF(7), + sage: M1 = LinearMatroid(groundset='abcd', matrix=Matrix(GF(7), # optional - sage.rings.finite_rings ....: [[1, 0, 1, 1], [0, 1, 1, 2]])) - sage: M2 = LinearMatroid(groundset='abcd', matrix=Matrix(GF(7), + sage: M2 = LinearMatroid(groundset='abcd', matrix=Matrix(GF(7), # optional - sage.rings.finite_rings ....: [[1, 0, 1, 1], [0, 1, 1, 3]])) - sage: M3 = LinearMatroid(groundset='abcd', matrix=Matrix(GF(7), + sage: M3 = LinearMatroid(groundset='abcd', matrix=Matrix(GF(7), # optional - sage.rings.finite_rings ....: [[2, 6, 1, 0], [6, 1, 0, 1]])) - sage: M1.equals(M2) + sage: M1.equals(M2) # optional - sage.rings.finite_rings True - sage: M1.equals(M3) + sage: M1.equals(M3) # optional - sage.rings.finite_rings True - sage: M1 == M2 + sage: M1 == M2 # optional - sage.rings.finite_rings False - sage: M1 == M3 + sage: M1 == M3 # optional - sage.rings.finite_rings True """ if self is other: @@ -3463,19 +3463,19 @@ cdef class Matroid(SageObject): sage: N.is_isomorphism(M, {e:e for e in M.groundset()}) False - sage: M = matroids.named_matroids.Fano() \ ['g'] - sage: N = matroids.Wheel(3) - sage: morphism = {'a':0, 'b':1, 'c': 2, 'd':4, 'e':5, 'f':3} - sage: M.is_isomorphism(N, morphism) + sage: M = matroids.named_matroids.Fano() \ ['g'] # optional - sage.rings.finite_rings + sage: N = matroids.Wheel(3) # optional - sage.rings.finite_rings + sage: morphism = {'a':0, 'b':1, 'c': 2, 'd':4, 'e':5, 'f':3} # optional - sage.rings.finite_rings + sage: M.is_isomorphism(N, morphism) # optional - sage.rings.finite_rings True A morphism can be specified as a dictionary (above), a permutation, a function, and many other types of maps:: - sage: M = matroids.named_matroids.Fano() - sage: P = PermutationGroup([[('a', 'b', 'c'), + sage: M = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings + sage: P = PermutationGroup([[('a', 'b', 'c'), # optional - sage.rings.finite_rings ....: ('d', 'e', 'f'), ('g')]]).gen() - sage: M.is_isomorphism(M, P) + sage: M.is_isomorphism(M, P) # optional - sage.rings.finite_rings True sage: M = matroids.named_matroids.Pappus() @@ -3572,10 +3572,10 @@ cdef class Matroid(SageObject): sage: N._is_isomorphism(M, {e:e for e in M.groundset()}) False - sage: M = matroids.named_matroids.Fano() \ ['g'] + sage: M = matroids.named_matroids.Fano() \ ['g'] # optional - sage.rings.finite_rings sage: N = matroids.Wheel(3) sage: morphism = {'a':0, 'b':1, 'c': 2, 'd':4, 'e':5, 'f':3} - sage: M._is_isomorphism(N, morphism) + sage: M._is_isomorphism(N, morphism) # optional - sage.rings.finite_rings True """ from . import basis_exchange_matroid @@ -3639,19 +3639,19 @@ cdef class Matroid(SageObject): EXAMPLES:: - sage: M1 = Matroid(groundset='abcd', matrix=Matrix(GF(7), + sage: M1 = Matroid(groundset='abcd', matrix=Matrix(GF(7), # optional - sage.rings.finite_rings ....: [[1, 0, 1, 1], [0, 1, 1, 2]])) - sage: M2 = Matroid(groundset='abcd', matrix=Matrix(GF(7), + sage: M2 = Matroid(groundset='abcd', matrix=Matrix(GF(7), # optional - sage.rings.finite_rings ....: [[1, 0, 1, 1], [0, 1, 1, 3]])) - sage: M3 = Matroid(groundset='abcd', matrix=Matrix(GF(7), + sage: M3 = Matroid(groundset='abcd', matrix=Matrix(GF(7), # optional - sage.rings.finite_rings ....: [[2, 6, 1, 0], [6, 1, 0, 1]])) - sage: M1.equals(M2) + sage: M1.equals(M2) # optional - sage.rings.finite_rings True - sage: M1.equals(M3) + sage: M1.equals(M3) # optional - sage.rings.finite_rings True - sage: M1 != M2 # indirect doctest + sage: M1 != M2 # indirect doctest # optional - sage.rings.finite_rings True - sage: M1 == M3 # indirect doctest + sage: M1 == M3 # indirect doctest # optional - sage.rings.finite_rings True """ if op not in [Py_EQ, Py_NE]: @@ -3713,10 +3713,10 @@ cdef class Matroid(SageObject): The sets of contractions and deletions need not be independent, respectively coindependent:: - sage: M = matroids.named_matroids.Fano() - sage: M.rank('abf') + sage: M = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings + sage: M.rank('abf') # optional - sage.rings.finite_rings 2 - sage: M.minor(contractions='abf') + sage: M.minor(contractions='abf') # optional - sage.rings.finite_rings Binary matroid of rank 1 on 4 elements, type (1, 0) However, they need to be subsets of the groundset, and disjoint:: @@ -3819,12 +3819,12 @@ cdef class Matroid(SageObject): :: - sage: M = matroids.named_matroids.Fano() - sage: sorted(M.groundset()) + sage: M = 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: M.contract(['a', 'c']) + sage: M.contract(['a', 'c']) # optional - sage.rings.finite_rings Binary matroid of rank 1 on 5 elements, type (1, 0) - sage: M.contract(['a']) == M / ['a'] + sage: M.contract(['a']) == M / ['a'] # optional - sage.rings.finite_rings True One can use a single element, rather than a set:: @@ -3837,8 +3837,8 @@ cdef class Matroid(SageObject): Note that one can iterate over strings:: - sage: M = matroids.named_matroids.Fano() - sage: M / 'abc' + sage: M = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings + sage: M / 'abc' # optional - sage.rings.finite_rings Binary matroid of rank 0 on 4 elements, type (0, 0) The following is therefore ambiguous. Sage will contract the single @@ -3896,12 +3896,12 @@ cdef class Matroid(SageObject): :: - sage: M = matroids.named_matroids.Fano() - sage: sorted(M.groundset()) + sage: M = 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: M.delete(['a', 'c']) + sage: M.delete(['a', 'c']) # optional - sage.rings.finite_rings Binary matroid of rank 3 on 5 elements, type (1, 6) - sage: M.delete(['a']) == M \ ['a'] + sage: M.delete(['a']) == M \ ['a'] # optional - sage.rings.finite_rings True One can use a single element, rather than a set:: @@ -3914,8 +3914,8 @@ cdef class Matroid(SageObject): Note that one can iterate over strings:: - sage: M = matroids.named_matroids.Fano() - sage: M \ 'abc' + sage: M = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings + sage: M \ 'abc' # optional - sage.rings.finite_rings Binary matroid of rank 3 on 4 elements, type (0, 5) The following is therefore ambiguous. Sage will delete the single @@ -3994,9 +3994,9 @@ cdef class Matroid(SageObject): EXAMPLES:: - sage: M = matroids.named_matroids.Fano() - sage: N = M.truncation() - sage: N.is_isomorphic(matroids.Uniform(2, 7)) + sage: M = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings + sage: N = M.truncation() # optional - sage.rings.finite_rings + sage: N.is_isomorphic(matroids.Uniform(2, 7)) # optional - sage.rings.finite_rings True """ if self.full_rank() == 0: @@ -4034,15 +4034,15 @@ cdef class Matroid(SageObject): EXAMPLES:: sage: M = matroids.Whirl(3) - sage: matroids.named_matroids.Fano().has_minor(M) + sage: matroids.named_matroids.Fano().has_minor(M) # optional - sage.rings.finite_rings False - sage: matroids.named_matroids.NonFano().has_minor(M) + sage: matroids.named_matroids.NonFano().has_minor(M) # optional - sage.rings.finite_rings True - sage: matroids.named_matroids.NonFano().has_minor(M, certificate=True) + sage: matroids.named_matroids.NonFano().has_minor(M, certificate=True) # optional - sage.rings.finite_rings (True, (frozenset(), frozenset({'g'}), {0: 'b', 1: 'c', 2: 'a', 3: 'd', 4: 'e', 5: 'f'})) - sage: M = matroids.named_matroids.Fano() - sage: M.has_minor(M, True) + sage: M = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings + sage: M.has_minor(M, True) # optional - sage.rings.finite_rings (True, (frozenset(), frozenset(), @@ -4083,21 +4083,21 @@ cdef class Matroid(SageObject): EXAMPLES:: - sage: M = matroids.named_matroids.N1() - sage: M.has_line_minor(4) + sage: M = matroids.named_matroids.N1() # optional - sage.rings.finite_rings + sage: M.has_line_minor(4) # optional - sage.rings.finite_rings True - sage: M.has_line_minor(5) + sage: M.has_line_minor(5) # optional - sage.rings.finite_rings False - sage: M.has_line_minor(k=4, hyperlines=[['a', 'b', 'c']]) + sage: M.has_line_minor(k=4, hyperlines=[['a', 'b', 'c']]) # optional - sage.rings.finite_rings False - sage: M.has_line_minor(k=4, hyperlines=[['a', 'b', 'c'], + sage: M.has_line_minor(k=4, hyperlines=[['a', 'b', 'c'], # optional - sage.rings.finite_rings ....: ['a', 'b', 'd' ]]) True - sage: M.has_line_minor(4, certificate=True) + sage: M.has_line_minor(4, certificate=True) # optional - sage.rings.finite_rings (True, frozenset({'a', 'b', 'd'})) - sage: M.has_line_minor(5, certificate=True) + sage: M.has_line_minor(5, certificate=True) # optional - sage.rings.finite_rings (False, None) - sage: M.has_line_minor(k=4, hyperlines=[['a', 'b', 'c'], + sage: M.has_line_minor(k=4, hyperlines=[['a', 'b', 'c'], # optional - sage.rings.finite_rings ....: ['a', 'b', 'd' ]], certificate=True) (True, frozenset({'a', 'b', 'd'})) @@ -4231,9 +4231,9 @@ cdef class Matroid(SageObject): Putting an element in parallel with another:: - sage: M = matroids.named_matroids.Fano() - sage: N = M.extension('z', ['c']) - sage: N.rank('cz') + sage: M = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings + sage: N = M.extension('z', ['c']) # optional - sage.rings.finite_rings + sage: N.rank('cz') # optional - sage.rings.finite_rings 1 """ r = self.full_rank() - 1 @@ -4304,9 +4304,9 @@ cdef class Matroid(SageObject): Put an element in series with another:: - sage: M = matroids.named_matroids.Fano() - sage: N = M.coextension('z', ['c']) - sage: N.corank('cz') + sage: M = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings + sage: N = M.coextension('z', ['c']) # optional - sage.rings.finite_rings + sage: N.corank('cz') # optional - sage.rings.finite_rings 1 """ return self.dual().extension(element, subsets).dual() @@ -4374,8 +4374,8 @@ cdef class Matroid(SageObject): The modular cut of the full groundset is equal to just the groundset:: - sage: M = matroids.named_matroids.Fano() - sage: M.modular_cut([M.groundset()]).difference( + sage: M = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings + sage: M.modular_cut([M.groundset()]).difference( # optional - sage.rings.finite_rings ....: [frozenset(M.groundset())]) set() """ @@ -4446,12 +4446,12 @@ cdef class Matroid(SageObject): EXAMPLES:: - sage: M = matroids.named_matroids.Fano() - sage: len(list(M.linear_subclasses())) + sage: M = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings + sage: len(list(M.linear_subclasses())) # optional - sage.rings.finite_rings 16 - sage: len(list(M.linear_subclasses(line_length=3))) + sage: len(list(M.linear_subclasses(line_length=3))) # optional - sage.rings.finite_rings 8 - sage: len(list(M.linear_subclasses(subsets=[{'a', 'b'}]))) + sage: len(list(M.linear_subclasses(subsets=[{'a', 'b'}]))) # optional - sage.rings.finite_rings 5 The following matroid has an extension by element `e` such that @@ -4515,14 +4515,14 @@ cdef class Matroid(SageObject): EXAMPLES:: - sage: M = matroids.named_matroids.P8() - sage: len(list(M.extensions())) + sage: M = matroids.named_matroids.P8() # optional - sage.rings.finite_rings + sage: len(list(M.extensions())) # optional - sage.rings.finite_rings 1705 - sage: len(list(M.extensions(line_length=4))) + sage: len(list(M.extensions(line_length=4))) # optional - sage.rings.finite_rings 41 - sage: sorted(M.groundset()) + sage: sorted(M.groundset()) # optional - sage.rings.finite_rings ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'] - sage: len(list(M.extensions(subsets=[{'a', 'b'}], line_length=4))) + sage: len(list(M.extensions(subsets=[{'a', 'b'}], line_length=4))) # optional - sage.rings.finite_rings 5 """ @@ -4583,14 +4583,14 @@ cdef class Matroid(SageObject): EXAMPLES:: - sage: M = matroids.named_matroids.P8() - sage: len(list(M.coextensions())) + sage: M = matroids.named_matroids.P8() # optional - sage.rings.finite_rings + sage: len(list(M.coextensions())) # optional - sage.rings.finite_rings 1705 - sage: len(list(M.coextensions(coline_length=4))) + sage: len(list(M.coextensions(coline_length=4))) # optional - sage.rings.finite_rings 41 - sage: sorted(M.groundset()) + sage: sorted(M.groundset()) # optional - sage.rings.finite_rings ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'] - sage: len(list(M.coextensions(subsets=[{'a', 'b'}], coline_length=4))) + sage: len(list(M.coextensions(subsets=[{'a', 'b'}], coline_length=4))) # optional - sage.rings.finite_rings 5 """ @@ -4624,8 +4624,8 @@ cdef class Matroid(SageObject): EXAMPLES:: - sage: M = matroids.named_matroids.Fano().contract('a') - sage: M.size() - M.simplify().size() + sage: M = matroids.named_matroids.Fano().contract('a') # optional - sage.rings.finite_rings + sage: M.size() - M.simplify().size() # optional - sage.rings.finite_rings 3 """ @@ -4663,8 +4663,8 @@ cdef class Matroid(SageObject): EXAMPLES:: - sage: M = matroids.named_matroids.Fano().dual().delete('a') - sage: M.cosimplify().size() + sage: M = matroids.named_matroids.Fano().dual().delete('a') # optional - sage.rings.finite_rings + sage: M.cosimplify().size() # optional - sage.rings.finite_rings 3 """ @@ -4698,11 +4698,11 @@ cdef class Matroid(SageObject): EXAMPLES:: - sage: M = matroids.named_matroids.Fano() - sage: M.is_simple() + sage: M = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings + sage: M.is_simple() # optional - sage.rings.finite_rings True - sage: N = M / 'a' - sage: N.is_simple() + sage: N = M / 'a' # optional - sage.rings.finite_rings + sage: N.is_simple() # optional - sage.rings.finite_rings False """ if self._closure(frozenset()): @@ -4734,11 +4734,11 @@ cdef class Matroid(SageObject): EXAMPLES:: - sage: M = matroids.named_matroids.Fano().dual() - sage: M.is_cosimple() + sage: M = matroids.named_matroids.Fano().dual() # optional - sage.rings.finite_rings + sage: M.is_cosimple() # optional - sage.rings.finite_rings True - sage: N = M \ 'a' - sage: N.is_cosimple() + sage: N = M \ 'a' # optional - sage.rings.finite_rings + sage: N.is_cosimple() # optional - sage.rings.finite_rings False """ if self._coclosure(frozenset()): @@ -5081,7 +5081,7 @@ cdef class Matroid(SageObject): False sage: matroids.named_matroids.BetsyRoss().is_kconnected(3) True - sage: matroids.AG(5,2).is_kconnected(4) + sage: matroids.AG(5,2).is_kconnected(4) # optional - sage.rings.finite_rings True sage: M = matroids.named_matroids.R6() sage: M.is_kconnected(3) @@ -5281,14 +5281,14 @@ cdef class Matroid(SageObject): (False, True) sage: matroids.Uniform(4, 8).is_4connected() True - sage: M = Matroid(field=GF(2), matrix=[[1,0,0,1,0,1,1,0,0,1,1,1], + sage: M = Matroid(field=GF(2), matrix=[[1,0,0,1,0,1,1,0,0,1,1,1], # optional - sage.rings.finite_rings ....: [0,1,0,1,0,1,0,1,0,0,0,1], ....: [0,0,1,1,0,0,1,1,0,1,0,1], ....: [0,0,0,0,1,1,1,1,0,0,1,1], ....: [0,0,0,0,0,0,0,0,1,1,1,1]]) - sage: M.is_4connected() == M.is_4connected(algorithm="shifting") + sage: M.is_4connected() == M.is_4connected(algorithm="shifting") # optional - sage.rings.finite_rings True - sage: M.is_4connected() == M.is_4connected(algorithm="intersection") + sage: M.is_4connected() == M.is_4connected(algorithm="intersection") # optional - sage.rings.finite_rings True """ if algorithm is None or algorithm == "intersection": @@ -5530,12 +5530,12 @@ cdef class Matroid(SageObject): (False, True) sage: matroids.Uniform(4, 8)._is_4connected_shifting() True - sage: M = Matroid(field=GF(2), matrix=[[1,0,0,1,0,1,1,0,0,1,1,1], + sage: M = Matroid(field=GF(2), matrix=[[1,0,0,1,0,1,1,0,0,1,1,1], # optional - sage.rings.finite_rings ....: [0,1,0,1,0,1,0,1,0,0,0,1], ....: [0,0,1,1,0,0,1,1,0,1,0,1], ....: [0,0,0,0,1,1,1,1,0,0,1,1], ....: [0,0,0,0,0,0,0,0,1,1,1,1]]) - sage: M._is_4connected_shifting() + sage: M._is_4connected_shifting() # optional - sage.rings.finite_rings True """ if self.rank()>self.size()-self.rank(): @@ -5636,18 +5636,20 @@ cdef class Matroid(SageObject): EXAMPLES:: - sage: M = Matroid(field=GF(2), matrix=[[1,0,0,1,0,1,1,0,0,1,1,1], + sage: M = Matroid(field=GF(2), matrix=[[1,0,0,1,0,1,1,0,0,1,1,1], # optional - sage.rings.finite_rings ....: [0,1,0,1,0,1,0,1,0,0,0,1], ....: [0,0,1,1,0,0,1,1,0,1,0,1], ....: [0,0,0,0,1,1,1,1,0,0,1,1], ....: [0,0,0,0,0,0,0,0,1,1,1,1]]) - sage: M._shifting_all(M.basis(),set([0,1]),set([0,1]),set([]),set([]),3) + sage: M._shifting_all(M.basis(), # optional - sage.rings.finite_rings + ....: set([0,1]), set([0,1]), set([]), set([]), 3) (False, None) - sage: M = Matroid(field=GF(2), reduced_matrix=[[1,0,1,1,1], + sage: M = Matroid(field=GF(2), reduced_matrix=[[1,0,1,1,1], # optional - sage.rings.finite_rings ....: [1,1,1,1,0], ....: [0,1,1,1,0], ....: [0,0,0,1,1]]) - sage: M._shifting_all(M.basis(), set([0,1]), set([5,8]), set([]), set([]), 3)[0] + sage: M._shifting_all(M.basis(), # optional - sage.rings.finite_rings + ....: set([0,1]), set([5,8]), set([]), set([]), 3)[0] True """ @@ -5672,8 +5674,8 @@ cdef class Matroid(SageObject): Given a basis ``X``. If the submatrix of the partial matrix using rows `X_1` columns `Y_2` and submatrix using rows `X_2` columns `Y_1` can be extended to a ``m``-separator, then it returns - `True, E`, where `E` is a ``m``-separator. Otherwise it returns - `False, None` + ``True, E``, where `E` is a ``m``-separator. Otherwise it returns + ``False, None`` `X_1` and `X_2` must be disjoint subsets of `X`. `Y_1` and `Y_2` must be disjoint subsets of `Y`. @@ -5691,23 +5693,25 @@ cdef class Matroid(SageObject): OUTPUT: - - `False, None` -- if there is no ``m``-separator. - - `True, E` -- if there exist a ``m``-separator ``E``. + - ``False, None`` -- if there is no ``m``-separator. + - ``True, E`` -- if there exist a ``m``-separator ``E``. EXAMPLES:: - sage: M = Matroid(field=GF(2), matrix=[[1,0,0,1,0,1,1,0,0,1,1,1], + sage: M = Matroid(field=GF(2), matrix=[[1,0,0,1,0,1,1,0,0,1,1,1], # optional - sage.rings.finite_rings ....: [0,1,0,1,0,1,0,1,0,0,0,1], ....: [0,0,1,1,0,0,1,1,0,1,0,1], ....: [0,0,0,0,1,1,1,1,0,0,1,1], ....: [0,0,0,0,0,0,0,0,1,1,1,1]]) - sage: M._shifting(M.basis(),set([0,1]),set([0,1]),set([]),set([]),3) + sage: M._shifting(M.basis(), # optional - sage.rings.finite_rings + ....: set([0,1]), set([0,1]), set([]), set([]), 3) (False, None) - sage: M = Matroid(field=GF(2), reduced_matrix=[[1,0,1,1,1], + sage: M = Matroid(field=GF(2), reduced_matrix=[[1,0,1,1,1], # optional - sage.rings.finite_rings ....: [1,1,1,1,0], ....: [0,1,1,1,0], ....: [0,0,0,1,1]]) - sage: M._shifting(M.basis(), set([0,1]), set([5,8]), set([]), set([4]), 3)[0] + sage: M._shifting(M.basis(), # optional - sage.rings.finite_rings + ....: set([0,1]), set([5,8]), set([]), set([4]), 3)[0] True """ @@ -5784,15 +5788,14 @@ cdef class Matroid(SageObject): ....: [0, 0, 1, 0, 0, 1]]) sage: M._is_3connected_BC() False - sage: N = Matroid(circuit_closures={2: ['abc', 'cdef'], - ....: 3: ['abcdef']}, + sage: N = Matroid(circuit_closures={2: ['abc', 'cdef'], 3: ['abcdef']}, ....: groundset='abcdef') sage: N._is_3connected_BC() False sage: matroids.named_matroids.BetsyRoss()._is_3connected_BC() True - sage: M = matroids.named_matroids.R6() - sage: M._is_3connected_BC() + sage: M = matroids.named_matroids.R6() # optional - sage.rings.finite_rings + sage: M._is_3connected_BC() # optional - sage.rings.finite_rings False """ # The 5 stages of the algorithm @@ -5837,9 +5840,9 @@ cdef class Matroid(SageObject): sage: M._is_3connected_BC_recursion(B, ....: [M.fundamental_cocircuit(B, e) for e in B]) True - sage: M = matroids.named_matroids.R6() - sage: B = M.basis() - sage: M._is_3connected_BC_recursion(B, + sage: M = matroids.named_matroids.R6() # optional - sage.rings.finite_rings + sage: B = M.basis() # optional - sage.rings.finite_rings + sage: M._is_3connected_BC_recursion(B, # optional - sage.rings.finite_rings ....: [M.fundamental_cocircuit(B, e) for e in B]) False @@ -5929,13 +5932,13 @@ cdef class Matroid(SageObject): EXAMPLES:: - sage: N = matroids.named_matroids.Fano() - sage: M = N._local_binary_matroid() - sage: N.is_isomorphism(M, {e:e for e in N.groundset()}) + sage: N = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings + sage: M = N._local_binary_matroid() # optional - sage.rings.finite_rings + sage: N.is_isomorphism(M, {e:e for e in N.groundset()}) # optional - sage.rings.finite_rings True - sage: N = matroids.named_matroids.NonFano() - sage: M = N._local_binary_matroid() - sage: N.is_isomorphism(M, {e:e for e in N.groundset()}) + sage: N = matroids.named_matroids.NonFano() # optional - sage.rings.finite_rings + sage: M = N._local_binary_matroid() # optional - sage.rings.finite_rings + sage: N.is_isomorphism(M, {e:e for e in N.groundset()}) # optional - sage.rings.finite_rings False """ if basis is None: @@ -5987,11 +5990,11 @@ cdef class Matroid(SageObject): EXAMPLES:: - sage: M = matroids.named_matroids.Fano() - sage: M.binary_matroid() + sage: M = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings + sage: M.binary_matroid() # optional - sage.rings.finite_rings Fano: Binary matroid of rank 3 on 7 elements, type (3, 0) - sage: N = matroids.named_matroids.NonFano() - sage: N.binary_matroid() is None + sage: N = matroids.named_matroids.NonFano() # optional - sage.rings.finite_rings + sage: N.binary_matroid() is None # optional - sage.rings.finite_rings True """ @@ -6039,11 +6042,11 @@ cdef class Matroid(SageObject): EXAMPLES:: - sage: N = matroids.named_matroids.Fano() - sage: N.is_binary() + sage: N = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings + sage: N.is_binary() # optional - sage.rings.finite_rings True - sage: N = matroids.named_matroids.NonFano() - sage: N.is_binary() + sage: N = matroids.named_matroids.NonFano() # optional - sage.rings.finite_rings + sage: N.is_binary() # optional - sage.rings.finite_rings False """ @@ -6080,13 +6083,13 @@ cdef class Matroid(SageObject): EXAMPLES:: - sage: N = matroids.named_matroids.Fano() - sage: M = N._local_ternary_matroid() - sage: N.is_isomorphism(M, {e:e for e in N.groundset()}) + sage: N = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings + sage: M = N._local_ternary_matroid() # optional - sage.rings.finite_rings + sage: N.is_isomorphism(M, {e:e for e in N.groundset()}) # optional - sage.rings.finite_rings False - sage: N = matroids.named_matroids.NonFano() - sage: M = N._local_ternary_matroid() - sage: N.is_isomorphism(M, {e:e for e in N.groundset()}) + sage: N = matroids.named_matroids.NonFano() # optional - sage.rings.finite_rings + sage: M = N._local_ternary_matroid() # optional - sage.rings.finite_rings + sage: N.is_isomorphism(M, {e:e for e in N.groundset()}) # optional - sage.rings.finite_rings True """ if basis is None: @@ -6172,11 +6175,11 @@ cdef class Matroid(SageObject): EXAMPLES:: - sage: M = matroids.named_matroids.Fano() - sage: M.ternary_matroid() is None + sage: M = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings + sage: M.ternary_matroid() is None # optional - sage.rings.finite_rings True - sage: N = matroids.named_matroids.NonFano() - sage: N.ternary_matroid() + sage: N = matroids.named_matroids.NonFano() # optional - sage.rings.finite_rings + sage: N.ternary_matroid() # optional - sage.rings.finite_rings NonFano: Ternary matroid of rank 3 on 7 elements, type 0- """ @@ -6224,11 +6227,11 @@ cdef class Matroid(SageObject): EXAMPLES:: - sage: N = matroids.named_matroids.Fano() - sage: N.is_ternary() + sage: N = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings + sage: N.is_ternary() # optional - sage.rings.finite_rings False - sage: N = matroids.named_matroids.NonFano() - sage: N.is_ternary() + sage: N = matroids.named_matroids.NonFano() # optional - sage.rings.finite_rings + sage: N.is_ternary() # optional - sage.rings.finite_rings True """ @@ -6292,12 +6295,12 @@ cdef class Matroid(SageObject): sage: M = matroids.Uniform(2,4) sage: [M._is_circuit_chordal(C) for C in M.circuits()] [False, False, False, False] - sage: M = matroids.named_matroids.Fano() - sage: M._is_circuit_chordal(frozenset(['b','c','d'])) + sage: M = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings + sage: M._is_circuit_chordal(frozenset(['b','c','d'])) # optional - sage.rings.finite_rings False - sage: M._is_circuit_chordal(frozenset(['b','c','d']), certificate=True) + sage: M._is_circuit_chordal(frozenset(['b','c','d']), certificate=True) # optional - sage.rings.finite_rings (False, None) - sage: M._is_circuit_chordal(frozenset(['a','b','d','e'])) + sage: M._is_circuit_chordal(frozenset(['a','b','d','e'])) # optional - sage.rings.finite_rings True """ cdef set X @@ -6392,15 +6395,15 @@ cdef class Matroid(SageObject): sage: M = matroids.Uniform(2,4) sage: [M.is_chordal(i) for i in range(4, 8)] [True, True, True, True] - sage: M = matroids.named_matroids.NonFano() - sage: [M.is_chordal(i) for i in range(4, 8)] + sage: M = matroids.named_matroids.NonFano() # optional - sage.rings.finite_rings + sage: [M.is_chordal(i) for i in range(4, 8)] # optional - sage.rings.finite_rings [False, True, True, True] - sage: M = matroids.named_matroids.N2() - sage: [M.is_chordal(i) for i in range(4, 10)] + sage: M = matroids.named_matroids.N2() # optional - sage.rings.finite_rings + sage: [M.is_chordal(i) for i in range(4, 10)] # optional - sage.rings.finite_rings [False, False, False, False, True, True] - sage: M.is_chordal(4, 5) + sage: M.is_chordal(4, 5) # optional - sage.rings.finite_rings False - sage: M.is_chordal(4, 5, certificate=True) + sage: M.is_chordal(4, 5, certificate=True) # optional - sage.rings.finite_rings (False, frozenset({'a', 'b', 'e', 'f', 'g'})) """ cdef frozenset C @@ -6428,11 +6431,11 @@ cdef class Matroid(SageObject): sage: M = matroids.Uniform(2,4) sage: M.chordality() 4 - sage: M = matroids.named_matroids.NonFano() - sage: M.chordality() + sage: M = matroids.named_matroids.NonFano() # optional - sage.rings.finite_rings + sage: M.chordality() # optional - sage.rings.finite_rings 5 - sage: M = matroids.named_matroids.Fano() - sage: M.chordality() + sage: M = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings + sage: M.chordality() # optional - sage.rings.finite_rings 4 """ cdef frozenset C @@ -6474,14 +6477,14 @@ cdef class Matroid(SageObject): EXAMPLES:: sage: from sage.matroids.advanced import setprint - sage: M = matroids.named_matroids.Fano() - sage: X = M.max_weight_independent() - sage: M.is_basis(X) + sage: M = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings + sage: X = M.max_weight_independent() # optional - sage.rings.finite_rings + sage: M.is_basis(X) # optional - sage.rings.finite_rings True sage: wt = {'a': 1, 'b': 2, 'c': 2, 'd': 1/2, 'e': 1, ....: 'f': 2, 'g': 2} - sage: setprint(M.max_weight_independent(weights=wt)) + sage: setprint(M.max_weight_independent(weights=wt)) # optional - sage.rings.finite_rings {'b', 'f', 'g'} sage: def wt(x): ....: return x @@ -6561,18 +6564,16 @@ cdef class Matroid(SageObject): EXAMPLES:: sage: from sage.matroids.advanced import setprint - sage: M = matroids.named_matroids.Fano() - sage: X = M.max_weight_coindependent() - sage: M.is_cobasis(X) + sage: M = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings + sage: X = M.max_weight_coindependent() # optional - sage.rings.finite_rings + sage: M.is_cobasis(X) # optional - sage.rings.finite_rings True - sage: wt = {'a': 1, 'b': 2, 'c': 2, 'd': 1/2, 'e': 1, 'f': 2, - ....: 'g': 2} - sage: setprint(M.max_weight_coindependent(weights=wt)) + sage: wt = {'a': 1, 'b': 2, 'c': 2, 'd': 1/2, 'e': 1, 'f': 2, 'g': 2} + sage: setprint(M.max_weight_coindependent(weights=wt)) # optional - sage.rings.finite_rings {'b', 'c', 'f', 'g'} - sage: wt = {'a': 1, 'b': -10, 'c': 2, 'd': 1/2, 'e': 1, 'f': 2, - ....: 'g': 2} - sage: setprint(M.max_weight_coindependent(weights=wt)) + sage: wt = {'a': 1, 'b': -10, 'c': 2, 'd': 1/2, 'e': 1, 'f': 2, 'g': 2} + sage: setprint(M.max_weight_coindependent(weights=wt)) # optional - sage.rings.finite_rings Traceback (most recent call last): ... ValueError: nonnegative weights were expected. @@ -6643,9 +6644,7 @@ cdef class Matroid(SageObject): - ``weights`` -- a dictionary or function mapping the elements of ``X`` to nonnegative weights. - OUTPUT: - - Boolean. + OUTPUT: Boolean. ALGORITHM: @@ -6660,8 +6659,8 @@ cdef class Matroid(SageObject): EXAMPLES:: sage: from sage.matroids.advanced import setprint - sage: M = matroids.named_matroids.Fano() - sage: M.is_max_weight_independent_generic() + sage: M = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings + sage: M.is_max_weight_independent_generic() # optional - sage.rings.finite_rings False sage: def wt(x): @@ -6810,8 +6809,8 @@ cdef class Matroid(SageObject): EXAMPLES:: sage: from sage.matroids.advanced import setprint - sage: M = matroids.named_matroids.Fano() - sage: M.is_max_weight_coindependent_generic() + sage: M = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings + sage: M.is_max_weight_coindependent_generic() # optional - sage.rings.finite_rings False sage: def wt(x): @@ -6958,18 +6957,18 @@ cdef class Matroid(SageObject): EXAMPLES:: - sage: M = matroids.named_matroids.T12() - sage: N = matroids.named_matroids.ExtendedTernaryGolayCode() + sage: M = matroids.named_matroids.T12() # optional - sage.rings.finite_rings + sage: N = matroids.named_matroids.ExtendedTernaryGolayCode() # optional - sage.rings.finite_rings sage: w = {'a':30, 'b':10, 'c':11, 'd':20, 'e':70, 'f':21, 'g':90, ....: 'h':12, 'i':80, 'j':13, 'k':40, 'l':21} - sage: Y = M.intersection(N, w) - sage: sorted(Y) + sage: Y = M.intersection(N, w) # optional - sage.rings.finite_rings + sage: sorted(Y) # optional - sage.rings.finite_rings ['a', 'd', 'e', 'g', 'i', 'k'] - sage: sum([w[y] for y in Y]) + sage: sum([w[y] for y in Y]) # optional - sage.rings.finite_rings 330 - sage: M = matroids.named_matroids.Fano() + sage: M = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings sage: N = matroids.Uniform(4, 7) - sage: M.intersection(N) + sage: M.intersection(N) # optional - sage.rings.finite_rings Traceback (most recent call last): ... ValueError: matroid intersection requires equal groundsets. @@ -7017,14 +7016,14 @@ cdef class Matroid(SageObject): EXAMPLES:: - sage: M = matroids.named_matroids.T12() - sage: N = matroids.named_matroids.ExtendedTernaryGolayCode() + sage: M = matroids.named_matroids.T12() # optional - sage.rings.finite_rings + sage: N = matroids.named_matroids.ExtendedTernaryGolayCode() # optional - sage.rings.finite_rings sage: w = {'a':30, 'b':10, 'c':11, 'd':20, 'e':70, 'f':21, 'g':90, ....: 'h':12, 'i':80, 'j':13, 'k':40, 'l':21} - sage: Y = M._intersection(N, w) - sage: sorted(Y) + sage: Y = M._intersection(N, w) # optional - sage.rings.finite_rings + sage: sorted(Y) # optional - sage.rings.finite_rings ['a', 'd', 'e', 'g', 'i', 'k'] - sage: sum([w[y] for y in Y]) + sage: sum([w[y] for y in Y]) # optional - sage.rings.finite_rings 330 """ Y = set() @@ -7063,14 +7062,14 @@ cdef class Matroid(SageObject): EXAMPLES:: - sage: M = matroids.named_matroids.T12() - sage: N = matroids.named_matroids.ExtendedTernaryGolayCode() + sage: M = matroids.named_matroids.T12() # optional - sage.rings.finite_rings + sage: N = matroids.named_matroids.ExtendedTernaryGolayCode() # optional - sage.rings.finite_rings sage: w = {'a':30, 'b':10, 'c':11, 'd':20, 'e':70, 'f':21, 'g':90, ....: 'h':12, 'i':80, 'j':13, 'k':40, 'l':21} - sage: Y = M.intersection(N, w) - sage: sorted(Y) + sage: Y = M.intersection(N, w) # optional - sage.rings.finite_rings + sage: sorted(Y) # optional - sage.rings.finite_rings ['a', 'd', 'e', 'g', 'i', 'k'] - sage: M._intersection_augmentation(N, w, Y)[0] + sage: M._intersection_augmentation(N, w, Y)[0] # optional - sage.rings.finite_rings False """ X = self.groundset() - Y @@ -7144,13 +7143,13 @@ cdef class Matroid(SageObject): EXAMPLES:: - sage: M = matroids.named_matroids.T12() - sage: N = matroids.named_matroids.ExtendedTernaryGolayCode() - sage: len(M.intersection_unweighted(N)) + sage: M = matroids.named_matroids.T12() # optional - sage.rings.finite_rings + sage: N = matroids.named_matroids.ExtendedTernaryGolayCode() # optional - sage.rings.finite_rings + sage: len(M.intersection_unweighted(N)) # optional - sage.rings.finite_rings 6 - sage: M = matroids.named_matroids.Fano() - sage: N = matroids.Uniform(4, 7) - sage: M.intersection_unweighted(N) + sage: M = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings + sage: N = matroids.Uniform(4, 7) # optional - sage.rings.finite_rings + sage: M.intersection_unweighted(N) # optional - sage.rings.finite_rings Traceback (most recent call last): ... ValueError: matroid intersection requires equal groundsets. @@ -7185,9 +7184,9 @@ cdef class Matroid(SageObject): EXAMPLES:: - sage: M = matroids.named_matroids.T12() - sage: N = matroids.named_matroids.ExtendedTernaryGolayCode() - sage: len(M._intersection_unweighted(N)) + sage: M = matroids.named_matroids.T12() # optional - sage.rings.finite_rings + sage: N = matroids.named_matroids.ExtendedTernaryGolayCode() # optional - sage.rings.finite_rings + sage: len(M._intersection_unweighted(N)) # optional - sage.rings.finite_rings 6 """ Y = set() @@ -7219,15 +7218,15 @@ cdef class Matroid(SageObject): EXAMPLES:: - sage: M = matroids.named_matroids.T12() - sage: N = matroids.named_matroids.ExtendedTernaryGolayCode() - sage: Y = M.intersection(N) - sage: M._intersection_augmentation_unweighted(N, Y)[0] + sage: M = matroids.named_matroids.T12() # optional - sage.rings.finite_rings + sage: N = matroids.named_matroids.ExtendedTernaryGolayCode() # optional - sage.rings.finite_rings + sage: Y = M.intersection(N) # optional - sage.rings.finite_rings + sage: M._intersection_augmentation_unweighted(N, Y)[0] # optional - sage.rings.finite_rings False - sage: Y = M._intersection_augmentation_unweighted(N,set()) - sage: Y[0] + sage: Y = M._intersection_augmentation_unweighted(N,set()) # optional - sage.rings.finite_rings + sage: Y[0] # optional - sage.rings.finite_rings True - sage: len(Y[1])>0 + sage: len(Y[1])>0 # optional - sage.rings.finite_rings True """ E = self.groundset() @@ -7425,10 +7424,10 @@ cdef class Matroid(SageObject): EXAMPLES:: - sage: M = matroids.named_matroids.Fano() - sage: sorted(M._internal({'a', 'b', 'c'})) + sage: M = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings + sage: sorted(M._internal({'a', 'b', 'c'})) # optional - sage.rings.finite_rings ['a', 'b', 'c'] - sage: sorted(M._internal({'e', 'f', 'g'})) + sage: sorted(M._internal({'e', 'f', 'g'})) # optional - sage.rings.finite_rings [] """ N = self.groundset() - B @@ -7464,10 +7463,10 @@ cdef class Matroid(SageObject): EXAMPLES:: - sage: M = matroids.named_matroids.Fano() - sage: sorted(M._external({'a', 'b', 'c'})) + sage: M = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings + sage: sorted(M._external({'a', 'b', 'c'})) # optional - sage.rings.finite_rings [] - sage: sorted(M._external({'e', 'f', 'g'})) + sage: sorted(M._external({'e', 'f', 'g'})) # optional - sage.rings.finite_rings ['a', 'b', 'c', 'd'] """ @@ -7517,10 +7516,10 @@ cdef class Matroid(SageObject): EXAMPLES:: - sage: M = matroids.named_matroids.Fano() - sage: M.tutte_polynomial() + sage: M = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings + sage: M.tutte_polynomial() # optional - sage.rings.finite_rings y^4 + x^3 + 3*y^3 + 4*x^2 + 7*x*y + 6*y^2 + 3*x + 3*y - sage: M.tutte_polynomial(1, 1) == M.bases_count() + sage: M.tutte_polynomial(1, 1) == M.bases_count() # optional - sage.rings.finite_rings True ALGORITHM: @@ -7565,8 +7564,8 @@ cdef class Matroid(SageObject): EXAMPLES:: sage: from sage.matroids.advanced import setprint - sage: M = matroids.named_matroids.Fano() - sage: setprint(M.flat_cover()) + sage: M = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings + sage: setprint(M.flat_cover()) # optional - sage.rings.finite_rings [{'a', 'b', 'f'}, {'a', 'c', 'e'}, {'a', 'd', 'g'}, {'b', 'c', 'd'}, {'b', 'e', 'g'}, {'c', 'f', 'g'}, {'d', 'e', 'f'}] @@ -7634,21 +7633,21 @@ cdef class Matroid(SageObject): We construct a more interesting example using the Fano matroid:: - sage: M = matroids.named_matroids.Fano() - sage: A = M.chow_ring(QQ) - sage: A + sage: M = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings + sage: A = M.chow_ring(QQ) # optional - sage.rings.finite_rings + sage: A # optional - sage.rings.finite_rings Chow ring of Fano: Binary matroid of rank 3 on 7 elements, type (3, 0) over Rational Field Next we get the non-trivial generators and do some computations:: - sage: G = A.gens()[6:] - sage: Ag, Aabf, Aace, Aadg, Abcd, Abeg, Acfg, Adef = G - sage: Ag * Ag + sage: G = A.gens()[6:] # optional - sage.rings.finite_rings + sage: Ag, Aabf, Aace, Aadg, Abcd, Abeg, Acfg, Adef = G # optional - sage.rings.finite_rings + sage: Ag * Ag # optional - sage.rings.finite_rings 2*Adef^2 - sage: Ag * Abeg + sage: Ag * Abeg # optional - sage.rings.finite_rings -Adef^2 - sage: matrix([[x * y for x in G] for y in G]) + sage: matrix([[x * y for x in G] for y in G]) # optional - sage.rings.finite_rings [2*Adef^2 0 0 -Adef^2 0 -Adef^2 -Adef^2 0] [ 0 Adef^2 0 0 0 0 0 0] [ 0 0 Adef^2 0 0 0 0 0] @@ -7723,11 +7722,11 @@ cdef class Matroid(SageObject): EXAMPLES:: - sage: M=matroids.named_matroids.Fano() - sage: G=M.plot() - sage: type(G) + sage: M = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings + sage: G = M.plot() # optional - sage.rings.finite_rings sage.plot + sage: type(G) # optional - sage.rings.finite_rings sage.plot - sage: G.show() + sage: G.show() # optional - sage.rings.finite_rings sage.plot """ from . import matroids_plot_helpers @@ -7780,11 +7779,12 @@ cdef class Matroid(SageObject): EXAMPLES:: - sage: M=matroids.named_matroids.TernaryDowling3() - sage: M.show(B=['a','b','c']) - sage: M.show(B=['a','b','c'],lineorders=[['f','e','i']]) - sage: pos = {'a':(0,0), 'b': (0,1), 'c':(1,0), 'd':(1,1), 'e':(1,-1), 'f':(-1,1), 'g':(-1,-1),'h':(2,0), 'i':(0,2)} - sage: M.show(pos_method=1, pos_dict=pos,lims=[-3,3,-3,3]) + sage: M = matroids.named_matroids.TernaryDowling3() # optional - sage.rings.finite_rings + sage: M.show(B=['a','b','c']) # optional - sage.rings.finite_rings sage.plot + sage: M.show(B=['a','b','c'], lineorders=[['f','e','i']]) # optional - sage.rings.finite_rings sage.plot + sage: pos = {'a':(0,0), 'b': (0,1), 'c':(1,0), 'd':(1,1), # optional - sage.rings.finite_rings sage.plot + ....: 'e':(1,-1), 'f':(-1,1), 'g':(-1,-1),'h':(2,0), 'i':(0,2)} + sage: M.show(pos_method=1, pos_dict=pos, lims=[-3,3,-3,3]) # optional - sage.rings.finite_rings sage.plot """ if self.rank() > 3: raise NotImplementedError @@ -7823,15 +7823,15 @@ cdef class Matroid(SageObject): sage: t="fghij" sage: x=1.61 sage: y=1/1.61 - sage: for i in range(5): + sage: for i in range(5): # optional - sage.symbolic ....: pos[s[i]]=(RR(x*sin(2*pi*i/5)), RR(x*cos(2*pi*i/5))) ....: pos[t[i]]=(RR(y*sin(2*pi*(i+1/2)/5)), RR(y*cos(2*pi*(i+1/2)/5))) ....: sage: pos['k']=(0,0) - sage: M._fix_positions(pos_dict=pos) - sage: M._cached_info['lineorders'] is None + sage: M._fix_positions(pos_dict=pos) # optional - sage.symbolic + sage: M._cached_info['lineorders'] is None # optional - sage.symbolic True - sage: M._cached_info['plot_positions']['k'] + sage: M._cached_info['plot_positions']['k'] # optional - sage.symbolic (0, 0) """ if self.rank() > 3: @@ -7886,8 +7886,8 @@ cdef class Matroid(SageObject): EXAMPLES:: - sage: M = matroids.named_matroids.Fano() - sage: B = M.bergman_complex(); B + sage: M = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings + sage: B = M.bergman_complex(); B # optional - sage.rings.finite_rings Simplicial complex with 14 vertices and 21 facets .. SEEALSO:: @@ -7925,12 +7925,12 @@ cdef class Matroid(SageObject): EXAMPLES:: - sage: M = matroids.named_matroids.Fano() - sage: A = M.augmented_bergman_complex(); A + sage: M = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings + sage: A = M.augmented_bergman_complex(); A # optional - sage.graphs sage.rings.finite_rings Simplicial complex with 22 vertices and 91 facets sage: M = matroids.Uniform(2,3) - sage: A = M.augmented_bergman_complex(); A + sage: A = M.augmented_bergman_complex(); A # optional - sage.graphs Simplicial complex with 7 vertices and 9 facets Both the independent set complex of the matroid and the usual @@ -8059,7 +8059,7 @@ cdef class Matroid(SageObject): EXAMPLES:: sage: M = matroids.named_matroids.Pappus() - sage: N = matroids.named_matroids.Fano().direct_sum(M); N + sage: N = matroids.named_matroids.Fano().direct_sum(M); N # optional - sage.rings.finite_rings Matroid of rank 6 on 16 elements as matroid sum of Binary matroid of rank 3 on 7 elements, type (3, 0) Matroid of rank 3 on 9 elements with circuit-closures @@ -8067,9 +8067,9 @@ cdef class Matroid(SageObject): {'b', 'd', 'i'}, {'b', 'f', 'g'}, {'c', 'd', 'h'}, {'c', 'e', 'g'}, {'d', 'e', 'f'}, {'g', 'h', 'i'}}, 3: {{'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i'}}} - sage: len(N.independent_sets()) + sage: len(N.independent_sets()) # optional - sage.rings.finite_rings 6897 - sage: len(N.bases()) + sage: len(N.bases()) # optional - sage.rings.finite_rings 2100 """ from . import union_matroid diff --git a/src/sage/matroids/matroids_plot_helpers.py b/src/sage/matroids/matroids_plot_helpers.py index 99ada7f3b3a..dedb0b11df6 100644 --- a/src/sage/matroids/matroids_plot_helpers.py +++ b/src/sage/matroids/matroids_plot_helpers.py @@ -1,3 +1,4 @@ +# sage.doctest: optional - scipy r""" Helper functions for plotting the geometric representation of matroids @@ -50,13 +51,14 @@ EXAMPLES:: sage: from sage.matroids import matroids_plot_helpers - sage: M1=Matroid(ring=GF(2), matrix=[[1, 0, 0, 0, 1, 1, 1,0,1,0,1], - ....: [0, 1, 0, 1, 0, 1, 1,0,0,1,0], [0, 0, 1, 1, 1, 0, 1,0,0,0,0]]) - sage: pos_dict= {0: (0, 0), 1: (2, 0), 2: (1, 2), 3: (1.5, 1.0), - ....: 4: (0.5, 1.0), 5: (1.0, 0.0), 6: (1.0, 0.666666666666667), - ....: 7: (3,3), 8: (4,0), 9: (-1,1), 10: (-2,-2)} - sage: M1._cached_info={'plot_positions': pos_dict, 'plot_lineorders': None} - sage: matroids_plot_helpers.geomrep(M1, sp=True) + sage: M1 = Matroid(ring=GF(2), matrix=[[1, 0, 0, 0, 1, 1, 1,0,1,0,1], # optional - sage.rings.finite_rings + ....: [0, 1, 0, 1, 0, 1, 1,0,0,1,0], + ....: [0, 0, 1, 1, 1, 0, 1,0,0,0,0]]) + sage: pos_dict = {0: (0, 0), 1: (2, 0), 2: (1, 2), 3: (1.5, 1.0), + ....: 4: (0.5, 1.0), 5: (1.0, 0.0), 6: (1.0, 0.666666666666667), + ....: 7: (3,3), 8: (4,0), 9: (-1,1), 10: (-2,-2)} + sage: M1._cached_info = {'plot_positions': pos_dict, 'plot_lineorders': None} # optional - sage.rings.finite_rings + sage: matroids_plot_helpers.geomrep(M1, sp=True) # optional - sage.plot sage.rings.finite_rings Graphics object consisting of 22 graphics primitives """ @@ -321,22 +323,22 @@ def createline(ptsdict, ll, lineorders2=None): EXAMPLES:: sage: from sage.matroids import matroids_plot_helpers - sage: ptsdict={'a':(1,3),'b':(2,1),'c':(4,5),'d':(5,2)} - sage: x,y,x_i,y_i=matroids_plot_helpers.createline(ptsdict, + sage: ptsdict = {'a':(1,3),'b':(2,1),'c':(4,5),'d':(5,2)} + sage: x,y,x_i,y_i = matroids_plot_helpers.createline(ptsdict, ....: ['a','b','c','d']) sage: [len(x), len(y), len(x_i), len(y_i)] [4, 4, 100, 100] - sage: G = line(zip(x_i, y_i),color='black',thickness=3,zorder=1) - sage: G+=points(zip(x, y), color='black', size=300,zorder=2) - sage: G.show() - sage: x,y,x_i,y_i=matroids_plot_helpers.createline(ptsdict, + sage: G = line(zip(x_i, y_i), color='black', thickness=3, zorder=1) # optional - sage.plot + sage: G += points(zip(x, y), color='black', size=300, zorder=2) # optional - sage.plot + sage: G.show() # optional - sage.plot + sage: x,y,x_i,y_i = matroids_plot_helpers.createline(ptsdict, ....: ['a','b','c','d'],lineorders2=[['b','a','c','d'], ....: ['p','q','r','s']]) sage: [len(x), len(y), len(x_i), len(y_i)] [4, 4, 100, 100] - sage: G = line(zip(x_i, y_i),color='black',thickness=3,zorder=1) - sage: G+=points(zip(x, y), color='black', size=300,zorder=2) - sage: G.show() + sage: G = line(zip(x_i, y_i), color='black', thickness=3, zorder=1) # optional - sage.plot + sage: G += points(zip(x, y), color='black', size=300, zorder=2) # optional - sage.plot + sage: G.show() # optional - sage.plot .. NOTE:: @@ -401,21 +403,23 @@ def slp(M1, pos_dict=None, B=None): sage: from sage.matroids import matroids_plot_helpers sage: from sage.matroids.advanced import setprint - sage: M1=Matroid(ring=GF(2), matrix=[[1, 0, 0, 0, 1, 1, 1,0,1,0,1], - ....: [0, 1, 0, 1, 0, 1, 1,0,0,1,0],[0, 0, 1, 1, 1, 0, 1,0,0,0,0]]) - sage: [M,L,P]=matroids_plot_helpers.slp(M1) - sage: M.is_simple() + sage: M1 = Matroid(ring=GF(2), matrix=[[1, 0, 0, 0, 1, 1, 1,0,1,0,1], # optional - sage.rings.finite_rings + ....: [0, 1, 0, 1, 0, 1, 1,0,0,1,0], + ....: [0, 0, 1, 1, 1, 0, 1,0,0,0,0]]) + sage: [M,L,P] = matroids_plot_helpers.slp(M1) # optional - sage.rings.finite_rings + sage: M.is_simple() # optional - sage.rings.finite_rings True - sage: setprint([L,P]) + sage: setprint([L,P]) # optional - sage.rings.finite_rings [{10, 8, 9}, {7}] - sage: M1=Matroid(ring=GF(2), matrix=[[1, 0, 0, 0, 1, 1, 1,0,1,0,1], - ....: [0, 1, 0, 1, 0, 1, 1,0,0,1,0],[0, 0, 1, 1, 1, 0, 1,0,0,0,0]]) - sage: posdict= {8: (0, 0), 1: (2, 0), 2: (1, 2), 3: (1.5, 1.0), - ....: 4: (0.5, 1.0), 5: (1.0, 0.0), 6: (1.0, 0.6666666666666666)} - sage: [M,L,P]=matroids_plot_helpers.slp(M1,pos_dict=posdict) - sage: M.is_simple() + sage: M1 = Matroid(ring=GF(2), matrix=[[1, 0, 0, 0, 1, 1, 1,0,1,0,1], # optional - sage.rings.finite_rings + ....: [0, 1, 0, 1, 0, 1, 1,0,0,1,0], + ....: [0, 0, 1, 1, 1, 0, 1,0,0,0,0]]) + sage: posdict = {8: (0, 0), 1: (2, 0), 2: (1, 2), 3: (1.5, 1.0), # optional - sage.rings.finite_rings + ....: 4: (0.5, 1.0), 5: (1.0, 0.0), 6: (1.0, 0.6666666666666666)} + sage: [M,L,P] = matroids_plot_helpers.slp(M1, pos_dict=posdict) # optional - sage.rings.finite_rings + sage: M.is_simple() # optional - sage.rings.finite_rings True - sage: setprint([L,P]) + sage: setprint([L,P]) # optional - sage.rings.finite_rings [{0, 10, 9}, {7}] .. NOTE:: @@ -483,11 +487,12 @@ def addlp(M, M1, L, P, ptsdict, G=None, limits=None): EXAMPLES:: sage: from sage.matroids import matroids_plot_helpers - sage: M=Matroid(ring=GF(2), matrix=[[1, 0, 0, 0, 1, 1, 1,0,1], - ....: [0, 1, 0, 1, 0, 1, 1,0,0],[0, 0, 1, 1, 1, 0, 1,0,0]]) - sage: [M1,L,P]=matroids_plot_helpers.slp(M) - sage: G,lims=matroids_plot_helpers.addlp(M,M1,L,P,{0:(0,0)}) - sage: G.show(axes=False) + sage: M = Matroid(ring=GF(2), matrix=[[1, 0, 0, 0, 1, 1, 1,0,1], # optional - sage.rings.finite_rings + ....: [0, 1, 0, 1, 0, 1, 1,0,0], + ....: [0, 0, 1, 1, 1, 0, 1,0,0]]) + sage: [M1,L,P] = matroids_plot_helpers.slp(M) # optional - sage.rings.finite_rings + sage: G, lims = matroids_plot_helpers.addlp(M,M1,L,P,{0:(0,0)}) # optional - sage.plot sage.rings.finite_rings + sage: G.show(axes=False) # optional - sage.plot sage.rings.finite_rings .. NOTE:: @@ -664,15 +669,16 @@ def posdict_is_sane(M1, pos_dict): EXAMPLES:: sage: from sage.matroids import matroids_plot_helpers - sage: M1=Matroid(ring=GF(2), matrix=[[1, 0, 0, 0, 1, 1, 1,0,1,0,1], - ....: [0, 1, 0, 1, 0, 1, 1,0,0,1,0],[0, 0, 1, 1, 1, 0, 1,0,0,0,0]]) - sage: pos_dict= {0: (0, 0), 1: (2, 0), 2: (1, 2), 3: (1.5, 1.0), + sage: M1 = Matroid(ring=GF(2), matrix=[[1, 0, 0, 0, 1, 1, 1,0,1,0,1], # optional - sage.rings.finite_rings + ....: [0, 1, 0, 1, 0, 1, 1,0,0,1,0], + ....: [0, 0, 1, 1, 1, 0, 1,0,0,0,0]]) + sage: pos_dict = {0: (0, 0), 1: (2, 0), 2: (1, 2), 3: (1.5, 1.0), # optional - sage.rings.finite_rings ....: 4: (0.5, 1.0), 5: (1.0, 0.0), 6: (1.0, 0.6666666666666666)} - sage: matroids_plot_helpers.posdict_is_sane(M1,pos_dict) + sage: matroids_plot_helpers.posdict_is_sane(M1,pos_dict) # optional - sage.rings.finite_rings True - sage: pos_dict= {1: (2, 0), 2: (1, 2), 3: (1.5, 1.0), - ....: 4: (0.5, 1.0), 5: (1.0, 0.0), 6: (1.0, 0.6666666666666666)} - sage: matroids_plot_helpers.posdict_is_sane(M1,pos_dict) + sage: pos_dict = {1: (2, 0), 2: (1, 2), 3: (1.5, 1.0), + ....: 4: (0.5, 1.0), 5: (1.0, 0.0), 6: (1.0, 0.6666666666666666)} + sage: matroids_plot_helpers.posdict_is_sane(M1,pos_dict) # optional - sage.rings.finite_rings False .. NOTE:: @@ -757,12 +763,12 @@ def geomrep(M1, B1=None, lineorders1=None, pd=None, sp=False): EXAMPLES:: sage: from sage.matroids import matroids_plot_helpers - sage: M=matroids.named_matroids.P7() - sage: G=matroids_plot_helpers.geomrep(M) - sage: G.show(xmin=-2, xmax=3, ymin=-2, ymax=3) - sage: M=matroids.named_matroids.P7() - sage: G=matroids_plot_helpers.geomrep(M,lineorders1=[['f','e','d']]) - sage: G.show(xmin=-2, xmax=3, ymin=-2, ymax=3) + sage: M = matroids.named_matroids.P7() + sage: G = matroids_plot_helpers.geomrep(M) # optional - sage.plot + sage: G.show(xmin=-2, xmax=3, ymin=-2, ymax=3) # optional - sage.plot + sage: M = matroids.named_matroids.P7() + sage: G = matroids_plot_helpers.geomrep(M, lineorders1=[['f','e','d']]) # optional - sage.plot + sage: G.show(xmin=-2, xmax=3, ymin=-2, ymax=3) # optional - sage.plot .. NOTE:: diff --git a/src/sage/matroids/minor_matroid.py b/src/sage/matroids/minor_matroid.py index 907bb54356f..21122fcb59b 100644 --- a/src/sage/matroids/minor_matroid.py +++ b/src/sage/matroids/minor_matroid.py @@ -13,23 +13,23 @@ EXAMPLES:: - sage: M = matroids.named_matroids.Fano() - sage: M \ ['a', 'c' ] == M.delete(['a', 'c']) + sage: M = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings + sage: M \ ['a', 'c' ] == M.delete(['a', 'c']) # optional - sage.rings.finite_rings True - sage: M / 'a' == M.contract('a') + sage: M / 'a' == M.contract('a') # optional - sage.rings.finite_rings True - sage: M / 'c' \ 'ab' == M.minor(contractions='c', deletions='ab') + sage: M / 'c' \ 'ab' == M.minor(contractions='c', deletions='ab') # optional - sage.rings.finite_rings True If a contraction set is not independent (or a deletion set not coindependent), this is taken care of:: - sage: M = matroids.named_matroids.Fano() - sage: M.rank('abf') + sage: M = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings + sage: M.rank('abf') # optional - sage.rings.finite_rings 2 - sage: M / 'abf' == M / 'ab' \ 'f' + sage: M / 'abf' == M / 'ab' \ 'f' # optional - sage.rings.finite_rings True - sage: M / 'abf' == M / 'af' \ 'b' + sage: M / 'abf' == M / 'af' \ 'b' # optional - sage.rings.finite_rings True .. SEEALSO:: @@ -132,9 +132,9 @@ def __init__(self, matroid, contractions=None, deletions=None): EXAMPLES:: sage: from sage.matroids.advanced import * - sage: M = MinorMatroid(matroids.named_matroids.Fano(), # indirect doctest + sage: M = MinorMatroid(matroids.named_matroids.Fano(), # indirect doctest, optional - sage.rings.finite_rings ....: contractions=set(), deletions=set(['g'])) - sage: M.is_isomorphic(matroids.Wheel(3)) + sage: M.is_isomorphic(matroids.Wheel(3)) # optional - sage.rings.finite_rings True """ if not isinstance(matroid, Matroid): @@ -423,15 +423,15 @@ def __eq__(self, other): EXAMPLES:: sage: from sage.matroids.advanced import * - sage: M = matroids.named_matroids.Fano() - sage: M1 = MinorMatroid(M, set('ab'), set('f')) - sage: M2 = MinorMatroid(M, set('af'), set('b')) - sage: M3 = MinorMatroid(M, set('a'), set('f'))._minor(set('b'), set()) - sage: M1 == M2 # indirect doctest + sage: M = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings + sage: M1 = MinorMatroid(M, set('ab'), set('f')) # optional - sage.rings.finite_rings + sage: M2 = MinorMatroid(M, set('af'), set('b')) # optional - sage.rings.finite_rings + sage: M3 = MinorMatroid(M, set('a'), set('f'))._minor(set('b'), set()) # optional - sage.rings.finite_rings + sage: M1 == M2 # indirect doctest # optional - sage.rings.finite_rings False - sage: M1.equals(M2) + sage: M1.equals(M2) # optional - sage.rings.finite_rings True - sage: M1 == M3 + sage: M1 == M3 # optional - sage.rings.finite_rings True """ if not isinstance(other, MinorMatroid): @@ -455,15 +455,15 @@ def __ne__(self, other): EXAMPLES:: sage: from sage.matroids.advanced import * - sage: M = matroids.named_matroids.Fano() - sage: M1 = MinorMatroid(M, set('ab'), set('f')) - sage: M2 = MinorMatroid(M, set('af'), set('b')) - sage: M3 = MinorMatroid(M, set('a'), set('f'))._minor(set('b'), set()) - sage: M1 != M2 # indirect doctest + sage: M = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings + sage: M1 = MinorMatroid(M, set('ab'), set('f')) # optional - sage.rings.finite_rings + sage: M2 = MinorMatroid(M, set('af'), set('b')) # optional - sage.rings.finite_rings + sage: M3 = MinorMatroid(M, set('a'), set('f'))._minor(set('b'), set()) # optional - sage.rings.finite_rings + sage: M1 != M2 # indirect doctest # optional - sage.rings.finite_rings True - sage: M1.equals(M2) + sage: M1.equals(M2) # optional - sage.rings.finite_rings True - sage: M1 != M3 + sage: M1 != M3 # optional - sage.rings.finite_rings False """ return not self == other diff --git a/src/sage/matroids/set_system.pyx b/src/sage/matroids/set_system.pyx index d183f6ed5d1..14a95f4dce6 100644 --- a/src/sage/matroids/set_system.pyx +++ b/src/sage/matroids/set_system.pyx @@ -38,8 +38,8 @@ cdef class SetSystem: contents. One is most likely to encounter these as output from some Matroid methods:: - sage: M = matroids.named_matroids.Fano() - sage: M.circuits() + sage: M = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings + sage: M.circuits() # optional - sage.rings.finite_rings Iterator over a system of subsets To access the sets in this structure, simply iterate over them. The @@ -729,11 +729,11 @@ cdef class SetSystem: Check that :trac:`15189` is fixed:: - sage: M = Matroid(ring=GF(5), reduced_matrix=[[1,0,3],[0,1,1],[1,1,0]]) - sage: N = Matroid(ring=GF(5), reduced_matrix=[[1,0,1],[0,1,1],[1,1,0]]) - sage: M.is_field_isomorphic(N) + sage: M = Matroid(ring=GF(5), reduced_matrix=[[1,0,3],[0,1,1],[1,1,0]]) # optional - sage.rings.finite_rings + sage: N = Matroid(ring=GF(5), reduced_matrix=[[1,0,1],[0,1,1],[1,1,0]]) # optional - sage.rings.finite_rings + sage: M.is_field_isomorphic(N) # optional - sage.rings.finite_rings False - sage: any(M.is_field_isomorphism(N, p) for p in Permutations(range(6))) + sage: any(M.is_field_isomorphism(N, p) for p in Permutations(range(6))) # optional - sage.combinat sage.rings.finite_rings False """ cdef long v diff --git a/src/sage/matroids/unpickling.pyx b/src/sage/matroids/unpickling.pyx index b37ae49a37f..1167bb8c230 100644 --- a/src/sage/matroids/unpickling.pyx +++ b/src/sage/matroids/unpickling.pyx @@ -211,11 +211,11 @@ def unpickle_binary_matrix(version, data): EXAMPLES:: sage: from sage.matroids.lean_matrix import * - sage: A = BinaryMatrix(2, 5) - sage: A == loads(dumps(A)) # indirect doctest + sage: A = BinaryMatrix(2, 5) # optional - sage.rings.finite_rings + sage: A == loads(dumps(A)) # indirect doctest # optional - sage.rings.finite_rings True - sage: C = BinaryMatrix(2, 2, Matrix(GF(2), [[1, 1], [0, 1]])) - sage: C == loads(dumps(C)) + sage: C = BinaryMatrix(2, 2, Matrix(GF(2), [[1, 1], [0, 1]])) # optional - sage.rings.finite_rings + sage: C == loads(dumps(C)) # optional - sage.rings.finite_rings True """ cdef BinaryMatrix A @@ -240,11 +240,11 @@ def unpickle_ternary_matrix(version, data): EXAMPLES:: sage: from sage.matroids.lean_matrix import * - sage: A = TernaryMatrix(2, 5) - sage: A == loads(dumps(A)) # indirect doctest + sage: A = TernaryMatrix(2, 5) # optional - sage.rings.finite_rings + sage: A == loads(dumps(A)) # indirect doctest # optional - sage.rings.finite_rings True - sage: C = TernaryMatrix(2, 2, Matrix(GF(3), [[1, 1], [0, 1]])) - sage: C == loads(dumps(C)) + sage: C = TernaryMatrix(2, 2, Matrix(GF(3), [[1, 1], [0, 1]])) # optional - sage.rings.finite_rings + sage: C == loads(dumps(C)) # optional - sage.rings.finite_rings True """ cdef TernaryMatrix A @@ -270,11 +270,11 @@ def unpickle_quaternary_matrix(version, data): EXAMPLES:: sage: from sage.matroids.lean_matrix import * - sage: A = QuaternaryMatrix(2, 5, ring=GF(4, 'x')) - sage: A == loads(dumps(A)) # indirect doctest + sage: A = QuaternaryMatrix(2, 5, ring=GF(4, 'x')) # optional - sage.rings.finite_rings + sage: A == loads(dumps(A)) # indirect doctest # optional - sage.rings.finite_rings True - sage: C = QuaternaryMatrix(2, 2, Matrix(GF(4, 'x'), [[1, 1], [0, 1]])) - sage: C == loads(dumps(C)) + sage: C = QuaternaryMatrix(2, 2, Matrix(GF(4, 'x'), [[1, 1], [0, 1]])) # optional - sage.rings.finite_rings + sage: C == loads(dumps(C)) # optional - sage.rings.finite_rings True """ cdef QuaternaryMatrix A @@ -388,12 +388,12 @@ def unpickle_linear_matroid(version, data): EXAMPLES:: - sage: M = Matroid(Matrix(GF(7), [[1, 0, 0, 1, 1], [0, 1, 0, 1, 2], + sage: M = Matroid(Matrix(GF(7), [[1, 0, 0, 1, 1], [0, 1, 0, 1, 2], # optional - sage.rings.finite_rings ....: [0, 1, 1, 1, 3]])) - sage: M == loads(dumps(M)) # indirect doctest + sage: M == loads(dumps(M)) # indirect doctest # optional - sage.rings.finite_rings True - sage: M.rename("U35") - sage: loads(dumps(M)) + sage: M.rename("U35") # optional - sage.rings.finite_rings + sage: loads(dumps(M)) # optional - sage.rings.finite_rings U35 """ if version != 0: @@ -434,12 +434,12 @@ def unpickle_binary_matroid(version, data): EXAMPLES:: - sage: M = Matroid(Matrix(GF(2), [[1, 0, 0, 1], [0, 1, 0, 1], + sage: M = Matroid(Matrix(GF(2), [[1, 0, 0, 1], [0, 1, 0, 1], # optional - sage.rings.finite_rings ....: [0, 0, 1, 1]])) - sage: M == loads(dumps(M)) # indirect doctest + sage: M == loads(dumps(M)) # indirect doctest # optional - sage.rings.finite_rings True - sage: M.rename("U34") - sage: loads(dumps(M)) + sage: M.rename("U34") # optional - sage.rings.finite_rings + sage: loads(dumps(M)) # optional - sage.rings.finite_rings U34 """ if version != 0: @@ -481,12 +481,12 @@ def unpickle_ternary_matroid(version, data): EXAMPLES:: sage: from sage.matroids.advanced import * - sage: M = TernaryMatroid(Matrix(GF(3), [[1, 0, 0, 1], [0, 1, 0, 1], + sage: M = TernaryMatroid(Matrix(GF(3), [[1, 0, 0, 1], [0, 1, 0, 1], # optional - sage.rings.finite_rings ....: [0, 0, 1, 1]])) - sage: M == loads(dumps(M)) # indirect doctest + sage: M == loads(dumps(M)) # indirect doctest # optional - sage.rings.finite_rings True - sage: M.rename("U34") - sage: loads(dumps(M)) + sage: M.rename("U34") # optional - sage.rings.finite_rings + sage: loads(dumps(M)) # optional - sage.rings.finite_rings U34 """ if version != 0: @@ -528,16 +528,16 @@ def unpickle_quaternary_matroid(version, data): EXAMPLES:: sage: from sage.matroids.advanced import * - sage: M = QuaternaryMatroid(Matrix(GF(3), [[1, 0, 0, 1], [0, 1, 0, 1], + sage: M = QuaternaryMatroid(Matrix(GF(3), [[1, 0, 0, 1], [0, 1, 0, 1], # optional - sage.rings.finite_rings ....: [0, 0, 1, 1]])) - sage: M == loads(dumps(M)) # indirect doctest + sage: M == loads(dumps(M)) # indirect doctest # optional - sage.rings.finite_rings True - sage: M.rename("U34") - sage: loads(dumps(M)) + sage: M.rename("U34") # optional - sage.rings.finite_rings + sage: loads(dumps(M)) # optional - sage.rings.finite_rings U34 - sage: M = QuaternaryMatroid(Matrix(GF(4, 'x'), [[1, 0, 1], + sage: M = QuaternaryMatroid(Matrix(GF(4, 'x'), [[1, 0, 1], # optional - sage.rings.finite_rings ....: [1, 0, 1]])) - sage: loads(dumps(M)).representation() + sage: loads(dumps(M)).representation() # optional - sage.rings.finite_rings [1 0 1] [1 0 1] """ @@ -670,8 +670,8 @@ def unpickle_graphic_matroid(version, data): EXAMPLES:: - sage: M = Matroid(graphs.DiamondGraph()) - sage: M == loads(dumps(M)) + sage: M = Matroid(graphs.DiamondGraph()) # optional - sage.graphs + sage: M == loads(dumps(M)) # optional - sage.graphs True """ if version != 0: diff --git a/src/sage/matroids/utilities.py b/src/sage/matroids/utilities.py index eb2999ea07b..ab4985eb0e7 100644 --- a/src/sage/matroids/utilities.py +++ b/src/sage/matroids/utilities.py @@ -74,19 +74,19 @@ def setprint(X): Note that for iterables, the effect can be undesirable:: sage: from sage.matroids.advanced import setprint - sage: M = matroids.named_matroids.Fano().delete('efg') - sage: M.bases() + sage: M = matroids.named_matroids.Fano().delete('efg') # optional - sage.rings.finite_rings + sage: M.bases() # optional - sage.rings.finite_rings Iterator over a system of subsets - sage: setprint(M.bases()) + sage: setprint(M.bases()) # optional - sage.rings.finite_rings [{'a', 'b', 'c'}, {'a', 'b', 'd'}, {'a', 'c', 'd'}] An exception was made for subclasses of SageObject:: sage: from sage.matroids.advanced import setprint - sage: G = graphs.PetersenGraph() - sage: list(G) + sage: G = graphs.PetersenGraph() # optional - sage.graphs + sage: list(G) # optional - sage.graphs [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] - sage: setprint(G) + sage: setprint(G) # optional - sage.graphs Petersen graph: Graph on 10 vertices """ print(setprint_s(X, toplevel=True)) @@ -215,20 +215,20 @@ def sanitize_contractions_deletions(matroid, contractions, deletions): sage: from sage.matroids.utilities import setprint sage: from sage.matroids.utilities import sanitize_contractions_deletions - sage: M = matroids.named_matroids.Fano() - sage: setprint(sanitize_contractions_deletions(M, 'abc', 'defg')) + sage: M = matroids.named_matroids.Fano() # optional - sage.rings.finite_rings + sage: setprint(sanitize_contractions_deletions(M, 'abc', 'defg')) # optional - sage.rings.finite_rings [{'a', 'b', 'c'}, {'d', 'e', 'f', 'g'}] - sage: setprint(sanitize_contractions_deletions(M, 'defg', 'abc')) + sage: setprint(sanitize_contractions_deletions(M, 'defg', 'abc')) # optional - sage.rings.finite_rings [{'a', 'b', 'c', 'f'}, {'d', 'e', 'g'}] - sage: setprint(sanitize_contractions_deletions(M, [1, 2, 3], 'efg')) + sage: setprint(sanitize_contractions_deletions(M, [1, 2, 3], 'efg')) # optional - sage.rings.finite_rings Traceback (most recent call last): ... ValueError: [1, 2, 3] is not a subset of the groundset - sage: setprint(sanitize_contractions_deletions(M, 'efg', [1, 2, 3])) + sage: setprint(sanitize_contractions_deletions(M, 'efg', [1, 2, 3])) # optional - sage.rings.finite_rings Traceback (most recent call last): ... ValueError: [1, 2, 3] is not a subset of the groundset - sage: setprint(sanitize_contractions_deletions(M, 'ade', 'efg')) + sage: setprint(sanitize_contractions_deletions(M, 'ade', 'efg')) # optional - sage.rings.finite_rings Traceback (most recent call last): ... ValueError: contraction and deletion sets are not disjoint. @@ -270,7 +270,7 @@ def make_regular_matroid_from_matroid(matroid): EXAMPLES:: sage: from sage.matroids.utilities import make_regular_matroid_from_matroid - sage: make_regular_matroid_from_matroid( + sage: make_regular_matroid_from_matroid( # optional - sage.graphs ....: matroids.CompleteGraphic(6)).is_isomorphic( ....: matroids.CompleteGraphic(6)) True @@ -378,9 +378,10 @@ def spanning_forest(M): EXAMPLES:: - sage: len(sage.matroids.utilities.spanning_forest(matrix([[1,1,1],[1,1,1],[1,1,1]]))) + sage: from sage.matroids.utilities import spanning_forest + sage: len(spanning_forest(matrix([[1,1,1],[1,1,1],[1,1,1]]))) # optional - sage.graphs 5 - sage: len(sage.matroids.utilities.spanning_forest(matrix([[0,0,1],[0,1,0],[0,1,0]]))) + sage: len(spanning_forest(matrix([[0,0,1],[0,1,0],[0,1,0]]))) # optional - sage.graphs 3 """ # Given a matrix, produce a spanning tree @@ -418,8 +419,9 @@ def spanning_stars(M): EXAMPLES:: - sage: edges = sage.matroids.utilities.spanning_stars(matrix([[1,1,1],[1,1,1],[1,1,1]])) - sage: Graph([(x+3, y) for x,y in edges]).is_connected() + sage: from sage.matroids.utilities import spanning_stars + sage: edges = spanning_stars(matrix([[1,1,1],[1,1,1],[1,1,1]])) # optional - sage.graphs + sage: Graph([(x+3, y) for x,y in edges]).is_connected() # optional - sage.graphs True """ @@ -532,25 +534,25 @@ def lift_cross_ratios(A, lift_map=None): EXAMPLES:: sage: from sage.matroids.advanced import lift_cross_ratios, lift_map, LinearMatroid - sage: R = GF(7) - sage: to_sixth_root_of_unity = lift_map('sru') - sage: A = Matrix(R, [[1, 0, 6, 1, 2],[6, 1, 0, 0, 1],[0, 6, 3, 6, 0]]) - sage: A + sage: R = GF(7) # optional - sage.graphs sage.rings.finite_rings + sage: to_sixth_root_of_unity = lift_map('sru') # optional - sage.graphs sage.rings.number_field + sage: A = Matrix(R, [[1, 0, 6, 1, 2],[6, 1, 0, 0, 1],[0, 6, 3, 6, 0]]) # optional - sage.graphs sage.rings.finite_rings + sage: A # optional - sage.graphs sage.rings.finite_rings [1 0 6 1 2] [6 1 0 0 1] [0 6 3 6 0] - sage: Z = lift_cross_ratios(A, to_sixth_root_of_unity) - sage: Z + sage: Z = lift_cross_ratios(A, to_sixth_root_of_unity) # optional - sage.graphs sage.rings.finite_rings sage.rings.number_field + sage: Z # optional - sage.graphs sage.rings.finite_rings sage.rings.number_field [ 1 0 1 1 1] [ 1 1 0 0 z] [ 0 -1 z 1 0] - sage: M = LinearMatroid(reduced_matrix = A) - sage: sorted(M.cross_ratios()) + sage: M = LinearMatroid(reduced_matrix=A) # optional - sage.graphs sage.rings.finite_rings + sage: sorted(M.cross_ratios()) # optional - sage.graphs sage.rings.finite_rings [3, 5] - sage: N = LinearMatroid(reduced_matrix = Z) - sage: sorted(N.cross_ratios()) + sage: N = LinearMatroid(reduced_matrix=Z) # optional - sage.graphs sage.rings.finite_rings sage.rings.number_field + sage: sorted(N.cross_ratios()) # optional - sage.graphs sage.rings.finite_rings sage.rings.number_field [-z + 1, z] - sage: M.is_isomorphism(N, {e:e for e in M.groundset()}) + sage: M.is_isomorphism(N, {e:e for e in M.groundset()}) # optional - sage.graphs sage.rings.finite_rings sage.rings.number_field True """ @@ -690,8 +692,8 @@ def lift_map(target): EXAMPLES:: sage: from sage.matroids.utilities import lift_map - sage: lm = lift_map('gm') - sage: for x in lm: + sage: lm = lift_map('gm') # optional - sage.rings.finite_rings sage.rings.number_field + sage: for x in lm: # optional - sage.rings.finite_rings sage.rings.number_field ....: if (x == 1) is not (lm[x] == 1): ....: print('not a proper lift map') ....: for y in lm: @@ -740,7 +742,7 @@ def split_vertex(G, u, v=None, edges=None): INPUT: - - ``G`` -- A SageMath Graph. + - ``G`` -- A SageMath :class:`Graph`. - ``u`` -- A vertex in ``G``. - ``v`` -- (optional) The name of the new vertex after the splitting. If ``v`` is specified and already in the graph, it must be an isolated vertex. @@ -751,13 +753,13 @@ def split_vertex(G, u, v=None, edges=None): EXAMPLES:: sage: from sage.matroids.utilities import split_vertex - sage: G = graphs.BullGraph() - sage: split_vertex(G, u=1, v=55, edges=[(1, 3)]) + sage: G = graphs.BullGraph() # optional - sage.graphs + sage: split_vertex(G, u=1, v=55, edges=[(1, 3)]) # optional - sage.graphs Traceback (most recent call last): ... ValueError: the edges are not all incident with u - sage: split_vertex(G, u=1, v=55, edges=[(1, 3, None)]) - sage: list(G.edges(sort=True)) + sage: split_vertex(G, u=1, v=55, edges=[(1, 3, None)]) # optional - sage.graphs + sage: list(G.edges(sort=True)) # optional - sage.graphs [(0, 1, None), (0, 2, None), (1, 2, None), (2, 4, None), (3, 55, None)] """ if v is None: diff --git a/src/sage/misc/functional.py b/src/sage/misc/functional.py index 9407f588848..cd79889fb14 100644 --- a/src/sage/misc/functional.py +++ b/src/sage/misc/functional.py @@ -1337,9 +1337,9 @@ def norm(x): sage: M = matrix(ZZ, [[1,2,4,3], [-1,0,3,-10]]) sage: norm(M) # abs tol 1e-14 10.690331129154467 - sage: norm(CDF(z)) + sage: norm(CDF(z)) # optional - sage.modules 5.0 - sage: norm(CC(z)) + sage: norm(CC(z)) # optional - sage.modules 5.00000000000000 The norm of complex numbers:: diff --git a/src/sage/repl/rich_output/pretty_print.py b/src/sage/repl/rich_output/pretty_print.py index 4fcbfe4d5af..05c9a102876 100644 --- a/src/sage/repl/rich_output/pretty_print.py +++ b/src/sage/repl/rich_output/pretty_print.py @@ -246,10 +246,10 @@ def pretty_print(*args, **kwds): sage: pretty_print(x^2 / (x + 1)) # optional - sage.symbolic x^2/(x + 1) - sage: t = BinaryTrees(3).first() # optional - sage.combinat - sage: pretty_print(t) # optional - sage.combinat + sage: t = BinaryTrees(3).first() # optional - sage.graphs + sage: pretty_print(t) # optional - sage.graphs [., [., [., .]]] - sage: print(t) # optional - sage.combinat + sage: print(t) # optional - sage.graphs [., [., [., .]]] TESTS:: @@ -263,7 +263,7 @@ def pretty_print(*args, **kwds): The following illustrates a possible use-case:: sage: %display ascii_art # not tested - sage: for t in BinaryTrees(3)[:3]: # optional - sage.combinat + sage: for t in BinaryTrees(3)[:3]: # optional - sage.graphs ....: pretty_print(t) o \ diff --git a/src/sage/structure/sage_object.pyx b/src/sage/structure/sage_object.pyx index 2140a285f2c..74bac0150ca 100644 --- a/src/sage/structure/sage_object.pyx +++ b/src/sage/structure/sage_object.pyx @@ -360,18 +360,18 @@ cdef class SageObject: modified to return ``True`` for objects which might behave differently in some computations:: - sage: K. = Qq(9) # optional - sage.rings.padics - sage: b = a + O(3) # optional - sage.rings.padics - sage: c = a + 3 # optional - sage.rings.padics - sage: b # optional - sage.rings.padics + sage: K. = Qq(9) # optional - sage.rings.padics + sage: b = a + O(3) # optional - sage.rings.padics + sage: c = a + 3 # optional - sage.rings.padics + sage: b # optional - sage.rings.padics a + O(3) - sage: c # optional - sage.rings.padics + sage: c # optional - sage.rings.padics a + 3 + O(3^20) - sage: b == c # optional - sage.rings.padics + sage: b == c # optional - sage.rings.padics True - sage: b == a # optional - sage.rings.padics + sage: b == a # optional - sage.rings.padics True - sage: c == a # optional - sage.rings.padics + sage: c == a # optional - sage.rings.padics False If such objects defined a non-trivial hash function, this would break @@ -379,20 +379,20 @@ cdef class SageObject: caches. This can be achieved by defining an appropriate ``_cache_key``:: - sage: hash(b) # optional - sage.rings.padics + sage: hash(b) # optional - sage.rings.padics Traceback (most recent call last): ... TypeError: unhashable type: 'sage.rings.padics.qadic_flint_CR.qAdicCappedRelativeElement' sage: @cached_method ....: def f(x): return x==a - sage: f(b) # optional - sage.rings.padics + sage: f(b) # optional - sage.rings.padics True - sage: f(c) # if b and c were hashable, this would return True # optional - sage.rings.padics + sage: f(c) # if b and c were hashable, this would return True # optional - sage.rings.padics False - sage: b._cache_key() # optional - sage.rings.padics + sage: b._cache_key() # optional - sage.rings.padics (..., ((0, 1),), 0, 1) - sage: c._cache_key() # optional - sage.rings.padics + sage: c._cache_key() # optional - sage.rings.padics (..., ((0, 1), (1,)), 0, 20) An implementation must make sure that for elements ``a`` and ``b``, @@ -400,8 +400,8 @@ cdef class SageObject: In practice this means that the ``_cache_key`` should always include the parent as its first argument:: - sage: S. = Qq(4) # optional - sage.rings.padics - sage: d = a + O(2) # optional - sage.rings.padics + sage: S. = Qq(4) # optional - sage.rings.padics + sage: d = a + O(2) # optional - sage.rings.padics sage: b._cache_key() == d._cache_key() # this would be True if the parents were not included # optional - sage.rings.padics False @@ -525,10 +525,10 @@ cdef class SageObject: EXAMPLES:: - sage: t = log(sqrt(2) - 1) + log(sqrt(2) + 1); t # optional - sage.symbolic + sage: t = log(sqrt(2) - 1) + log(sqrt(2) + 1); t # optional - sage.symbolic log(sqrt(2) + 1) + log(sqrt(2) - 1) - sage: u = t.maxima_methods() # optional - sage.symbolic - sage: u.parent() # optional - sage.symbolic + sage: u = t.maxima_methods() # optional - sage.symbolic + sage: u.parent() # optional - sage.symbolic """ return type(self) @@ -847,10 +847,10 @@ cdef class SageObject: sage: x = polygen(ZZ, 'x') sage: K. = NumberField(x^3 + 2) - sage: magma(K) is magma(K) # optional - magma + sage: magma(K) is magma(K) # optional - magma True sage: magma2 = Magma() - sage: magma(K) is magma2(K) # optional - magma + sage: magma(K) is magma2(K) # optional - magma False """ return repr(self) # default