Skip to content

Commit

Permalink
Code formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
thvitt committed Aug 10, 2018
1 parent f6a3c2c commit 3418534
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
15 changes: 10 additions & 5 deletions graph.py
Expand Up @@ -20,6 +20,7 @@
LATEST = date.today()
DAY = timedelta(days=1)


def subgraphs_with_conflicts(graph: nx.MultiDiGraph) -> List[nx.MultiDiGraph]:
"""
Extracts the smallest conflicted subgraphs of the given graph, i.e. the
Expand Down Expand Up @@ -182,9 +183,11 @@ def _augment_details(self):
for index, ref in enumerate(self.order_refs(), start=1):
ref.index = index
ref.rank = self.closure.in_degree(ref)
max_before_date = max((d for d, _ in self.closure.in_edges(ref) if isinstance(d, date)), default=EARLIEST-DAY)
max_before_date = max((d for d, _ in self.closure.in_edges(ref) if isinstance(d, date)),
default=EARLIEST - DAY)
ref.earliest = max_before_date + DAY
min_after_date = min((d for _, d in self.closure.out_edges(ref) if isinstance(d, date)), default=LATEST+DAY)
min_after_date = min((d for _, d in self.closure.out_edges(ref) if isinstance(d, date)),
default=LATEST + DAY)
ref.latest = min_after_date - DAY


Expand All @@ -197,12 +200,14 @@ def adopt_orphans(graph: nx.MultiDiGraph):
for node in nodes:
if isinstance(node, Inscription):
if node.witness not in nodes and isinstance(node.witness, Witness):
graph.add_edge(node, node.witness, kind='orphan', source=BiblSource('faust://orphan/adoption'), comments=(), xml='')
graph.add_edge(node, node.witness, kind='orphan', source=BiblSource('faust://orphan/adoption'),
comments=(), xml='')
logger.info('Adopted %s from inscription %s', node.witness, node)
if isinstance(node, AmbiguousRef):
for witness in node.witnesses:
if witness not in nodes:
graph.add_edge(node, witness, kind='orphan', source=BiblSource('faust://orphan/adoption'), comments=(), xml='')
graph.add_edge(node, witness, kind='orphan', source=BiblSource('faust://orphan/adoption'),
comments=(), xml='')
logger.info('Adopted %s from ambiguous ref %s', witness, node)


Expand Down Expand Up @@ -240,7 +245,7 @@ def macrogenesis_graphs() -> MacrogenesisInfo:
selfloops = list(nx.selfloop_edges(working, data=True, keys=True))
if selfloops:
logger.warning('Found %d self loops, will also remove those. Affected nodes: %s',
len(selfloops), ", ".join(str(u) for u,v,k,attr in selfloops))
len(selfloops), ", ".join(str(u) for u, v, k, attr in selfloops))
all_conflicting_edges.extend(selfloops)

logger.info('Marking %d conflicting edges for deletion', len(all_conflicting_edges))
Expand Down
2 changes: 1 addition & 1 deletion uris.py
Expand Up @@ -247,7 +247,7 @@ def get(cls, uri, allow_duplicate=True):
if correction in cls.database:
logger.info('Corrected %s to %s -> %s', uri, correction, cls.database[correction])
else:
logger.warning('Corrected %s to %s, but it is not in the databse', uri, correction)
logger.warning('Corrected %s to %s, but it is not in the database', uri, correction)
uri = correction

orig_uri = uri
Expand Down

0 comments on commit 3418534

Please sign in to comment.