diff options
author | Bryan Newbold <bnewbold@robocracy.org> | 2019-05-30 16:34:24 -0700 |
---|---|---|
committer | Bryan Newbold <bnewbold@robocracy.org> | 2019-05-30 16:34:24 -0700 |
commit | 894b1d51742a3f38e717a5777bf381096619a931 (patch) | |
tree | bef4c2ba9860144432ba8e1314b62cd828fb5e78 /extra/journal_metadata | |
parent | 3d2fe9c9a4f0c1754fad5b789ed91cebd495f1cf (diff) | |
download | fatcat-894b1d51742a3f38e717a5777bf381096619a931.tar.gz fatcat-894b1d51742a3f38e717a5777bf381096619a931.zip |
fix parse_merge_metadata.py merge_spans()
Diffstat (limited to 'extra/journal_metadata')
-rwxr-xr-x | extra/journal_metadata/parse_merge_metadata.py | 12 |
1 files changed, 8 insertions, 4 deletions
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(): |