File tree 2 files changed +7
-2
lines changed
2 files changed +7
-2
lines changed Original file line number Diff line number Diff line change 94
94
assert hash (complex (- float ('inf' ))) == hash (- float ('inf' ))
95
95
assert hash (1j ) != hash (1 )
96
96
97
+ # TODO: Find a way to test platform dependent values
98
+ assert hash (3.1 - 4.2j ) == hash (3.1 - 4.2j )
99
+ assert hash (3.1 + 4.2j ) == hash (3.1 + 4.2j )
100
+
97
101
# numbers.Complex
98
102
99
103
a = complex (3 , 4 )
Original file line number Diff line number Diff line change 1
1
use num_complex:: Complex64 ;
2
2
use num_traits:: Zero ;
3
+ use std:: num:: Wrapping ;
3
4
4
5
use crate :: function:: OptionalArg ;
5
6
use crate :: pyhash;
@@ -254,7 +255,7 @@ impl PyComplex {
254
255
fn hash ( & self , _vm : & VirtualMachine ) -> pyhash:: PyHash {
255
256
let re_hash = pyhash:: hash_float ( self . value . re ) ;
256
257
let im_hash = pyhash:: hash_float ( self . value . im ) ;
257
-
258
- re_hash + im_hash * pyhash :: IMAG
258
+ let ret = Wrapping ( re_hash ) + Wrapping ( im_hash ) * Wrapping ( pyhash :: IMAG ) ;
259
+ ret . 0
259
260
}
260
261
}
You can’t perform that action at this time.
0 commit comments