diff options
author | josch <j.schauer@email.de> | 2020-09-05 19:32:40 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-05 10:32:40 -0700 |
commit | 2bfdee687d0db533555384f92ce3670d47c45aec (patch) | |
tree | 893ee18d4855896553ce9f3f2e5dd970bdab6329 | |
parent | 663b5eb351ac94a6ee39fd47270904f5537c4841 (diff) | |
download | networkx-2bfdee687d0db533555384f92ce3670d47c45aec.tar.gz |
graphml: re-add graph attribute type 'long' after 857aa81 removed it (#4189)
closes: #4188
-rw-r--r-- | networkx/readwrite/graphml.py | 1 | ||||
-rw-r--r-- | networkx/readwrite/tests/test_graphml.py | 23 |
2 files changed, 24 insertions, 0 deletions
diff --git a/networkx/readwrite/graphml.py b/networkx/readwrite/graphml.py index f24307bb..a44c7c5d 100644 --- a/networkx/readwrite/graphml.py +++ b/networkx/readwrite/graphml.py @@ -358,6 +358,7 @@ class GraphML: (str, "yfiles"), (str, "string"), (int, "int"), + (int, "long"), (float, "float"), (float, "double"), (bool, "boolean"), diff --git a/networkx/readwrite/tests/test_graphml.py b/networkx/readwrite/tests/test_graphml.py index 7b90791f..fd85d132 100644 --- a/networkx/readwrite/tests/test_graphml.py +++ b/networkx/readwrite/tests/test_graphml.py @@ -992,6 +992,29 @@ class TestReadGraphML(BaseGraphML): for node_data in data: assert node_data["CustomProperty"] != "" + def test_long_attribute_type(self): + # test that graphs with attr.type="long" (as produced by botch and + # dose3) can be parsed + s = """<?xml version='1.0' encoding='utf-8'?> +<graphml xmlns="http://graphml.graphdrawing.org/xmlns" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns + http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd"> + <key attr.name="cudfversion" attr.type="long" for="node" id="d6" /> + <graph edgedefault="directed"> + <node id="n1"> + <data key="d6">4284</data> + </node> + </graph> +</graphml>""" + fh = io.BytesIO(s.encode("UTF-8")) + G = nx.read_graphml(fh) + expected = [("n1", {"cudfversion": 4284})] + assert sorted(G.nodes(data=True)) == expected + fh.seek(0) + H = nx.parse_graphml(s) + assert sorted(H.nodes(data=True)) == expected + class TestWriteGraphML(BaseGraphML): writer = staticmethod(nx.write_graphml_lxml) |