Skip to content

Commit

Permalink
use holo_kw in dataset identifier hash
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmueller committed Feb 8, 2018
1 parent c2a8881 commit d88ddf6
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
0.1.4
- add hologram file formats: HyperSpy and tif-based
- use hologram keyword arguments to generate dataset identifer
0.1.3
- format series and single hdf5: override raw meta data
- include background data in determination of data set identifiers
Expand Down
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ODTbrain documentation
qpformat documentation
======================
To install the requirements for building the documentation, run

Expand Down
7 changes: 3 additions & 4 deletions qpformat/file_formats/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,9 @@ def _identifier_data(self):
data.sort()
# also use the folder name
data.append(op.basename(self.path))
for key in sorted(list(self.meta_data.keys())):
data.append("{}={}".format(key, self.meta_data[key]))
idsum = hash_obj(data)
return idsum
# add meta data
data += self._identifier_meta()
return hash_obj(data)

@staticmethod
def _search_files(path):
Expand Down
12 changes: 12 additions & 0 deletions qpformat/file_formats/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,23 @@ def _compute_bgid(self, bg=None):
@functools.lru_cache(maxsize=32)
def _identifier_data(self):
data = []
# data
with open(self.path, "rb") as fd:
data.append(fd.read(50 * 1024))
data += self._identifier_meta()
return hash_obj(data)

@functools.lru_cache(maxsize=32)
def _identifier_meta(self):
data = []
# meta data
for key in sorted(list(self.meta_data.keys())):
value = self.meta_data[key]
data.append("{}={}".format(key, value))
# hologram info
for key in sorted(list(self.holo_kw.keys())):
value = self.holo_kw[key]
data.append("{}={}".format(key, value))
return hash_obj(data)

@property
Expand Down

0 comments on commit d88ddf6

Please sign in to comment.