Skip to content

Commit

Permalink
fixing also multi power series and adding gens methods
Browse files Browse the repository at this point in the history
  • Loading branch information
fchapoton committed Sep 29, 2024
1 parent ad1cc55 commit 1480abb
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 5 deletions.
22 changes: 18 additions & 4 deletions src/sage/rings/multi_power_series_ring.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,8 @@
from sage.rings.polynomial.multi_polynomial_ring import MPolynomialRing_base
from sage.rings.polynomial.term_order import TermOrder
from sage.rings.power_series_ring import PowerSeriesRing, PowerSeriesRing_generic
from sage.rings.ring import CommutativeRing
from sage.structure.nonexact import Nonexact
from sage.structure.parent import Parent

from sage.categories.commutative_rings import CommutativeRings
_CommutativeRings = CommutativeRings()
Expand Down Expand Up @@ -389,8 +389,9 @@ def __init__(self, base_ring, num_gens, name_list,
# Multivariate power series rings inherit from power series rings. But
# apparently we can not call their initialisation. Instead, initialise
# CommutativeRing and Nonexact:
CommutativeRing.__init__(self, base_ring, name_list, category=_IntegralDomains if base_ring in
_IntegralDomains else _CommutativeRings)
Parent.__init__(self, base=base_ring, names=name_list,
category=_IntegralDomains if base_ring in
_IntegralDomains else _CommutativeRings)
Nonexact.__init__(self, default_prec)

# underlying polynomial ring in which to represent elements
Expand Down Expand Up @@ -1005,7 +1006,7 @@ def gen(self, n=0):
if n < 0 or n >= self._ngens:
raise ValueError("Generator not defined.")
#return self(self._poly_ring().gens()[int(n)])
return self.element_class(parent=self,x=self._poly_ring().gens()[int(n)], is_gen=True)
return self.element_class(parent=self, x=self._poly_ring().gens()[int(n)], is_gen=True)

def ngens(self):
"""
Expand All @@ -1019,6 +1020,19 @@ def ngens(self):
"""
return self._ngens

def gens(self):
"""
Return the generators of this ring.
EXAMPLES::
sage: M = PowerSeriesRing(ZZ, 3, 'v')
sage: M.gens()
(v0, v1, v2)
"""

return tuple(self.gen(i) for i in range(self._ngens))

def prec_ideal(self):
"""
Return the ideal which determines precision; this is the ideal
Expand Down
14 changes: 13 additions & 1 deletion src/sage/rings/power_series_ring.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ def is_PowerSeriesRing(R):
return False


class PowerSeriesRing_generic(UniqueRepresentation, ring.CommutativeRing, Nonexact):
class PowerSeriesRing_generic(UniqueRepresentation, Parent, Nonexact):
"""
A power series ring.
"""
Expand Down Expand Up @@ -1100,6 +1100,18 @@ def gen(self, n=0):
raise IndexError("generator n>0 not defined")
return self.__generator

def gens(self):
"""
Return the generators of this ring.
EXAMPLES::
sage: R.<t> = PowerSeriesRing(ZZ)
sage: R.gens()
(t,)
"""
return (self.__generator,)

def uniformizer(self):
"""
Return a uniformizer of this power series ring if it is
Expand Down

0 comments on commit 1480abb

Please sign in to comment.