#19163: LatticePoset creation: Empty argument, better error reporting
-------------------------------------+-------------------------------------
Reporter: jmantysalo | Owner:
Type: enhancement | Status: needs_review
Priority: minor | Milestone: sage-7.1
Component: combinatorics | Resolution:
Keywords: | Merged in:
Authors: Jori Mäntysalo | Reviewers:
Report Upstream: N/A | Work issues:
Branch: | Commit:
u/jmantysalo/latticeposet_creation__empty_argument__better_error_reporting|
b42c0e7cabca4264e55291ff5e6114d1d00a0a7b
Dependencies: | Stopgaps:
-------------------------------------+-------------------------------------
Comment (by tscrim):
Thanks for doing those timings. I didn't expect too much of a penalty, but
if we can have cleaner and less fragile code with extra speed, then why
shouldn't we?
I would say the lack of response for your question (if it was "Am I doing
something stupid?") is a strong indication that you are not. Personally, I
don't think we need to include this in the error message as pdb can be
used, but I'm neutral if we add it responsibly.
In more detail, the fragility comes from the fact that we have to rewrite
this error message if the underlying error message changes wording. By
having a custom class, it means we can easily change the message without
having to rewrite this (essentially unrelated) code.
Also, the `int(error.message.split()[3][2:])` creates many, many new
transient objects: the `split`, in and of itself, creates a new list, plus
the `int`, plus each of the strings in the split. However I was thinking
of doing a catch-and-release with the error message by simply updating the
two elements of said message. So the error class would look something like
this:
{{{#!python
class LatticeException(ValueError):
def __init__(self, fail, x, y):
ValueError.__init__(self, None)
self.fail = fail
self.x = x
self.y = y
def __str__(self):
return "no {} for {} and {}".format(self.fail, self.x, self.y)
}}}
The result would look like this:
{{{
sage: raise LatticeException('meet', 5, 2)
---------------------------------------------------------------------------
LatticeException Traceback (most recent call
last)
<ipython-input-20-626aad3b7a17> in <module>()
----> 1 raise LatticeException('meet', Integer(5), Integer(2))
LatticeException: no meet for 5 and 2
}}}
--
Ticket URL: <http://trac.sagemath.org/ticket/19163#comment:15>
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 https://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.