Skip to content

Commit

Permalink
Sort test case, add docstring
Browse files Browse the repository at this point in the history
  • Loading branch information
jmelot committed Feb 5, 2024
1 parent 662d167 commit a4cec1d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
7 changes: 4 additions & 3 deletions tests/test_make_unlink_rows.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ def test_make_pairs(self):
"2": {"d", "e"},
"3": {"f"}
}
expected_output = [
gen_sort_key = lambda pair: f"{pair[0]}-{pair[1]}"
expected_output = sorted([
("a", "d"),
("a", "e"),
("a", "f"),
Expand All @@ -31,5 +32,5 @@ def test_make_pairs(self):
("f", "b"),
("f", "d"),
("f", "e")
]
self.assertEqual(expected_output, make_pairs(manual_to_orig))
], key=gen_sort_key)
self.assertEqual(expected_output, sorted(make_pairs(manual_to_orig), key=gen_sort_key))
15 changes: 8 additions & 7 deletions utils/make_unlink_rows.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

def make_pairs(manual_to_orig: dict) -> list:
"""
:param manual_to_orig:
:return:
Make all pairs of ids that should be unlinked
:param manual_to_orig: Dict mapping manually assigned ids to original ids that we believe to be the same article
:return: A list of pairs of ids that should not be linked together
"""
pairs = []
for manual1 in manual_to_orig:
Expand All @@ -21,10 +21,11 @@ def make_pairs(manual_to_orig: dict) -> list:

def write_unlink_rows(unlinking_file: str, output_file: str) -> None:
"""
:param unlinking_file:
:param output_file:
:return:
Write a sql file containing a query that adds new rows to the staging_literature.unlink table
:param unlinking_file: CSV containing two columns, `manual_id` (a manually assigned id marking articles that are the same),
and `orig_id`, the id for the article in its source corpus
:param output_file: SQL file containing a query that adds new rows to staging_literature.unlink
:return: None
"""
manual_to_orig = {}
with open(unlinking_file) as f:
Expand Down

0 comments on commit a4cec1d

Please sign in to comment.