#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 jmantysalo):

 Replying to [comment:12 tscrim]:

 > Suppose you iterate over a collection of posets and you want to
 determine which of them are (semi)lattices. Then for those that are
 lattices, you do some extra processing on them. Being Pythonic (and to
 avoid double checking things), you just cast the poset to a lattice and do
 nothing if an error is thrown. That is where the slowdown comes in.

 You mean something like

 {{{
 n = 0
 for P in PP:
     try:
         if LatticePoset(P).cardinality() != 0:
             n += 1
     except:
         pass
 }}}

 where `PP` is precomputed list of posets. This error reporting is `O(1)`
 and checking if a poset is lattice is `O(n^2.5)`. So this would be a
 question only if most posets are non-lattices that are easily recognized
 (like a poset that is not bounded). I will run some timing on this.

 > > > Instead, I would just allow the error from calling
 `self._hasse_diagram.meet_matrix()` to propagate up.
 > >
 > > It is very irritating if the elements of the lattice are integers.
 Then we may got error saying that 5 and 8 have no meet, when actually it
 is 6 and 10 that have no meet.
 >
 > That is a good point. However, I would much rather have a less
 informative error message than the (IMO fugly) string parsing code you
 currently have. It seems like Volker's suggestion of doing a custom error
 class will be what you want (if you think it is important to see (only)
 one instance where the lattice property fails).

 I guess this conflicts with performance you cared in a paragraph just
 before this one `:=)`. I suppose creating an object is slower than
 manipulating a string.

 Actually I did a code using specific error class and tried to get comments
 on it, to be sure that I did nothing stupid. But as I got no comments, I
 decided to do this in a way that I know to work. (And added tests, so that
 if somebody changes the error string at `hasse_diagram.py` it will be
 noticed.)

--
Ticket URL: <http://trac.sagemath.org/ticket/19163#comment:13>
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.

Reply via email to