Skip to content

Commit

Permalink
fix: add file size to dataset identifier hashing process
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmueller committed Aug 30, 2019
1 parent c2e3729 commit db04444
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
8 changes: 4 additions & 4 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
0.10.4
- fix: missing keyword argument `idx` in `SingleTifHolo.get_time`
- example: add conversion script to hdf5 qpimage data
0.10.3
- fix: Correctly pass precision to phasics and hologram zip file
- fix: missing keyword argument `idx` in `SingleTifHolo.get_time`
- fix: correctly pass precision to phasics and hologram zip file
formats
- fix: add file size to dataset identifier hashing process
- example: add conversion script to hdf5 qpimage data
0.10.2
- fix: SeriesFolder did not pass on holo_kw when loading hologram data
0.10.1
Expand Down
3 changes: 3 additions & 0 deletions qpformat/file_formats/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ def _identifier_data(self):
else:
with self.path.open("rb") as fd:
data.append(fd.read(50 * 1024))
data.append(self.path.stat().st_size)
data += self._identifier_meta()
return hash_obj(data)

Expand Down Expand Up @@ -398,6 +399,8 @@ def obj2bytes(data):
tohash.append(data)
elif isinstance(data, np.ndarray):
tohash.append(data.tobytes())
elif isinstance(data, int):
tohash.append(bytes(data))
else:
msg = "No rule to convert to bytes: {}".format(data)
raise NotImplementedError(msg)
Expand Down
6 changes: 3 additions & 3 deletions tests/test_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ def test_identifier():
path = datapath / "series_phasics.zip"

ds1 = qpformat.load_data(path=path)
assert ds1.identifier == "7fc65"
assert ds1.identifier == "49bbc"

bg_data = ds1.get_qpimage(0)
ds2 = qpformat.load_data(path=path, bg_data=bg_data)
assert ds2.background_identifier == "26461"
assert ds2.identifier == "67213"
assert ds2.background_identifier == "bf13f"
assert ds2.identifier == "b6d1c"


def test_meta():
Expand Down
2 changes: 1 addition & 1 deletion tests/test_single_tif_holo.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def test_basic():
def test_identifier():
path = datapath / "single_holo.tif"
ds = qpformat.load_data(path, holo_kw={"sideband": 1})
assert ds.identifier == "e9d9d"
assert ds.identifier == "b65c8"


def test_load_data():
Expand Down

0 comments on commit db04444

Please sign in to comment.