File tree Expand file tree Collapse file tree 2 files changed +9
-11
lines changed Expand file tree Collapse file tree 2 files changed +9
-11
lines changed Original file line number Diff line number Diff line change @@ -772,6 +772,7 @@ def test_fmpq():
772
772
assert raises (lambda : Q ([]), TypeError )
773
773
assert raises (lambda : Q (1 , []), TypeError )
774
774
assert raises (lambda : Q ([], 1 ), TypeError )
775
+ assert raises (lambda : Q (1 , 1 , 1 ), TypeError )
775
776
assert bool (Q (0 )) == False
776
777
assert bool (Q (1 )) == True
777
778
assert Q (1 ,3 ) + Q (2 ,3 ) == 1
Original file line number Diff line number Diff line change @@ -107,9 +107,6 @@ cdef class fmpq(flint_scalar):
107
107
108
108
def __richcmp__ (s , t , int op ):
109
109
cdef bint res
110
- s = any_as_fmpq(s)
111
- if s is NotImplemented :
112
- return s
113
110
t = any_as_fmpq(t)
114
111
if t is NotImplemented :
115
112
return t
@@ -119,17 +116,17 @@ cdef class fmpq(flint_scalar):
119
116
res = not res
120
117
return res
121
118
else :
122
- # todo: use fmpq_cmp when available
119
+ res = fmpq_cmp(s.val, ( < fmpq > t).val)
123
120
if op == 0 :
124
- res = (s - t).p < 0
121
+ res = res < 0
125
122
elif op == 1 :
126
- res = (s - t).p <= 0
123
+ res = res <= 0
127
124
elif op == 4 :
128
- res = (s - t).p > 0
125
+ res = res > 0
129
126
elif op == 5 :
130
- res = (s - t).p >= 0
127
+ res = res >= 0
131
128
else :
132
- raise ValueError
129
+ assert False
133
130
return res
134
131
135
132
def numer (self ):
@@ -442,9 +439,9 @@ cdef class fmpq(flint_scalar):
442
439
import sys
443
440
from fractions import Fraction
444
441
if sys.version_info < (3 , 12 ):
445
- return hash (Fraction(int (self .p), int (self .q), _normalize = False ))
442
+ return hash (Fraction(int (self .p), int (self .q), _normalize = False )) # pragma: no cover
446
443
else :
447
- return hash (Fraction._from_coprime_ints(int (self .p), int (self .q)))
444
+ return hash (Fraction._from_coprime_ints(int (self .p), int (self .q))) # pragma: no cover
448
445
449
446
def height_bits (self , bint signed = False ):
450
447
"""
You can’t perform that action at this time.
0 commit comments