Skip to content

Commit

Permalink
Fix a bug when there is no matching setups
Browse files Browse the repository at this point in the history
  • Loading branch information
dostuffthatmatters committed Sep 17, 2024
1 parent e549604 commit 83f4eec
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
3 changes: 3 additions & 0 deletions em27_metadata/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ def get(
for s1, s2 in zip(relevant_setups[:-1], relevant_setups[1 :]):
assert s1.to_datetime < s2.from_datetime, f"this should not happen, overlapping setups: {s1} and {s2}"

if len(relevant_setups) == 0:
return []

# crop setups list to requested time period

if relevant_setups[0].from_datetime < from_datetime:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "em27_metadata"
version = "1.1.1"
version = "1.1.2"
description = "Single source of truth for ESM's EM27 measurement logistics"
authors = [
{ name = "Moritz Makowski", email = "[email protected]" },
Expand Down
7 changes: 6 additions & 1 deletion tests/test_getter_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,14 @@ def test_getter_function() -> None:
campaigns=em27_metadata.types.CampaignMetadataList(root=[]),
)

from_datetime = datetime.datetime.fromisoformat("2018-02-01T00:00:00+00:00")
to_datetime = datetime.datetime.fromisoformat("2019-02-02T23:59:59+00:00")
chunks = metadata.get("sid1", from_datetime, to_datetime)
# none
assert len(chunks) == 0

from_datetime = datetime.datetime.fromisoformat("2020-02-01T00:00:00+00:00")
to_datetime = datetime.datetime.fromisoformat("2020-02-02T23:59:59+00:00")

chunks = metadata.get("sid1", from_datetime, to_datetime)
# 1-10, 12-22, 22-24

Expand Down

0 comments on commit 83f4eec

Please sign in to comment.