The following code breaks (on sage.math:8101)
R, (x, y) = PolynomialRing(QQ, 2, 'xy').objgens()
S, t = PowerSeriesRing(R, 't').objgen()
t*(x+y)
with a long stack trace:
Traceback (most recent call last):
File "", line 1, in
File "/home/server2/sage_notebook/worksheets/ncalexan/code/79.py",
line 6, in
t*(x+y)
File "/sage-1.5/local/lib/python2.5/", line 1, in
File "element.pyx", line 983, in element.RingElement.__mul__
File "element.pyx", line 1728, in element.bin_op_c
File "element.pyx", line 1669, in element.canonical_coercion_c
File "parent.pyx", line 110, in parent.Parent._coerce_c
File
"/sage-1.5/local/lib/python2.5/site-packages/sage/rings/power_series_ring.py",
line 280, in _coerce_impl
return self._coerce_try(x, [self.__poly_ring, self.base_ring()])
File "parent.pyx", line 143, in parent.Parent._coerce_try
File "parent.pyx", line 98, in parent.Parent._coerce_
File "parent.pyx", line 110, in parent.Parent._coerce_c
File
"/sage-1.5/local/lib/python2.5/site-packages/sage/rings/polynomial_ring.py",
line 185, in _coerce_impl
return self._coerce_try(x, [self.base_ring()])
File "parent.pyx", line 144, in parent.Parent._coerce_try
File
"/sage-1.5/local/lib/python2.5/site-packages/sage/rings/polynomial_ring.py",
line 154, in __call__
return x.univariate_polynomial(self)
File
"/sage-1.5/local/lib/python2.5/site-packages/sage/rings/multi_polynomial_element.py",
line 733, in univariate_polynomial
raise ValueError, "polynomial must involve at most one variable"
ValueError: polynomial must involve at most one variable
The problem seems to be that the coercion fundamentally doesn't like
multivariate polynomials -- there's a call to univariate_polynomial in
there :) Can someone patch this or point at docs explaining the new
coercion model so I can try to figure out what is supposed to happen?
Also, I believe the following bug is a manifestation of a similar
coercion problem:
R, (x, y) = PolynomialRing(QQ, 2, 'xy').objgens()
S, t = PowerSeriesRing(R, 't').objgen()
(x**2 + 3*x + 2)*t
results in
2*t + 3*t^2 + t^3
It appears that x gets coerced to a univariate polynomial in t. This
might be fixed by changing the ordering of coerce target rings in
power_series_ring.py:280 from
280 return self._coerce_try(x, [self.__poly_ring,
self.base_ring()])
to
280 return self._coerce_try(x, [self.base_ring(),
self.__poly_ring])
However, should x be coerced to t at any point? This is a question for
the coercion model docs.
Cheers,
Nick Alexander
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://sage.scipy.org/sage/ and http://modular.math.washington.edu/sage/
-~----------~----~----~----~------~----~------~--~---