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():
772772 assert raises (lambda : Q ([]), TypeError )
773773 assert raises (lambda : Q (1 , []), TypeError )
774774 assert raises (lambda : Q ([], 1 ), TypeError )
775+ assert raises (lambda : Q (1 , 1 , 1 ), TypeError )
775776 assert bool (Q (0 )) == False
776777 assert bool (Q (1 )) == True
777778 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):
107107
108108 def __richcmp__ (s , t , int op ):
109109 cdef bint res
110- s = any_as_fmpq(s)
111- if s is NotImplemented :
112- return s
113110 t = any_as_fmpq(t)
114111 if t is NotImplemented :
115112 return t
@@ -119,17 +116,17 @@ cdef class fmpq(flint_scalar):
119116 res = not res
120117 return res
121118 else :
122- # todo: use fmpq_cmp when available
119+ res = fmpq_cmp(s.val, ( < fmpq > t).val)
123120 if op == 0 :
124- res = (s - t).p < 0
121+ res = res < 0
125122 elif op == 1 :
126- res = (s - t).p <= 0
123+ res = res <= 0
127124 elif op == 4 :
128- res = (s - t).p > 0
125+ res = res > 0
129126 elif op == 5 :
130- res = (s - t).p >= 0
127+ res = res >= 0
131128 else :
132- raise ValueError
129+ assert False
133130 return res
134131
135132 def numer (self ):
@@ -442,9 +439,9 @@ cdef class fmpq(flint_scalar):
442439 import sys
443440 from fractions import Fraction
444441 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
446443 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
448445
449446 def height_bits (self , bint signed = False ):
450447 """
You can’t perform that action at this time.
0 commit comments