Skip to content

Commit 32df472

Browse files
committed
DeepHash: check numpy booleans like native booleans
Fixes #494
1 parent 6d8a4c7 commit 32df472

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

deepdiff/deephash.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@
2424
import polars
2525
except ImportError:
2626
polars = False
27+
try:
28+
import numpy as np
29+
booleanTypes = (bool, np.bool_)
30+
except ImportError:
31+
booleanTypes = bool
2732

2833
logger = logging.getLogger(__name__)
2934

@@ -492,7 +497,7 @@ def _hash(self, obj, parent, parents_ids=EMPTY_FROZENSET):
492497
"""The main hash method"""
493498
counts = 1
494499

495-
if isinstance(obj, bool):
500+
if isinstance(obj, booleanTypes):
496501
obj = self._prep_bool(obj)
497502
result = None
498503
elif self.use_enum_value and isinstance(obj, Enum):

0 commit comments

Comments
 (0)