File tree Expand file tree Collapse file tree 2 files changed +14
-13
lines changed
Expand file tree Collapse file tree 2 files changed +14
-13
lines changed Original file line number Diff line number Diff line change @@ -126,21 +126,20 @@ def arb_pi(prec):
126126 (arb (10 ), arb (10 ), True ),
127127 (arb (10 ), arb (11 ), False ),
128128 (arb (10.0 ), arb (10 ), True ),
129- (
130- arb (mid = 10 , rad = 2 ),
131- arb (mid = 10 , rad = 2 ),
132- True ,
133- ),
134- (
135- arb (mid = 10 , rad = 2 ),
136- arb (mid = 10 , rad = 3 ),
137- False ,
138- ),
139- (arb_pi (100 ), arb_pi (100 ), True ),
140- (arb_pi (100 ), arb_pi (1000 ), False ),
141129 ]:
142130 assert (hash (x ) == hash (y )) == expected
143131
132+ for x in [
133+ arb (mid = 10 , rad = 2 ),
134+ arb_pi (100 ),
135+ ]:
136+ try :
137+ hash (x )
138+ except ValueError :
139+ pass
140+ else :
141+ assert False , f"Expected { x } to raise an error if hashed, but succeeded."
142+
144143
145144
146145# Tests for arithmetic functions in `flint.arb`.
Original file line number Diff line number Diff line change @@ -529,7 +529,9 @@ cdef class arb(flint_scalar):
529529
530530 def __hash__ (self ):
531531 """ Hash."""
532- return hash ((self .mid().man_exp(), self .rad().man_exp()))
532+ if self .is_exact():
533+ return hash ((self .mid().man_exp(), self .rad().man_exp()))
534+ raise ValueError (f" Cannot hash non-exact arb: {self}. See pull/341 for details." )
533535
534536 def __contains__ (self , other ):
535537 other = any_as_arb(other)
You can’t perform that action at this time.
0 commit comments