summaryrefslogtreecommitdiff
path: root/networkx/drawing
diff options
context:
space:
mode:
authorMridul Seth <seth.mridul@gmail.com>2022-06-02 19:54:09 +0400
committerGitHub <noreply@github.com>2022-06-02 08:54:09 -0700
commit5c0b11afb4c0882a070d522ef3fa41482ba935d3 (patch)
tree1b8f21413afd65617420203cf834a8d15d8282ab /networkx/drawing
parent4dba24ba22fc8c4906e16f67b5cf103ee0a830b3 (diff)
downloadnetworkx-5c0b11afb4c0882a070d522ef3fa41482ba935d3.tar.gz
Use isort with pre-commit to enforce import guidelines (#5659)
* Add isort to pre-commit * Run isort on all python files (except __init__.py ones)
Diffstat (limited to 'networkx/drawing')
-rw-r--r--networkx/drawing/nx_agraph.py4
-rw-r--r--networkx/drawing/nx_pydot.py3
-rw-r--r--networkx/drawing/nx_pylab.py21
-rw-r--r--networkx/drawing/tests/test_agraph.py4
-rw-r--r--networkx/drawing/tests/test_layout.py4
-rw-r--r--networkx/drawing/tests/test_pylab.py4
6 files changed, 23 insertions, 17 deletions
diff --git a/networkx/drawing/nx_agraph.py b/networkx/drawing/nx_agraph.py
index a2350ef2..dc636b4b 100644
--- a/networkx/drawing/nx_agraph.py
+++ b/networkx/drawing/nx_agraph.py
@@ -19,6 +19,7 @@ See Also
"""
import os
import tempfile
+
import networkx as nx
__all__ = [
@@ -469,9 +470,10 @@ def display_pygraphviz(graph, path, format=None, prog=None, args=""):
calls if you experience problems.
"""
- from PIL import Image
import warnings
+ from PIL import Image
+
warnings.warn(
"display_pygraphviz is deprecated and will be removed in NetworkX 3.0. "
"To view a graph G using pygraphviz, use nx.nx_agraph.view_pygraphviz(G). "
diff --git a/networkx/drawing/nx_pydot.py b/networkx/drawing/nx_pydot.py
index 0aa6612a..7df22b9c 100644
--- a/networkx/drawing/nx_pydot.py
+++ b/networkx/drawing/nx_pydot.py
@@ -20,8 +20,9 @@ See Also
- DOT Language: http://www.graphviz.org/doc/info/lang.html
"""
from locale import getpreferredencoding
-from networkx.utils import open_file
+
import networkx as nx
+from networkx.utils import open_file
__all__ = [
"write_dot",
diff --git a/networkx/drawing/nx_pylab.py b/networkx/drawing/nx_pylab.py
index 6c5cb804..18ce0845 100644
--- a/networkx/drawing/nx_pylab.py
+++ b/networkx/drawing/nx_pylab.py
@@ -17,15 +17,16 @@ See Also
- :obj:`matplotlib.patches.FancyArrowPatch`
"""
from numbers import Number
+
import networkx as nx
from networkx.drawing.layout import (
- shell_layout,
circular_layout,
kamada_kawai_layout,
+ planar_layout,
+ random_layout,
+ shell_layout,
spectral_layout,
spring_layout,
- random_layout,
- planar_layout,
)
__all__ = [
@@ -405,10 +406,11 @@ def draw_networkx_nodes(
draw_networkx_edge_labels
"""
from collections.abc import Iterable
- import numpy as np
+
import matplotlib as mpl
import matplotlib.collections # call as mpl.collections
import matplotlib.pyplot as plt
+ import numpy as np
if ax is None:
ax = plt.gca()
@@ -636,13 +638,13 @@ def draw_networkx_edges(
draw_networkx_edge_labels
"""
- import numpy as np
import matplotlib as mpl
+ import matplotlib.collections # call as mpl.collections
import matplotlib.colors # call as mpl.colors
import matplotlib.patches # call as mpl.patches
- import matplotlib.collections # call as mpl.collections
import matplotlib.path # call as mpl.path
import matplotlib.pyplot as plt
+ import numpy as np
# The default behavior is to use LineCollection to draw edges for
# undirected graphs (for performance reasons) and use FancyArrowPatches
@@ -1475,11 +1477,12 @@ def apply_alpha(colors, alpha, elem_list, cmap=None, vmin=None, vmax=None):
Array containing RGBA format values for each of the node colours.
"""
- from itertools import islice, cycle
- import numpy as np
+ from itertools import cycle, islice
+
import matplotlib as mpl
- import matplotlib.colors # call as mpl.colors
import matplotlib.cm # call as mpl.cm
+ import matplotlib.colors # call as mpl.colors
+ import numpy as np
# If we have been provided with a list of numbers as long as elem_list,
# apply the color mapping.
diff --git a/networkx/drawing/tests/test_agraph.py b/networkx/drawing/tests/test_agraph.py
index 33e77c36..c99d29fb 100644
--- a/networkx/drawing/tests/test_agraph.py
+++ b/networkx/drawing/tests/test_agraph.py
@@ -1,14 +1,14 @@
"""Unit tests for PyGraphviz interface."""
import os
import tempfile
+
import pytest
pygraphviz = pytest.importorskip("pygraphviz")
-from networkx.utils import nodes_equal, edges_equal, graphs_equal
-
import networkx as nx
+from networkx.utils import edges_equal, graphs_equal, nodes_equal
class TestAGraph:
diff --git a/networkx/drawing/tests/test_layout.py b/networkx/drawing/tests/test_layout.py
index 2626c70a..f2fd90e7 100644
--- a/networkx/drawing/tests/test_layout.py
+++ b/networkx/drawing/tests/test_layout.py
@@ -1,8 +1,8 @@
"""Unit tests for layout functions."""
-import networkx as nx
-
import pytest
+import networkx as nx
+
np = pytest.importorskip("numpy")
pytest.importorskip("scipy")
diff --git a/networkx/drawing/tests/test_pylab.py b/networkx/drawing/tests/test_pylab.py
index c5189fd6..33ce4e85 100644
--- a/networkx/drawing/tests/test_pylab.py
+++ b/networkx/drawing/tests/test_pylab.py
@@ -1,6 +1,6 @@
"""Unit tests for matplotlib drawing functions."""
-import os
import itertools
+import os
import pytest
@@ -641,8 +641,8 @@ def test_draw_edges_toggling_with_arrows_kwarg():
- ``arrows=True`` -> FancyArrowPatches
- ``arrows=False`` -> LineCollection
"""
- import matplotlib.patches
import matplotlib.collections
+ import matplotlib.patches
UG = nx.path_graph(3)
DG = nx.path_graph(3, create_using=nx.DiGraph)