summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRandy <73545062+randallwvr90@users.noreply.github.com>2021-06-22 18:42:33 -0400
committerGitHub <noreply@github.com>2021-06-22 15:42:33 -0700
commite5754fadc9da3c99fca09c316b230b05c81c2b0a (patch)
treea2b508370e610f6267e485226e282efd125cb187
parent196194b7e04d3e7fe8d7d11a8f929c437274f6e4 (diff)
downloadnetworkx-e5754fadc9da3c99fca09c316b230b05c81c2b0a.tar.gz
Update read_gml docstring with destringizer ex (#4916)
* Update read_gml docstring with destringizer ex Responding to issue 4877 by adding a simple destringizer example to the read_gml docstring. * Update doc strings The documentation stated that the code can read data types other than str without specifying a destringizer. While the code can write several other data types, a destringizer is required for any type other than str. The documentation is repeated in the file and was updated in all 5 places: the gml.py module docstring, as well as the read_gml, parse_gml, generate_gml, and write_gml docstrings. Co-authored-by: Randy Weaver <randyweaver@randys-mbp.attlocal.net>
-rw-r--r--networkx/readwrite/gml.py31
1 files changed, 16 insertions, 15 deletions
diff --git a/networkx/readwrite/gml.py b/networkx/readwrite/gml.py
index 434b9478..a2f5a0b5 100644
--- a/networkx/readwrite/gml.py
+++ b/networkx/readwrite/gml.py
@@ -17,9 +17,9 @@ interact with different languages and even different Python versions.
Re-importing from gml is also a concern.
Without specifying a `stringizer`/`destringizer`, the code is capable of
-handling `int`/`float`/`str`/`dict`/`list` data as required by the GML
-specification. For other data types, you need to explicitly supply a
-`stringizer`/`destringizer`.
+writing `int`/`float`/`str`/`dict`/`list` data as required by the GML
+specification. For writing other data types, and for reading data other
+than `str` you need to explicitly supply a `stringizer`/`destringizer`.
For additional documentation on the GML file format, please see the
`GML website <https://web.archive.org/web/20190207140002/http://www.fim.uni-passau.de/index.php?id=17297&L=1>`_.
@@ -150,9 +150,9 @@ def read_gml(path, label="label", destringizer=None):
GML files are stored using a 7-bit ASCII encoding with any extended
ASCII characters (iso8859-1) appearing as HTML character entities.
Without specifying a `stringizer`/`destringizer`, the code is capable of
- handling `int`/`float`/`str`/`dict`/`list` data as required by the GML
- specification. For other data types, you need to explicitly supply a
- `stringizer`/`destringizer`.
+ writing `int`/`float`/`str`/`dict`/`list` data as required by the GML
+ specification. For writing other data types, and for reading data other
+ than `str` you need to explicitly supply a `stringizer`/`destringizer`.
For additional documentation on the GML file format, please see the
`GML url <https://web.archive.org/web/20190207140002/http://www.fim.uni-passau.de/index.php?id=17297&L=1>`_.
@@ -164,6 +164,7 @@ def read_gml(path, label="label", destringizer=None):
>>> G = nx.path_graph(4)
>>> nx.write_gml(G, "test.gml")
>>> H = nx.read_gml("test.gml")
+ >>> I = nx.read_gml("test.gml", destringizer=int)
"""
def filter_lines(lines):
@@ -221,9 +222,9 @@ def parse_gml(lines, label="label", destringizer=None):
GML files are stored using a 7-bit ASCII encoding with any extended
ASCII characters (iso8859-1) appearing as HTML character entities.
Without specifying a `stringizer`/`destringizer`, the code is capable of
- handling `int`/`float`/`str`/`dict`/`list` data as required by the GML
- specification. For other data types, you need to explicitly supply a
- `stringizer`/`destringizer`.
+ writing `int`/`float`/`str`/`dict`/`list` data as required by the GML
+ specification. For writing other data types, and for reading data other
+ than `str` you need to explicitly supply a `stringizer`/`destringizer`.
For additional documentation on the GML file format, please see the
`GML url <https://web.archive.org/web/20190207140002/http://www.fim.uni-passau.de/index.php?id=17297&L=1>`_.
@@ -620,9 +621,9 @@ def generate_gml(G, stringizer=None):
GML files are stored using a 7-bit ASCII encoding with any extended
ASCII characters (iso8859-1) appearing as HTML character entities.
Without specifying a `stringizer`/`destringizer`, the code is capable of
- handling `int`/`float`/`str`/`dict`/`list` data as required by the GML
- specification. For other data types, you need to explicitly supply a
- `stringizer`/`destringizer`.
+ writing `int`/`float`/`str`/`dict`/`list` data as required by the GML
+ specification. For writing other data types, and for reading data other
+ than `str` you need to explicitly supply a `stringizer`/`destringizer`.
For additional documentation on the GML file format, please see the
`GML url <https://web.archive.org/web/20190207140002/http://www.fim.uni-passau.de/index.php?id=17297&L=1>`_.
@@ -812,9 +813,9 @@ def write_gml(G, path, stringizer=None):
GML files are stored using a 7-bit ASCII encoding with any extended
ASCII characters (iso8859-1) appearing as HTML character entities.
Without specifying a `stringizer`/`destringizer`, the code is capable of
- handling `int`/`float`/`str`/`dict`/`list` data as required by the GML
- specification. For other data types, you need to explicitly supply a
- `stringizer`/`destringizer`.
+ writing `int`/`float`/`str`/`dict`/`list` data as required by the GML
+ specification. For writing other data types, and for reading data other
+ than `str` you need to explicitly supply a `stringizer`/`destringizer`.
Note that while we allow non-standard GML to be read from a file, we make
sure to write GML format. In particular, underscores are not allowed in