#12040: Lack of comparisons between polydic.ETuple and tuples and consequences
-----------------------------+----------------------------------------------
Reporter: kohel | Owner: was
Type: defect | Status: new
Priority: major | Milestone: sage-4.8
Component: number theory | Keywords:
Work_issues: | Upstream: N/A
Reviewer: | Author: David Kohel
Merged: | Dependencies:
-----------------------------+----------------------------------------------
sage: P.<t> = PolynomialRing(QQ)
sage: F.<a> = FractionField(P)
sage: Pxy.<x,y> = PolynomialRing(F,2)
sage: f = y^2 - x*(x-1)*(x-2)
sage: E = EllipticCurve(f)
---------------------------------------------------------------------------
TypeError Traceback (most recent call
last)
/Users/kohel/<ipython console> in <module>()
/usr/local/sage/local/lib/python2.6/site-
packages/sage/schemes/elliptic_curves/constructor.pyc in EllipticCurve(x,
y, j)
235 if f.degree() != 3:
236 raise ValueError, "Elliptic curves must be defined by
a cubic polynomial."
--> 237 if f.degrees() == (3,2):
238 x, y = f.parent().gens()
239 elif f.degree() == (2,3):
/usr/local/sage/local/lib/python2.6/site-
packages/sage/rings/polynomial/polydict.so in
sage.rings.polynomial.polydict.ETuple.__richcmp__
(sage/rings/polynomial/polydict.c:11114)()
TypeError: Argument 'other' has incorrect type (expected
sage.rings.polynomial.polydict.ETuple, got tuple)
The problem arises from the type of the return argument for f.degrees():
sage: type(f.degrees())
<type 'sage.rings.polynomial.polydict.ETuple'>
In contrast for a polynomial over QQ:
sage: Pxy.<x,y> = PolynomialRing(QQ,2)
sage: f = y^2 - x*(x-1)*(x-2)
sage: type(f.degrees())
<type 'tuple'>
The elliptic curve example above is a red herring, except to show that
this unexpected and inconsistent return type is likely to create major
issues elsewhere. I can imagine a resolution to this particular issue by
defining a coercion from tuples so that the comparison does not fail, but
someone knowledgeable about the design of polynomial rings and/or
coercions needs to look at this. Note that a coercion does exist and
parent(x.degrees())((1,0)) == x.degrees() returns True.
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/12040>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
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-trac?hl=en.