#9094: is_square and sqrt for polynomials and fraction fields
---------------------------------------------------------------------------------------+
Reporter: robertwb
| Owner: AlexGhitza
Type: enhancement
| Status: needs_work
Priority: major
| Milestone: sage-4.5.2
Component: algebra
| Keywords:
Author: Robert Bradshaw, Maarten Derickx
| Upstream: N/A
Reviewer: John Cremona, Marco Streng
| Merged:
Work_issues: make general sqrt compatible with lazy reals, or go back to
double code |
---------------------------------------------------------------------------------------+
Changes (by mstreng):
* work_issues: catching the right errors => make general sqrt compatible
with lazy reals, or go back to double
code
Comment:
Are you sure you did a complete doctest of sage before submitting the
patch?
{{{
sage: QuadraticField(2, 'a')
NotImplementedError: Please implement is_square with option 'root = True'
for <type 'sage.rings.real_lazy.LazyWrapper'>
}}}
The problem is in RLF(2).sqrt()
{{{
sage: RLF(2).sqrt()
NotImplementedError: Please implement is_square with option 'root = True'
for <type 'sage.rings.real_lazy.LazyWrapper'>
}}}
RLF(2) is a LazyWrapper, which doesn't have a sqrt attribute, but
simulates one via __getattr__ (line 631 of sage/rings/real_lazy.pyx). But
LazyWrapper extends (via some other classes) CommutativeRingElement, so
that now it does have an attribute sqrt (your sqrt function), which means
the __getattr__ of LazyWrapper doesn't get a chance. Your sqrt function
then complains about the non-existence of is_square with root = 'True'.
You can probably fix this by making a sqrt function for LazyWrapper that
calls LazyNamedUnop(self._parent, self, 'sqrt'). Or you can follow your
own advice: "implement is_square with option 'root = True' for ....".
Maybe there is a better way, you can also ask one of the mailing lists.
Alternatively, you can always go back to your double code.
Anyway, every time before submitting a patch, do everything that a
reviewer would do, including a full doctest of all of Sage:
[http://www.sagemath.org/doc/developer/walk_through.html#reviewing-a-patch]
On a multi-core machine, you can speed up the doctest by using
{{{./sage -tp 4 -long devel/sage-main/}}}
where 4 is replaced by the number of cores you are willing to use.
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/9094#comment:22>
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.