Skip to content
This repository was archived by the owner on Jan 30, 2023. It is now read-only.

Commit 139abc8

Browse files
rwstjdemeyer
authored andcommitted
Trac #10483: deprecate the misuse of symbolic variables as polynomial variable
Also-by: Simon King <[email protected]>
1 parent 92bafe2 commit 139abc8

File tree

8 files changed

+17
-20
lines changed

8 files changed

+17
-20
lines changed

src/sage/categories/rings.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -947,14 +947,7 @@ def __getitem__(self, arg):
947947
...
948948
TypeError: power series rings must have at least one variable
949949
950-
Some flexibility is allowed when specifying variables::
951-
952-
sage: QQ["x", SR.var('y'), polygen(CC, 'z')]
953-
Multivariate Polynomial Ring in x, y, z over Rational Field
954-
sage: QQ[["x", SR.var('y'), polygen(CC, 'z')]]
955-
Multivariate Power Series Ring in x, y, z over Rational Field
956-
957-
but more baroque expressions do not work::
950+
These kind of expressions do not work::
958951
959952
sage: QQ['a,b','c']
960953
Traceback (most recent call last):

src/sage/coding/linear_code.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3555,7 +3555,7 @@ def weight_enumerator(self, names=None, name2=None, bivariate=True):
35553555
sage: C.weight_enumerator(names="var1, var2")
35563556
var1^7 + 7*var1^4*var2^3 + 7*var1^3*var2^4 + var2^7
35573557
sage: (var1, var2) = var('var1, var2')
3558-
sage: C.weight_enumerator(names=(var1, var2))
3558+
sage: C.weight_enumerator(names=('var1', 'var2'))
35593559
var1^7 + 7*var1^4*var2^3 + 7*var1^3*var2^4 + var2^7
35603560
sage: C.weight_enumerator(bivariate=False)
35613561
x^7 + 7*x^4 + 7*x^3 + 1

src/sage/functions/piecewise.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -996,10 +996,10 @@ def trapezoid(cls, self, parameters, variable, N):
996996
sage: f.trapezoid(2)
997997
piecewise(y|-->1/2*y on (0, 1/2), y|-->3/2*y - 1/2 on (1/2, 1), y|-->7/2*y - 5/2 on (1, 3/2), y|-->-7/2*y + 8 on (3/2, 2); y)
998998
"""
999-
x = QQ[self.default_variable()].gen()
1000999
def func(x0, x1):
10011000
f0, f1 = self(x0), self(x1)
1002-
return [[(x0,x1),f0+(f1-f0)*(x1-x0)**(-1)*(x-x0)]]
1001+
return [[(x0,x1), f0 + (f1-f0) * (x1-x0)**(-1)
1002+
* (self.default_variable()-x0)]]
10031003
rsum = []
10041004
for domain, f in parameters:
10051005
for interval in domain:

src/sage/matrix/matrix2.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10983,7 +10983,7 @@ cdef class Matrix(Matrix1):
1098310983
sage: p, S = A.cyclic_subspace(v, var='T'); p
1098410984
T^3 - 9*T^2 + 24*T - 16
1098510985
sage: gen = polygen(QQ, 'z')
10986-
sage: p, S = A.cyclic_subspace(v, var=gen); p
10986+
sage: p, S = A.cyclic_subspace(v, var='z'); p
1098710987
z^3 - 9*z^2 + 24*z - 16
1098810988
sage: p.degree() == E.dimension()
1098910989
True

src/sage/rings/polynomial/polynomial_element.pyx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6654,9 +6654,10 @@ cdef class Polynomial(CommutativeAlgebraElement):
66546654
66556655
The following examples show that :trac:`11782` has been fixed::
66566656
6657-
sage: ZZ.quo(81)[x](3*x^2 + 3*x + 3).discriminant()
6657+
sage: x = var('x')
6658+
sage: ZZ.quo(81)['x'](3*x^2 + 3*x + 3).discriminant()
66586659
54
6659-
sage: ZZ.quo(9)[x](2*x^3 + x^2 + x).discriminant()
6660+
sage: ZZ.quo(9)['x'](2*x^3 + x^2 + x).discriminant()
66606661
2
66616662
66626663
This was fixed by :trac:`15422`::

src/sage/rings/polynomial/polynomial_ring_constructor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def PolynomialRing(base_ring, *args, **kwds):
7272
7373
- ``name`` -- a string
7474
75-
- ``names`` -- a list or tuple of names, or a comma separated string
75+
- ``names`` -- a list or tuple of names (strings), or a comma separated string
7676
7777
- ``var_array`` -- a list or tuple of names, or a comma separated string
7878

src/sage/rings/quotient_ring.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@
107107
# (at your option) any later version.
108108
# http://www.gnu.org/licenses/
109109
#*****************************************************************************
110+
110111
from __future__ import absolute_import
111112
from six.moves import range
112113

@@ -185,7 +186,9 @@ def QuotientRing(R, I, names=None):
185186
186187
::
187188
188-
sage: S = QuotientRing(QQ[x], QQ[x].ideal(x^2 - 2)); S
189+
sage: P.<x> = QQ[]
190+
sage: S.<xbar> = QuotientRing(P, P.ideal(x^2 - 2))
191+
sage: S
189192
Univariate Quotient Polynomial Ring in xbar over Rational Field with
190193
modulus x^2 - 2
191194
sage: xbar = S.gen(); S.gen()
@@ -197,7 +200,8 @@ def QuotientRing(R, I, names=None):
197200
198201
Sage coerces objects into ideals when possible::
199202
200-
sage: R = QuotientRing(QQ[x], x^2 + 1); R
203+
sage: P.<x> = QQ[]
204+
sage: R.<xbar> = QuotientRing(P, x^2 + 1); R
201205
Univariate Quotient Polynomial Ring in xbar over Rational Field with
202206
modulus x^2 + 1
203207

src/sage/rings/ring.pyx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -983,9 +983,8 @@ cdef class Ring(ParentWithGens):
983983
984984
Make sure :trac:`10481` is fixed::
985985
986-
sage: var(x)
987-
x
988-
sage: R.<a>=ZZ[x].quo(x^2)
986+
sage: x = var('x')
987+
sage: R.<a> = ZZ['x'].quo(x^2)
989988
sage: R.fraction_field()
990989
Traceback (most recent call last):
991990
...

0 commit comments

Comments
 (0)