Skip to content

Commit

Permalink
corner case issues
Browse files Browse the repository at this point in the history
  • Loading branch information
thvitt committed Oct 15, 2019
1 parent e220e4a commit 7ef8a8c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/macrogen/graph.py
Expand Up @@ -298,7 +298,7 @@ def baseline_order(self) -> pd.Series:
if isinstance(ref, SplitReference) and ref.side == Side.END]
else:
unsorted_refs = [node for node in self.dag.nodes if isinstance(node, Reference)]
refs = sorted(unsorted_refs, key=self._secondary_key)
refs = sorted(unsorted_refs, key=lambda ref: ref.sort_tuple()[1:])
return pd.Series(index=refs, data=range(1, len(refs) + 1))

def spearman_rank_correlation(self) -> float:
Expand Down Expand Up @@ -331,7 +331,7 @@ def add_missing_wits(self, working: nx.MultiDiGraph):
all_wits = {wit for wit in Witness.database.values() if isinstance(wit, Witness)}
if any(isinstance(ref, SplitReference) for ref in working.nodes):
known_wits = {ref for ref in references(working) if isinstance(ref, Witness)}
mentioned_refs = {ref.reference for ref in self.base.nodes if isinstance(ref.reference, Reference)}
mentioned_refs = {ref.reference for ref in self.base.nodes if isinstance(ref, SplitReference)}
inscription_bases = {inscr.witness for inscr in mentioned_refs if isinstance(inscr, Inscription)}
missing_wits = (all_wits | mentioned_refs | inscription_bases) - known_wits
for wit in sorted(missing_wits, key=lambda ref: ref.sort_tuple()):
Expand Down
2 changes: 1 addition & 1 deletion src/macrogen/report.py
Expand Up @@ -1172,7 +1172,7 @@ def write_order_xml(graphs: MacrogenesisInfo):
root.getroottree().write(str(order_xml), pretty_print=True)

stats = graphs.year_stats()
data = dict(max=max(stats.values()), counts=stats)
data = dict(max=max(stats.values(), default=None), counts=stats)
config.path.report_dir.mkdir(exist_ok=True, parents=True)
with (config.path.report_dir / 'witness-stats.json').open('wt', encoding='utf-8') as out:
json.dump(data, out)
Expand Down

0 comments on commit 7ef8a8c

Please sign in to comment.