Skip to content

Commit 834a1b2

Browse files
Remove need for date and artifical strain key in metadata
1 parent 23c6aa3 commit 834a1b2

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

sc2ts/dataset.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -184,11 +184,12 @@ def get_metadata(self, j):
184184
d[key] = bool(d[key])
185185
else:
186186
d[key] = str(d[key])
187-
if self.date_field is None:
188-
raise ValueError("No date field set, cannot get metadata items")
189-
# For compatibility in the short term:
190-
d["date"] = self.sample_date[j]
191-
d["strain"] = self.sample_id[j]
187+
if self.date_field is not None:
188+
# For compatibility in the short term:
189+
d["date"] = self.sample_date[j]
190+
# NOTE 'strain' will be removed
191+
# https://github.com/tskit-dev/sc2ts/issues/574
192+
d["strain"] = self.sample_id[j]
192193
return d
193194

194195
def __getitem__(self, key):

tests/test_dataset.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -469,9 +469,8 @@ def test_known(self, fx_dataset):
469469

470470
def test_known_no_date_field(self, fx_dataset):
471471
ds = sc2ts.Dataset(fx_dataset.path)
472-
473-
with pytest.raises(ValueError, match="No date field set"):
474-
ds.metadata["SRR11772659"]
472+
d = ds.metadata["SRR11772659"]
473+
assert "strain" not in d
475474

476475
@pytest.mark.parametrize(
477476
["chunk_size", "cache_size"],

0 commit comments

Comments
 (0)