#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: catching the right errors |
------------------------------------------------+---------------------------
Changes (by mstreng):
* status: needs_review => needs_work
* work_issues: documentation, double code => catching the right errors
Comment:
On line 1903 you check if the message is "is_square() got an unexpected
keyword argument 'root'", but you should also check for "is_square() takes
no keyword arguments", which happens for 5.sqrt(root = True). This
behaviour should have a good doctest.
After catching a ValueError, line 1904 says:
raise NotImplementedError("Please implement is_square with option 'root =
True' for %s" % type(self))
The ValueError may have been raised by another object than self. For
example, if self has an is_square(root = True), but calls b.is_square(root
= root) of another object b. In that case, this message is misleading: it
says that self.is_square(root = True) should be implemented, while it is
already well implemented and it is in fact b.is_square(root = True) that
should be implemented. You can replace the message by the following:
raise NotImplementedError("Please implement sqrt() for objects of type %s"
% type(self))
Can you get examples where these errors are raised and add them to the
doctests?
Alternatively, you can either
* make sure "is_square" exists for CommutativeRingElement and "is_square"
has a keyword argument "root" for every subclass of CommutativeRingElement
(you'll be writing NotImplementedError a lot :) and should check for
tickets that implement the root = True behaviour). This seems to be a lot
more stable than the current approach.
* or bring back the double-code version with the same sqrt() function in
two distinct classes.
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/9094#comment:21>
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.