Commit 516c8daa authored by payno's avatar payno
Browse files

[esrftaskgraph][hasing] handle case value us a Sized empty

parent 43e5386c
...@@ -3,6 +3,7 @@ import hashlib ...@@ -3,6 +3,7 @@ import hashlib
from collections.abc import Mapping, Iterable, Set from collections.abc import Mapping, Iterable, Set
import numpy import numpy
from esrftaskgraph.utils import qualname from esrftaskgraph.utils import qualname
from collections import Sized
def uhashtype(_type): def uhashtype(_type):
...@@ -10,7 +11,7 @@ def uhashtype(_type): ...@@ -10,7 +11,7 @@ def uhashtype(_type):
def uhash(value, _hash=None): def uhash(value, _hash=None):
"""Universial hash (as opposed to python's hash). """Universal hash (as opposed to python's hash).
This is an example. Must find something better. This is an example. Must find something better.
:param value: :param value:
...@@ -22,7 +23,7 @@ def uhash(value, _hash=None): ...@@ -22,7 +23,7 @@ def uhash(value, _hash=None):
if bdigest: if bdigest:
_hash = hashlib.sha256() _hash = hashlib.sha256()
_hash.update(uhashtype(type(value))) _hash.update(uhashtype(type(value)))
if value is None: if value is None or isinstance(value, Sized) and len(value) == 0:
pass pass
elif isinstance(value, UniversalHashable): elif isinstance(value, UniversalHashable):
_hash.update(repr(value.uhash).encode()) _hash.update(repr(value.uhash).encode())
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment