Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hvplot.networkx.draw fails with unsigned dtypes #217

Closed
stuarteberg opened this issue Jun 13, 2019 · 1 comment · Fixed by holoviz/holoviews#3773
Closed

hvplot.networkx.draw fails with unsigned dtypes #217

stuarteberg opened this issue Jun 13, 2019 · 1 comment · Fixed by holoviz/holoviews#3773

Comments

@stuarteberg
Copy link

stuarteberg commented Jun 13, 2019

The following code can draw a networkx graph:

import numpy as np
import networkx as nx
import hvplot.networkx as hvnx

edges = np.array([[1,2],[2,3]])
g = nx.Graph()
g.add_edges_from(edges)
hvnx.draw_networkx(g)

But if you use an unsigned dtype, like this:

edges = np.array([[1,2],[2,3]], dtype=np.uint8)

...then you get an exception whose traceback ends with:

/miniforge/envs/flyem37/lib/python3.7/site-packages/holoviews/plotting/bokeh/graphs.py in <listcomp>(.0)
    220             start, end = start.astype(np.int32), end.astype(np.int32)
    221         elif nodes.dtype.kind != 'i':
--> 222             start = np.array([node_indices.get(x, nan_node) for x in start], dtype=np.int32)
    223             end = np.array([node_indices.get(y, nan_node) for y in end], dtype=np.int32)
    224         path_data = dict(start=start, end=end)

NameError: free variable 'node_indices' referenced before assignment in enclosing scope
Environment details
$ conda list | grep -E 'holoviews|hvplot|networkx|numpy|python|bokeh|matplotlib'
bokeh                     1.2.0                    py37_0    conda-forge
holoviews                 1.12.3                     py_2    conda-forge
hvplot                    0.4.0                      py_1    conda-forge
ipython                   7.5.0            py37h24bf2e0_0    conda-forge
ipython_genutils          0.2.0                      py_1    conda-forge
matplotlib-base           3.1.0            py37hfd891ef_1    conda-forge
msgpack-python            0.6.1            py37h6bb024c_0    conda-forge
networkx                  2.3                        py_0    conda-forge
neuprint-python           0.1.2                      py_0    flyem-forge
numpy                     1.16.4           py37h95a1406_0    conda-forge
python                    3.7.3                h5b0a415_0    conda-forge
python-dateutil           2.8.0                      py_0    conda-forge
python-snappy             0.5.4            py37hee44bf9_0    conda-forge
@stuarteberg
Copy link
Author

Should be fixed when holoviz/holoviews#3773 is merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant