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

Commit 09c2670

Browse files
Frederic Chapotonvbraun
Frederic Chapoton
authored andcommitted
trac #14814 review patch (minor details)
1 parent aeea9a1 commit 09c2670

File tree

1 file changed

+16
-21
lines changed

1 file changed

+16
-21
lines changed

src/sage/rings/multi_power_series_ring_element.py

+16-21
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@
151151
152152
"""
153153

154-
155154
#*****************************************************************************
156155
# Copyright (C) 2010 Niles Johnson <[email protected]>
157156
#
@@ -164,7 +163,6 @@
164163
from sage.rings.polynomial.all import is_PolynomialRing
165164
from sage.rings.power_series_ring import is_PowerSeriesRing
166165

167-
from sage.rings.all import ZZ
168166
from sage.rings.integer import Integer
169167
from sage.rings.finite_rings.integer_mod_ring import Zmod
170168

@@ -392,7 +390,8 @@ def __init__(self, parent, x=0, prec=infinity, is_gen=False, check=False):
392390
#self._value = x
393391
self._bg_value = parent._send_to_bg(x).add_bigoh(prec)
394392
except (TypeError, AttributeError):
395-
raise TypeError("Input does not coerce to any of the expected rings.")
393+
raise TypeError("Input does not coerce to any of the "
394+
"expected rings.")
396395

397396
self._go_to_fg = parent._send_to_fg
398397
self._prec = self._bg_value.prec()
@@ -789,6 +788,8 @@ def trailing_monomial(self):
789788
"""
790789
Return the trailing monomial of ``self``
791790
791+
This is defined here as the lowest term of the underlying polynomial.
792+
792793
EXAMPLE::
793794
794795
sage: R.<a,b,c> = PowerSeriesRing(ZZ)
@@ -809,7 +810,7 @@ def trailing_monomial(self):
809810

810811
def quo_rem(self, other):
811812
r"""
812-
Quotient and remainder for increassing power division
813+
Quotient and remainder for increasing power division
813814
814815
INPUT: ``other`` - an element of the same power series ring as ``self``
815816
@@ -851,11 +852,10 @@ def quo_rem(self, other):
851852
ZeroDivisionError
852853
"""
853854
if other.parent() is not self.parent():
854-
raise ValueError, "Don't know how to divide by a element of %s"%(other.parent())
855+
raise ValueError("Do not know how to divide by a element of %s" % (other.parent()))
855856
other_tt = other.trailing_monomial()
856857
if not other_tt:
857858
raise ZeroDivisionError()
858-
mprec = min(self.prec(), other.prec())
859859
rem = self.parent().zero().add_bigoh(self.prec())
860860
quo = self.parent().zero().add_bigoh(self.prec()-other.valuation())
861861
while self:
@@ -900,7 +900,7 @@ def _div_(self, denom_r):
900900
sage: f/(a*f)
901901
Traceback (most recent call last):
902902
...
903-
ValueError: Not divisible
903+
ValueError: not divisible
904904
905905
An example where one looses precision::
906906
@@ -918,7 +918,7 @@ def _div_(self, denom_r):
918918
return self*~denom_r
919919
quo, rem = self.quo_rem(denom_r)
920920
if rem:
921-
raise ValueError("Not divisible")
921+
raise ValueError("not divisible")
922922
else:
923923
return quo
924924

@@ -981,8 +981,6 @@ def __mod__(self, other):
981981
return self.change_ring(Zmod(other))
982982
raise NotImplementedError("Mod on multivariate power series ring elements not defined except modulo an integer.")
983983

984-
985-
986984
def dict(self):
987985
"""
988986
Return underlying dictionary with keys the exponents and values the
@@ -1216,7 +1214,6 @@ def add_bigoh(self, prec):
12161214
"""
12171215
return self.parent(self._bg_value.add_bigoh(prec))
12181216

1219-
12201217
def O(self, prec):
12211218
"""
12221219
Return a multivariate power series of total precision obtained
@@ -1341,7 +1338,6 @@ def is_nilpotent(self):
13411338
else:
13421339
return False
13431340

1344-
13451341
def degree(self):
13461342
"""
13471343
Return degree of underlying polynomial of ``self``.
@@ -1485,7 +1481,7 @@ def integral(self, *args):
14851481
If the base ring is not a field (e.g. `ZZ`), or if it has a non
14861482
zero characteristic, (e.g. `ZZ/3ZZ`), integration is not always
14871483
possible, while staying with the same base ring. In the first
1488-
case, Sage will report that it hasn't been able to coerce some
1484+
case, Sage will report that it has not been able to coerce some
14891485
coefficient to the base ring::
14901486
14911487
sage: T.<a,b> = PowerSeriesRing(ZZ,2)
@@ -1564,15 +1560,16 @@ def _integral(self, xx):
15641560
R = P.base_ring()
15651561
xx = P(xx)
15661562
if not xx.is_gen():
1567-
for g in P.gens(): # try to find a generator equal to xx
1563+
for g in P.gens(): # try to find a generator equal to xx
15681564
if g == xx:
15691565
xx = g
15701566
break
15711567
else:
1572-
raise ValueError, "%s is not a variable"%(xx)
1568+
raise ValueError("%s is not a variable" % xx)
15731569
xxe = xx.exponents()[0]
1574-
pos = [i for i, c in enumerate(xxe) if c != 0][0] # get the position of the variable
1575-
res = { mon.eadd(xxe) : R(co / (mon[pos]+1)) for mon, co in self.dict().iteritems() }
1570+
pos = [i for i, c in enumerate(xxe) if c != 0][0] # get the position of the variable
1571+
res = {mon.eadd(xxe): R(co / (mon[pos]+1))
1572+
for mon, co in self.dict().iteritems()}
15761573
return P( res ).add_bigoh(self.prec()+1)
15771574

15781575
def ogf(self):
@@ -1749,7 +1746,7 @@ def exp(self, prec=infinity):
17491746
OUTPUT:
17501747
17511748
The exponentiated multivariate power series as a new
1752-
multivaritate power series.
1749+
multivariate power series.
17531750
17541751
EXAMPLES::
17551752
@@ -1840,7 +1837,7 @@ def log(self, prec=infinity):
18401837
OUTPUT:
18411838
18421839
The logarithm of the multivariate power series as a new
1843-
multivaritate power series.
1840+
multivariate power series.
18441841
18451842
EXAMPLES::
18461843
@@ -1986,5 +1983,3 @@ def __pow__(self, prec):
19861983
if self._vars != parent.gens():
19871984
raise NotImplementedError
19881985
return self._vars[0].parent()(0,prec)
1989-
1990-

0 commit comments

Comments
 (0)