Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save SomeoneSerge/32e97fbab80de23e53edc5c0d407cd5f to your computer and use it in GitHub Desktop.
Save SomeoneSerge/32e97fbab80de23e53edc5c0d407cd5f to your computer and use it in GitHub Desktop.
nix log /nix/store/pvi591yvwbmrxfsn8xnap2qnc1idxx0m-python3.10-retworkx-0.11.0.drv
Sourcing python-remove-tests-dir-hook
Sourcing python-catch-conflicts-hook.sh
Sourcing python-remove-bin-bytecode-hook.sh
Sourcing pip-build-hook
Using pipBuildPhase
Using pipShellHook
Sourcing pip-install-hook
Using pipInstallPhase
Sourcing python-imports-check-hook.sh
Using pythonImportsCheckPhase
Sourcing python-namespaces-hook
Sourcing python-catch-conflicts-hook.sh
Sourcing pytest-check-hook
Using pytestCheckPhase
@nix { "action": "setPhase", "phase": "unpackPhase" }
unpacking sources
unpacking source archive /nix/store/5g136amf6s7kjl2ddppw802173qxlnfi-source
source root is source
Executing cargoSetupPostUnpackHook
unpacking source archive /nix/store/az9a8g8nq83pjglyyhl1mmzlg3fd1dh9-retworkx-0.11.0-vendor.tar.gz
Finished cargoSetupPostUnpackHook
setting SOURCE_DATE_EPOCH to timestamp 315619200 of file source/tox.ini
@nix { "action": "setPhase", "phase": "patchPhase" }
patching sources
Executing cargoSetupPostPatchHook
Validating consistency between /build/source/Cargo.lock and /build/retworkx-0.11.0-vendor.tar.gz/Cargo.lock
Finished cargoSetupPostPatchHook
@nix { "action": "setPhase", "phase": "configurePhase" }
configuring
no configure script, doing nothing
@nix { "action": "setPhase", "phase": "buildPhase" }
building
Executing maturinBuildHook
++ env CC_x86_64-unknown-linux-gnu=/nix/store/rj91g41smpmp92xvhx6rjxz6878bn2b4-gcc-wrapper-12.2.0/bin/cc CXX_x86_64-unknown-linux-gnu=/nix/store/rj91g41smpmp92xvhx6rjxz6878bn2b4-gcc-wrapper-12.2.0/bin/c++ CC_x86_64-unknown-linux-gnu=/nix/store/rj91g41smpmp92xvhx6rjxz6878bn2b4-gcc-wrapper-12.2.0/bin/cc CXX_x86_64-unknown-linux-gnu=/nix/store/rj91g41smpmp92xvhx6rjxz6878bn2b4-gcc-wrapper-12.2.0/bin/c++ maturin build --jobs=24 --frozen --target x86_64-unknown-linux-gnu --manylinux off --strip --release
⚠️ Warning: `build-backend` in pyproject.toml is not set to `maturin`, packaging tools such as pip will not use maturin to build this project.
🍹 Building a mixed python/rust project
🔗 Found pyo3 bindings
🐍 Found CPython 3.10 at /nix/store/0n4y44dnaxafqs7cg625aldrb152x7bx-python3-3.10.10/bin/python3
 Compiling autocfg v1.0.1
 Compiling cfg-if v1.0.0
 Compiling libc v0.2.101
 Compiling crossbeam-utils v0.8.5
 Compiling lazy_static v1.4.0
 Compiling scopeguard v1.1.0
 Compiling crossbeam-epoch v0.9.5
 Compiling rayon-core v1.9.1
 Compiling proc-macro2 v1.0.29
 Compiling version_check v0.9.3
 Compiling unicode-xid v0.2.2
 Compiling syn v1.0.76
 Compiling proc-macro-hack v0.5.19
 Compiling either v1.6.1
 Compiling pyo3-build-config v0.15.1
 Compiling once_cell v1.8.0
 Compiling parking_lot_core v0.8.5
 Compiling unindent v0.1.7
 Compiling smallvec v1.6.1
 Compiling ndarray v0.13.1
 Compiling rawpointer v0.2.1
 Compiling fixedbitset v0.4.1
 Compiling instant v0.1.10
 Compiling lock_api v0.4.5
 Compiling matrixmultiply v0.2.4
 Compiling ppv-lite86 v0.2.10
 Compiling cfg-if v0.1.10
 Compiling ahash v0.7.6
 Compiling memoffset v0.6.4
 Compiling num-traits v0.2.14
 Compiling rayon v1.5.1
 Compiling num-integer v0.1.44
 Compiling indexmap v1.7.0
 Compiling num-bigint v0.4.3
 Compiling num-complex v0.2.4
 Compiling crossbeam-channel v0.5.1
 Compiling quote v1.0.9
 Compiling getrandom v0.2.3
 Compiling num_cpus v1.13.0
 Compiling rand_core v0.6.3
 Compiling crossbeam-deque v0.8.1
 Compiling parking_lot v0.11.2
 Compiling paste-impl v0.1.18
 Compiling rand_chacha v0.3.1
 Compiling rand_pcg v0.3.1
 Compiling rand v0.8.4
 Compiling pyo3 v0.15.1
 Compiling num-complex v0.4.0
 Compiling paste v0.1.18
 Compiling pyo3-macros-backend v0.15.1
 Compiling hashbrown v0.11.2
 Compiling indoc-impl v0.3.6
 Compiling indoc v0.3.6
 Compiling petgraph v0.6.0
 Compiling pyo3-macros v0.15.1
 Compiling retworkx-core v0.11.0 (/build/source/retworkx-core)
 Compiling numpy v0.15.1
 Compiling retworkx v0.11.0 (/build/source)
 Finished release [optimized] target(s) in 17m 18s
