Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
complete docstrings and 100% coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
dkrenn committed Aug 19, 2016
1 parent 4331957 commit dab4db8
Showing 1 changed file with 55 additions and 19 deletions.
74 changes: 55 additions & 19 deletions src/sage/combinat/k_regular_sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,19 @@ def __init__(self, parent, mu, left=None, right=None):
from the left to the matrix product. If ``None``, then this
multiplication is skipped.
When created via the parent :class:`kRegularSequence`, then
the following option is available.
- ``transpose`` -- (default: ``False``) a boolean. If set, then
each of the matrices in
:meth:`mu <sage.combinat.recognizable_series.RecognizableSeries.mu>`
is transposed. Additionally the vectors
:meth`left <sage.combinat.recognizable_series.RecognizableSeries.left>`
and
:meth:`right <sage.combinat.recognizable_series.RecognizableSeries.right>`
are switched.
(This is done by calling :meth:`~sage.combinat.recognizable_series.RecognizableSeries.transposed`.)
EXAMPLES::
sage: Seq2 = kRegularSequenceSpace(2, ZZ)
Expand All @@ -133,7 +146,7 @@ def _repr_(self):
OUTPUT:
A string
A string.
TESTS::
Expand Down Expand Up @@ -172,7 +185,14 @@ def __getitem__(self, n):
sage: S[7]
3
TESTS::
TESTS
sage: S[-1]
Traceback (most recent call last):
...
OverflowError: can't convert negative value to unsigned char
::
sage: Seq2 = kRegularSequenceSpace(2, ZZ)
sage: W = Seq2.indices()
Expand All @@ -185,13 +205,6 @@ def __getitem__(self, n):
True
sage: S._mu_of_word_(W(3.digits(2))) == M1^2
True
::
sage: S._product_of_mu_(-1)
Traceback (most recent call last):
...
ValueError: m=-1 is not a nonnegative integer.
"""
from sage.rings.integer_ring import ZZ
n = ZZ(n)
Expand Down Expand Up @@ -226,9 +239,35 @@ def __iter__(self):


class kRegularSequenceSpace(RecognizableSeriesSpace):
r"""
The space of `k`-regular Sequences over the given ``coefficients``.
INPUT:
- ``k`` -- an integer at least `2` specifying the base.
- ``coefficients`` -- a (semi-)ring. If not specified (``None``),
then the integer ring is used.
- ``category`` -- (default: ``None``) the category of this
space.
EXAMPLES::
sage: kRegularSequenceSpace(2, ZZ)
Space of 2-regular sequences over Integer Ring
sage: kRegularSequenceSpace(3, ZZ)
Space of 3-regular sequences over Integer Ring
.. SEEALSO::
:doc:`k-regular sequence <k_regular_sequence>`,
:class:`kRegularSequence`.
"""

Element = kRegularSequence


@classmethod
def __normalize__(cls, k, coefficients=None, **kwds):
r"""
Expand Down Expand Up @@ -257,21 +296,18 @@ def __normalize__(cls, k, coefficients=None, **kwds):
return (k,) + nargs


def __init__(self, k, coefficients, indices, category):
def __init__(self, k, *args, **kwds):
r"""
The space of `k`-regular Sequences over the given ``universe``.
See :class:`kRegularSequenceSpace` for details.
INPUT:
- ``k`` -- an integer at least `2` specifying the base.
- ``coefficients`` -- a (semi-)ring.
Other input arguments are passed on to
:meth:`~sage.combinat.recognizable_series.RecognizableSeriesSpace.__init__`.
- ``category`` -- (default: ``None``) the category of the
sequence space. If ``None``, then the category of
:class:`~sage.categories.sets_cat.Sets` is used.
EXAMPLES::
TESTS::
sage: kRegularSequenceSpace(2, ZZ)
Space of 2-regular sequences over Integer Ring
Expand All @@ -284,7 +320,7 @@ def __init__(self, k, coefficients, indices, category):
:class:`kRegularSequence`.
"""
self.k = k
super(kRegularSequenceSpace, self).__init__(coefficients, indices, category)
super(kRegularSequenceSpace, self).__init__(*args, **kwds)


def _repr_(self):
Expand All @@ -293,7 +329,7 @@ def _repr_(self):
OUTPUT:
A string
A string.
TESTS::
Expand Down

0 comments on commit dab4db8

Please sign in to comment.