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

networkx 2.4 breaks koala #240

Open
brianmay opened this issue Oct 18, 2019 · 3 comments
Open

networkx 2.4 breaks koala #240

brianmay opened this issue Oct 18, 2019 · 3 comments

Comments

@brianmay
Copy link
Collaborator

brianmay commented Oct 18, 2019

After updating to networkx 2.4, I noticed koala2 0.0.30 is broken:

[...]
  File "/home/brian/.virtualenvs/energy_rating/lib/python3.6/site-packages/koala/ExcelCompiler.py", line 92, in gen_graph
    cellmap, G = graph_from_seeds(seeds, self)
  File "/home/brian/.virtualenvs/energy_rating/lib/python3.6/site-packages/koala/ast/__init__.py", line 473, in graph_from_seeds
    pystr, ast = cell2code(c1, names)
  File "/home/brian/.virtualenvs/energy_rating/lib/python3.6/site-packages/koala/ast/__init__.py", line 374, in cell2code
    code = root.emit(ast, context=sheet)
  File "/home/brian/.virtualenvs/energy_rating/lib/python3.6/site-packages/koala/ast/astnodes.py", line 303, in emit
    args = self.children(ast)
  File "/home/brian/.virtualenvs/energy_rating/lib/python3.6/site-packages/koala/ast/astnodes.py", line 45, in children
    args = sorted(args,key=lambda x: ast.node[x]['pos'])
  File "/home/brian/.virtualenvs/energy_rating/lib/python3.6/site-packages/koala/ast/astnodes.py", line 45, in <lambda>
    args = sorted(args,key=lambda x: ast.node[x]['pos'])
AttributeError: 'DiGraph' object has no attribute 'node'

If this is fixed in a later version, of koala, then do worry about it, just close. However I suspect it may not be.

@SlavaKozlov
Copy link

I got the same error in these versions:

koala2=0.0.36
networkx=2.5.

The local fix I put in is to upgrade to the networkx 2.1 interface (made obsolete in networkx 2.4) -- that is, change the node to nodes.

That is, on line 45 of ast/astnodes.py

args = sorted(args,key=lambda x: ast.node[x]['pos'])

to

args = sorted(args,key=lambda x: ast.nodes[x]['pos'])

@brianmay
Copy link
Collaborator Author

brianmay commented Feb 5, 2020

A pull request to fix this would be good :-)

If possible, a change that allows koala to continue working with networkx 2.4 preferred, as it means projects don't have to upgrade both packages at the same time.

@kmonson
Copy link

kmonson commented Feb 26, 2020

I'm working on a pull request for this and the old openpyxl version issue.

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

No branches or pull requests

3 participants