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

Commit

Permalink
creation of element via parent method for ring
Browse files Browse the repository at this point in the history
  • Loading branch information
dkrenn committed Aug 30, 2015
1 parent 5408f6d commit 8730ab8
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 3 deletions.
34 changes: 34 additions & 0 deletions src/sage/rings/asymptotic/asymptotic_ring.py
Original file line number Diff line number Diff line change
Expand Up @@ -1482,6 +1482,40 @@ def _create_empty_summands_():
merge=absorption)


def _create_element_via_parent_(self, term, old_parent=None):
r"""
Create an element with a possibly other parent.
INPUT:
- ``term`` -- the element data.
- ``old_parent`` -- the parent of ``term`` is compared to this parent.
OUTPUT:
An element.
sage: from sage.rings.asymptotic.term_monoid import TermMonoid
sage: from sage.rings.asymptotic.growth_group import GrowthGroup
sage: G = GrowthGroup('z^ZZ')
sage: T = TermMonoid('exact', G, ZZ)
sage: T._create_element_via_parent_(G.an_element(), 3, G, ZZ)
3*z
sage: T._create_element_via_parent_(G.an_element(), 3/2, G, ZZ).parent()
Exact Term Monoid z^ZZ with coefficients in Rational Field
"""
if old_parent is None or term.parent() is old_parent:
parent = self
else:
# Insert an 'if' here once terms can have different
# coefficient rings, as this will be for L-terms.
parent = self.change_parameter(
growth_group=term.parent().growth_group,
coefficient_ring=term.parent().coefficient_ring)
return parent(term, simplify=False, convert=False)


def _element_constructor_(self, data, simplify=True, convert=True):
r"""
Convert a given object to this asymptotic ring.
Expand Down
3 changes: 2 additions & 1 deletion src/sage/rings/asymptotic/growth_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -1401,7 +1401,8 @@ def _create_element_via_parent_(self, raw_element, old_parent=None):
- ``raw_element`` -- the element data.
- ``old_parent`` -- the parent of ``raw_element`` is compared to ``old_parent``.
- ``old_parent`` -- the parent of ``raw_element`` is compared
to this parent.
OUTPUT:
Expand Down
6 changes: 4 additions & 2 deletions src/sage/rings/asymptotic/term_monoid.py
Original file line number Diff line number Diff line change
Expand Up @@ -1423,9 +1423,11 @@ def _create_element_via_parent_(self, growth, coefficient,
INPUT:
- ``raw_element`` -- the element data.
- ``growth`` and ``coefficient`` -- the element data.
- ``old_parent`` -- the parent of ``raw_element`` is compared to ``old_parent``.
- ``old_parent_growth`` and ``old_parent_coefficient`` -- the
parents of ``growth`` and ``coefficient`` are compared to
these parents.
OUTPUT:
Expand Down

0 comments on commit 8730ab8

Please sign in to comment.