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

Commit

Permalink
restructure and rewrite classcall and init of growth group
Browse files Browse the repository at this point in the history
  • Loading branch information
dkrenn committed Aug 28, 2015
1 parent ecf5ba8 commit 55d6ad3
Showing 1 changed file with 20 additions and 25 deletions.
45 changes: 20 additions & 25 deletions src/sage/rings/asymptotic/growth_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -1120,16 +1120,30 @@ def __classcall__(cls, base, var=None, category=None):
sage: L1 is L2
True
"""
from sage.categories.sets_cat import Sets
Sets_parent_class = Sets().parent_class
while issubclass(cls, Sets_parent_class):
cls = cls.__base__

if not isinstance(base, sage.structure.parent.Parent):
raise TypeError('%s is not a valid base.' % (base,))

if var is None:
var = Variable('')
elif not isinstance(var, Variable):
var = Variable(var)

if category is None:
from sage.categories.monoids import Monoids
from sage.categories.posets import Posets
category = Monoids() & Posets()

return super(GenericGrowthGroup, cls).__classcall__(
cls, base, var, category)


@sage.misc.superseded.experimental(trac_number=17601)
def __init__(self, base, var, category=None):
def __init__(self, base, var, category):
r"""
See :class:`GenericGrowthElement` for more information.
Expand Down Expand Up @@ -1168,56 +1182,37 @@ def __init__(self, base, var, category=None):
sage: G2 = agg.GenericGrowthGroup(ZZ, category=FiniteGroups() & Posets())
sage: G2.category()
Join of Category of finite groups and Category of finite posets
sage: G3 = agg.GenericGrowthGroup(ZZ, category=Rings())
Traceback (most recent call last):
...
ValueError: (Category of rings,) is not a subcategory of Join of Category of monoids and Category of posets
::
sage: G = agg.GenericGrowthGroup('42')
Traceback (most recent call last):
...
TypeError: 42 is not a valid base
TypeError: 42 is not a valid base.
::
sage: agg.MonomialGrowthGroup('x', ZZ)
Traceback (most recent call last):
...
ValueError: 'Integer Ring' is not a valid name for a variable.
TypeError: x is not a valid base.
sage: agg.MonomialGrowthGroup('x', 'y')
Traceback (most recent call last):
...
TypeError: x is not a valid base
TypeError: x is not a valid base.
::
sage: agg.ExponentialGrowthGroup('x', ZZ)
Traceback (most recent call last):
...
ValueError: 'Integer Ring' is not a valid name for a variable.
TypeError: x is not a valid base.
sage: agg.ExponentialGrowthGroup('x', 'y')
Traceback (most recent call last):
...
TypeError: x is not a valid base
TypeError: x is not a valid base.
"""
if not isinstance(base, sage.structure.parent.Parent):
raise TypeError('%s is not a valid base' % (base,))
from sage.categories.monoids import Monoids
from sage.categories.posets import Posets

if category is None:
category = Monoids() & Posets()
else:
if not isinstance(category, tuple):
category = (category,)
if not any(cat.is_subcategory(Monoids() & Posets()) for cat in
category):
raise ValueError('%s is not a subcategory of %s'
% (category, Monoids() & Posets()))

self._var_ = var
super(GenericGrowthGroup, self).__init__(category=category,
base=base)
Expand Down

0 comments on commit 55d6ad3

Please sign in to comment.