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

Commit

Permalink
variable_names
Browse files Browse the repository at this point in the history
  • Loading branch information
dkrenn committed Aug 21, 2015
1 parent 18a292a commit f43d197
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 1 deletion.
36 changes: 36 additions & 0 deletions src/sage/rings/asymptotic/growth_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -1213,6 +1213,23 @@ def gens_monomial(self):
" implementations.")


def variable_names(self):
r"""
Return the names of the variables.
OUTPUT:
A tuple of strings.
EXAMPLES::
sage: import sage.rings.asymptotic.growth_group as agg
sage: agg.GenericGrowthGroup(ZZ).variable_names()
()
"""
return tuple()


CartesianProduct = CartesianProductGrowthGroups


Expand Down Expand Up @@ -1870,6 +1887,25 @@ def ngens(self):
return len(self.gens())


def variable_names(self):
r"""
Return the names of the variables.
OUTPUT:
A tuple of strings.
EXAMPLES::
sage: from sage.rings.asymptotic.growth_group import GrowthGroup
sage: GrowthGroup('x^ZZ').variable_names()
('x',)
sage: GrowthGroup('log(x)^ZZ').variable_names()
('x',)
"""
return self._var_.variable_names()


class GrowthGroupFactory(sage.structure.factory.UniqueFactory):
r"""
A factory creating asymptotic growth groups.
Expand Down
23 changes: 22 additions & 1 deletion src/sage/rings/asymptotic/growth_group_cartesian.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def create_object(self, version, growth_groups, **kwds):

# check if multivariate and all have distinct single variables
vg = tuple((g.variable_names(), g) for g in growth_groups)
vars = add(iter(v for v, _ in vg), tuple())
vars = sum(iter(v for v, _ in vg), tuple())
if len(vars) != len(set(vars)):
raise ValueError('Growth groups %s do not have distinct variables.' %
growth_groups)
Expand Down Expand Up @@ -313,6 +313,27 @@ def gens_monomial(self):
return t


def variable_names(self):
r"""
Return the names of the variables.
OUTPUT:
A tuple of strings.
EXAMPLES::
sage: from sage.rings.asymptotic.growth_group import GrowthGroup
sage: GrowthGroup('x^ZZ * log(x)^ZZ * y^QQ * log(z)^ZZ').variable_names()
('x', 'y', 'z')
"""
vars = sum(iter(factor.variable_names()
for factor in self.cartesian_factors()),
tuple())
from itertools import groupby
return tuple(v for v, _ in groupby(vars))


class Element(CartesianProductPosets.Element):
def _repr_(self):
r"""
Expand Down

0 comments on commit f43d197

Please sign in to comment.