Skip to content

Commit ee239b1

Browse files
Merge pull request #143 from edgarcosta/showgood
pass *args and **kwargs into str methods for all a{r,c}b_* and expand goodstr domain
2 parents 9a165cd + 998b33d commit ee239b1

File tree

4 files changed

+8
-10
lines changed

4 files changed

+8
-10
lines changed

src/flint/flint_base/flint_base.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,15 @@ cdef class flint_poly(flint_elem):
4848
"""
4949
return list(self)
5050

51-
def str(self, bint ascending=False):
51+
def str(self, bint ascending=False, *args, **kwargs):
5252
"""
5353
Convert to a human-readable string (generic implementation for
5454
all polynomial types).
5555
5656
If *ascending* is *True*, the monomials are output from low degree to
5757
high, otherwise from high to low.
5858
"""
59-
coeffs = [str(c) for c in self]
59+
coeffs = [c.str(*args, **kwargs) for c in self]
6060
if not coeffs:
6161
return "0"
6262
s = []

src/flint/functions/showgood.pyx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,9 @@ cdef goodstr(x):
3232
return "(" + ", ".join(goodstr(y) for y in x) + ")"
3333
if isinstance(x, list):
3434
return "[" + ", ".join(goodstr(y) for y in x) + "]"
35-
if isinstance(x, arb):
36-
return x.str(radius=False)
37-
if isinstance(x, acb):
35+
if isinstance(x, (arb, acb, arb_mat, acb_mat, arb_poly, acb_poly, arb_series, acb_series)):
3836
return x.str(radius=False)
39-
raise TypeError("must have arb or acb")
37+
raise TypeError("must be a element/tuple/list of arb, acb, arb_mat, acb_mat, arb_poly, acb_poly, arb_series, or acb_series")
4038

4139
def good(func, slong prec=0, slong maxprec=0, slong dps=0,
4240
slong maxdps=0, slong padding=10, bint verbose=False, bint show=False, bint parts=True, metric=None):

src/flint/types/acb_series.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@ cdef class acb_series(flint_series):
9393
def repr(self, **kwargs):
9494
return "acb_series([%s], prec=%s)" % (", ".join(map(str, self)), self.prec)
9595

96-
def str(self, **kwargs):
96+
def str(self, *args, **kwargs):
9797
if self.prec > 0:
98-
s = acb_poly(list(self)).str(ascending=True)
98+
s = acb_poly(list(self)).str(ascending=True, *args, **kwargs)
9999
return s + (" + O(x^%s)" % self.prec)
100100
elif self.prec == 0:
101101
return "O(x^0)"

src/flint/types/arb_series.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ cdef class arb_series(flint_series):
8888
def repr(self, **kwargs):
8989
return "arb_series([%s], prec=%s)" % (", ".join(map(str, self)), self.prec)
9090

91-
def str(self, **kwargs):
91+
def str(self, *args, **kwargs):
9292
if self.prec > 0:
93-
s = arb_poly(list(self)).str(ascending=True)
93+
s = arb_poly(list(self)).str(ascending=True, *args, **kwargs)
9494
return s + (" + O(x^%s)" % self.prec)
9595
elif self.prec == 0:
9696
return "O(x^0)"

0 commit comments

Comments
 (0)