Skip to content

Commit

Permalink
FIX(<PY3.5): ORDERED DiGRAPH for old Python to fix TCs
Browse files Browse the repository at this point in the history
  • Loading branch information
ankostis committed Oct 7, 2019
1 parent f9b2415 commit 1566a7f
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion graphkit/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
"""
import logging
import os
import sys
import time
from collections import defaultdict, namedtuple
from io import StringIO
Expand All @@ -79,6 +80,22 @@

log = logging.getLogger(__name__)


from networkx import DiGraph
if sys.version_info < (3, 6):
"""
Consistently ordered variant of :class:`~networkx.DiGraph`.
PY3.6 has inmsertion-order dicts, but PY3.5 has not.
And behvavior *and TCs) in these environments may fail spuriously!
Still *subgraphs* may not patch!
Fix from:
https://networkx.github.io/documentation/latest/reference/classes/ordered.html#module-networkx.classes.ordered
"""
from networkx import OrderedDiGraph as DiGraph


class DataPlaceholderNode(str):
"""
Dag node naming a data-value produced or required by an operation.
Expand Down Expand Up @@ -123,7 +140,7 @@ class Network(plot.Plotter):

def __init__(self, **kwargs):
# directed graph of layer instances and data-names defining the net.
self.graph = nx.DiGraph()
self.graph = DiGraph()

# this holds the timing information for each layer
self.times = {}
Expand Down

0 comments on commit 1566a7f

Please sign in to comment.