Skip to content

Commit

Permalink
fix: support latest version of dclab, ironically by enforcing the dep…
Browse files Browse the repository at this point in the history
…endency (close #132)
  • Loading branch information
paulmueller committed Oct 19, 2022
1 parent 38dae99 commit b4ea0a2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 39 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
2.11.8
- setup: bump dclab from 0.45.0 to 0.46.2 (#132)
- ref: use `hashobj` from upstream dclab (#132)
2.11.7
- build: fix build pipelines
2.11.6
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
description=description,
long_description=open('README.rst').read() if exists('README.rst') else '',
install_requires=["fcswrite>=0.5.1",
"dclab[dcor,lme4]>=0.45.0",
"dclab[dcor,lme4]>=0.46.2",
"h5py>=2.8.0",
"numpy>=1.21", # CVE-2021-33430
"pyqt5",
Expand Down
42 changes: 4 additions & 38 deletions shapeout2/util.py
Original file line number Diff line number Diff line change
@@ -1,41 +1,7 @@
import hashlib
import numbers
import pathlib

import h5py
import numpy as np


def hashobj(obj):
"""Compute md5 hex-hash of a Python object"""
return hashlib.md5(obj2bytes(obj)).hexdigest()


def obj2bytes(obj):
"""String representation of an object for hashing"""
if isinstance(obj, str):
return obj.encode("utf-8")
elif isinstance(obj, pathlib.Path):
return obj2bytes(str(obj))
elif isinstance(obj, (bool, numbers.Number)):
return str(obj).encode("utf-8")
elif obj is None:
return b"none"
elif isinstance(obj, np.ndarray):
return obj.tobytes()
elif isinstance(obj, tuple):
return obj2bytes(list(obj))
elif isinstance(obj, list):
return b"".join(obj2bytes(o) for o in obj)
elif isinstance(obj, dict):
return obj2bytes(sorted(obj.items()))
elif hasattr(obj, "identifier"):
return obj2bytes(obj.identifier)
elif isinstance(obj, h5py.Dataset):
return obj2bytes(obj[0])
else:
raise ValueError("No rule to convert object '{}' to string.".
format(obj.__class__))
# hashobj is imported from several other submodules in Shape-Out.
# Would we need to add additional functionalities in the future, which
# are not within the scope of dclab, then we can patch this method here.
from dclab.util import hashobj # noqa: F401


def get_valid_filename(value):
Expand Down

0 comments on commit b4ea0a2

Please sign in to comment.