#17053: Add function for disjoint union and ordinal sum of posets
-------------------------------------+-------------------------------------
       Reporter:  jmantysalo         |        Owner:
           Type:  enhancement        |       Status:  needs_review
       Priority:  major              |    Milestone:  sage-wishlist
      Component:  combinatorics      |   Resolution:
       Keywords:                     |    Merged in:
        Authors:                     |    Reviewers:
Report Upstream:  N/A                |  Work issues:
         Branch:                     |       Commit:
  u/jmantysalo/add_function_for_direct_sum_of_posets|  
7a801e8d3045ef87d8a35d8491ed2e76b18d30a3
   Dependencies:                     |     Stopgaps:
-------------------------------------+-------------------------------------

Comment (by ncohen):

 > Works. But how to check if class of P is meet- or join-semilattice
 without ugly code like this?

 I am not sure that you can. The way you do it is wrong, however, for when
 you do `type(other) == type(MeetSemilattice({}))` you create a semilattice
 object for nothing. What you need is the 'isinstance' Python function.

 Then you will probably have to do something like that:

 {{{
 if isinstance(self, LatticePoset) and isinstance(other, LatticePoset):
    return a_lattice
 elif isinstance(self, MeetSemilattice) and isinstance(other,
 MeetSemilattice):
    return a_join_semilattice
 elif isinstance(self, JoinSemilattice) and isinstance(other,
 JoinSemilattice):
    return a_join_semilattice
 else:
    return a_poset
 }}}

 The 'if' will execute a bit more code than in your layout, but considering
 the operations involved here we do not care at all, the speed loss is
 nonexistent. And it is *much* clearer to read.

 Nathann

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

Reply via email to