@@ -254,7 +254,7 @@ def hash_array(
254
254
encoding = encoding , hash_key = hash_key , categorize = categorize
255
255
)
256
256
257
- elif not isinstance (vals , np .ndarray ):
257
+ if not isinstance (vals , np .ndarray ):
258
258
# GH#42003
259
259
raise TypeError (
260
260
"hash_array requires np.ndarray or ExtensionArray, not "
@@ -275,14 +275,15 @@ def _hash_ndarray(
275
275
"""
276
276
dtype = vals .dtype
277
277
278
- # we'll be working with everything as 64-bit values, so handle this
279
- # 128-bit value early
278
+ # _hash_ndarray only takes 64-bit values, so handle 128-bit by parts
280
279
if np .issubdtype (dtype , np .complex128 ):
281
- return hash_array (np .real (vals )) + 23 * hash_array (np .imag (vals ))
280
+ hash_real = _hash_ndarray (vals .real , encoding , hash_key , categorize )
281
+ hash_imag = _hash_ndarray (vals .imag , encoding , hash_key , categorize )
282
+ return hash_real + 23 * hash_imag
282
283
283
284
# First, turn whatever array this is into unsigned 64-bit ints, if we can
284
285
# manage it.
285
- elif dtype == bool :
286
+ if dtype == bool :
286
287
vals = vals .astype ("u8" )
287
288
elif issubclass (dtype .type , (np .datetime64 , np .timedelta64 )):
288
289
vals = vals .view ("i8" ).astype ("u8" , copy = False )
0 commit comments