diff options
author | Jarrod Millman <jarrod.millman@gmail.com> | 2020-08-19 13:56:18 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-19 13:56:18 -0700 |
commit | 99fc1bb6690ac1a45124db2a01c12fd64dcb109b (patch) | |
tree | 1891fc18beca7b6d1005b9ce32175ddfed29870f /networkx/relabel.py | |
parent | 7b3ad34e1be1c61dbccae3df920afb898e2eb8ad (diff) | |
download | networkx-99fc1bb6690ac1a45124db2a01c12fd64dcb109b.tar.gz |
Format python in docstrings (#4168)
* Format code w/ black
* Format docstrings w/ black
* Manual cleanup
* Tell pytest to ignore planned deprecations
* Don't call plt.show during testing
* Another known deprecation
* DOC: rm duplicate line from docstring example
* Minor cleanup
Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
Diffstat (limited to 'networkx/relabel.py')
-rw-r--r-- | networkx/relabel.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/networkx/relabel.py b/networkx/relabel.py index 26f50d24..424a8289 100644 --- a/networkx/relabel.py +++ b/networkx/relabel.py @@ -26,7 +26,7 @@ def relabel_nodes(G, mapping, copy=True): >>> G = nx.path_graph(3) >>> sorted(G) [0, 1, 2] - >>> mapping = {0: 'a', 1: 'b', 2: 'c'} + >>> mapping = {0: "a", 1: "b", 2: "c"} >>> H = nx.relabel_nodes(G, mapping) >>> sorted(H) ['a', 'b', 'c'] @@ -39,7 +39,7 @@ def relabel_nodes(G, mapping, copy=True): >>> sorted(G)[:3] [0, 1, 2] >>> mapping = dict(zip(G, string.ascii_lowercase)) - >>> G = nx.relabel_nodes(G, mapping) # nodes are characters a through z + >>> G = nx.relabel_nodes(G, mapping) # nodes are characters a through z >>> sorted(G)[:3] ['a', 'b', 'c'] >>> mapping = dict(zip(G, range(1, 27))) @@ -52,7 +52,7 @@ def relabel_nodes(G, mapping, copy=True): argument to False: >>> G = nx.path_graph(3) # nodes 0-1-2 - >>> mapping = {0: 'a', 1: 'b'} # 0->'a' and 1->'b' + >>> mapping = {0: "a", 1: "b"} # 0->'a' and 1->'b' >>> G = nx.relabel_nodes(G, mapping, copy=False) >>> sorted(G, key=str) [2, 'a', 'b'] @@ -167,9 +167,9 @@ def _relabel_inplace(G, mapping): # Ensure new edges won't overwrite existing ones seen = set() for i, (source, target, key, data) in enumerate(new_edges): - if (target in G[source] and key in G[source][target]): + if target in G[source] and key in G[source][target]: new_key = 0 if not isinstance(key, (int, float)) else key - while (new_key in G[source][target] or (target, new_key) in seen): + while new_key in G[source][target] or (target, new_key) in seen: new_key += 1 new_edges[i] = (source, target, new_key, data) seen.add((target, new_key)) |