From 54214b82804be2dd8495c870d4a34ed34adae443 Mon Sep 17 00:00:00 2001 From: "John H. Palmieri" Date: Thu, 28 Sep 2023 15:36:19 -0700 Subject: [PATCH] Deprecate the backslash operator. --- src/doc/de/tutorial/tour_linalg.rst | 10 ------ src/doc/en/tutorial/tour_linalg.rst | 10 ------ src/doc/es/tutorial/tour_linalg.rst | 10 ------ src/doc/fr/tutorial/tour_linalg.rst | 11 ------ src/doc/ja/tutorial/tour_linalg.rst | 12 ------- src/doc/pt/tutorial/tour_linalg.rst | 10 ------ src/doc/ru/tutorial/tour_linalg.rst | 9 ----- src/sage/combinat/binary_tree.py | 5 +-- src/sage/features/sagemath.py | 2 +- src/sage/matrix/matrix2.pyx | 35 +++++++++++-------- src/sage/matrix/matrix_complex_ball_dense.pyx | 6 ++-- src/sage/matrix/matrix_integer_dense.pyx | 12 +++---- src/sage/matrix/matrix_integer_sparse.pyx | 6 ++-- .../matrix/matrix_modn_dense_template.pxi | 2 +- src/sage/matrix/matrix_modn_sparse.pyx | 6 ++-- src/sage/matrix/matrix_space.py | 4 +-- src/sage/matroids/basis_exchange_matroid.pyx | 4 +-- src/sage/matroids/catalog.py | 2 +- src/sage/matroids/linear_matroid.pyx | 22 ++++++------ src/sage/matroids/matroid.pyx | 33 ++++++++++------- src/sage/matroids/minor_matroid.py | 8 ++--- src/sage/misc/misc.py | 19 ++++++++++ .../linalg_doctest.py | 2 ++ .../linsolve_doctest.py | 2 +- 24 files changed, 103 insertions(+), 139 deletions(-) diff --git a/src/doc/de/tutorial/tour_linalg.rst b/src/doc/de/tutorial/tour_linalg.rst index 2a5467e8884..1be6540c89e 100644 --- a/src/doc/de/tutorial/tour_linalg.rst +++ b/src/doc/de/tutorial/tour_linalg.rst @@ -42,16 +42,6 @@ gelöst werden. Das Auswerten von ``A.solve_right(Y)`` gibt eine Matrix sage: A * X # wir überprüfen unsere Antwort... (0, -4, -1) -Anstelle von ``solve_right`` kann auch ein Backslash ``\`` verwendet -werden. Benutzen Sie ``A \ Y`` anstelle von ``A.solve_right(Y)``. - -.. link - -:: - - sage: A \ Y - (-2, 1, 0) - Falls keine Lösung existiert, gibt Sage einen Fehler zurück: .. skip diff --git a/src/doc/en/tutorial/tour_linalg.rst b/src/doc/en/tutorial/tour_linalg.rst index 054e338cea7..84a45f4931b 100644 --- a/src/doc/en/tutorial/tour_linalg.rst +++ b/src/doc/en/tutorial/tour_linalg.rst @@ -42,16 +42,6 @@ Evaluating ``A.solve_right(Y)`` returns a matrix (or vector) sage: A * X # checking our answer... (0, -4, -1) -A backslash ``\`` can be used in the place of ``solve_right``; use -``A \ Y`` instead of ``A.solve_right(Y)``. - -.. link - -:: - - sage: A \ Y - (-2, 1, 0) - If there is no solution, Sage returns an error: .. skip diff --git a/src/doc/es/tutorial/tour_linalg.rst b/src/doc/es/tutorial/tour_linalg.rst index eb2caa35440..a9b543cca0e 100644 --- a/src/doc/es/tutorial/tour_linalg.rst +++ b/src/doc/es/tutorial/tour_linalg.rst @@ -49,16 +49,6 @@ Resolver ecuaciones matriciales es sencillo, usando el método sage: A * X # comprobando la solución... (0, -4, -1) -Se puede usar una barra invertida ``\`` en lugar de ``solve_right``; -usamos ``A \ Y`` en lugar de ``A.solve_right(Y)``. - -.. link - -:: - - sage: A \ Y - (-2, 1, 0) - Si no hay solución, Sage lanza un error: .. skip diff --git a/src/doc/fr/tutorial/tour_linalg.rst b/src/doc/fr/tutorial/tour_linalg.rst index 1343fa126fa..582a915edef 100644 --- a/src/doc/fr/tutorial/tour_linalg.rst +++ b/src/doc/fr/tutorial/tour_linalg.rst @@ -42,17 +42,6 @@ une matrice (ou un vecteur) :math:`X` tel que :math:`AX=Y`: sage: A * X # vérifions la réponse... (0, -4, -1) -Un antislash (contre-oblique) ``\`` peut être employé à la place de -``solve_right`` : il suffit d'écrire ``A \ Y`` au lieu de -``A.solve_right(Y)``. - -.. link - -:: - - sage: A \ Y - (-2, 1, 0) - S'il n'y a aucune solution, Sage renvoie une erreur : .. skip diff --git a/src/doc/ja/tutorial/tour_linalg.rst b/src/doc/ja/tutorial/tour_linalg.rst index cf24ab37ed1..7af81486a30 100644 --- a/src/doc/ja/tutorial/tour_linalg.rst +++ b/src/doc/ja/tutorial/tour_linalg.rst @@ -45,18 +45,6 @@ Sageでは,行列 :math:`A` の核空間は「左」核空間,すなわち : (0, -4, -1) -``solve_right`` の代わりにバックスラッシュ ``\`` を使うこともできる. -つまり ``A.solve_right(Y)`` ではなく ``A \ Y`` と書くわけである. - -.. link - -:: - - sage: A \ Y - (-2, 1, 0) - - - 解がない場合は,Sageはエラーを返してくる: .. skip diff --git a/src/doc/pt/tutorial/tour_linalg.rst b/src/doc/pt/tutorial/tour_linalg.rst index 9cdf7671dd7..806a36c6446 100644 --- a/src/doc/pt/tutorial/tour_linalg.rst +++ b/src/doc/pt/tutorial/tour_linalg.rst @@ -40,16 +40,6 @@ Calculando ``A.solve_right(Y)`` obtém-se uma matrix (ou vetor) sage: A * X # checking our answer... (0, -4, -1) -Uma barra invertida ``\`` pode ser usada no lugar de ``solve_right``; -use ``A \ Y`` no lugar de ``A.solve_right(Y)``. - -.. link - -:: - - sage: A \ Y - (-2, 1, 0) - Se não existir solução, o Sage retorna um erro: .. skip diff --git a/src/doc/ru/tutorial/tour_linalg.rst b/src/doc/ru/tutorial/tour_linalg.rst index 2e1e6620549..6b4c64764c8 100644 --- a/src/doc/ru/tutorial/tour_linalg.rst +++ b/src/doc/ru/tutorial/tour_linalg.rst @@ -37,15 +37,6 @@ Sage поддерживает стандартные конструкции из sage: A * X # проверка... (0, -4, -1) -``\`` может быть использован вместо ``solve_right``; используйте -``A \ Y`` вместо ``A.solve_right(Y)``. - -.. link - -:: - - sage: A \ Y - (-2, 1, 0) Если решения не существует, то Sage вернет ошибку: diff --git a/src/sage/combinat/binary_tree.py b/src/sage/combinat/binary_tree.py index 8e876ab137a..e150a1fe9cc 100644 --- a/src/sage/combinat/binary_tree.py +++ b/src/sage/combinat/binary_tree.py @@ -39,6 +39,7 @@ from sage.sets.disjoint_union_enumerated_sets import DisjointUnionEnumeratedSets from sage.sets.family import Family from sage.misc.cachefunc import cached_method +from sage.misc.superseded import deprecated_function_alias class BinaryTree(AbstractClonableTree, ClonableArray, @@ -3214,7 +3215,7 @@ def under(self, bt): sage: b1 = BinaryTree([[],[]]) sage: b2 = BinaryTree([None,[]]) - sage: ascii_art((b1, b2, b1 \ b2)) + sage: ascii_art((b1, b2, b1.under(b2))) ( o , o , _o_ ) ( / \ \ / \ ) ( o o o o o ) @@ -3276,7 +3277,7 @@ def under(self, bt): else: return B([self.under(bt[0]), bt[1]]) - _backslash_ = under + _backslash_ = deprecated_function_alias(80000, under) def under_decomposition(self): r""" diff --git a/src/sage/features/sagemath.py b/src/sage/features/sagemath.py index ac3922552e4..7404e6d0a8e 100644 --- a/src/sage/features/sagemath.py +++ b/src/sage/features/sagemath.py @@ -232,7 +232,7 @@ class sage__graphs(JoinFeature): sage: M = Matroid(Matrix(QQ, [[1, 0, 0, 0, 1, 1, 1], ....: [0, 1, 0, 1, 0, 1, 1], ....: [0, 0, 1, 1, 1, 0, 1]])) - sage: N = M / [2] \ [3, 4] + sage: N = (M / [2]).delete([3, 4]) sage: sorted(N.groundset()) [0, 1, 5, 6] diff --git a/src/sage/matrix/matrix2.pyx b/src/sage/matrix/matrix2.pyx index 86aca6e00d8..a3e98fd2b66 100644 --- a/src/sage/matrix/matrix2.pyx +++ b/src/sage/matrix/matrix2.pyx @@ -106,7 +106,7 @@ from sage.matrix.matrix_misc import permanental_minor_polynomial from sage.misc.misc_c import prod # used to deprecate only adjoint method -from sage.misc.superseded import deprecated_function_alias +from sage.misc.superseded import deprecation, deprecated_function_alias # temporary hack to silence the warnings from #34806 @@ -146,21 +146,28 @@ cdef class Matrix(Matrix1): Used to compute `A \backslash B`, i.e., the backslash solver operator. + DEPRECATED + EXAMPLES:: sage: A = matrix(QQ, 3, [1,2,4,2,3,1,0,1,2]) sage: B = matrix(QQ, 3, 2, [1,7,5, 2,1,3]) sage: C = A._backslash_(B); C + doctest:...: DeprecationWarning: the backslash operator has been deprecated; use A.solve_right(B) instead + See https://github.com/sagemath/sage/issues/80000 for details. [ -1 1] [13/5 -3/5] [-4/5 9/5] sage: A*C == B True sage: A._backslash_(B) == A \ B + doctest:...: DeprecationWarning: the backslash operator has been deprecated; use A.solve_right(B) instead + See https://github.com/sagemath/sage/issues/80000 for details. True sage: A._backslash_(B) == A.solve_right(B) True """ + deprecation(80000, 'the backslash operator has been deprecated; use A.solve_right(B) instead') return self.solve_right(B) def subs(self, *args, **kwds): @@ -462,7 +469,7 @@ cdef class Matrix(Matrix1): .. NOTE:: - In Sage one can also write ``A \ B`` for + DEPRECATED. In Sage one can also write ``A \ B`` for ``A.solve_right(B)``, that is, Sage implements "the MATLAB/Octave backslash operator". @@ -506,7 +513,7 @@ cdef class Matrix(Matrix1): sage: A = matrix(QQ, 3, [1,2,3,-1,2,5,2,3,1]) sage: b = vector(QQ,[1,2,3]) - sage: x = A \ b; x + sage: x = A.solve_right(b); x (-13/12, 23/12, -7/12) sage: A * x (1, 2, 3) @@ -525,7 +532,7 @@ cdef class Matrix(Matrix1): Another nonsingular example:: sage: A = matrix(QQ,2,3, [1,2,3,2,4,6]); v = vector([-1/2,-1]) - sage: x = A \ v; x + sage: x = A.solve_right(v); x (-1/2, 0, 0) sage: A*x == v True @@ -533,13 +540,13 @@ cdef class Matrix(Matrix1): Same example but over `\ZZ`:: sage: A = matrix(ZZ,2,3, [1,2,3,2,4,6]); v = vector([-1,-2]) - sage: A \ v + sage: A.solve_right(v) (-1, 0, 0) An example in which there is no solution:: sage: A = matrix(QQ,2,3, [1,2,3,2,4,6]); v = vector([1,1]) - sage: A \ v + sage: A.solve_right(v) Traceback (most recent call last): ... ValueError: matrix equation has no solutions @@ -564,24 +571,24 @@ cdef class Matrix(Matrix1): sage: A*X == B True - We illustrate left associativity, etc., of the backslash operator. + We illustrate left associativity, etc., of the ``solve_right`` operator. :: sage: A = matrix(QQ, 2, [1,2,3,4]) - sage: A \ A + sage: A.solve_right(A) [1 0] [0 1] - sage: A \ A \ A + sage: (A.solve_right(A)).solve_right(A) [1 2] [3 4] - sage: A.parent()(1) \ A + sage: A.parent()(1).solve_right(A) [1 2] [3 4] - sage: A \ (A \ A) + sage: A.solve_right(A.solve_right(A)) [ -2 1] [ 3/2 -1/2] - sage: X = A \ (A - 2); X + sage: X = A.solve_right(A - 2); X [ 5 -2] [-3 2] sage: A * X @@ -593,7 +600,7 @@ cdef class Matrix(Matrix1): sage: x = polygen(QQ, 'x') sage: A = matrix(2, [x,2*x,-5*x^2+1,3]) sage: v = vector([3,4*x - 2]) - sage: X = A \ v + sage: X = A.solve_right(v) sage: X ((-4/5*x^2 + 2/5*x + 9/10)/(x^3 + 1/10*x), (19/10*x^2 - 1/5*x - 3/10)/(x^3 + 1/10*x)) sage: A * X == v @@ -635,7 +642,7 @@ cdef class Matrix(Matrix1): [ 2 + O(5^4) 5 + O(5^5) 4 + O(5^4)] [ 1 + O(5^4) 1 + O(5^4) 2 + O(5^4)] sage: v = vector(k, 3, [1,2,3]) - sage: x = a \ v; x + sage: x = a.solve_right(v); x (4 + 5 + 5^2 + 3*5^3 + O(5^4), 2 + 5 + 3*5^2 + 5^3 + O(5^4), 1 + 5 + O(5^4)) sage: a * x == v True diff --git a/src/sage/matrix/matrix_complex_ball_dense.pyx b/src/sage/matrix/matrix_complex_ball_dense.pyx index 47ca41070fa..3f56772a663 100644 --- a/src/sage/matrix/matrix_complex_ball_dense.pyx +++ b/src/sage/matrix/matrix_complex_ball_dense.pyx @@ -569,14 +569,14 @@ cdef class Matrix_complex_ball_dense(Matrix_dense): r""" TESTS:: - sage: matrix(CBF, [[1/2, 1/3], [1, 1]]) \ vector([-1, 1]) + sage: matrix(CBF, [[1/2, 1/3], [1, 1]]).solve_right(vector([-1, 1])) ([-8.00000000000000 +/- ...], [9.00000000000000 +/- ...]) - sage: matrix(CBF, 2, 2, 0) \ vector([-1, 1]) + sage: matrix(CBF, 2, 2, 0).solve_right(vector([-1, 1])) Traceback (most recent call last): ... ValueError: unable to invert this matrix sage: b = CBF(0, RBF(0, rad=.1r)) - sage: matrix(CBF, [[1, 1], [0, b]]) \ vector([-1, 1]) + sage: matrix(CBF, [[1, 1], [0, b]]).solve_right(vector([-1, 1])) Traceback (most recent call last): ... ValueError: unable to invert this matrix diff --git a/src/sage/matrix/matrix_integer_dense.pyx b/src/sage/matrix/matrix_integer_dense.pyx index 8c276f2ca29..b093e576f74 100644 --- a/src/sage/matrix/matrix_integer_dense.pyx +++ b/src/sage/matrix/matrix_integer_dense.pyx @@ -4138,7 +4138,7 @@ cdef class Matrix_integer_dense(Matrix_dense): .. NOTE:: - In Sage one can also write ``A \ B`` for + DEPRECATED. In Sage one can also write ``A \ B`` for ``A.solve_right(B)``, i.e., Sage implements the "the MATLAB/Octave backslash operator". @@ -4162,7 +4162,7 @@ cdef class Matrix_integer_dense(Matrix_dense): sage: a = matrix(ZZ, 2, [0, -1, 1, 0]) sage: v = vector(ZZ, [2, 3]) - sage: a \ v + sage: a.solve_right(v) (3, -2) Note that the output vector or matrix is always over @@ -4170,7 +4170,7 @@ cdef class Matrix_integer_dense(Matrix_dense): :: - sage: parent(a\v) + sage: parent(a.solve_right(v)) Vector space of dimension 2 over Rational Field We solve a bigger system where the answer is over the rationals. @@ -4179,7 +4179,7 @@ cdef class Matrix_integer_dense(Matrix_dense): sage: a = matrix(ZZ, 3, 3, [1,2,3,4, 5, 6, 8, -2, 3]) sage: v = vector(ZZ, [1,2,3]) - sage: w = a \ v; w + sage: w = a.solve_right(v); w (2/15, -4/15, 7/15) sage: parent(w) Vector space of dimension 3 over Rational Field @@ -4193,7 +4193,7 @@ cdef class Matrix_integer_dense(Matrix_dense): sage: a = matrix(ZZ, 3, 3, [1,2,3,4, 5, 6, 8, -2, 3]) sage: b = matrix(ZZ, 3, 2, [1,5, 2, -3, 3, 0]) - sage: w = a \ b; w + sage: w = a.solve_right(b); w [ 2/15 -19/5] [-4/15 -27/5] [ 7/15 98/15] @@ -4214,7 +4214,7 @@ cdef class Matrix_integer_dense(Matrix_dense): sage: n = 100 sage: a = random_matrix(ZZ,n) sage: v = vector(ZZ,n,range(n)) - sage: x = a \ v + sage: x = a.solve_right(v) sage: a * x == v True diff --git a/src/sage/matrix/matrix_integer_sparse.pyx b/src/sage/matrix/matrix_integer_sparse.pyx index f6d79abf56a..f4320fcd914 100644 --- a/src/sage/matrix/matrix_integer_sparse.pyx +++ b/src/sage/matrix/matrix_integer_sparse.pyx @@ -985,7 +985,7 @@ cdef class Matrix_integer_sparse(Matrix_sparse): .. NOTE:: - In Sage one can also write ``A \ B`` for + DEPRECATED. In Sage one can also write ``A \ B`` for ``A.solve_right(B)``, i.e., Sage implements the "the MATLAB/Octave backslash operator". @@ -1019,14 +1019,14 @@ cdef class Matrix_integer_sparse(Matrix_sparse): sage: A = matrix(ZZ, 3, [1,2,3,-1,2,5,2,3,1], sparse=True) sage: b = vector(ZZ, [1,2,3]) - sage: x = A \ b + sage: x = A.solve_right(b) sage: x (-13/12, 23/12, -7/12) sage: A * x (1, 2, 3) sage: u = matrix(ZZ, 3, 2, [0,1,1,1,0,2]) - sage: x = A \ u + sage: x = A.solve_right(u) sage: x [-7/12 -1/6] [ 5/12 5/6] diff --git a/src/sage/matrix/matrix_modn_dense_template.pxi b/src/sage/matrix/matrix_modn_dense_template.pxi index 69569297923..f00e8bef6ef 100644 --- a/src/sage/matrix/matrix_modn_dense_template.pxi +++ b/src/sage/matrix/matrix_modn_dense_template.pxi @@ -23,7 +23,7 @@ EXAMPLES:: sage: A.rank() 4 sage: v = vector(GF(127), 4, (100, 93, 47, 110)) - sage: x = A\v + sage: x = A.solve_right(v) sage: A*x == v True diff --git a/src/sage/matrix/matrix_modn_sparse.pyx b/src/sage/matrix/matrix_modn_sparse.pyx index 80a74bf1761..9c12d6b9e1d 100644 --- a/src/sage/matrix/matrix_modn_sparse.pyx +++ b/src/sage/matrix/matrix_modn_sparse.pyx @@ -880,7 +880,7 @@ cdef class Matrix_modn_sparse(Matrix_sparse): .. NOTE:: - In Sage one can also write ``A \ B`` for + DEPRECATED. In Sage one can also write ``A \ B`` for ``A.solve_right(B)``, i.e., Sage implements the "the MATLAB/Octave backslash operator". @@ -914,14 +914,14 @@ cdef class Matrix_modn_sparse(Matrix_sparse): sage: A = matrix(ZZ, 3, [1,2,3,-1,2,5,2,3,1], sparse=True) sage: b = vector(ZZ, [1,2,3]) - sage: x = A \ b + sage: x = A.solve_right(b) sage: x (-13/12, 23/12, -7/12) sage: A * x (1, 2, 3) sage: u = matrix(ZZ, 3, 2, [0,1,1,1,0,2]) - sage: x = A \ u + sage: x = A.solve_right(u) sage: x [-7/12 -1/6] [ 5/12 5/6] diff --git a/src/sage/matrix/matrix_space.py b/src/sage/matrix/matrix_space.py index 6aab58352be..ca77503ba96 100644 --- a/src/sage/matrix/matrix_space.py +++ b/src/sage/matrix/matrix_space.py @@ -677,9 +677,9 @@ def __init__(self, base_ring, nrows, ncols, sparse, implementation): Vector space of degree 125 and dimension 124 over Rational Field Basis matrix: 124 x 125 dense matrix over Rational Field - sage: MatrixSpace(ZZ,20,20)(1) \ MatrixSpace(ZZ,20,1).random_element() + sage: MatrixSpace(ZZ,20,20)(1).solve_right(MatrixSpace(ZZ,20,1).random_element()) 20 x 1 dense matrix over Rational Field (use the '.str()' method to see the entries) - sage: MatrixSpace(ZZ,200,200)(1) \ MatrixSpace(ZZ,200,1).random_element() + sage: MatrixSpace(ZZ,200,200)(1).solve_right(MatrixSpace(ZZ,200,1).random_element()) 200 x 1 dense matrix over Rational Field (use the '.str()' method to see the entries) sage: A = MatrixSpace(RDF,1000,1000).random_element() sage: B = MatrixSpace(RDF,1000,1000).random_element() diff --git a/src/sage/matroids/basis_exchange_matroid.pyx b/src/sage/matroids/basis_exchange_matroid.pyx index 015fa8b8df3..fc902bc19c0 100644 --- a/src/sage/matroids/basis_exchange_matroid.pyx +++ b/src/sage/matroids/basis_exchange_matroid.pyx @@ -1134,7 +1134,7 @@ cdef class BasisExchangeMatroid(Matroid): sage: M.connectivity(X) 2 sage: J = M.groundset()-(S|T|I) - sage: N = M/I\J + sage: N = (M/I).delete(J) sage: N.connectivity(S) 2 """ @@ -2132,7 +2132,7 @@ 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: M = matroids.named_matroids.Fano().delete(['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) diff --git a/src/sage/matroids/catalog.py b/src/sage/matroids/catalog.py index 4bc93a6b8a0..949f7367b40 100644 --- a/src/sage/matroids/catalog.py +++ b/src/sage/matroids/catalog.py @@ -1006,7 +1006,7 @@ def AG(n, q, x=None): EXAMPLES:: - sage: M = matroids.AG(2, 3) \ 8 + sage: M = matroids.AG(2, 3).delete(8) sage: M.is_isomorphic(matroids.named_matroids.AG23minus()) True sage: matroids.AG(5, 4, 'z').size() == ((4 ^ 6 - 1) / (4 - 1) - # needs sage.rings.finite_rings diff --git a/src/sage/matroids/linear_matroid.pyx b/src/sage/matroids/linear_matroid.pyx index 36f563aa433..8ba09084c1f 100644 --- a/src/sage/matroids/linear_matroid.pyx +++ b/src/sage/matroids/linear_matroid.pyx @@ -819,7 +819,7 @@ cdef class LinearMatroid(BasisExchangeMatroid): EXAMPLES:: sage: from sage.matroids.advanced import * - sage: M = matroids.named_matroids.Fano() \ ['g'] + sage: M = matroids.named_matroids.Fano().delete(['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) @@ -1004,7 +1004,7 @@ cdef class LinearMatroid(BasisExchangeMatroid): False sage: from sage.matroids.advanced import * - sage: M = matroids.named_matroids.Fano() \ ['g'] + sage: M = matroids.named_matroids.Fano().delete(['g']) sage: N = LinearMatroid(reduced_matrix=Matrix(GF(2), ....: [[-1, 0, 1], [1, -1, 0], [0, 1, -1]])) sage: morphism = {'a':0, 'b':1, 'c': 2, 'd':4, 'e':5, 'f':3} @@ -3413,8 +3413,8 @@ cdef class BinaryMatroid(LinearMatroid): EXAMPLES:: - sage: M = matroids.named_matroids.Fano() \ ['a'] - sage: N = matroids.named_matroids.Fano() \ ['b'] + sage: M = matroids.named_matroids.Fano().delete(['a']) + sage: N = matroids.named_matroids.Fano().delete(['b']) sage: morphism = {'b':'a', 'c':'c', 'd':'e', 'e':'d', 'f':'f', 'g':'g'} sage: M._is_isomorphism(N, morphism) True @@ -3632,7 +3632,7 @@ cdef class BinaryMatroid(LinearMatroid): 2 sage: for i in [-1, 0, 1]: ....: print(sorted(e for e in M.groundset() - ....: if (M\e).bicycle_dimension() == 2 + i)) + ....: if (M.delete(e)).bicycle_dimension() == 2 + i)) ['a', 'b', 'c', 'e', 'f', 'g'] ['d'] ['h'] @@ -5459,7 +5459,7 @@ cdef class QuaternaryMatroid(LinearMatroid): EXAMPLES:: sage: # needs sage.rings.finite_rings - sage: M = matroids.named_matroids.Q10()\'a' + sage: M = matroids.named_matroids.Q10().delete('a') sage: for F in M._principal_tripartition(): print(sorted(F)) ['b', 'c', 'd', 'e', 'h', 'i'] ['f', 'g', 'j'] @@ -5468,7 +5468,7 @@ cdef class QuaternaryMatroid(LinearMatroid): 1 sage: for i in [-1, 0, 1]: ....: print(sorted(e for e in M.groundset() - ....: if (M\e).bicycle_dimension() == 1 + i)) + ....: if (M.delete(e)).bicycle_dimension() == 1 + i)) ['b', 'c', 'd', 'e', 'h', 'i'] ['f', 'g', 'j'] [] @@ -5497,8 +5497,8 @@ cdef class QuaternaryMatroid(LinearMatroid): EXAMPLES:: - sage: M = matroids.named_matroids.Q10()\'a' # needs sage.rings.finite_rings - sage: N = matroids.named_matroids.Q10()\'b' # needs sage.rings.finite_rings + sage: M = matroids.named_matroids.Q10().delete('a') # needs sage.rings.finite_rings + sage: N = matroids.named_matroids.Q10().delete('b') # needs sage.rings.finite_rings sage: M._fast_isom_test(N) is None # needs sage.rings.finite_rings True """ @@ -6182,8 +6182,8 @@ cdef class RegularMatroid(LinearMatroid): EXAMPLES:: - sage: M = matroids.named_matroids.R10()\'a' - sage: N = matroids.named_matroids.R10()\'b' + sage: M = matroids.named_matroids.R10().delete('a') + sage: N = matroids.named_matroids.R10().delete('b') sage: M._fast_isom_test(N) # needs sage.graphs True """ diff --git a/src/sage/matroids/matroid.pyx b/src/sage/matroids/matroid.pyx index 4d19c589bdf..2fc0129c2d1 100644 --- a/src/sage/matroids/matroid.pyx +++ b/src/sage/matroids/matroid.pyx @@ -280,7 +280,7 @@ Minors:: sage: M = Matroid(Matrix(QQ, [[1, 0, 0, 0, 1, 1, 1], ....: [0, 1, 0, 1, 0, 1, 1], ....: [0, 0, 1, 1, 1, 0, 1]])) - sage: N = M / [2] \ [3, 4] + sage: N = (M / [2]).delete([3, 4]) sage: sorted(N.groundset()) [0, 1, 5, 6] sage: N.full_rank() @@ -337,6 +337,7 @@ from itertools import combinations, product from sage.matrix.constructor import matrix from sage.misc.lazy_import import LazyImport from sage.misc.prandom import shuffle +from sage.misc.superseded import deprecation from sage.rings.integer_ring import ZZ from sage.structure.richcmp cimport rich_to_bool, richcmp from sage.structure.sage_object cimport SageObject @@ -2142,7 +2143,7 @@ cdef class Matroid(SageObject): sage: M = matroids.named_matroids.Fano().dual() sage: M.coloops() frozenset() - sage: (M \ ['a', 'b']).coloops() + sage: (M.delete(['a', 'b'])).coloops() frozenset({'f'}) """ return self._coclosure(set()) @@ -3475,7 +3476,7 @@ 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().delete(['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) @@ -3603,7 +3604,7 @@ 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().delete(['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) @@ -3907,7 +3908,8 @@ cdef class Matroid(SageObject): one. It can be shown that the resulting matroid does not depend on the order of the deletions. - Sage supports the shortcut notation ``M \ X`` for ``M.delete(X)``. + DEPRECATED: Sage supports the shortcut notation ``M \ X`` for + ``M.delete(X)``. INPUT: @@ -3932,7 +3934,7 @@ cdef class Matroid(SageObject): ['a', 'b', 'c', 'd', 'e', 'f', 'g'] sage: M.delete(['a', 'c']) Binary matroid of rank 3 on 5 elements, type (1, 6) - sage: M.delete(['a']) == M \ ['a'] + sage: M.delete(['a']) == M.delete(['a']) True One can use a single element, rather than a set:: @@ -3940,13 +3942,13 @@ cdef class Matroid(SageObject): sage: M = matroids.CompleteGraphic(4) # needs sage.graphs sage: M.delete(1) == M.delete([1]) # needs sage.graphs True - sage: M \ 1 # needs sage.graphs + sage: M.delete(1) # needs sage.graphs Graphic matroid of rank 3 on 5 elements Note that one can iterate over strings:: sage: M = matroids.named_matroids.Fano() - sage: M \ 'abc' + sage: M.delete('abc') Binary matroid of rank 3 on 4 elements, type (0, 5) The following is therefore ambiguous. Sage will delete the single @@ -3954,7 +3956,7 @@ cdef class Matroid(SageObject): sage: M = Matroid(groundset=['a', 'b', 'c', 'abc'], ....: bases=[['a', 'b', 'c'], ['a', 'b', 'abc']]) - sage: sorted((M \ 'abc').groundset()) + sage: sorted((M.delete('abc')).groundset()) ['a', 'b', 'c'] """ return self.minor(deletions=X) @@ -3963,12 +3965,17 @@ cdef class Matroid(SageObject): r""" Shorthand for ``self.delete(X)``. + DEPRECATED + EXAMPLES:: sage: M = matroids.CompleteGraphic(4) # needs sage.graphs sage: M.delete(1) == M \ 1 # indirect doctest # needs sage.graphs + doctest:...: DeprecationWarning: the backslash operator has been deprecated; use M.delete(X) instead + See https://github.com/sagemath/sage/issues/80000 for details. True """ + deprecation(80000, 'the backslash operator has been deprecated; use M.delete(X) instead') return self.delete(X) cpdef dual(self): @@ -4399,7 +4406,7 @@ cdef class Matroid(SageObject): `\{b, f\}`:: sage: M = matroids.named_matroids.S8() - sage: N = M \ 'h' + sage: N = M.delete('h') sage: frozenset('bf') in N.modular_cut(['cg', 'ae']) True @@ -4768,7 +4775,7 @@ cdef class Matroid(SageObject): sage: M = matroids.named_matroids.Fano().dual() sage: M.is_cosimple() True - sage: N = M \ 'a' + sage: N = M.delete('a') sage: N.is_cosimple() False """ @@ -4977,7 +4984,7 @@ cdef class Matroid(SageObject): sage: M.connectivity(X) 2 sage: J = M.groundset()-(S|T|I) - sage: N = M/I\J + sage: N = (M/I).delete(J) sage: N.connectivity(S) 2 """ @@ -5026,7 +5033,7 @@ cdef class Matroid(SageObject): sage: M.connectivity(X) 2 sage: J = M.groundset()-(S|T|I) - sage: N = M/I\J + sage: N = (M/I).delete(J) sage: N.connectivity(S) 2 """ diff --git a/src/sage/matroids/minor_matroid.py b/src/sage/matroids/minor_matroid.py index 98856348ac1..ff27affc665 100644 --- a/src/sage/matroids/minor_matroid.py +++ b/src/sage/matroids/minor_matroid.py @@ -14,11 +14,11 @@ EXAMPLES:: sage: M = matroids.named_matroids.Fano() - sage: M \ ['a', 'c' ] == M.delete(['a', 'c']) + sage: M.delete(['a', 'c' ]) == M.delete(['a', 'c']) True sage: M / 'a' == M.contract('a') True - sage: M / 'c' \ 'ab' == M.minor(contractions='c', deletions='ab') + sage: (M / 'c').delete('ab') == M.minor(contractions='c', deletions='ab') True If a contraction set is not independent (or a deletion set not coindependent), @@ -27,9 +27,9 @@ sage: M = matroids.named_matroids.Fano() sage: M.rank('abf') 2 - sage: M / 'abf' == M / 'ab' \ 'f' + sage: M / 'abf' == (M / 'ab').delete('f') True - sage: M / 'abf' == M / 'af' \ 'b' + sage: M / 'abf' == (M / 'af').delete('b') True .. SEEALSO:: diff --git a/src/sage/misc/misc.py b/src/sage/misc/misc.py index a4f8ebb826e..ba75dd92506 100644 --- a/src/sage/misc/misc.py +++ b/src/sage/misc/misc.py @@ -560,12 +560,20 @@ def __rmul__(self, left): ....: A = random_matrix(ZZ, 4) sage: B = random_matrix(ZZ, 4) sage: temp = A * BackslashOperator() + doctest:...: + DeprecationWarning: the backslash operator has been deprecated + See https://github.com/sagemath/sage/issues/80000 for details. sage: temp.left is A True sage: X = temp * B + doctest:...: + DeprecationWarning: the backslash operator has been deprecated; use A.solve_right(B) instead + See https://github.com/sagemath/sage/issues/80000 for details. sage: A * X == B True """ + from sage.misc.superseded import deprecation + deprecation(80000, 'the backslash operator has been deprecated') self.left = left return self @@ -577,15 +585,26 @@ def __mul__(self, right): sage: A = matrix(RDF, 5, 5, 2) sage: b = vector(RDF, 5, range(5)) sage: v = A \ b + doctest:...: + DeprecationWarning: the backslash operator has been deprecated; use A.solve_right(B) instead + See https://github.com/sagemath/sage/issues/80000 for details. sage: v.zero_at(1e-19) # On at least one platform, we get a "negative zero" (0.0, 0.5, 1.0, 1.5, 2.0) sage: v = A._backslash_(b) + doctest:...: + DeprecationWarning: the backslash operator has been deprecated; use A.solve_right(B) instead + See https://github.com/sagemath/sage/issues/80000 for details. sage: v.zero_at(1e-19) (0.0, 0.5, 1.0, 1.5, 2.0) sage: v = A * BackslashOperator() * b + doctest:...: + DeprecationWarning: the backslash operator has been deprecated; use A.solve_right(B) instead + See https://github.com/sagemath/sage/issues/80000 for details. sage: v.zero_at(1e-19) (0.0, 0.5, 1.0, 1.5, 2.0) """ + from sage.misc.superseded import deprecation + deprecation(80000, 'the backslash operator has been deprecated') return self.left._backslash_(right) diff --git a/src/sage/tests/books/computational-mathematics-with-sagemath/linalg_doctest.py b/src/sage/tests/books/computational-mathematics-with-sagemath/linalg_doctest.py index 5b99bdfa6ac..c2d51fb2f87 100644 --- a/src/sage/tests/books/computational-mathematics-with-sagemath/linalg_doctest.py +++ b/src/sage/tests/books/computational-mathematics-with-sagemath/linalg_doctest.py @@ -288,6 +288,8 @@ Sage example in ./linalg.tex, line 1855:: sage: A.solve_right(b) == A\b + doctest:...: DeprecationWarning: the backslash operator has been deprecated; use A.solve_right(B) instead + See https://github.com/sagemath/sage/issues/80000 for details. True Sage example in ./linalg.tex, line 1910:: diff --git a/src/sage/tests/books/computational-mathematics-with-sagemath/linsolve_doctest.py b/src/sage/tests/books/computational-mathematics-with-sagemath/linsolve_doctest.py index 7932167b41d..7c5b83423ea 100644 --- a/src/sage/tests/books/computational-mathematics-with-sagemath/linsolve_doctest.py +++ b/src/sage/tests/books/computational-mathematics-with-sagemath/linsolve_doctest.py @@ -49,7 +49,7 @@ sage: A = matrix(RDF, [[-1,2],[3,4]]) sage: b = vector(RDF, [2,3]) - sage: x = A\b; x + sage: x = A.solve_right(b); x (-0.20000000000000018, 0.9000000000000001) Sage example in ./linsolve.tex, line 666::