#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:22 andrew.mathas]:
> One aspect of the options code that I don't like at the moment is that
some of the options are only accessible if you change or set the
corresponding global option. For example, there are five different options
for TeX-ing partitions (and friends) but there is no easy way for an
external class to access these individual options.
>
> I can see three alternatives here:
>
> 1. Don't worry about this and leave everything as it is.
> 1. Have the option as a optionable argument to the method using
something like:
> {{{#!python
> def _latex_(self, latex=None):
> if latex is None: latex=partition_options['latex']
> ...
> }}}
> This has the advantage that it won't be necessary to have a plethora of
minor variations for the different options of the method.
> 1. Implement each option as a separate method as has been done for
_repr_ and then define the optionable method using something like
> {{{#!python
> def _latex_(self):
> return getattr(self,'_latex_'+self.options['latex'])()
> }}}
> This has the advantage that you could check generically to see whether
an option was a valid option by checking
hasattr(self,'_latex_'+self.options['latex']) when the option is changed.
Since we are advertising (for lack of a better word) #3 as a general
design pattern, I'm going with that. Plus it makes easy to access a
particular latex output you want and is very extendable. I've done this
for `Partition` currently.
> The reason that I care about this is that I have a class which wants to
use particular TeX and display options for partitions -- namely, a class
for displaying matrices which which have rows and columns indexed by
particular partitions. As it is currently written, the only way that my
class will able to access the latex methods it wants is by playing silly
games with partition_options. As partitions and tableaux are widely used
as indices I would think that there will be other examples eventually.
However the major point of the options is so you can customize the output
to what you want. Since partitions would be the indices for your matrix, I
would want the matrix's indices output to depend on what I set in the
partition options. A place where you might want to call a specific latex
output would be something like a `StrictlyDecreasingIntegers` (I'm sorry
it's somewhat of a contrived example) class which would inherit from
`Partition` but only has meaning as a list.
> A second point, as above, I think that none of the "option clients"
should ever access partition_options and tableau_options directly. Rather,
they should call self.options() or self.parent().options() to do this.
Then how would you allow global access? I don't think these dictionaries
should be private (and/or name-mangled) to `Partitions` (and `Tableaux`)
because it indicates (to me) the options are only bound to `Partitions`,
and that they don't have a global impact (such as to `PartitionTuple`). I
think we should have the `option()` method to `PartitionTuples` and any
other class that wants access to options.
Actually, I just had a thought. I think we need an abstract class
`PartitionOptions` which holds the name-mangled dictionary and only
accessible through a method `options()`. Thus any class which wants to use
the partition options must also inherit from `PartitionOptions`.
(Similarly for `TableauxOptions` of course.) Is this what you were
thinking of?
Replying to [comment:23 andrew.mathas]:
> Another two questions:
>
> 1. In sage.combinat.tableau there is an optionable argument (currently
*order* but I will deprecate this to) *convention* which defaults to
"French". Now that there is a global option for choosing the *convention*
I think that the default *convention* here should be
`tableau_options['convention']`.
>
> Although I think that this sounds sensible one consequence of doing this
is that the default option will change from "French" to "English".
>
> What do you think?
I'm guessing you're referring to `from_shape_and_word()`. I thought about
this, and in an ideal world, the default argument would be `None` which
just pulls from the partition options. However, I'm thinking methods such
as `to_word()` should also do the same first.
Also somewhere in promotion in the crystals code uses this, and I think
(it was awhile ago) I tried overriding this back to French but it still
was broken. So I just left this alone.
> 2. Secondly, should skew_tableau and ribbon_tableau care about
tableau_options? This could just be added as a TODO:
Yes, and same for skew_partition (which doesn't have a proper latex method
yet...I probably should write this...) and ribbon.
Thanks,[[BR]]
Travis
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/13605#comment:24>
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.