Skip to content

Commit 28541c1

Browse files
committed
keep order of affiliations the same for re-runs of the script; this also keeps the order suggested by the order of authors
1 parent 20e9f69 commit 28541c1

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

contributors.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@
99

1010
# Ensure that we have unique indices for the affiliations
1111
affiliations = list()
12-
for authors in data["authors"]:
13-
affiliations.extend(authors.get("affiliations", []))
14-
data["affiliations"] = {aff: i + 1 for i, aff in enumerate(set(affiliations))}
12+
for author in data["authors"]:
13+
affiliations.extend(author.get("affiliations", []))
14+
data["affiliations"] = {aff: i + 1 for i, aff in enumerate(list(dict.fromkeys(affiliations)))}
15+
print(data['affiliations'])
1516
for author in data["authors"]:
1617
author["affiliations"] = [data["affiliations"][aff] for aff in author.get("affiliations", [])]
1718

0 commit comments

Comments
 (0)