summaryrefslogtreecommitdiff
path: root/networkx/convert.py
diff options
context:
space:
mode:
authorRoss Barnowski <rossbar@berkeley.edu>2020-11-24 15:22:42 -0800
committerGitHub <noreply@github.com>2020-11-24 15:22:42 -0800
commit001b37b55d03479303674a1a5d25256986a6f330 (patch)
treec168c484df7a80e22799a688bbe33b11f0d13ee9 /networkx/convert.py
parentb25a66d5cd0a53bf031d48c22b97a5b66f7db475 (diff)
downloadnetworkx-001b37b55d03479303674a1a5d25256986a6f330.tar.gz
Improve test coverage of convert module (#4306)
* TST: Improve coverage of conversion module. * WIP: Remove attr checks for graph/nodes? * TST: remove to_dict_of_dict tests.
Diffstat (limited to 'networkx/convert.py')
-rw-r--r--networkx/convert.py16
1 files changed, 8 insertions, 8 deletions
diff --git a/networkx/convert.py b/networkx/convert.py
index 3fe40ca1..860d0868 100644
--- a/networkx/convert.py
+++ b/networkx/convert.py
@@ -78,14 +78,14 @@ def to_networkx_graph(data, create_using=None, multigraph_input=False):
create_using=create_using,
multigraph_input=data.is_multigraph(),
)
- if hasattr(data, "graph"): # data.graph should be dict-like
- result.graph.update(data.graph)
- if hasattr(data, "nodes"): # data.nodes should be dict-like
- # result.add_node_from(data.nodes.items()) possible but
- # for custom node_attr_dict_factory which may be hashable
- # will be unexpected behavior
- for n, dd in data.nodes.items():
- result._node[n].update(dd)
+ # data.graph should be dict-like
+ result.graph.update(data.graph)
+ # data.nodes should be dict-like
+ # result.add_node_from(data.nodes.items()) possible but
+ # for custom node_attr_dict_factory which may be hashable
+ # will be unexpected behavior
+ for n, dd in data.nodes.items():
+ result._node[n].update(dd)
return result
except Exception as e:
raise nx.NetworkXError("Input is not a correct NetworkX graph.") from e