Skip to content

Commit

Permalink
enh: identifier indexing now starts at 1 instead of 0
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmueller committed Oct 15, 2018
1 parent e6a7be7 commit 31d3297
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 8 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
0.4.2
- fix: implement `get_name` method for SeriesFolder format
- enh: start identifier/name indexing at 1 instead of 0
0.4.1
- fix: do not allow intensity values less than zero for SingleTifPhasics
0.4.0
Expand Down
15 changes: 13 additions & 2 deletions qpformat/file_formats/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,20 @@ def storage_type(self):
return ds.storage_type

def get_identifier(self, idx):
"""Return an identifier for the data at index `idx`"""
"""Return an identifier for the data at index `idx`
.. versionchanged:: 0.4.2
indexing starts at 1 instead of 0
"""
name = self._get_cropped_file_names()[idx]
return "{}:{}:{}".format(self.identifier, name, idx)
return "{}:{}:{}".format(self.identifier, name, idx + 1)

def get_name(self, idx):
"""Return name of data at index `idx`
.. versionadded:: 0.4.2
"""
return "{}".format(self.path / self.files[idx])

def get_qpimage_raw(self, idx):
"""Return QPImage without background correction"""
Expand Down
16 changes: 12 additions & 4 deletions qpformat/file_formats/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,20 @@ def identifier(self):
return idsum

def get_identifier(self, idx):
"""Return an identifier for the data at index `idx`"""
return "{}:{}".format(self.identifier, idx)
"""Return an identifier for the data at index `idx`
.. versionchanged:: 0.4.2
indexing starts at 1 instead of 0
"""
return "{}:{}".format(self.identifier, idx + 1)

def get_name(self, idx):
"""Return name of data at index `idx`"""
return "{}:{}".format(self.path, idx)
"""Return name of data at index `idx`
.. versionchanged:: 0.4.2
indexing starts at 1 instead of 0
"""
return "{}:{}".format(self.path, idx + 1)

def get_qpimage(self, idx):
"""Return background-corrected QPImage of data at index `idx`"""
Expand Down
4 changes: 2 additions & 2 deletions tests/test_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ def test_identifier():

bg_data = ds1.get_qpimage(0)
ds2 = qpformat.load_data(path=path, bg_data=bg_data)
assert ds2.background_identifier == "3f328"
assert ds2.identifier == "1e92f"
assert ds2.background_identifier == "26461"
assert ds2.identifier == "67213"


def test_meta():
Expand Down

0 comments on commit 31d3297

Please sign in to comment.