# Revision history [back]

This (mainly) comes from the construction of your univariate polynomial ring. Compare

sage: R1 = PolynomialRing(QQ, 'x'); R1
Univariate Polynomial Ring in x over Rational Field
sage: R2 = PolynomialRing(QQ, 1, 'x'); R2
Multivariate Polynomial Ring in x over Rational Field


This means that if you explicitly give the number of variables, the polynomial ring is considered as a multivariate one (in this case a "one-variable multivariate polynomial ring") while if you don't, it is considered a univariate polynomial ring. As a consequence, R1 and R2 in my example use two completely distinct implementations.

Now you can do what you need:

sage: P = PolynomialRing(QQ, 1, 'x', order = TermOrder('wdegrevlex', (2,)))
sage: P.inject_variables()
Defining x
sage: x.degree()
2


Note the two changes: 1. add the number of variables ; 2. change (2) into (2,). The second change is due to the fact that TermOrder needs a tuple, and (2) is an integer for Python while (2,) is a 1-tuple containing an integer.

It is a pity that you did not get any warning: In my sense, you should have been told that order = ... has no effect for a univariate polynomial ring, and that TermOrder(...) requires a tuple rather than an integer.