Ticket #10483: 10483deprecate_symbolics_in_polynomial_rings.patch

File 10483deprecate_symbolics_in_polynomial_rings.patch, 28.9 KB (added by SimonKing, 8 years ago)
  • sage/calculus/tests.py

    # HG changeset patch
    # User Simon King <simon.king@uni-jena.de>
    # Date 1292510934 -3600
    # Node ID 05f427146088f4bfb606d8f8b7ea0d95c4ca2246
    # Parent  04a2bc7a2cc25428a220769155bd81a1350651c1
    10483: Deprecate the use of non-strings as variable names in polynomial (quotient) rings
    
    diff -r 04a2bc7a2cc2 -r 05f427146088 sage/calculus/tests.py
    a b  
    4545
    4646A polynomial over a symbolic base ring::
    4747
    48     sage: R = SR[x]
     48    sage: R = SR['x']
    4949    sage: f = R([1/sqrt(2), 1/(4*sqrt(2))])
    5050    sage: f
    5151    1/8*sqrt(2)*x + 1/2*sqrt(2)   
  • sage/categories/algebra_ideals.py

    diff -r 04a2bc7a2cc2 -r 05f427146088 sage/categories/algebra_ideals.py
    a b  
    5353        """
    5454        EXAMPLES::
    5555
    56             sage: AlgebraIdeals(QQ[x]).algebra()
     56            sage: AlgebraIdeals(QQ['x']).algebra()
    5757            Univariate Polynomial Ring in x over Rational Field
    5858        """
    5959        return self.ambient()
     
    6363        """
    6464        EXAMPLES::
    6565
    66             sage: AlgebraIdeals(QQ[x]).super_categories()
     66            sage: AlgebraIdeals(QQ['x']).super_categories()
    6767            [Category of algebra modules over Univariate Polynomial Ring in x over Rational Field]
    6868        """
    6969        from algebra_modules import AlgebraModules
  • sage/categories/algebra_modules.py

    diff -r 04a2bc7a2cc2 -r 05f427146088 sage/categories/algebra_modules.py
    a b  
    7272        """
    7373        EXAMPLES::
    7474
    75             sage: AlgebraModules(QQ[x]).algebra()
     75            sage: AlgebraModules(QQ['x']).algebra()
    7676            Univariate Polynomial Ring in x over Rational Field
    7777        """
    7878        return self.base_ring()
     
    8282        """
    8383        EXAMPLES::
    8484
    85             sage: AlgebraModules(QQ[x]).super_categories()
     85            sage: AlgebraModules(QQ['x']).super_categories()
    8686            [Category of modules over Univariate Polynomial Ring in x over Rational Field]
    8787        """
    8888        R = self.algebra()
  • sage/categories/algebras.py

    diff -r 04a2bc7a2cc2 -r 05f427146088 sage/categories/algebras.py
    a b  
    5252
    5353        EXAMPLES::
    5454
    55             sage: QQ[x] in Algebras(QQ)
     55            sage: QQ['x'] in Algebras(QQ)
    5656            True
    5757
    5858            sage: QQ^3 in Algebras(QQ)
    5959            False
    60             sage: QQ[x] in Algebras(CDF)
     60            sage: QQ['x'] in Algebras(CDF)
    6161            False
    6262        """
    6363        if super(Algebras, self).__contains__(x):
  • sage/categories/commutative_algebra_ideals.py

    diff -r 04a2bc7a2cc2 -r 05f427146088 sage/categories/commutative_algebra_ideals.py
    a b  
    1919
    2020    EXAMPLES::
    2121
    22         sage: C = CommutativeAlgebraIdeals(QQ[x])
     22        sage: C = CommutativeAlgebraIdeals(QQ['x'])
    2323        sage: C
    2424        Category of commutative algebra ideals in Univariate Polynomial Ring in x over Rational Field
    2525    """
     
    4747
    4848        TESTS::
    4949
    50             sage: TestSuite(CommutativeAlgebraIdeals(QQ[x])).run()
     50            sage: TestSuite(CommutativeAlgebraIdeals(QQ['x'])).run()
    5151        """
    5252        # TODO: replace by ``A in CommutativeAlgebras(*)`` once a
    5353        # suitable mantra has been implemented for this.
     
    6161        """
    6262        EXAMPLES::
    6363
    64             sage: CommutativeAlgebraIdeals(QQ[x]).algebra()
     64            sage: CommutativeAlgebraIdeals(QQ['x']).algebra()
    6565            Univariate Polynomial Ring in x over Rational Field
    6666        """
    6767        return self.ambient()
     
    7171        """
    7272        EXAMPLES::
    7373
    74             sage: CommutativeAlgebraIdeals(QQ[x]).super_categories()
     74            sage: CommutativeAlgebraIdeals(QQ['x']).super_categories()
    7575            [Category of algebra ideals in Univariate Polynomial Ring in x over Rational Field]
    7676        """
    7777        from algebra_ideals import AlgebraIdeals
  • sage/categories/hopf_algebras_with_basis.py

    diff -r 04a2bc7a2cc2 -r 05f427146088 sage/categories/hopf_algebras_with_basis.py
    a b  
    117117        """
    118118        Returns an example of algebra with basis::
    119119
    120             sage: HopfAlgebrasWithBasis(QQ[x]).example()
     120            sage: HopfAlgebrasWithBasis(QQ['x']).example()
    121121            An example of Hopf algebra with basis: the group algebra of the Dihedral group of order 6 as a permutation group over Univariate Polynomial Ring in x over Rational Field
    122122
    123123        An other group can be specified as optional argument::
  • sage/combinat/sf/monomial.py

    diff -r 04a2bc7a2cc2 -r 05f427146088 sage/combinat/sf/monomial.py
    a b  
    132132        out = self.sum_of_terms((Partition(e), c)
    133133                                for (e,c) in f.dict().iteritems()
    134134                                if tuple(sorted(e)) == tuple(reversed(e)))
    135         if check and out.expand(f.parent().ngens(),f.parent().gens()) <> f:
     135        if check and out.expand(f.parent().ngens(),f.parent().variable_names()) <> f:
    136136            raise ValueError, "%s is not a symmetric polynomial"%f
    137137        return out
    138138
  • sage/combinat/sf/schur.py

    diff -r 04a2bc7a2cc2 -r 05f427146088 sage/combinat/sf/schur.py
    a b  
    119119         
    120120          EXAMPLES::
    121121
    122               sage: s = SFASchur(QQ[x])
     122              sage: s = SFASchur(QQ['x'])
    123123              sage: len(s([2,1])^8) # long time (~ 4 s)
    124124              1485
    125125              sage: len(s([2,1])^9) # long time (~10 s)
  • sage/combinat/sf/sf.py

    diff -r 04a2bc7a2cc2 -r 05f427146088 sage/combinat/sf/sf.py
    a b  
    432432
    433433        EXAMPLES:
    434434
    435             sage: Sym = SymmetricFunctions(QQ[x])
     435            sage: Sym = SymmetricFunctions(QQ['x'])
    436436            sage: p = Sym.p(); s = Sym.s()
    437437            sage: def t(x) : [(p,c)] = x; return [ (p,2*c), (p.conjugate(), c) ]
    438438            sage: f = sage.combinat.sf.sf.SymmetricaConversionOnBasis(t, p, s)
     
    446446
    447447    def __call__(self, partition):
    448448        """
    449             sage: Sym = SymmetricFunctions(QQ[x])
     449            sage: Sym = SymmetricFunctions(QQ['x'])
    450450            sage: p = Sym.p(); s = Sym.s()
    451451            sage: p[1] + s[1]                           # indirect doctest
    452452            2*p[1]
  • sage/crypto/lattice.py

    diff -r 04a2bc7a2cc2 -r 05f427146088 sage/crypto/lattice.py
    a b  
    170170        x = quotient.default_variable()
    171171        if n != quotient.degree(x): raise \
    172172            ValueError('ideal bases require n  = quotient.degree()')
    173         R = ZZ_q[x].quotient(quotient, x)
     173        R = ZZ_q[x if isinstance(x,basestring) else repr(x)].quotient(quotient, x if isinstance(x,basestring) else repr(x))
    174174        for i in range(m//n):
    175175            A = A.stack(R.random_element().matrix())
    176176
  • sage/matrix/matrix2.pyx

    diff -r 04a2bc7a2cc2 -r 05f427146088 sage/matrix/matrix2.pyx
    a b  
    15211521        cdef Matrix M  = <Matrix> self
    15221522        n  = M._ncols
    15231523        R  = M._base_ring
    1524         S  = PolynomialRing(R, var)
     1524        S  = PolynomialRing(R, [repr(x) for x in var])
    15251525       
    15261526        # Corner cases
    15271527        # N.B.  We already tested for M to be square, hence we do not need to
  • sage/matrix/matrix_symbolic_dense.pyx

    diff -r 04a2bc7a2cc2 -r 05f427146088 sage/matrix/matrix_symbolic_dense.pyx
    a b  
    370370        # det(xI-matrix), which is what Sage uses elsewhere.  We
    371371        # correct for the discrepancy.
    372372        cp = self._maxima_(maxima).charpoly(var)._sage_()
    373         cp = cp.expand().polynomial(None, ring=SR[var])
     373        cp = cp.expand().polynomial(None, ring=SR[repr(var)])
    374374        if self.nrows() % 2 == 1:
    375375            cp = -cp
    376376        return cp
  • sage/modules/free_module_element.pyx

    diff -r 04a2bc7a2cc2 -r 05f427146088 sage/modules/free_module_element.pyx
    a b  
    15521552       
    15531553        TESTS::
    15541554       
    1555             sage: x, y = var('x, y')
     1555            sage: x, y = 'x', 'y'
    15561556       
    15571557        ::
    15581558       
  • sage/rings/finite_rings/finite_field_base.pyx

    diff -r 04a2bc7a2cc2 -r 05f427146088 sage/rings/finite_rings/finite_field_base.pyx
    a b  
    537537
    538538        Although `f` is irreducible over the base field, we can double-check
    539539        whether or not `f` factors in `F` as follows. The command
    540         `F[x](f)` coerces `f` as a polynomial with coefficients in `F`.
     540        `F['x'](f)` coerces `f` as a polynomial with coefficients in `F`.
    541541        (Instead of a polynomial with coefficients over the base field.)
    542542
    543543        ::
    544544
    545545            sage: f.factor()
    546546            x^2 + 6*x + 3
    547             sage: F[x](f).factor()
     547            sage: F['x'](f).factor()
    548548            (x + a + 6) * (x + 6*a)
    549549
    550550        Here is an example with a degree 3 extension::
  • sage/rings/ideal.py

    diff -r 04a2bc7a2cc2 -r 05f427146088 sage/rings/ideal.py
    a b  
    646646        Note that this method is not implemented for all rings where it
    647647        could be::
    648648       
    649             sage: R = ZZ[x]
     649            sage: R.<x> = ZZ[]
    650650            sage: I = R.ideal(7)
    651651            sage: I.is_prime()        # when implemented, should be True
    652652            Traceback (most recent call last):
  • sage/rings/polynomial/multi_polynomial.pyx

    diff -r 04a2bc7a2cc2 -r 05f427146088 sage/rings/polynomial/multi_polynomial.pyx
    a b  
    436436        if R.ngens() <= 1:
    437437            return self.univariate_polynomial()
    438438
    439         other_vars = Z
     439        other_vars = [repr(v) for v in Z]
    440440        del other_vars[ind]
    441441         
    442442        # Make polynomial ring over all variables except var.
    443443        S = R.base_ring()[tuple(other_vars)]
    444         ring = S[var]
     444        ring = S[repr(var)]
    445445        if not self:
    446446            return ring(0)
    447447
  • sage/rings/polynomial/multi_polynomial_libsingular.pyx

    diff -r 04a2bc7a2cc2 -r 05f427146088 sage/rings/polynomial/multi_polynomial_libsingular.pyx
    a b  
    548548        , coercion from symbolic variables::
    549549
    550550            sage: x,y,z = var('x,y,z')
    551             sage: R = QQ[x,y,z]
     551            sage: R = QQ['x,y,z']
    552552            sage: R(x)
    553553            x
    554554
     
    44854485            #where the numerator of a polynomial over RationalField
    44864486            #is a polynomial over IntegerRing
    44874487            integer_polynomial_ring = MPolynomialRing_libsingular(ZZ,\
    4488             self.parent().ngens(), self.parent().gens(), order =\
     4488            self.parent().ngens(), self.parent().variable_names(), order =\
    44894489            self.parent().term_order())
    44904490            return integer_polynomial_ring(self * self.denominator())
    44914491        else:
  • sage/rings/polynomial/multi_polynomial_ring.py

    diff -r 04a2bc7a2cc2 -r 05f427146088 sage/rings/polynomial/multi_polynomial_ring.py
    a b  
    240240        Conversion from symbolic variables::
    241241       
    242242            sage: x,y,z = var('x,y,z')
    243             sage: R = QQ[x,y,z]
     243            sage: R = QQ['x,y,z']
    244244            sage: type(x)
    245245            <type 'sage.symbolic.expression.Expression'>
    246246            sage: type(R(x))
     
    257257       
    258258        ::
    259259       
    260             sage: R = QQ[x,y,z]
    261260            sage: f = (x^3 + y^3 - z^3)^10; f
    262261            (x^3 + y^3 - z^3)^10
    263262            sage: g = R(f); parent(g)
  • sage/rings/polynomial/polynomial_element.pyx

    diff -r 04a2bc7a2cc2 -r 05f427146088 sage/rings/polynomial/polynomial_element.pyx
    a b  
    13701370            sage: f^3
    13711371            x^3 - 3*x^2 + 3*x - 1           
    13721372       
    1373             sage: R = PolynomialRing(GF(2), x)
     1373            sage: R = GF(2)['x']
    13741374            sage: f = R(x^9 + x^7 + x^6 + x^5 + x^4 + x^2 + x)
    13751375            sage: h = R(x^10 + x^7 + x^6 + x^5 + x^4 + x^3 + x^2 + 1)
    13761376            sage: pow(f, 2, h)
  • sage/rings/polynomial/polynomial_ring.py

    diff -r 04a2bc7a2cc2 -r 05f427146088 sage/rings/polynomial/polynomial_ring.py
    a b  
    211211       
    212212    def _element_constructor_(self, x=None, check=True, is_gen = False, construct=False, **kwds):
    213213        r"""
    214         Coerce ``x`` into this univariate polynomial ring,
     214        Convert ``x`` into this univariate polynomial ring,
    215215        possibly non-canonically.
    216216       
    217217        Stacked polynomial rings coerce into constants if possible. First,
     
    269269       
    270270            sage: x = var('x')
    271271            sage: R = IntegerModRing(4)
    272             sage: S = PolynomialRing(R, x)
     272            sage: S = R['x']
    273273            sage: S(x)
    274274            x
    275275        """
  • sage/rings/polynomial/polynomial_ring_constructor.py

    diff -r 04a2bc7a2cc2 -r 05f427146088 sage/rings/polynomial/polynomial_ring_constructor.py
    a b  
    6767
    6868    - ``base_ring`` -- a commutative ring
    6969    - ``name`` -- a string
    70     - ``names`` -- a list or tuple of names, or a comma separated string
     70    - ``names`` -- a list or tuple of names (strings), or a comma separated string
    7171    - ``n`` -- an integer
    7272    - ``sparse`` -- bool (default: False), whether or not elements are sparse
    7373    - ``order`` -- string or
     
    8181    - ``implementation`` -- string or None; selects an implementation in cases
    8282      where Sage includes multiple choices (currently `\ZZ[x]` can be
    8383      implemented with 'NTL' or 'FLINT'; default is 'FLINT')
    84                  
     84
     85    REMARK:
     86
     87    In earlier versions of Sage, the names have not necessarily been
     88    strings. Some users provided a symbolic variable instead of a string,
     89    and expected that this symbolic variable is the same as the generator
     90    of the resulting polynomial ring, which is of course not the case.
     91    This common mistake is now deprecated.
     92
    8593    OUTPUT:
    8694
    8795    ``PolynomialRing(base_ring, name, sparse=False)`` returns a univariate
     
    299307        Defining x2, x3, x5, x7, x11, x13, x17, x19, x23, x29, x31, x37, x41, x43, x47, x53, x59, x61, x67, x71, x73, x79, x83, x89, x97       
    300308        sage: (x2 + x41 + x71)^2
    301309        x2^2 + 2*x2*x41 + x41^2 + 2*x2*x71 + 2*x41*x71 + x71^2
     310
     311    TESTS:
     312
     313    We test that the common misuse of symbolic expressions and other
     314    objects as variable names is now deprecated (trac ticket #10483)::
     315
     316        sage: x = var('x')
     317        sage: R = PolynomialRing(ZZ,[x,singular])
     318        doctest:...: DeprecationWarning: (Since Sage Version 4.6.1) Variable name 'x' should be a string, but we obtained <type 'sage.symbolic.expression.Expression'>.
     319        In an interactive session, you should use a definition of the form 'R.<x,y,z>=QQ[]'.
     320        doctest:...: DeprecationWarning: (Since Sage Version 4.6.1) Variable name 'Singular' should be a string, but we obtained <class 'sage.interfaces.singular.Singular'>.
     321        In an interactive session, you should use a definition of the form 'R.<x,y,z>=QQ[]'.
     322
    302323    """
    303324    import sage.rings.polynomial.polynomial_ring as m
    304325
     326    from sage.misc.misc import deprecation
    305327    if is_Element(arg1) and not isinstance(arg1, (int, long, Integer)):
     328        deprecation("The second argument (%s) should be a string, a list or tuple of strings or an integer, but not %s.\nIn an interactive session, you should use a definition of the form 'R.<x,y,z>=QQ[]"%(arg1,type(arg1)),'Sage Version 4.6.1')
    306329        arg1 = repr(arg1)
    307330    if is_Element(arg2) and not isinstance(arg2, (int, long, Integer)):
     331        deprecation("The third argument (%s) should be a string, a list or tuple of strings or an integer, but not %s.\nIn an interactive session, you should use a definition of the form 'R.<x,y,z>=QQ[]"%(arg2,type(arg2)),'Sage Version 4.6.1')
    308332        arg2 = repr(arg2)
    309333
    310334    if isinstance(arg1, (int, long, Integer)):
     
    323347
    324348    R = None
    325349    if isinstance(arg1, (list, tuple)):
     350        for foo in arg1:
     351            if not isinstance(foo,basestring):
     352                deprecation("Variable name '%s' should be a string, but we obtained %s.\nIn an interactive session, you should use a definition of the form 'R.<x,y,z>=QQ[]'."%(foo,type(foo)),'Sage Version 4.6.1')
    326353        arg1 = [str(x) for x in arg1]
    327354    if isinstance(arg2, (list, tuple)):
     355        for foo in arg2:
     356            if not isinstance(foo,basestring):
     357                deprecation("Variable name '%s' should be a string, but we obtained %s.\nIn an interactive session, you should use a definition of the form 'R.<x,y,z>=QQ[]'."%(foo,type(foo)),'Sage Version 4.6.1')
    328358        arg2 = [str(x) for x in arg2]
    329359    if isinstance(arg2, (int, long, Integer)):
    330360        # 3. PolynomialRing(base_ring, names, n, order='degrevlex'):
    331         if not isinstance(arg1, (list, tuple, str)):
     361        if not isinstance(arg1, (list, tuple, basestring)):
    332362            raise TypeError, "You *must* specify the names of the variables."
    333363        n = int(arg2)
    334364        names = arg1
     
    338368        if not ',' in arg1:
    339369            # 1. PolynomialRing(base_ring, name, sparse=False):
    340370            if not arg2 is None:
    341                 raise TypeError, "if second arguments is a string with no commas, then there must be no other non-optional arguments"
     371                raise TypeError, "if the second argument is a string with no commas, then there must be no other non-optional arguments"
    342372            name = arg1
    343373            R = _single_variate(base_ring, name, sparse, implementation)
    344374        else:
  • sage/rings/quotient_ring.py

    diff -r 04a2bc7a2cc2 -r 05f427146088 sage/rings/quotient_ring.py
    a b  
    4040    polynomial ring).  If ``names`` isn't given, 'bar' will be appended to
    4141    the variable names in `R`.
    4242   
    43     INPUTS:
     43    INPUT:
    4444
    45     - ``R`` - a commutative ring
     45    - ``R`` - a commutative ring.
    4646
    47     - ``I`` - an ideal of R
     47    - ``I`` - an ideal of R.
    4848
    49     - ``names`` - a list of
    50       strings to be used as names for the variables in the quotient ring
    51       `R/I`
     49    - ``names`` - a list of strings to be used as names for the variables
     50      in the quotient ring `R/I`.
    5251   
    53     OUTPUTS: `R/I` - the quotient ring `R` mod the ideal `I`
     52    REMARK:
     53
     54    In earlier versions of Sage, the names have not necessarily been
     55    strings. Some users provided a symbolic variable instead of a string,
     56    and expected that this symbolic variable is the same as the generator
     57    of the resulting quotient ring, which is of course not the case.
     58    This common mistake is now deprecated.
     59
     60    OUTPUT:
     61
     62    `R/I` - the quotient ring `R` mod the ideal `I`
    5463   
    5564    EXAMPLES:
    5665
     
    7786   
    7887    ::
    7988   
    80         sage: R.<xx> = QuotientRing(QQ[x], QQ[x].ideal(x^2 + 1)); R
     89        sage: R.<xx> = QuotientRing(QQ['x'], QQ['x'].ideal(x^2 + 1)); R
    8190        Univariate Quotient Polynomial Ring in xx over Rational Field with modulus x^2 + 1
    8291        sage: R.gens(); R.gen()
    8392        (xx,)
     
    9099   
    91100    ::
    92101   
    93         sage: S = QuotientRing(QQ[x], QQ[x].ideal(x^2 - 2)); S
     102        sage: S = QuotientRing(QQ['x'], QQ['x'].ideal(x^2 - 2)); S
    94103        Univariate Quotient Polynomial Ring in xbar over Rational Field with
    95104        modulus x^2 - 2
    96105        sage: xbar = S.gen(); S.gen()
     
    102111   
    103112    Sage coerces objects into ideals when possible::
    104113   
    105         sage: R = QuotientRing(QQ[x], x^2 + 1); R
     114        sage: R = QuotientRing(QQ['x'], x^2 + 1); R
    106115        Univariate Quotient Polynomial Ring in xbar over Rational Field with
    107116        modulus x^2 + 1
    108117   
     
    125134        d
    126135        -1
    127136        -d
     137
     138    TESTS:
     139
     140    We test that the common misuse of symbolic expressions and other
     141    objects as variable names is now deprecated (trac ticket #10483)::
     142
     143        sage: P.<a,b> = QQ[]
     144        sage: x = var('x')
     145        sage: Q = P.quotient(P*[a*b],[x,singular])
     146        doctest:...: DeprecationWarning: (Since Sage Version 4.6.1) Variable name 'x' should be a string, but we obtained <type 'sage.symbolic.expression.Expression'>.
     147        In an interactive session, you should use a definition of the form 'Q.<x,y,z>=R.quo(I)'.
     148        doctest:...: DeprecationWarning: (Since Sage Version 4.6.1) Variable name 'Singular' should be a string, but we obtained <class 'sage.interfaces.singular.Singular'>.
     149        In an interactive session, you should use a definition of the form 'Q.<x,y,z>=R.quo(I)'.
     150        doctest:...: DeprecationWarning: (Since Sage Version 4.6.1) Names must be a string or a list or tuple of strings, but 'x' is <type 'sage.symbolic.expression.Expression'>
     151        doctest:...: DeprecationWarning: (Since Sage Version 4.6.1) Names must be a string or a list or tuple of strings, but 'Singular' is <class 'sage.interfaces.singular.Singular'>
    128152    """
    129153    if not isinstance(R, commutative_ring.CommutativeRing):
    130154        raise TypeError, "R must be a commutative ring."
    131155    if names is None:
    132156        names = tuple([x + 'bar' for x in R.variable_names()])
    133157    else:
     158        if not isinstance(names, (list,tuple,basestring)):
     159            raise TypeError, "The variable names must be given by a list or tuple of strings."
     160        from sage.misc.misc import deprecation
     161        for foo in names:
     162            if not isinstance(foo,basestring):
     163                deprecation("Variable name '%s' should be a string, but we obtained %s.\nIn an interactive session, you should use a definition of the form 'Q.<x,y,z>=R.quo(I)'."%(foo,type(foo)),'Sage Version 4.6.1')
    134164        names = sage.structure.parent_gens.normalize_names(R.ngens(), names)
    135165    if not isinstance(I, ideal.Ideal_generic) or I.ring() != R:
    136166        I = R.ideal(I)
     
    482512            sage: R.is_noetherian()
    483513            True
    484514
    485             sage: R = QuotientRing(QQ[x], x^2+1)
     515            sage: R = QuotientRing(QQ['x'], x^2+1)
    486516            sage: R.is_noetherian()
    487517            True
    488518
     
    521551       
    522552        ::
    523553       
    524             sage: Q = QuotientRing(QQ[x], x^2 + 1)
     554            sage: Q = QuotientRing(QQ['x'], x^2 + 1)
    525555            sage: Q.cover_ring()
    526556            Univariate Polynomial Ring in x over Rational Field
    527557        """
  • sage/structure/element.pyx

    diff -r 04a2bc7a2cc2 -r 05f427146088 sage/structure/element.pyx
    a b  
    13441344
    13451345        Here we test (scalar * vector) multiplication::
    13461346
    1347             sage: x, y = var('x, y')
     1347            sage: x, y = 'x', 'y'
    13481348
    13491349            sage: parent(ZZ(1)*vector(ZZ,[1,2]))
    13501350            Ambient free module of rank 2 over the principal ideal domain Integer Ring
     
    18821882
    18831883        Here we test (vector * vector) multiplication::
    18841884
    1885             sage: x, y = var('x, y')
     1885            sage: x, y = 'x', 'y'
    18861886           
    18871887            sage: parent(vector(ZZ,[1,2])*vector(ZZ,[1,2]))
    18881888            Integer Ring
     
    21292129
    21302130        Here we test (matrix * matrix) multiplication::
    21312131
    2132             sage: x, y = var('x, y')
     2132            sage: x, y = 'x', 'y'
    21332133
    21342134            sage: parent(matrix(ZZ,2,2,[1,2,3,4])*matrix(ZZ,2,2,[1,2,3,4]))
    21352135            Full MatrixSpace of 2 by 2 dense matrices over Integer Ring
  • sage/structure/parent_gens.pyx

    diff -r 04a2bc7a2cc2 -r 05f427146088 sage/structure/parent_gens.pyx
    a b  
    129129    return PY_TYPE_CHECK(x, ParentWithMultiplicativeAbelianGens)
    130130
    131131def _certify_names(names):
     132    """
     133    Test that the argument provides a list of valid variable names.
     134
     135    INPUT:
     136
     137    ``names`` - A string or a list or tuple of strings
     138
     139    OUTPUT:
     140
     141    A tuple of variable names obtained from ``names``.
     142
     143    TESTS::
     144
     145        sage: from sage.structure.parent_gens import _certify_names
     146        sage: _certify_names('abc')
     147        ('a', 'b', 'c')
     148
     149    Test that a certain usage is deprecated (trac ticket #10483)::
     150
     151        sage: _certify_names([singular,gap])
     152        doctest:...: DeprecationWarning: (Since Sage Version 4.6.1) Names must be a string or a list or tuple of strings, but 'Singular' is <class 'sage.interfaces.singular.Singular'>
     153        doctest:...: DeprecationWarning: (Since Sage Version 4.6.1) Names must be a string or a list or tuple of strings, but 'Gap' is <class 'sage.interfaces.gap.Gap'>
     154        ('Singular', 'Gap')
     155
     156    """
    132157    v = []
    133158    try:
    134159        names = tuple(names)
    135160    except TypeError:
     161        if not isinstance(names, str):
     162            from sage.misc.misc import deprecation
     163            deprecation("Names must be a string or a list or tuple of strings, but '%s' is %s"%(names,type(names)), 'Sage Version 4.6.1')
    136164        names = [str(names)]
    137165    for N in names:
    138166        if not isinstance(N, str):
     167            from sage.misc.misc import deprecation
     168            deprecation("Names must be a string or a list or tuple of strings, but '%s' is %s"%(N,type(N)), 'Sage Version 4.6.1')
    139169            N = str(N)
    140170        N = N.strip().strip("'")
    141171        if len(N) == 0:
  • sage/symbolic/expression.pyx

    diff -r 04a2bc7a2cc2 -r 05f427146088 sage/symbolic/expression.pyx
    a b  
    44264426       
    44274427        ::
    44284428       
    4429             sage: R = QQ[x,y,z]
     4429            sage: R = QQ['x,y,z']
    44304430            sage: R(x^2 + y)
    44314431            x^2 + y
    4432             sage: R = QQ[w]
     4432            sage: R = QQ['w']
    44334433            sage: R(w^3 + w + 1)
    44344434            w^3 + w + 1
    4435             sage: R = GF(7)[z]
     4435            sage: R = GF(7)['z']
    44364436            sage: R(z^3 + 10*z)
    44374437            z^3 + 3*z
    44384438       
     
    44434443       
    44444444        ::
    44454445       
    4446             sage: R = SR[x]
     4446            sage: R = SR['x']
    44474447            sage: a = R(sqrt(2) + x^3 + y)
    44484448            sage: a
    44494449            y + sqrt(2) + x^3
     
    44564456       
    44574457            sage: f = e*x^3 + pi*y^3 + sqrt(2) + I; f
    44584458            pi*y^3 + x^3*e + sqrt(2) + I
    4459             sage: R = CDF[x,y]
     4459            sage: R.<x,y> = CDF[]
    44604460            sage: R(f)
    44614461            2.71828182846*x^3 + 3.14159265359*y^3 + 1.41421356237 + 1.0*I
    44624462       
     
    44644464       
    44654465        ::
    44664466       
    4467             sage: R = ComplexField(100)[x,y]
     4467            sage: R = ComplexField(100)['x,y']
    44684468            sage: R(f)
    44694469            2.7182818284590452353602874714*x^3 + 3.1415926535897932384626433833*y^3 + 1.4142135623730950488016887242 + 1.0000000000000000000000000000*I
    44704470
  • sage/symbolic/expression_conversions.py

    diff -r 04a2bc7a2cc2 -r 05f427146088 sage/symbolic/expression_conversions.py
    a b  
    871871            self.base_ring = base_ring
    872872        elif base_ring is not None:
    873873            self.base_ring = base_ring
    874             vars = self.ex.variables()
     874            vars = [repr(x) for x in self.ex.variables()]
    875875            if len(vars) == 0:
    876876                vars = ['x']
    877877            from sage.rings.all import PolynomialRing
  • sage/symbolic/relation.py

    diff -r 04a2bc7a2cc2 -r 05f427146088 sage/symbolic/relation.py
    a b  
    832832    if modulus < 1:
    833833         raise ValueError, "the modulus must be a positive integer"
    834834    vars = list(set(sum([list(e.variables()) for e in eqns], [])))
    835     vars.sort(cmp = lambda x,y: cmp(repr(x), repr(y)))
     835    #vars.sort(cmp = lambda x,y: cmp(repr(x), repr(y)))
     836    vars = [repr(x) for x in vars]
     837    vars.sort()
    836838    n = len(vars)
    837839    R = Integers(modulus)
    838840    S = PolynomialRing(R, len(vars), vars)