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

Error with dfa in twtl code #4

Open
zserlin opened this issue Sep 2, 2020 · 1 comment
Open

Error with dfa in twtl code #4

zserlin opened this issue Sep 2, 2020 · 1 comment

Comments

@zserlin
Copy link

zserlin commented Sep 2, 2020

When I run the twtl code with the new lomap, I get an error where relabel_nodes doesnt seem to have the right structure, but it is correct with respect to networkx=1.11 documentation. Any ideas?

File "twtl/twtl/dfa.py", line 324, in relabel_dfa
ret.g = nx.relabel_nodes(dfa.g, mapping, copy=True)
TypeError: relabel_nodes() got an unexpected keyword argument 'copy'

@visualne
Copy link

visualne commented Sep 28, 2020

It looks like the copy keyword argument defaults to True here:
https://github.com/networkx/networkx/blob/v1.11/networkx/relabel.py
You can ignore it entirely by calling it as follows: ret.g = nx.relabel_nodes(dfa.g, mapping)

*Unable to duplicate in 1.11

Test..

import networkx as nx
G = nx.Graph()
G.add_edge('A', 'B', weight=4)
G.add_edge('B', 'D', weight=2)
G.add_edge('A', 'C', weight=3)
G.add_edge('C', 'D', weight=4)
mapping = {'A':'R','B':'T','C':'Y','D':'Z'}

Without keyword copy agument

new_graph = nx.relabel_nodes(G, mapping)
print(sorted(new_graph))
['R', 'T', 'Y', 'Z']
newer_mapping = {'R':1,'T':2,'Y':3,'Z':4}

With keyword copy argument.

newer_graph = nx.relabel_nodes(new_graph, newer_mapping,copy=True)
print(sorted(newer_graph))
[1, 2, 3, 4]

Both ways of calling the function seem work fine.

networkx and python version listed below...

(env)$ pip freeze | grep networkx
networkx==1.11

python --version
Python 3.7.7

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

2 participants