📦 Built wheel for CPython 3.10 to /build/source/target/wheels/retworkx-0.11.0-cp310-cp310-linux_x86_64.whl
Finished maturinBuildHook
buildPhase completed in 17 minutes 20 seconds
@nix { "action": "setPhase", "phase": "installPhase" }
installing
Executing pipInstallPhase
/build/source/dist /build/source
Processing ./retworkx-0.11.0-cp310-cp310-linux_x86_64.whl
Installing collected packages: retworkx
Successfully installed retworkx-0.11.0
/build/source
Finished executing pipInstallPhase
@nix { "action": "setPhase", "phase": "pythonOutputDistPhase" }
pythonOutputDistPhase
Executing pythonOutputDistPhase
Finished executing pythonOutputDistPhase
@nix { "action": "setPhase", "phase": "fixupPhase" }
post-installation fixup
shrinking RPATHs of ELF executables and libraries in /nix/store/2x320q4976sx7qhy8y1lj751l18f8y8p-python3.10-retworkx-0.11.0
shrinking /nix/store/2x320q4976sx7qhy8y1lj751l18f8y8p-python3.10-retworkx-0.11.0/lib/python3.10/site-packages/retworkx/retworkx.cpython-310-x86_64-linux-gnu.so
checking for references to /build/ in /nix/store/2x320q4976sx7qhy8y1lj751l18f8y8p-python3.10-retworkx-0.11.0...
patching script interpreter paths in /nix/store/2x320q4976sx7qhy8y1lj751l18f8y8p-python3.10-retworkx-0.11.0
stripping (with command strip and flags -S) in /nix/store/2x320q4976sx7qhy8y1lj751l18f8y8p-python3.10-retworkx-0.11.0/lib
shrinking RPATHs of ELF executables and libraries in /nix/store/c0n334lijj8hbq1xjpf7di69wkr1r8dv-python3.10-retworkx-0.11.0-dist
checking for references to /build/ in /nix/store/c0n334lijj8hbq1xjpf7di69wkr1r8dv-python3.10-retworkx-0.11.0-dist...
patching script interpreter paths in /nix/store/c0n334lijj8hbq1xjpf7di69wkr1r8dv-python3.10-retworkx-0.11.0-dist
Executing pythonRemoveTestsDir
Finished executing pythonRemoveTestsDir
@nix { "action": "setPhase", "phase": "installCheckPhase" }
running install tests
no Makefile or custom installCheckPhase, doing nothing
@nix { "action": "setPhase", "phase": "pythonCatchConflictsPhase" }
pythonCatchConflictsPhase
@nix { "action": "setPhase", "phase": "pythonRemoveBinBytecodePhase" }
pythonRemoveBinBytecodePhase
@nix { "action": "setPhase", "phase": "pythonImportsCheckPhase" }
pythonImportsCheckPhase
Executing pythonImportsCheckPhase
Check whether the following modules can be imported: retworkx
@nix { "action": "setPhase", "phase": "pytestCheckPhase" }
pytestCheckPhase
Executing pytestCheckPhase
/build/tmp.5q6QvqzTsi /build/source
============================= test session starts ==============================
platform linux -- Python 3.10.10, pytest-7.2.1, pluggy-1.0.0
rootdir: /build/tmp.5q6QvqzTsi
collecting ...  collecting 10 items  collecting 340 items  collecting 495 items  collecting 682 items  collecting 958 items  collecting 1057 items  collecting 1128 items  collecting 1303 items  collecting 1457 items  collecting 1567 items  collecting 1577 items  collected 1577 items 
tests/test_converters.py .......... [ 0%]
tests/test_custom_return_types.py ...................................... [ 3%]
........................................................................ [ 7%]
........................................................................ [ 12%]
........................................................................ [ 16%]
............................................................. [ 20%]
tests/test_dispatch.py .............................. [ 22%]
tests/test_random.py ............................... [ 24%]
tests/digraph/test_adj.py ........... [ 25%]
tests/digraph/test_adjacency_matrix.py ........................ [ 26%]
tests/digraph/test_all_simple_paths.py ....... [ 27%]
tests/digraph/test_ancestors_descendants.py ...... [ 27%]
tests/digraph/test_astar.py .... [ 27%]
tests/digraph/test_avg_shortest_path.py .................... [ 29%]
tests/digraph/test_bfs_search.py ........ [ 29%]
tests/digraph/test_cartesian_product.py ..... [ 29%]
tests/digraph/test_centrality.py ......... [ 30%]
tests/digraph/test_collect_bicolor_runs.py ....... [ 30%]
tests/digraph/test_collect_runs.py ........ [ 31%]
tests/digraph/test_complement.py .... [ 31%]
tests/digraph/test_compose.py ... [ 31%]
tests/digraph/test_contract_nodes.py ............. [ 32%]
tests/digraph/test_copy.py .... [ 32%]
tests/digraph/test_core_number.py .... [ 33%]
tests/digraph/test_deepcopy.py ... [ 33%]
tests/digraph/test_depth.py .................. [ 34%]
tests/digraph/test_dfs_edges.py .. [ 34%]
tests/digraph/test_dfs_search.py .... [ 34%]
tests/digraph/test_dijkstra.py ....................... [ 36%]
tests/digraph/test_dijkstra_search.py ...... [ 36%]
tests/digraph/test_dist_matrix.py ....... [ 37%]
tests/digraph/test_dot.py .... [ 37%]
tests/digraph/test_edgelist.py ............... [ 38%]
tests/digraph/test_edges.py ............................................ [ 41%]
............................................................ [ 44%]
tests/digraph/test_find_cycle.py ..... [ 45%]
tests/digraph/test_floyd_warshall.py .............................. [ 47%]
tests/digraph/test_isomorphic.py .......................... [ 48%]
tests/digraph/test_k_shortest_path.py ..... [ 49%]
tests/digraph/test_layers.py .. [ 49%]
tests/digraph/test_layout.py ................................. [ 51%]
tests/digraph/test_neighbors.py ..... [ 51%]
tests/digraph/test_nodes.py ........................................ [ 54%]
tests/digraph/test_num_shortest_path.py ....... [ 54%]
tests/digraph/test_pred_succ.py ..................... [ 55%]
tests/digraph/test_spring_layout.py ........ [ 56%]
tests/digraph/test_strongly_connected.py .... [ 56%]
tests/digraph/test_subgraph.py ......... [ 57%]
tests/digraph/test_subgraph_isomorphic.py ................... [ 58%]
tests/digraph/test_substitute_node_with_subgraph.py ........... [ 59%]
tests/digraph/test_symmetric.py .. [ 59%]
tests/digraph/test_to_undirected.py ...... [ 59%]
tests/digraph/test_toposort.py ...... [ 60%]
tests/digraph/test_transitivity.py .... [ 60%]
tests/digraph/test_union.py ...... [ 60%]
tests/digraph/test_weakly_connected.py ........ [ 61%]
tests/generators/test_barbell.py .... [ 61%]
tests/generators/test_binomial_tree.py ............. [ 62%]
tests/generators/test_cycle.py ....... [ 62%]
tests/generators/test_full_rary_tree.py ..... [ 63%]
tests/generators/test_grid.py .......... [ 63%]
tests/generators/test_heavy_hex.py ......... [ 64%]
tests/generators/test_heavy_square.py ......... [ 64%]
tests/generators/test_hexagonal.py ............ [ 65%]
tests/generators/test_lollipop.py ...... [ 66%]
tests/generators/test_mesh.py ...... [ 66%]
tests/generators/test_path.py ....... [ 66%]
tests/generators/test_petersen.py ... [ 67%]
tests/generators/test_star.py .......... [ 67%]
tests/graph/test_adj.py .. [ 67%]
tests/graph/test_adjencency_matrix.py ......................... [ 69%]
tests/graph/test_all_simple_paths.py ....... [ 69%]
tests/graph/test_astar.py .... [ 70%]
tests/graph/test_avg_shortest_path.py .......... [ 70%]
tests/graph/test_bfs_search.py ........ [ 71%]
tests/graph/test_biconnected.py ..... [ 71%]
tests/graph/test_cartesian_product.py ..... [ 71%]
tests/graph/test_centrality.py ...... [ 72%]
tests/graph/test_chain_decomposition.py .... [ 72%]
tests/graph/test_coloring.py ... [ 72%]
tests/graph/test_complement.py ..... [ 72%]
tests/graph/test_compose.py ... [ 73%]
tests/graph/test_connected_components.py ........ [ 73%]
tests/graph/test_contract_nodes.py ......... [ 74%]
tests/graph/test_copy.py .... [ 74%]
tests/graph/test_core_number.py .... [ 74%]
tests/graph/test_cycle_basis.py ..... [ 75%]
tests/graph/test_deepcopy.py ... [ 75%]
tests/graph/test_dfs_edges.py .. [ 75%]
tests/graph/test_dfs_search.py .... [ 75%]
tests/graph/test_dijkstra.py ................. [ 76%]
tests/graph/test_dijkstra_search.py ...... [ 77%]
tests/graph/test_dist_matrix.py ..... [ 77%]
tests/graph/test_dot.py ...... [ 77%]
tests/graph/test_edgelist.py ............... [ 78%]
tests/graph/test_edges.py .............................................. [ 81%]
.............................................. [ 84%]
tests/graph/test_floyd_warshall.py ........................ [ 86%]
tests/graph/test_isomorphic.py ......................... [ 87%]
tests/graph/test_k_shortest_path.py ..... [ 88%]
tests/graph/test_layout.py ................................. [ 90%]
tests/graph/test_matching.py ........ [ 90%]
tests/graph/test_max_weight_matching.py ............................ [ 92%]
tests/graph/test_mst.py ....... [ 92%]
tests/graph/test_neighbors.py ... [ 93%]
tests/graph/test_nodes.py ..................... [ 94%]
tests/graph/test_num_shortest_path.py ....... [ 94%]
tests/graph/test_spring_layout.py ........ [ 95%]
tests/graph/test_steiner_tree.py ......... [ 95%]
tests/graph/test_subgraph.py ......... [ 96%]
tests/graph/test_subgraph_isomorphic.py ...................... [ 97%]
tests/graph/test_to_directed.py .... [ 98%]
tests/graph/test_transitivity.py ..... [ 98%]
tests/graph/test_union.py ...... [ 98%]
tests/visualization/test_graphviz.py sssssssss [ 99%]
tests/visualization/test_mpl.py FF.F.FFFF. [100%]
=================================== FAILURES ===================================
_________________________ TestMPLDraw.test_alpha_iter __________________________
self = <tests.visualization.test_mpl.TestMPLDraw testMethod=test_alpha_iter>
def test_alpha_iter(self):
graph = retworkx.generators.grid_graph(4, 6)
# with fewer alpha elements than nodes
plt.subplot(131)
> mpl_draw(graph, alpha=[0.1, 0.2])
tests/visualization/test_mpl.py:130:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
graph = <retworkx.PyGraph object at 0x7fff27646540>, pos = None, ax = None
arrows = True, with_labels = False, kwds = {'alpha': [0.1, 0.2]}
plt = <module 'matplotlib.pyplot' from '/nix/store/w19ags7fn0h3vf1whck5pg548xan9afg-python3.10-matplotlib-3.7.0/lib/python3.10/site-packages/matplotlib/pyplot.py'>
cf = <Figure size 640x480 with 1 Axes>
def mpl_draw(graph, pos=None, ax=None, arrows=True, with_labels=False, **kwds):
r"""Draw a graph with Matplotlib.
.. note::
Matplotlib is an optional dependency and will not be installed with
retworkx by default. If you intend to use this function make sure that
you install matplotlib with either ``pip install matplotlib`` or
``pip install 'retworkx[mpl]'``
:param graph: A retworkx graph, either a :class:`~retworkx.PyGraph` or a
:class:`~retworkx.PyDiGraph`.
:param dict pos: An optional dictionary (or
a :class:`~retworkx.Pos2DMapping` object) with nodes as keys and
positions as values. If not specified a spring layout positioning will
be computed. See `layout_functions` for functions that compute
node positions.
:param matplotlib.Axes ax: An optional Matplotlib Axes object to draw the
graph in.
:param bool arrows: For :class:`~retworkx.PyDiGraph` objects if ``True``
draw arrowheads. (defaults to ``True``) Note, that the Arrows will
be the same color as edges.
:param str arrowstyle: An optional string for directed graphs to choose
the style of the arrowsheads. See
:class:`matplotlib.patches.ArrowStyle` for more options. By default the
value is set to ``'-\|>'``.
:param int arrow_size: For directed graphs, choose the size of the arrow
head's length and width. See
:class:`matplotlib.patches.FancyArrowPatch` attribute and constructor
kwarg ``mutation_scale`` for more info. Defaults to 10.
:param bool with_labels: Set to ``True`` to draw labels on the nodes. Edge
labels will only be drawn if the ``edge_labels`` parameter is set to a
function. Defaults to ``False``.
:param list node_list: An optional list of node indices in the graph to
draw. If not specified all nodes will be drawn.
:param list edge_list: An option list of edges in the graph to draw. If not
specified all edges will be drawn
:param int|list node_size: Optional size of nodes. If an array is
specified it must be the same length as node_list. Defaults to 300
:param node_color: Optional node color. Can be a single color or
a sequence of colors with the same length as node_list. Color can be
string or rgb (or rgba) tuple of floats from 0-1. If numeric values
are specified they will be mapped to colors using the ``cmap`` and
``vmin``,``vmax`` parameters. See :func:`matplotlib.scatter` for more
details. Defaults to ``'#1f78b4'``)
:param str node_shape: The optional shape node. The specification is the
same as the :func:`matplotlib.pyplot.scatter` function's ``marker``
kwarg, valid options are one of
``['s', 'o', '^', '>', 'v', '<', 'd', 'p', 'h', '8']``. Defaults to
``'o'``
:param float alpha: Optional value for node and edge transparency
:param matplotlib.colors.Colormap cmap: An optional Matplotlib colormap
object for mapping intensities of nodes
:param float vmin: Optional minimum value for node colormap scaling
:param float vmax: Optional minimum value for node colormap scaling
:param float|sequence linewidths: An optional line width for symbol
borders. If a sequence is specified it must be the same length as
node_list. Defaults to 1.0
:param float|sequence width: An optional width to use for edges. Can
either be a float or sequence of floats. If a sequence is specified
it must be the same length as node_list. Defaults to 1.0
:param str|sequence edge_color: color or array of colors (default='k')
Edge color. Can be a single color or a sequence of colors with the same
length as edge_list. Color can be string or rgb (or rgba) tuple of
floats from 0-1. If numeric values are specified they will be
mapped to colors using the ``edge_cmap`` and ``edge_vmin``,
``edge_vmax`` parameters.
:param matplotlib.colors.Colormap edge_cmap: An optional Matplotlib
colormap for mapping intensities of edges.
:param float edge_vmin: Optional minimum value for edge colormap scaling
:param float edge_vmax: Optional maximum value for node colormap scaling
:param str style: An optional string to specify the edge line style.
For example, ``'-'``, ``'--'``, ``'-.'``, ``':'`` or words like
``'solid'`` or ``'dashed'``. See the
:class:`matplotlib.patches.FancyArrowPatch` attribute and kwarg
``linestyle`` for more details. Defaults to ``'solid'``.
:param func labels: An optional callback function that will be passed a
node payload and return a string label for the node. For example::
labels=str
could be used to just return a string cast of the node's data payload.
Or something like::
labels=lambda node: node['label']
could be used if the node payloads are dictionaries.
:param func edge_labels: An optional callback function that will be passed
an edge payload and return a string label for the edge. For example::
edge_labels=str
could be used to just return a string cast of the edge's data payload.
Or something like::
edge_labels=lambda edge: edge['label']
could be used if the edge payloads are dictionaries. If this is set
edge labels will be drawn in the visualization.
:param int font_size: An optional fontsize to use for text labels, By
default a value of 12 is used for nodes and 10 for edges.
:param str font_color: An optional font color for strings. By default
``'k'`` (ie black) is set.
:param str font_weight: An optional string used to specify the font weight.
By default a value of ``'normal'`` is used.
:param str font_family: An optional font family to use for strings. By
default ``'sans-serif'`` is used.
:param str label: An optional string label to use for the graph legend.
:param str connectionstyle: An optional value used to create a curved arc
of rounding radius rad. For example,
``connectionstyle='arc3,rad=0.2'``. See
:class:`matplotlib.patches.ConnectionStyle` and
:class:`matplotlib.patches.FancyArrowPatch` for more info. By default
this is set to ``"arc3"``.
:returns: A matplotlib figure for the visualization if not running with an
interactive backend (like in jupyter) or if ``ax`` is not set.
:rtype: matplotlib.figure.Figure
For Example:
.. jupyter-execute::
import matplotlib.pyplot as plt
import retworkx
from retworkx.visualization import mpl_draw
G = retworkx.generators.directed_path_graph(25)
mpl_draw(G)
plt.draw()
"""
try:
import matplotlib.pyplot as plt
except ImportError as e:
raise ImportError(
"matplotlib needs to be installed prior to running "
"retworkx.visualization.mpl_draw(). You can install "
"matplotlib with:\n'pip install matplotlib'"
) from e
if ax is None:
cf = plt.gcf()
else:
cf = ax.get_figure()
cf.set_facecolor("w")
if ax is None:
> if cf._axstack() is None:
E TypeError: '_AxesStack' object is not callable
/nix/store/2x320q4976sx7qhy8y1lj751l18f8y8p-python3.10-retworkx-0.11.0/lib/python3.10/site-packages/retworkx/visualization/matplotlib.py:212: TypeError
___________________________ TestMPLDraw.test_arrows ____________________________
self = <tests.visualization.test_mpl.TestMPLDraw testMethod=test_arrows>
def test_arrows(self):
graph = retworkx.generators.directed_star_graph(24)
> fig = mpl_draw(graph)
tests/visualization/test_mpl.py:72:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
graph = <retworkx.PyDiGraph object at 0x7ffff7458460>, pos = None, ax = None
arrows = True, with_labels = False, kwds = {}
plt = <module 'matplotlib.pyplot' from '/nix/store/w19ags7fn0h3vf1whck5pg548xan9afg-python3.10-matplotlib-3.7.0/lib/python3.10/site-packages/matplotlib/pyplot.py'>
cf = <Figure size 640x480 with 1 Axes>
def mpl_draw(graph, pos=None, ax=None, arrows=True, with_labels=False, **kwds):
r"""Draw a graph with Matplotlib.
.. note::
Matplotlib is an optional dependency and will not be installed with
retworkx by default. If you intend to use this function make sure that
you install matplotlib with either ``pip install matplotlib`` or
``pip install 'retworkx[mpl]'``
:param graph: A retworkx graph, either a :class:`~retworkx.PyGraph` or a
:class:`~retworkx.PyDiGraph`.
:param dict pos: An optional dictionary (or
a :class:`~retworkx.Pos2DMapping` object) with nodes as keys and
positions as values. If not specified a spring layout positioning will
be computed. See `layout_functions` for functions that compute
node positions.
:param matplotlib.Axes ax: An optional Matplotlib Axes object to draw the
graph in.
:param bool arrows: For :class:`~retworkx.PyDiGraph` objects if ``True``
draw arrowheads. (defaults to ``True``) Note, that the Arrows will
be the same color as edges.
:param str arrowstyle: An optional string for directed graphs to choose
the style of the arrowsheads. See
:class:`matplotlib.patches.ArrowStyle` for more options. By default the
value is set to ``'-\|>'``.
:param int arrow_size: For directed graphs, choose the size of the arrow
head's length and width. See
:class:`matplotlib.patches.FancyArrowPatch` attribute and constructor
kwarg ``mutation_scale`` for more info. Defaults to 10.
:param bool with_labels: Set to ``True`` to draw labels on the nodes. Edge
labels will only be drawn if the ``edge_labels`` parameter is set to a
function. Defaults to ``False``.
:param list node_list: An optional list of node indices in the graph to
draw. If not specified all nodes will be drawn.
:param list edge_list: An option list of edges in the graph to draw. If not
specified all edges will be drawn
:param int|list node_size: Optional size of nodes. If an array is
specified it must be the same length as node_list. Defaults to 300
:param node_color: Optional node color. Can be a single color or
a sequence of colors with the same length as node_list. Color can be
string or rgb (or rgba) tuple of floats from 0-1. If numeric values
are specified they will be mapped to colors using the ``cmap`` and
``vmin``,``vmax`` parameters. See :func:`matplotlib.scatter` for more
details. Defaults to ``'#1f78b4'``)
:param str node_shape: The optional shape node. The specification is the
same as the :func:`matplotlib.pyplot.scatter` function's ``marker``
kwarg, valid options are one of
``['s', 'o', '^', '>', 'v', '<', 'd', 'p', 'h', '8']``. Defaults to
``'o'``
:param float alpha: Optional value for node and edge transparency
:param matplotlib.colors.Colormap cmap: An optional Matplotlib colormap
object for mapping intensities of nodes
:param float vmin: Optional minimum value for node colormap scaling
:param float vmax: Optional minimum value for node colormap scaling
:param float|sequence linewidths: An optional line width for symbol
borders. If a sequence is specified it must be the same length as
node_list. Defaults to 1.0
:param float|sequence width: An optional width to use for edges. Can
either be a float or sequence of floats. If a sequence is specified
it must be the same length as node_list. Defaults to 1.0
:param str|sequence edge_color: color or array of colors (default='k')
Edge color. Can be a single color or a sequence of colors with the same
length as edge_list. Color can be string or rgb (or rgba) tuple of
floats from 0-1. If numeric values are specified they will be
mapped to colors using the ``edge_cmap`` and ``edge_vmin``,
``edge_vmax`` parameters.
:param matplotlib.colors.Colormap edge_cmap: An optional Matplotlib
colormap for mapping intensities of edges.
:param float edge_vmin: Optional minimum value for edge colormap scaling
:param float edge_vmax: Optional maximum value for node colormap scaling
:param str style: An optional string to specify the edge line style.
For example, ``'-'``, ``'--'``, ``'-.'``, ``':'`` or words like
``'solid'`` or ``'dashed'``. See the
:class:`matplotlib.patches.FancyArrowPatch` attribute and kwarg
``linestyle`` for more details. Defaults to ``'solid'``.
:param func labels: An optional callback function that will be passed a
node payload and return a string label for the node. For example::
labels=str
could be used to just return a string cast of the node's data payload.
Or something like::
labels=lambda node: node['label']
could be used if the node payloads are dictionaries.
:param func edge_labels: An optional callback function that will be passed
an edge payload and return a string label for the edge. For example::
edge_labels=str
could be used to just return a string cast of the edge's data payload.
Or something like::
edge_labels=lambda edge: edge['label']
could be used if the edge payloads are dictionaries. If this is set
edge labels will be drawn in the visualization.
:param int font_size: An optional fontsize to use for text labels, By
default a value of 12 is used for nodes and 10 for edges.
:param str font_color: An optional font color for strings. By default
``'k'`` (ie black) is set.
:param str font_weight: An optional string used to specify the font weight.
By default a value of ``'normal'`` is used.
:param str font_family: An optional font family to use for strings. By
default ``'sans-serif'`` is used.
:param str label: An optional string label to use for the graph legend.
:param str connectionstyle: An optional value used to create a curved arc
of rounding radius rad. For example,
``connectionstyle='arc3,rad=0.2'``. See
:class:`matplotlib.patches.ConnectionStyle` and
:class:`matplotlib.patches.FancyArrowPatch` for more info. By default
this is set to ``"arc3"``.
:returns: A matplotlib figure for the visualization if not running with an
interactive backend (like in jupyter) or if ``ax`` is not set.
:rtype: matplotlib.figure.Figure
For Example:
.. jupyter-execute::
import matplotlib.pyplot as plt
import retworkx
from retworkx.visualization import mpl_draw
G = retworkx.generators.directed_path_graph(25)
mpl_draw(G)
plt.draw()
"""
try:
import matplotlib.pyplot as plt
except ImportError as e:
raise ImportError(
"matplotlib needs to be installed prior to running "
"retworkx.visualization.mpl_draw(). You can install "
"matplotlib with:\n'pip install matplotlib'"
) from e
if ax is None:
cf = plt.gcf()
else:
cf = ax.get_figure()
cf.set_facecolor("w")
if ax is None:
> if cf._axstack() is None:
E TypeError: '_AxesStack' object is not callable
/nix/store/2x320q4976sx7qhy8y1lj751l18f8y8p-python3.10-retworkx-0.11.0/lib/python3.10/site-packages/retworkx/visualization/matplotlib.py:212: TypeError
____________________________ TestMPLDraw.test_draw _____________________________
self = <tests.visualization.test_mpl.TestMPLDraw testMethod=test_draw>
def test_draw(self):
graph = retworkx.generators.star_graph(24)
options = {"node_color": "black", "node_size": 100, "width": 3}
> fig = mpl_draw(graph, **options)
tests/visualization/test_mpl.py:49:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
graph = <retworkx.PyGraph object at 0x7fff24276440>, pos = None, ax = None
arrows = True, with_labels = False
kwds = {'node_color': 'black', 'node_size': 100, 'width': 3}
plt = <module 'matplotlib.pyplot' from '/nix/store/w19ags7fn0h3vf1whck5pg548xan9afg-python3.10-matplotlib-3.7.0/lib/python3.10/site-packages/matplotlib/pyplot.py'>
cf = <Figure size 640x480 with 1 Axes>
def mpl_draw(graph, pos=None, ax=None, arrows=True, with_labels=False, **kwds):
r"""Draw a graph with Matplotlib.
.. note::
Matplotlib is an optional dependency and will not be installed with
retworkx by default. If you intend to use this function make sure that
you install matplotlib with either ``pip install matplotlib`` or
``pip install 'retworkx[mpl]'``
:param graph: A retworkx graph, either a :class:`~retworkx.PyGraph` or a
:class:`~retworkx.PyDiGraph`.
:param dict pos: An optional dictionary (or
a :class:`~retworkx.Pos2DMapping` object) with nodes as keys and
positions as values. If not specified a spring layout positioning will
be computed. See `layout_functions` for functions that compute
node positions.
:param matplotlib.Axes ax: An optional Matplotlib Axes object to draw the
graph in.
:param bool arrows: For :class:`~retworkx.PyDiGraph` objects if ``True``
draw arrowheads. (defaults to ``True``) Note, that the Arrows will
be the same color as edges.
:param str arrowstyle: An optional string for directed graphs to choose
the style of the arrowsheads. See
:class:`matplotlib.patches.ArrowStyle` for more options. By default the
value is set to ``'-\|>'``.
:param int arrow_size: For directed graphs, choose the size of the arrow
head's length and width. See
:class:`matplotlib.patches.FancyArrowPatch` attribute and constructor
kwarg ``mutation_scale`` for more info. Defaults to 10.
:param bool with_labels: Set to ``True`` to draw labels on the nodes. Edge
labels will only be drawn if the ``edge_labels`` parameter is set to a
function. Defaults to ``False``.
:param list node_list: An optional list of node indices in the graph to
draw. If not specified all nodes will be drawn.
:param list edge_list: An option list of edges in the graph to draw. If not
specified all edges will be drawn
:param int|list node_size: Optional size of nodes. If an array is
specified it must be the same length as node_list. Defaults to 300
:param node_color: Optional node color. Can be a single color or
a sequence of colors with the same length as node_list. Color can be
string or rgb (or rgba) tuple of floats from 0-1. If numeric values
are specified they will be mapped to colors using the ``cmap`` and
``vmin``,``vmax`` parameters. See :func:`matplotlib.scatter` for more
details. Defaults to ``'#1f78b4'``)
:param str node_shape: The optional shape node. The specification is the
same as the :func:`matplotlib.pyplot.scatter` function's ``marker``
kwarg, valid options are one of
``['s', 'o', '^', '>', 'v', '<', 'd', 'p', 'h', '8']``. Defaults to
``'o'``
:param float alpha: Optional value for node and edge transparency
:param matplotlib.colors.Colormap cmap: An optional Matplotlib colormap
object for mapping intensities of nodes
:param float vmin: Optional minimum value for node colormap scaling
:param float vmax: Optional minimum value for node colormap scaling
:param float|sequence linewidths: An optional line width for symbol
borders. If a sequence is specified it must be the same length as
node_list. Defaults to 1.0
:param float|sequence width: An optional width to use for edges. Can
either be a float or sequence of floats. If a sequence is specified
it must be the same length as node_list. Defaults to 1.0
:param str|sequence edge_color: color or array of colors (default='k')
Edge color. Can be a single color or a sequence of colors with the same
length as edge_list. Color can be string or rgb (or rgba) tuple of
floats from 0-1. If numeric values are specified they will be
mapped to colors using the ``edge_cmap`` and ``edge_vmin``,
``edge_vmax`` parameters.
:param matplotlib.colors.Colormap edge_cmap: An optional Matplotlib
colormap for mapping intensities of edges.
:param float edge_vmin: Optional minimum value for edge colormap scaling
:param float edge_vmax: Optional maximum value for node colormap scaling
:param str style: An optional string to specify the edge line style.
For example, ``'-'``, ``'--'``, ``'-.'``, ``':'`` or words like
``'solid'`` or ``'dashed'``. See the
:class:`matplotlib.patches.FancyArrowPatch` attribute and kwarg
``linestyle`` for more details. Defaults to ``'solid'``.
:param func labels: An optional callback function that will be passed a
node payload and return a string label for the node. For example::
labels=str
could be used to just return a string cast of the node's data payload.
Or something like::
labels=lambda node: node['label']
could be used if the node payloads are dictionaries.
:param func edge_labels: An optional callback function that will be passed
an edge payload and return a string label for the edge. For example::
edge_labels=str
could be used to just return a string cast of the edge's data payload.
Or something like::
edge_labels=lambda edge: edge['label']
could be used if the edge payloads are dictionaries. If this is set
edge labels will be drawn in the visualization.
:param int font_size: An optional fontsize to use for text labels, By
default a value of 12 is used for nodes and 10 for edges.
:param str font_color: An optional font color for strings. By default
``'k'`` (ie black) is set.
:param str font_weight: An optional string used to specify the font weight.
By default a value of ``'normal'`` is used.
:param str font_family: An optional font family to use for strings. By
default ``'sans-serif'`` is used.
:param str label: An optional string label to use for the graph legend.
:param str connectionstyle: An optional value used to create a curved arc
of rounding radius rad. For example,
``connectionstyle='arc3,rad=0.2'``. See
:class:`matplotlib.patches.ConnectionStyle` and
:class:`matplotlib.patches.FancyArrowPatch` for more info. By default
this is set to ``"arc3"``.
:returns: A matplotlib figure for the visualization if not running with an
interactive backend (like in jupyter) or if ``ax`` is not set.
:rtype: matplotlib.figure.Figure
For Example:
.. jupyter-execute::
import matplotlib.pyplot as plt
import retworkx
from retworkx.visualization import mpl_draw
G = retworkx.generators.directed_path_graph(25)
mpl_draw(G)
plt.draw()
"""
try:
import matplotlib.pyplot as plt
except ImportError as e:
raise ImportError(
"matplotlib needs to be installed prior to running "
"retworkx.visualization.mpl_draw(). You can install "
"matplotlib with:\n'pip install matplotlib'"
) from e
if ax is None:
cf = plt.gcf()
else:
cf = ax.get_figure()
cf.set_facecolor("w")
if ax is None:
> if cf._axstack() is None:
E TypeError: '_AxesStack' object is not callable
/nix/store/2x320q4976sx7qhy8y1lj751l18f8y8p-python3.10-retworkx-0.11.0/lib/python3.10/site-packages/retworkx/visualization/matplotlib.py:212: TypeError
________________________ TestMPLDraw.test_edge_colormap ________________________
self = <tests.visualization.test_mpl.TestMPLDraw testMethod=test_edge_colormap>
def test_edge_colormap(self):
graph = retworkx.generators.star_graph(24)
colors = range(len(graph.edge_list()))
> fig = mpl_draw(
graph,
edge_color=colors,
width=4,
edge_cmap=plt.cm.Blues,
with_labels=True,
)
tests/visualization/test_mpl.py:61:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
graph = <retworkx.PyGraph object at 0x7fff24276940>, pos = None, ax = None
arrows = True, with_labels = True
kwds = {'edge_cmap': <matplotlib.colors.LinearSegmentedColormap object at 0x7fff2cca2080>, 'edge_color': range(0, 23), 'width': 4}
plt = <module 'matplotlib.pyplot' from '/nix/store/w19ags7fn0h3vf1whck5pg548xan9afg-python3.10-matplotlib-3.7.0/lib/python3.10/site-packages/matplotlib/pyplot.py'>
cf = <Figure size 640x480 with 1 Axes>
def mpl_draw(graph, pos=None, ax=None, arrows=True, with_labels=False, **kwds):
r"""Draw a graph with Matplotlib.
.. note::
Matplotlib is an optional dependency and will not be installed with
retworkx by default. If you intend to use this function make sure that
you install matplotlib with either ``pip install matplotlib`` or
``pip install 'retworkx[mpl]'``
:param graph: A retworkx graph, either a :class:`~retworkx.PyGraph` or a
:class:`~retworkx.PyDiGraph`.
:param dict pos: An optional dictionary (or
a :class:`~retworkx.Pos2DMapping` object) with nodes as keys and
positions as values. If not specified a spring layout positioning will
be computed. See `layout_functions` for functions that compute
node positions.
:param matplotlib.Axes ax: An optional Matplotlib Axes object to draw the
graph in.
:param bool arrows: For :class:`~retworkx.PyDiGraph` objects if ``True``
draw arrowheads. (defaults to ``True``) Note, that the Arrows will
be the same color as edges.
:param str arrowstyle: An optional string for directed graphs to choose
the style of the arrowsheads. See
:class:`matplotlib.patches.ArrowStyle` for more options. By default the
value is set to ``'-\|>'``.
:param int arrow_size: For directed graphs, choose the size of the arrow
head's length and width. See
:class:`matplotlib.patches.FancyArrowPatch` attribute and constructor
kwarg ``mutation_scale`` for more info. Defaults to 10.
:param bool with_labels: Set to ``True`` to draw labels on the nodes. Edge
labels will only be drawn if the ``edge_labels`` parameter is set to a
function. Defaults to ``False``.
:param list node_list: An optional list of node indices in the graph to
draw. If not specified all nodes will be drawn.
:param list edge_list: An option list of edges in the graph to draw. If not
specified all edges will be drawn
:param int|list node_size: Optional size of nodes. If an array is
specified it must be the same length as node_list. Defaults to 300
:param node_color: Optional node color. Can be a single color or
a sequence of colors with the same length as node_list. Color can be
string or rgb (or rgba) tuple of floats from 0-1. If numeric values
are specified they will be mapped to colors using the ``cmap`` and
``vmin``,``vmax`` parameters. See :func:`matplotlib.scatter` for more
details. Defaults to ``'#1f78b4'``)
:param str node_shape: The optional shape node. The specification is the
same as the :func:`matplotlib.pyplot.scatter` function's ``marker``
kwarg, valid options are one of
``['s', 'o', '^', '>', 'v', '<', 'd', 'p', 'h', '8']``. Defaults to
``'o'``
:param float alpha: Optional value for node and edge transparency
:param matplotlib.colors.Colormap cmap: An optional Matplotlib colormap
object for mapping intensities of nodes
:param float vmin: Optional minimum value for node colormap scaling
:param float vmax: Optional minimum value for node colormap scaling
:param float|sequence linewidths: An optional line width for symbol
borders. If a sequence is specified it must be the same length as
node_list. Defaults to 1.0
:param float|sequence width: An optional width to use for edges. Can
either be a float or sequence of floats. If a sequence is specified
it must be the same length as node_list. Defaults to 1.0
:param str|sequence edge_color: color or array of colors (default='k')
Edge color. Can be a single color or a sequence of colors with the same
length as edge_list. Color can be string or rgb (or rgba) tuple of
floats from 0-1. If numeric values are specified they will be
mapped to colors using the ``edge_cmap`` and ``edge_vmin``,
``edge_vmax`` parameters.
:param matplotlib.colors.Colormap edge_cmap: An optional Matplotlib
colormap for mapping intensities of edges.
:param float edge_vmin: Optional minimum value for edge colormap scaling
:param float edge_vmax: Optional maximum value for node colormap scaling
:param str style: An optional string to specify the edge line style.
For example, ``'-'``, ``'--'``, ``'-.'``, ``':'`` or words like
``'solid'`` or ``'dashed'``. See the
:class:`matplotlib.patches.FancyArrowPatch` attribute and kwarg
``linestyle`` for more details. Defaults to ``'solid'``.
:param func labels: An optional callback function that will be passed a
node payload and return a string label for the node. For example::
labels=str
could be used to just return a string cast of the node's data payload.
Or something like::
labels=lambda node: node['label']
could be used if the node payloads are dictionaries.
:param func edge_labels: An optional callback function that will be passed
an edge payload and return a string label for the edge. For example::
edge_labels=str
could be used to just return a string cast of the edge's data payload.
Or something like::
edge_labels=lambda edge: edge['label']
could be used if the edge payloads are dictionaries. If this is set
edge labels will be drawn in the visualization.
:param int font_size: An optional fontsize to use for text labels, By
default a value of 12 is used for nodes and 10 for edges.
:param str font_color: An optional font color for strings. By default
``'k'`` (ie black) is set.
:param str font_weight: An optional string used to specify the font weight.
By default a value of ``'normal'`` is used.
:param str font_family: An optional font family to use for strings. By
default ``'sans-serif'`` is used.
:param str label: An optional string label to use for the graph legend.
:param str connectionstyle: An optional value used to create a curved arc
of rounding radius rad. For example,
``connectionstyle='arc3,rad=0.2'``. See
:class:`matplotlib.patches.ConnectionStyle` and
:class:`matplotlib.patches.FancyArrowPatch` for more info. By default
this is set to ``"arc3"``.
:returns: A matplotlib figure for the visualization if not running with an
interactive backend (like in jupyter) or if ``ax`` is not set.
:rtype: matplotlib.figure.Figure
For Example:
.. jupyter-execute::
import matplotlib.pyplot as plt
import retworkx
from retworkx.visualization import mpl_draw
G = retworkx.generators.directed_path_graph(25)
mpl_draw(G)
plt.draw()
"""
try:
import matplotlib.pyplot as plt
except ImportError as e:
raise ImportError(
"matplotlib needs to be installed prior to running "
"retworkx.visualization.mpl_draw(). You can install "
"matplotlib with:\n'pip install matplotlib'"
) from e
if ax is None:
cf = plt.gcf()
else:
cf = ax.get_figure()
cf.set_facecolor("w")
if ax is None:
> if cf._axstack() is None:
E TypeError: '_AxesStack' object is not callable
/nix/store/2x320q4976sx7qhy8y1lj751l18f8y8p-python3.10-retworkx-0.11.0/lib/python3.10/site-packages/retworkx/visualization/matplotlib.py:212: TypeError
_________________________ TestMPLDraw.test_empty_graph _________________________
self = <tests.visualization.test_mpl.TestMPLDraw testMethod=test_empty_graph>
def test_empty_graph(self):
graph = retworkx.PyGraph()
> fig = mpl_draw(graph)
tests/visualization/test_mpl.py:77:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
graph = <retworkx.PyGraph object at 0x7ffff5904840>, pos = None, ax = None
arrows = True, with_labels = False, kwds = {}
plt = <module 'matplotlib.pyplot' from '/nix/store/w19ags7fn0h3vf1whck5pg548xan9afg-python3.10-matplotlib-3.7.0/lib/python3.10/site-packages/matplotlib/pyplot.py'>
cf = <Figure size 640x480 with 1 Axes>
def mpl_draw(graph, pos=None, ax=None, arrows=True, with_labels=False, **kwds):
r"""Draw a graph with Matplotlib.
.. note::
Matplotlib is an optional dependency and will not be installed with
retworkx by default. If you intend to use this function make sure that
you install matplotlib with either ``pip install matplotlib`` or
``pip install 'retworkx[mpl]'``
:param graph: A retworkx graph, either a :class:`~retworkx.PyGraph` or a
:class:`~retworkx.PyDiGraph`.
:param dict pos: An optional dictionary (or
a :class:`~retworkx.Pos2DMapping` object) with nodes as keys and
positions as values. If not specified a spring layout positioning will
be computed. See `layout_functions` for functions that compute
node positions.
:param matplotlib.Axes ax: An optional Matplotlib Axes object to draw the
graph in.
:param bool arrows: For :class:`~retworkx.PyDiGraph` objects if ``True``
draw arrowheads. (defaults to ``True``) Note, that the Arrows will
be the same color as edges.
:param str arrowstyle: An optional string for directed graphs to choose
the style of the arrowsheads. See
:class:`matplotlib.patches.ArrowStyle` for more options. By default the
value is set to ``'-\|>'``.
:param int arrow_size: For directed graphs, choose the size of the arrow
head's length and width. See
:class:`matplotlib.patches.FancyArrowPatch` attribute and constructor
kwarg ``mutation_scale`` for more info. Defaults to 10.
:param bool with_labels: Set to ``True`` to draw labels on the nodes. Edge
labels will only be drawn if the ``edge_labels`` parameter is set to a
function. Defaults to ``False``.
:param list node_list: An optional list of node indices in the graph to
draw. If not specified all nodes will be drawn.
:param list edge_list: An option list of edges in the graph to draw. If not
specified all edges will be drawn
:param int|list node_size: Optional size of nodes. If an array is
specified it must be the same length as node_list. Defaults to 300
:param node_color: Optional node color. Can be a single color or
a sequence of colors with the same length as node_list. Color can be
string or rgb (or rgba) tuple of floats from 0-1. If numeric values
are specified they will be mapped to colors using the ``cmap`` and
``vmin``,``vmax`` parameters. See :func:`matplotlib.scatter` for more
details. Defaults to ``'#1f78b4'``)
:param str node_shape: The optional shape node. The specification is the
same as the :func:`matplotlib.pyplot.scatter` function's ``marker``
kwarg, valid options are one of
``['s', 'o', '^', '>', 'v', '<', 'd', 'p', 'h', '8']``. Defaults to
``'o'``
:param float alpha: Optional value for node and edge transparency
:param matplotlib.colors.Colormap cmap: An optional Matplotlib colormap
object for mapping intensities of nodes
:param float vmin: Optional minimum value for node colormap scaling
:param float vmax: Optional minimum value for node colormap scaling
:param float|sequence linewidths: An optional line width for symbol
borders. If a sequence is specified it must be the same length as
node_list. Defaults to 1.0
:param float|sequence width: An optional width to use for edges. Can
either be a float or sequence of floats. If a sequence is specified
it must be the same length as node_list. Defaults to 1.0
:param str|sequence edge_color: color or array of colors (default='k')
Edge color. Can be a single color or a sequence of colors with the same
length as edge_list. Color can be string or rgb (or rgba) tuple of
floats from 0-1. If numeric values are specified they will be
mapped to colors using the ``edge_cmap`` and ``edge_vmin``,
``edge_vmax`` parameters.
:param matplotlib.colors.Colormap edge_cmap: An optional Matplotlib
colormap for mapping intensities of edges.
:param float edge_vmin: Optional minimum value for edge colormap scaling
:param float edge_vmax: Optional maximum value for node colormap scaling
:param str style: An optional string to specify the edge line style.
For example, ``'-'``, ``'--'``, ``'-.'``, ``':'`` or words like
``'solid'`` or ``'dashed'``. See the
:class:`matplotlib.patches.FancyArrowPatch` attribute and kwarg
``linestyle`` for more details. Defaults to ``'solid'``.
:param func labels: An optional callback function that will be passed a
node payload and return a string label for the node. For example::
labels=str
could be used to just return a string cast of the node's data payload.
Or something like::
labels=lambda node: node['label']
could be used if the node payloads are dictionaries.
:param func edge_labels: An optional callback function that will be passed
an edge payload and return a string label for the edge. For example::
edge_labels=str
could be used to just return a string cast of the edge's data payload.
Or something like::
edge_labels=lambda edge: edge['label']
could be used if the edge payloads are dictionaries. If this is set
edge labels will be drawn in the visualization.
:param int font_size: An optional fontsize to use for text labels, By
default a value of 12 is used for nodes and 10 for edges.
:param str font_color: An optional font color for strings. By default
``'k'`` (ie black) is set.
:param str font_weight: An optional string used to specify the font weight.
By default a value of ``'normal'`` is used.
:param str font_family: An optional font family to use for strings. By
default ``'sans-serif'`` is used.
:param str label: An optional string label to use for the graph legend.
:param str connectionstyle: An optional value used to create a curved arc
of rounding radius rad. For example,
``connectionstyle='arc3,rad=0.2'``. See
:class:`matplotlib.patches.ConnectionStyle` and
:class:`matplotlib.patches.FancyArrowPatch` for more info. By default
this is set to ``"arc3"``.
:returns: A matplotlib figure for the visualization if not running with an
interactive backend (like in jupyter) or if ``ax`` is not set.
:rtype: matplotlib.figure.Figure
For Example:
.. jupyter-execute::
import matplotlib.pyplot as plt
import retworkx
from retworkx.visualization import mpl_draw
G = retworkx.generators.directed_path_graph(25)
mpl_draw(G)
plt.draw()
"""
try:
import matplotlib.pyplot as plt
except ImportError as e:
raise ImportError(
"matplotlib needs to be installed prior to running "
"retworkx.visualization.mpl_draw(). You can install "
"matplotlib with:\n'pip install matplotlib'"
) from e
if ax is None:
cf = plt.gcf()
else:
cf = ax.get_figure()
cf.set_facecolor("w")
if ax is None:
> if cf._axstack() is None:
E TypeError: '_AxesStack' object is not callable
/nix/store/2x320q4976sx7qhy8y1lj751l18f8y8p-python3.10-retworkx-0.11.0/lib/python3.10/site-packages/retworkx/visualization/matplotlib.py:212: TypeError
______________________ TestMPLDraw.test_labels_and_colors ______________________
self = <tests.visualization.test_mpl.TestMPLDraw testMethod=test_labels_and_colors>
def test_labels_and_colors(self):
graph = retworkx.PyGraph()
graph.add_nodes_from(list(range(8)))
edge_list = [
(0, 1, 5),
(1, 2, 2),
(2, 3, 7),
(3, 0, 6),
(5, 6, 1),
(4, 5, 7),
(6, 7, 3),
(7, 4, 7),
]
labels = {}
labels[0] = r"$a$"
labels[1] = r"$b$"
labels[2] = r"$c$"
labels[3] = r"$d$"
labels[4] = r"$\alpha$"
labels[5] = r"$\beta$"
labels[6] = r"$\gamma$"
labels[7] = r"$\delta$"
graph.add_edges_from(edge_list)
pos = retworkx.random_layout(graph)
> mpl_draw(
graph,
pos=pos,
node_list=[0, 1, 2, 3],
node_color="r",
edge_list=[(0, 1), (1, 2), (2, 3), (3, 0)],
node_size=500,
alpha=0.75,
width=1.0,
labels=lambda x: labels[x],
font_size=16,
)
tests/visualization/test_mpl.py:168:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
graph = <retworkx.PyGraph object at 0x7fff24280540>
pos = <retworkx.Pos2DMapping object at 0x7fff242803c0>, ax = None, arrows = True
with_labels = False
kwds = {'alpha': 0.75, 'edge_list': [(0, 1), (1, 2), (2, 3), (3, 0)], 'font_size': 16, 'labels': <function TestMPLDraw.test_labels_and_colors.<locals>.<lambda> at 0x7ffef4108820>, ...}
plt = <module 'matplotlib.pyplot' from '/nix/store/w19ags7fn0h3vf1whck5pg548xan9afg-python3.10-matplotlib-3.7.0/lib/python3.10/site-packages/matplotlib/pyplot.py'>
cf = <Figure size 640x480 with 1 Axes>
def mpl_draw(graph, pos=None, ax=None, arrows=True, with_labels=False, **kwds):
r"""Draw a graph with Matplotlib.
.. note::
Matplotlib is an optional dependency and will not be installed with
retworkx by default. If you intend to use this function make sure that
you install matplotlib with either ``pip install matplotlib`` or
``pip install 'retworkx[mpl]'``
:param graph: A retworkx graph, either a :class:`~retworkx.PyGraph` or a
:class:`~retworkx.PyDiGraph`.
:param dict pos: An optional dictionary (or
a :class:`~retworkx.Pos2DMapping` object) with nodes as keys and
positions as values. If not specified a spring layout positioning will
be computed. See `layout_functions` for functions that compute
node positions.
:param matplotlib.Axes ax: An optional Matplotlib Axes object to draw the
graph in.
:param bool arrows: For :class:`~retworkx.PyDiGraph` objects if ``True``
draw arrowheads. (defaults to ``True``) Note, that the Arrows will
be the same color as edges.
:param str arrowstyle: An optional string for directed graphs to choose
the style of the arrowsheads. See
:class:`matplotlib.patches.ArrowStyle` for more options. By default the
value is set to ``'-\|>'``.
:param int arrow_size: For directed graphs, choose the size of the arrow
head's length and width. See
:class:`matplotlib.patches.FancyArrowPatch` attribute and constructor
kwarg ``mutation_scale`` for more info. Defaults to 10.
:param bool with_labels: Set to ``True`` to draw labels on the nodes. Edge
labels will only be drawn if the ``edge_labels`` parameter is set to a
function. Defaults to ``False``.
:param list node_list: An optional list of node indices in the graph to
draw. If not specified all nodes will be drawn.
:param list edge_list: An option list of edges in the graph to draw. If not
specified all edges will be drawn
:param int|list node_size: Optional size of nodes. If an array is
specified it must be the same length as node_list. Defaults to 300
:param node_color: Optional node color. Can be a single color or
a sequence of colors with the same length as node_list. Color can be
string or rgb (or rgba) tuple of floats from 0-1. If numeric values
are specified they will be mapped to colors using the ``cmap`` and
``vmin``,``vmax`` parameters. See :func:`matplotlib.scatter` for more
details. Defaults to ``'#1f78b4'``)
:param str node_shape: The optional shape node. The specification is the
same as the :func:`matplotlib.pyplot.scatter` function's ``marker``
kwarg, valid options are one of
``['s', 'o', '^', '>', 'v', '<', 'd', 'p', 'h', '8']``. Defaults to
``'o'``
:param float alpha: Optional value for node and edge transparency
:param matplotlib.colors.Colormap cmap: An optional Matplotlib colormap
object for mapping intensities of nodes
:param float vmin: Optional minimum value for node colormap scaling
:param float vmax: Optional minimum value for node colormap scaling
:param float|sequence linewidths: An optional line width for symbol
borders. If a sequence is specified it must be the same length as
node_list. Defaults to 1.0
:param float|sequence width: An optional width to use for edges. Can
either be a float or sequence of floats. If a sequence is specified
it must be the same length as node_list. Defaults to 1.0
:param str|sequence edge_color: color or array of colors (default='k')
Edge color. Can be a single color or a sequence of colors with the same
length as edge_list. Color can be string or rgb (or rgba) tuple of
floats from 0-1. If numeric values are specified they will be
mapped to colors using the ``edge_cmap`` and ``edge_vmin``,
``edge_vmax`` parameters.
:param matplotlib.colors.Colormap edge_cmap: An optional Matplotlib
colormap for mapping intensities of edges.
:param float edge_vmin: Optional minimum value for edge colormap scaling
:param float edge_vmax: Optional maximum value for node colormap scaling
:param str style: An optional string to specify the edge line style.
For example, ``'-'``, ``'--'``, ``'-.'``, ``':'`` or words like
``'solid'`` or ``'dashed'``. See the
:class:`matplotlib.patches.FancyArrowPatch` attribute and kwarg
``linestyle`` for more details. Defaults to ``'solid'``.
:param func labels: An optional callback function that will be passed a
node payload and return a string label for the node. For example::
labels=str
could be used to just return a string cast of the node's data payload.
Or something like::
labels=lambda node: node['label']
could be used if the node payloads are dictionaries.
:param func edge_labels: An optional callback function that will be passed
an edge payload and return a string label for the edge. For example::
edge_labels=str
could be used to just return a string cast of the edge's data payload.
Or something like::
edge_labels=lambda edge: edge['label']
could be used if the edge payloads are dictionaries. If this is set
edge labels will be drawn in the visualization.
:param int font_size: An optional fontsize to use for text labels, By
default a value of 12 is used for nodes and 10 for edges.
:param str font_color: An optional font color for strings. By default
``'k'`` (ie black) is set.
:param str font_weight: An optional string used to specify the font weight.
By default a value of ``'normal'`` is used.
:param str font_family: An optional font family to use for strings. By
default ``'sans-serif'`` is used.
:param str label: An optional string label to use for the graph legend.
:param str connectionstyle: An optional value used to create a curved arc
of rounding radius rad. For example,
``connectionstyle='arc3,rad=0.2'``. See
:class:`matplotlib.patches.ConnectionStyle` and
:class:`matplotlib.patches.FancyArrowPatch` for more info. By default
this is set to ``"arc3"``.
:returns: A matplotlib figure for the visualization if not running with an
interactive backend (like in jupyter) or if ``ax`` is not set.
:rtype: matplotlib.figure.Figure
For Example:
.. jupyter-execute::
import matplotlib.pyplot as plt
import retworkx
from retworkx.visualization import mpl_draw
G = retworkx.generators.directed_path_graph(25)
mpl_draw(G)
plt.draw()
"""
try:
import matplotlib.pyplot as plt
except ImportError as e:
raise ImportError(
"matplotlib needs to be installed prior to running "
"retworkx.visualization.mpl_draw(). You can install "
"matplotlib with:\n'pip install matplotlib'"
) from e
if ax is None:
cf = plt.gcf()
else:
cf = ax.get_figure()
cf.set_facecolor("w")
if ax is None:
> if cf._axstack() is None:
E TypeError: '_AxesStack' object is not callable
/nix/store/2x320q4976sx7qhy8y1lj751l18f8y8p-python3.10-retworkx-0.11.0/lib/python3.10/site-packages/retworkx/visualization/matplotlib.py:212: TypeError
__________________________ TestMPLDraw.test_node_list __________________________
self = <tests.visualization.test_mpl.TestMPLDraw testMethod=test_node_list>
def test_node_list(self):
graph = retworkx.generators.star_graph(24)
node_list = list(range(4)) + list(range(4, 10)) + list(range(10, 14))
> fig = mpl_draw(graph, node_list=node_list)
tests/visualization/test_mpl.py:55:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
graph = <retworkx.PyGraph object at 0x7fff24283640>, pos = None, ax = None
arrows = True, with_labels = False
kwds = {'node_list': [0, 1, 2, 3, 4, 5, ...]}
plt = <module 'matplotlib.pyplot' from '/nix/store/w19ags7fn0h3vf1whck5pg548xan9afg-python3.10-matplotlib-3.7.0/lib/python3.10/site-packages/matplotlib/pyplot.py'>
cf = <Figure size 640x480 with 1 Axes>
def mpl_draw(graph, pos=None, ax=None, arrows=True, with_labels=False, **kwds):
r"""Draw a graph with Matplotlib.
.. note::
Matplotlib is an optional dependency and will not be installed with
retworkx by default. If you intend to use this function make sure that
you install matplotlib with either ``pip install matplotlib`` or
``pip install 'retworkx[mpl]'``
:param graph: A retworkx graph, either a :class:`~retworkx.PyGraph` or a
:class:`~retworkx.PyDiGraph`.
:param dict pos: An optional dictionary (or
a :class:`~retworkx.Pos2DMapping` object) with nodes as keys and
positions as values. If not specified a spring layout positioning will
be computed. See `layout_functions` for functions that compute
node positions.
:param matplotlib.Axes ax: An optional Matplotlib Axes object to draw the
graph in.
:param bool arrows: For :class:`~retworkx.PyDiGraph` objects if ``True``
draw arrowheads. (defaults to ``True``) Note, that the Arrows will
be the same color as edges.
:param str arrowstyle: An optional string for directed graphs to choose
the style of the arrowsheads. See
:class:`matplotlib.patches.ArrowStyle` for more options. By default the
value is set to ``'-\|>'``.
:param int arrow_size: For directed graphs, choose the size of the arrow
head's length and width. See
:class:`matplotlib.patches.FancyArrowPatch` attribute and constructor
kwarg ``mutation_scale`` for more info. Defaults to 10.
:param bool with_labels: Set to ``True`` to draw labels on the nodes. Edge
labels will only be drawn if the ``edge_labels`` parameter is set to a
function. Defaults to ``False``.
:param list node_list: An optional list of node indices in the graph to
draw. If not specified all nodes will be drawn.
:param list edge_list: An option list of edges in the graph to draw. If not
specified all edges will be drawn
:param int|list node_size: Optional size of nodes. If an array is
specified it must be the same length as node_list. Defaults to 300
:param node_color: Optional node color. Can be a single color or
a sequence of colors with the same length as node_list. Color can be
string or rgb (or rgba) tuple of floats from 0-1. If numeric values
are specified they will be mapped to colors using the ``cmap`` and
``vmin``,``vmax`` parameters. See :func:`matplotlib.scatter` for more
details. Defaults to ``'#1f78b4'``)
:param str node_shape: The optional shape node. The specification is the
same as the :func:`matplotlib.pyplot.scatter` function's ``marker``
kwarg, valid options are one of
``['s', 'o', '^', '>', 'v', '<', 'd', 'p', 'h', '8']``. Defaults to
``'o'``
:param float alpha: Optional value for node and edge transparency
:param matplotlib.colors.Colormap cmap: An optional Matplotlib colormap
object for mapping intensities of nodes
:param float vmin: Optional minimum value for node colormap scaling
:param float vmax: Optional minimum value for node colormap scaling
:param float|sequence linewidths: An optional line width for symbol
borders. If a sequence is specified it must be the same length as
node_list. Defaults to 1.0
:param float|sequence width: An optional width to use for edges. Can
either be a float or sequence of floats. If a sequence is specified
it must be the same length as node_list. Defaults to 1.0
:param str|sequence edge_color: color or array of colors (default='k')
Edge color. Can be a single color or a sequence of colors with the same
length as edge_list. Color can be string or rgb (or rgba) tuple of
floats from 0-1. If numeric values are specified they will be
mapped to colors using the ``edge_cmap`` and ``edge_vmin``,
``edge_vmax`` parameters.
:param matplotlib.colors.Colormap edge_cmap: An optional Matplotlib
colormap for mapping intensities of edges.
:param float edge_vmin: Optional minimum value for edge colormap scaling
:param float edge_vmax: Optional maximum value for node colormap scaling
:param str style: An optional string to specify the edge line style.
For example, ``'-'``, ``'--'``, ``'-.'``, ``':'`` or words like
``'solid'`` or ``'dashed'``. See the
:class:`matplotlib.patches.FancyArrowPatch` attribute and kwarg
``linestyle`` for more details. Defaults to ``'solid'``.
:param func labels: An optional callback function that will be passed a
node payload and return a string label for the node. For example::
labels=str
could be used to just return a string cast of the node's data payload.
Or something like::
labels=lambda node: node['label']
could be used if the node payloads are dictionaries.
:param func edge_labels: An optional callback function that will be passed
an edge payload and return a string label for the edge. For example::
edge_labels=str
could be used to just return a string cast of the edge's data payload.
Or something like::
edge_labels=lambda edge: edge['label']
could be used if the edge payloads are dictionaries. If this is set
edge labels will be drawn in the visualization.
:param int font_size: An optional fontsize to use for text labels, By
default a value of 12 is used for nodes and 10 for edges.
:param str font_color: An optional font color for strings. By default
``'k'`` (ie black) is set.
:param str font_weight: An optional string used to specify the font weight.
By default a value of ``'normal'`` is used.
:param str font_family: An optional font family to use for strings. By
default ``'sans-serif'`` is used.
:param str label: An optional string label to use for the graph legend.
:param str connectionstyle: An optional value used to create a curved arc
of rounding radius rad. For example,
``connectionstyle='arc3,rad=0.2'``. See
:class:`matplotlib.patches.ConnectionStyle` and
:class:`matplotlib.patches.FancyArrowPatch` for more info. By default
this is set to ``"arc3"``.
:returns: A matplotlib figure for the visualization if not running with an
interactive backend (like in jupyter) or if ``ax`` is not set.
:rtype: matplotlib.figure.Figure
For Example:
.. jupyter-execute::
import matplotlib.pyplot as plt
import retworkx
from retworkx.visualization import mpl_draw
G = retworkx.generators.directed_path_graph(25)
mpl_draw(G)
plt.draw()
"""
try:
import matplotlib.pyplot as plt
except ImportError as e:
raise ImportError(
"matplotlib needs to be installed prior to running "
"retworkx.visualization.mpl_draw(). You can install "
"matplotlib with:\n'pip install matplotlib'"
) from e
if ax is None:
cf = plt.gcf()
else:
cf = ax.get_figure()
cf.set_facecolor("w")
if ax is None:
> if cf._axstack() is None:
E TypeError: '_AxesStack' object is not callable
/nix/store/2x320q4976sx7qhy8y1lj751l18f8y8p-python3.10-retworkx-0.11.0/lib/python3.10/site-packages/retworkx/visualization/matplotlib.py:212: TypeError
=============================== warnings summary ===============================
../../nix/store/7jg7sp884jb2y1izw0gkgigjsi2n7m32-python3.10-testtools-2.5.0/lib/python3.10/site-packages/testtools/distutilscmd.py:7
/nix/store/7jg7sp884jb2y1izw0gkgigjsi2n7m32-python3.10-testtools-2.5.0/lib/python3.10/site-packages/testtools/distutilscmd.py:7: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
from distutils.core import Command
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
=========================== short test summary info ============================
FAILED tests/visualization/test_mpl.py::TestMPLDraw::test_alpha_iter - TypeError: '_AxesStack' object is not callable
FAILED tests/visualization/test_mpl.py::TestMPLDraw::test_arrows - TypeError: '_AxesStack' object is not callable
FAILED tests/visualization/test_mpl.py::TestMPLDraw::test_draw - TypeError: '_AxesStack' object is not callable
FAILED tests/visualization/test_mpl.py::TestMPLDraw::test_edge_colormap - TypeError: '_AxesStack' object is not callable
FAILED tests/visualization/test_mpl.py::TestMPLDraw::test_empty_graph - TypeError: '_AxesStack' object is not callable
FAILED tests/visualization/test_mpl.py::TestMPLDraw::test_labels_and_colors - TypeError: '_AxesStack' object is not callable
FAILED tests/visualization/test_mpl.py::TestMPLDraw::test_node_list - TypeError: '_AxesStack' object is not callable
======= 7 failed, 1561 passed, 9 skipped, 1 warning in 192.23s (0:03:12) =======
/nix/store/pw17yc3mwmsci4jygwalj8ppg0drz31v-stdenv-linux/setup: line 1593: pop_var_context: head of shell_variables not a function context
@samuela
Copy link

samuela commented Mar 23, 2023

matplotlib errors, not pytorch related

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment