#16707: Provide more useful error messages from categories
------------------------------+------------------------
Reporter: ppurka | Owner:
Type: defect | Status: new
Priority: critical | Milestone: sage-6.4
Component: categories | Resolution:
Keywords: | Merged in:
Authors: | Reviewers:
Report Upstream: N/A | Work issues:
Branch: | Commit:
Dependencies: | Stopgaps:
------------------------------+------------------------
Comment (by nthiery):
I am all for having more meaningful error messages. Finding what's
actually meaningfull is often hard however. So reports of the form "I
tried this, got this error message; this alternative other error message
would have been helpful" are very useful. Thanks! That's how I usually
improve the messages; by being bitten by them myself.
For the `element_class`: this is a general thing about conditionaly
defined lazy attributes. If we have them report an error (like `Element`
is required), then classes higher up in the hierarchy don't get a chance
to provide an alternative definition. Hence the NotImplemented protocol
for lazy attributes.
In the special case at hand, I could be convinced that no class above
`Parent` will provide `element_class`, and that we could report a message
(which one?) instead.
As for the fact that `element_class` appears in `dir` but is not
necessarily available: this is not really different from a method that
would raise a not implemented error upon being called, or is it?
Granted, looking up the documentation of the method is easier.
For `C.sum()`, it seems to me that the traceback is making it pretty clear
that it calls `C.zero`, and that the default implementation for the later
is to coerce in `0` which might, or not, be implemented:
{{{
sage: C.sum(())
---------------------------------------------------------------------------
NotImplementedError Traceback (most recent call
last)
<ipython-input-16-e76fdc39515c> in <module>()
----> 1 C.sum(())
/opt/sage-git/local/lib/python2.7/site-
packages/sage/categories/additive_monoids.pyc in sum(self, args)
67 True
68 """
---> 69 return sum(args, self.zero())
70
/opt/sage-git/local/lib/python2.7/site-packages/sage/misc/cachefunc.so in
sage.misc.cachefunc.CachedMethodCallerNoArgs.__call__
(build/cythonized/sage/misc/cachefunc.c:12263)()
/opt/sage-git/local/lib/python2.7/site-
packages/sage/categories/additive_magmas.pyc in zero(self)
707 """
708 # TODO: add a test that actually exercise this
default implementation
--> 709 return self(0)
710
711 def zero_element(self):
/opt/sage-git/local/lib/python2.7/site-packages/sage/structure/parent.so
in sage.structure.parent.Parent.__call__
(build/cythonized/sage/structure/parent.c:8685)()
NotImplementedError:
}}}
Now, if you think we should get rid of this default implementation of
`zero`, and replace it by an abstract method, please go for it: I find
coercing from `0` pretty ugly. I assume there are still a few parents
around that depend on it, so it might take a bit of work, but nothing
terrible.
Please keep on with futher suggestions of better error messages!
--
Ticket URL: <http://trac.sagemath.org/ticket/16707#comment:3>
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 unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.