Miscellaneous Functions#

sage.combinat.species.misc.accept_size(f)[source]#

The purpose of this decorator is to change calls like species.SetSpecies(size=1) to species.SetSpecies(min=1, max=2). This is to make caching species easier and to restrict the number of parameters that the lower level code needs to know about.

EXAMPLES:

sage: from sage.combinat.species.misc import accept_size
sage: def f(*args, **kwds):
....:       print("{} {}".format(args, sorted(kwds.items())))
sage: f = accept_size(f)
sage: f(min=1)
() [('min', 1)]
sage: f(size=2)
() [('max', 3), ('min', 2)]
>>> from sage.all import *
>>> from sage.combinat.species.misc import accept_size
>>> def f(*args, **kwds):
...       print("{} {}".format(args, sorted(kwds.items())))
>>> f = accept_size(f)
>>> f(min=Integer(1))
() [('min', 1)]
>>> f(size=Integer(2))
() [('max', 3), ('min', 2)]
sage.combinat.species.misc.change_support(perm, support, change_perm=None)[source]#

Changes the support of a permutation defined on [1, …, n] to support.

EXAMPLES:

sage: from sage.combinat.species.misc import change_support
sage: p = PermutationGroupElement((1,2,3)); p
(1,2,3)
sage: change_support(p, [3,4,5])
(3,4,5)
>>> from sage.all import *
>>> from sage.combinat.species.misc import change_support
>>> p = PermutationGroupElement((Integer(1),Integer(2),Integer(3))); p
(1,2,3)
>>> change_support(p, [Integer(3),Integer(4),Integer(5)])
(3,4,5)