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

Commit

Permalink
__classcall__ and __init__
Browse files Browse the repository at this point in the history
  • Loading branch information
dkrenn committed Aug 10, 2016
1 parent 1e5efc8 commit c14eceb
Showing 1 changed file with 52 additions and 4 deletions.
56 changes: 52 additions & 4 deletions src/sage/combinat/k_regular_sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,20 +294,68 @@ class kRegularSequenceSpace(UniqueRepresentation, Parent):

Element = kRegularSequence

def __init__(self, k, base, category=None):
@staticmethod
def __classcall__(cls, k, universe=None, category=None):
r"""
Normalizes the input in order to ensure a unique
representation.
For more information see :class:`kRegularSequenceSpace`.
TESTS::
sage: Seq2 = kRegularSequenceSpace(2, ZZ)
sage: Seq2
Space of 2-regular sequences over Integer Ring
sage: Seq2.category()
Category of sets
::
sage: Seq2 is kRegularSequenceSpace(2)
True
"""
if universe is None:
from sage.rings.integer_ring import ZZ
universe = ZZ

from sage.categories.sets_cat import Sets
category = category or Sets()

return super(kRegularSequenceSpace, cls).__classcall__(
cls, k, universe, category)


def __init__(self, k, universe, category):
r"""
The space of `k`-regular Sequences over the given ``universe``.
INPUT:
- ``k`` -- an integer at least `2` specifying the base.
- ``universe`` -- (default: ``None``) a object (e.g. a SageMath parent)
in which the entries of a sequence live.
If ``None``, then the integer ring `\ZZ` is used.
- ``category`` -- (default: ``None``) the category of the
sequence space. If ``None``, then the category of
:class:`~sage.categories.sets_cat.Sets` is used.
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`.
"""
self.k = k
self.universe = universe
super(kRegularSequenceSpace, self).__init__(
category=category or Sets(), base=base)
category=category, base=universe)


def _repr_(self):
Expand Down

0 comments on commit c14eceb

Please sign in to comment.