diff options
author | Ross Barnowski <rossbar@berkeley.edu> | 2022-03-25 12:10:10 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-25 12:10:10 -0700 |
commit | cc1db275efc709cb964ce88abbfa877798d58c10 (patch) | |
tree | 3d54236598cd075c1aeb7b4b3851da2ce35ab2b3 | |
parent | 93137c5427703ae1e60b53cea88bcbba216ae73f (diff) | |
download | networkx-cc1db275efc709cb964ce88abbfa877798d58c10.tar.gz |
Minor improvements from general code readthrough (#5414)
* Add deprecated directive to reversed docstring.
* Add missing dep directives to shpfiles.
* Remove defn of INF sentinel.
* typo.
* str -> comment in forloop.
* STY: appropriate casing for var name.
-rw-r--r-- | networkx/algorithms/approximation/connectivity.py | 4 | ||||
-rw-r--r-- | networkx/algorithms/approximation/kcomponents.py | 2 | ||||
-rw-r--r-- | networkx/algorithms/asteroidal.py | 7 | ||||
-rw-r--r-- | networkx/algorithms/chordal.py | 16 | ||||
-rw-r--r-- | networkx/readwrite/nx_shp.py | 15 | ||||
-rw-r--r-- | networkx/utils/contextmanagers.py | 5 |
6 files changed, 32 insertions, 17 deletions
diff --git a/networkx/algorithms/approximation/connectivity.py b/networkx/algorithms/approximation/connectivity.py index 2de068ea..06347514 100644 --- a/networkx/algorithms/approximation/connectivity.py +++ b/networkx/algorithms/approximation/connectivity.py @@ -11,8 +11,6 @@ __all__ = [ "all_pairs_node_connectivity", ] -INF = float("inf") - def local_node_connectivity(G, source, target, cutoff=None): """Compute node connectivity between source and target. @@ -95,7 +93,7 @@ def local_node_connectivity(G, source, target, cutoff=None): return K if cutoff is None: - cutoff = INF + cutoff = float("inf") exclude = set() for i in range(min(possible, cutoff)): diff --git a/networkx/algorithms/approximation/kcomponents.py b/networkx/algorithms/approximation/kcomponents.py index 518a0274..97e4e7b2 100644 --- a/networkx/algorithms/approximation/kcomponents.py +++ b/networkx/algorithms/approximation/kcomponents.py @@ -199,7 +199,7 @@ class _AntiGraph(nx.Graph): Class for complement graphs. The main goal is to be able to work with big and dense graphs with - a low memory foodprint. + a low memory footprint. In this class you add the edges that *do not exist* in the dense graph, the report methods of the class return the neighbors, the edges and diff --git a/networkx/algorithms/asteroidal.py b/networkx/algorithms/asteroidal.py index c1bc7181..8dfa9335 100644 --- a/networkx/algorithms/asteroidal.py +++ b/networkx/algorithms/asteroidal.py @@ -76,16 +76,15 @@ def find_asteroidal_triple(G): v_neighborhood = set(G[v]).union([v]) union_of_neighborhoods = u_neighborhood.union(v_neighborhood) for w in V - union_of_neighborhoods: - """Check for each pair of vertices whether they belong to the - same connected component when the closed neighborhood of the - third is removed.""" + # Check for each pair of vertices whether they belong to the + # same connected component when the closed neighborhood of the + # third is removed. if ( component_structure[u][v] == component_structure[u][w] and component_structure[v][u] == component_structure[v][w] and component_structure[w][u] == component_structure[w][v] ): return [u, v, w] - return None diff --git a/networkx/algorithms/chordal.py b/networkx/algorithms/chordal.py index 7c7177af..9cc12f98 100644 --- a/networkx/algorithms/chordal.py +++ b/networkx/algorithms/chordal.py @@ -102,7 +102,7 @@ def find_induced_nodes(G, s, t, treewidth_bound=sys.maxsize): Returns ------- - Induced_nodes : Set of nodes + induced_nodes : Set of nodes The set of induced nodes in the path from s to t in G Raises @@ -143,23 +143,23 @@ def find_induced_nodes(G, s, t, treewidth_bound=sys.maxsize): H = nx.Graph(G) H.add_edge(s, t) - Induced_nodes = set() + induced_nodes = set() triplet = _find_chordality_breaker(H, s, treewidth_bound) while triplet: (u, v, w) = triplet - Induced_nodes.update(triplet) + induced_nodes.update(triplet) for n in triplet: if n != s: H.add_edge(s, n) triplet = _find_chordality_breaker(H, s, treewidth_bound) - if Induced_nodes: + if induced_nodes: # Add t and the second node in the induced path from s to t. - Induced_nodes.add(t) + induced_nodes.add(t) for u in G[s]: - if len(Induced_nodes & set(G[u])) == 2: - Induced_nodes.add(u) + if len(induced_nodes & set(G[u])) == 2: + induced_nodes.add(u) break - return Induced_nodes + return induced_nodes def chordal_graph_cliques(G): diff --git a/networkx/readwrite/nx_shp.py b/networkx/readwrite/nx_shp.py index 74bc0595..58acc757 100644 --- a/networkx/readwrite/nx_shp.py +++ b/networkx/readwrite/nx_shp.py @@ -18,7 +18,14 @@ __all__ = ["read_shp", "write_shp"] def read_shp(path, simplify=True, geom_attrs=True, strict=True): - """Generates a networkx.DiGraph from shapefiles. Point geometries are + """Generates a networkx.DiGraph from shapefiles. + + .. deprecated:: 2.6 + + read_shp is deprecated and will be removed in NetworkX 3.0. + See https://networkx.org/documentation/latest/auto_examples/index.html#geospatial. + + Point geometries are translated into nodes, lines into edges. Coordinate tuples are used as keys. Attributes are preserved, line geometries are simplified into start and end coordinates. Accepts a single shapefile or directory of many @@ -196,6 +203,12 @@ def edges_from_line(geom, attrs, simplify=True, geom_attrs=True): def write_shp(G, outdir): """Writes a networkx.DiGraph to two shapefiles, edges and nodes. + + .. deprecated:: 2.6 + + write_shp is deprecated and will be removed in 3.0. + See https://networkx.org/documentation/latest/auto_examples/index.html#geospatial. + Nodes and edges are expected to have a Well Known Binary (Wkb) or Well Known Text (Wkt) key in order to generate geometries. Also acceptable are nodes with a numeric tuple key (x,y). diff --git a/networkx/utils/contextmanagers.py b/networkx/utils/contextmanagers.py index 870fecb8..d712e346 100644 --- a/networkx/utils/contextmanagers.py +++ b/networkx/utils/contextmanagers.py @@ -8,6 +8,11 @@ __all__ = ["reversed"] def reversed(G): """A context manager for temporarily reversing a directed graph in place. + .. deprecated:: 2.6 + + This context manager is deprecated and will be removed in 3.0. + Use ``G.reverse(copy=False) if G.is_directed() else G`` instead. + This is a no-op for undirected graphs. Parameters |