#13605: Partition options and cleanup partitions documentation
-----------------------------------------------+----------------------------
Reporter: tscrim | Owner: sage-combinat
Type: enhancement | Status: needs_review
Priority: major | Milestone: sage-5.7
Component: combinatorics | Resolution:
Keywords: partition, options, output | Work issues:
Report Upstream: N/A | Reviewers: Andew Mathas
Authors: Travis Scrimshaw | Merged in:
Dependencies: #13074 #13762 #13840 #10193 | Stopgaps:
-----------------------------------------------+----------------------------
Comment (by tscrim):
Hey Andrew,
Replying to [comment:20 andrew.mathas]:
> Looking more at the orderings the following behaviour strikes me as
being counter intuitive and confusing:
>
> {{{
> sage: mu=Partition([5,4])
> sage: Partitions(order='dominance')(mu) in Partitions(9)
> True
> sage: Partitions(order='dominance')(mu) < Partitions(9)(mu)
>
---------------------------------------------------------------------------
> TypeError Traceback (most recent call
last)
> ...
> TypeError: orders must be the same
> }}}
>
> If the ordering really is "part" of the elements then, above, I think
that we should have the following behaviour:
> {{{
> sage: Partitions(order='dominance')(mu) in Partitions(9)
> False
> }}}
Good point. This should definitely be the correct behavior.
> Two other (minor) things that I don't like about the current way the
orderings are done are:
>
> * the name "lex" and '"rev_lex" should really be "lexicographic" and
"reverse lexicographic", but accept shorthands. Having order[:3] == 'lex'
etc would solve this.
> * I don't really like have to use ''Partitions(order="...")'' for some
orderings and ''reverse(Partitions(order="..."))'' for others. I think
that each of the ordering should allow a ''reverse'' modifier: so
''Partitions(order='dom')'' and ''Partitions(order='rev dom')'' should
both be OK.
As for the slowdown, I don't think it's not the if statements per-say, but
all of the string comparisons done. However from a code maintenance
standpoint, it might be better to do something like the following:
{{{#!python
def __init__(self, ...):
...
if order == 'lex':
__gt__ = compare_lex
elif order == 'dominance':
__gt__ = dominated
...
def __lt__(self, other):
return other.__lt__(self)
def __ge__(self, other):
if other == self:
return True
return self.__lt__(other)
}}}
and so on.
I've created a new ticket for the options at #14013 and will upload the
separated patches to the respective tickets along with the other requested
changes within a few days. Also here's a link to Andrew's topic on sage-
combinat-devel:
https://groups.google.com/forum/?fromgroups=#!topic/sage-combinat-
devel/40YJR38-VU0
Thanks,[[BR]]
Travis
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/13605#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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.