From 894b1d51742a3f38e717a5777bf381096619a931 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Thu, 30 May 2019 16:34:24 -0700 Subject: fix parse_merge_metadata.py merge_spans() --- extra/journal_metadata/parse_merge_metadata.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'extra/journal_metadata') diff --git a/extra/journal_metadata/parse_merge_metadata.py b/extra/journal_metadata/parse_merge_metadata.py index 7e75cf84..b1d038bb 100755 --- a/extra/journal_metadata/parse_merge_metadata.py +++ b/extra/journal_metadata/parse_merge_metadata.py @@ -129,7 +129,7 @@ def merge_spans(old, new): old.extend(new) years = set() for span in old: - for y in range(span[0], span[1]): + for y in range(span[0], span[1]+1): years.add(y) if not years: return [] @@ -153,19 +153,23 @@ def merge_spans(old, new): spans.append([start, last]) start = y last = y - todo = False + todo = True if todo: spans.append([start, last]) return spans def test_merge_spans(): - assert merge_spans([[5, 10]], [10, 20]) == \ + assert merge_spans([[5, 10]], [[10, 20]]) == \ + [[5, 20]] + assert merge_spans([[5, 9]], [[10, 20]]) == \ + [[5, 20]] + assert merge_spans([[5, 11]], [[10, 20]]) == \ [[5, 20]] assert merge_spans([], []) == \ [] assert merge_spans([[9, 11]], []) == \ [[9,11]] - assert merge_spans([[2000, 2000]], [1450, 1900]) == \ + assert merge_spans([[2000, 2000]], [[1450, 1900]]) == \ [[1450, 1900], [2000, 2000]] class Munger(): -- cgit v1.2.3