Skip to content

Commit 47d6c8e

Browse files
committed
Replace series __eq__ -> _equal_repr
1 parent 9c168ce commit 47d6c8e

File tree

3 files changed

+115
-163
lines changed

3 files changed

+115
-163
lines changed

src/flint/fmpq_series.pyx

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,6 @@ cdef fmpq_series_coerce_operands(x, y):
1919
return acb_series(x), acb_series(y)
2020
return NotImplemented, NotImplemented
2121

22-
cdef any_as_fmpq_series(obj):
23-
if typecheck(obj, fmpq_series):
24-
return obj
25-
if typecheck(obj, fmpz_series):
26-
return fmpq_series(obj)
27-
return NotImplemented
28-
2922
cdef class fmpq_series(flint_series):
3023

3124
cdef fmpq_poly_t val
@@ -69,21 +62,13 @@ cdef class fmpq_series(flint_series):
6962
raise ZeroDivisionError("cannot create fmpq_series with zero denominator")
7063
fmpq_poly_scalar_div_fmpz(self.val, self.val, (<fmpz>den).val)
7164

72-
def __richcmp__(s, t, int op):
65+
def _equal_repr(s, t):
7366
cdef bint r
74-
if op != 2 and op != 3:
75-
raise TypeError("series cannot be ordered")
76-
s = any_as_fmpq_series(s)
77-
if t is NotImplemented:
78-
return s
79-
t = any_as_fmpq_series(t)
80-
if t is NotImplemented:
81-
return t
67+
if not typecheck(t, fmpq_series):
68+
return False
8269
r = fmpq_poly_equal((<fmpq_series>s).val, (<fmpq_series>t).val)
8370
if r:
8471
r = (<fmpq_series>s).prec == (<fmpq_series>t).prec
85-
if op == 3:
86-
r = not r
8772
return r
8873

8974
def __len__(self):

src/flint/fmpz_series.pyx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,17 +68,13 @@ cdef class fmpz_series(flint_series):
6868
fmpz_poly_set_list(self.val, [val])
6969
fmpz_poly_truncate(self.val, max(0, self.prec))
7070

71-
def __richcmp__(self, other, int op):
71+
def _equal_repr(self, other):
7272
cdef bint r
73-
if op != 2 and op != 3:
74-
raise TypeError("series cannot be ordered")
75-
if not (typecheck(self, fmpz_series) and typecheck(other, fmpz_series)):
76-
return NotImplemented
73+
if not typecheck(other, fmpz_series):
74+
return False
7775
r = fmpz_poly_equal((<fmpz_series>self).val, (<fmpz_series>other).val)
7876
if r:
7977
r = (<fmpz_series>self).prec == (<fmpz_series>other).prec
80-
if op == 3:
81-
r = not r
8278
return r
8379

8480
def __len__(self):

0 commit comments

Comments
 (0)