Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dag.py : ind_nodes implementation has wrong code!!! #9

Open
mrchaos opened this issue Jul 18, 2019 · 3 comments
Open

dag.py : ind_nodes implementation has wrong code!!! #9

mrchaos opened this issue Jul 18, 2019 · 3 comments

Comments

@mrchaos
Copy link

mrchaos commented Jul 18, 2019

def ind_nodes(self, graph=None):
    """ Returns a list of all nodes in the graph with no dependencies. """
    if graph is None:
        graph = self.graph
    dependent_nodes = set(tuple(node) for dependents in graph.items() for node in dependents)
    return [node for node in graph.keys() if node not in dependent_nodes]

set(tuple(node) for dependents in graph.items() for node in dependents) : wrong code!!

corrected code (python 3 base):
dependent_nodes = set(node for dependents in iter(graph.values() )for node in dependents)

compare : py-dag:ind_nodes method

@aqibsaeed
Copy link
Owner

Please submit a pull request with test cases.

@mrchaos
Copy link
Author

mrchaos commented Jul 19, 2019

example)
dag.graph : OrderedDict([('s1_1', {'s1_3'}), ('s1_2', {'s1_3'}), ('s1_3', set())])

  1. dependent_nodes = set(tuple(node) for dependents in graph.items() for node in dependents)
    ==> {(), ('s', '1', '', '1'), ('s', '1', '', '2'), ('s', '1', '_', '3'), ('s1_3',)}

  2. dependent_nodes = set(node for dependents in iter(graph.values() )for node in dependents)
    ==> {'s1_3'}

@aqibsaeed
Copy link
Owner

aqibsaeed commented Jul 19, 2019

Currently I am busy, I will look into this later to understand/verify the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants