scikit-tda / kepler-mapper

Kepler Mapper: A flexible Python implementation of the Mapper algorithm.
https://kepler-mapper.scikit-tda.org
MIT License
623 stars 180 forks source link

plotlyviz error #247

Open andreacortis opened 1 year ago

andreacortis commented 1 year ago

Hello,

this is the trace for the example when I try and run plotlyviz

Python 3.8.8 (default, Apr 13 2021, 15:08:03) [MSC v.1916 64 bit (AMD64)]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.10.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import kmapper as km
   ...:
   ...: # Some sample data
   ...: from sklearn import datasets
   ...: data, labels = datasets.make_circles(n_samples=5000, noise=0.03, factor=0.3)
   ...:
   ...: # Initialize
   ...: mapper = km.KeplerMapper(verbose=1)
   ...:
   ...: # Fit to and transform the data
   ...: projected_data = mapper.fit_transform(data, projection=[0,1]) # X-Y axis
   ...:
   ...: # Create a cover with 10 elements
   ...: cover = km.Cover(n_cubes=10)
   ...:
   ...: # Create dictionary called 'graph' with nodes, edges and meta-information
   ...: graph = mapper.map(projected_data, data, cover=cover)
KeplerMapper(verbose=1)
..Composing projection pipeline of length 1:
        Projections: [0, 1]
        Distance matrices: False
        Scalers: MinMaxScaler()
..Projecting on data shaped (5000, 2)

..Projecting data using: [0, 1]

..Scaling with: MinMaxScaler()

Mapping on data shaped (5000, 2) using lens shaped (5000, 2)

Creating 100 hypercubes.

Created 239 edges and 93 nodes in 0:00:00.430858.

In [2]:

In [2]: plotlyviz(graph, title="Basic plot")
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
Cell In[2], line 1
----> 1 plotlyviz(graph, title="Basic plot")

NameError: name 'plotlyviz' is not defined

In [3]: from kmapper.plotlyviz import plotlyviz

In [4]: plotlyviz(graph, title="Basic plot")
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[4], line 1
----> 1 plotlyviz(graph, title="Basic plot")

File ~\.virtualenvs\tda-UtggsFXo\lib\site-packages\kmapper\utils.py:11, in deprecated_alias.<locals>.deco.<locals>.wrapper(*args, **kwargs)
      8 @functools.wraps(f)
      9 def wrapper(*args, **kwargs):
     10     rename_kwargs(f.__name__, kwargs, aliases)
---> 11     return f(*args, **kwargs)

File ~\.virtualenvs\tda-UtggsFXo\lib\site-packages\kmapper\plotlyviz.py:168, in plotlyviz(scomplex, colorscale, title, graph_layout, color_values, color_function_name, node_color_function, dashboard, graph_data, factor_size, edge_linewidth, node_linecolor, width, height, bgcolor, left, bottom, summary_height, summary_width, summary_left, summary_right, hist_left, hist_right, member_textbox_width, filename)
    158 kmgraph, mapper_summary, n_color_distribution = get_mapper_graph(
    159     scomplex,
    160     colorscale=colorscale,
   (...)
    163     node_color_function=node_color_function,
    164 )
    166 annotation = get_kmgraph_meta(mapper_summary)
--> 168 plgraph_data = plotly_graph(
    169     kmgraph,
    170     graph_layout=graph_layout,
    171     colorscale=colorscale,
    172     factor_size=factor_size,
    173     edge_linewidth=edge_linewidth,
    174     node_linecolor=node_linecolor,
    175 )
    177 layout = plot_layout(
    178     title=title,
    179     width=width,
   (...)
    184     bottom=bottom,
    185 )
    186 result = go.FigureWidget(data=plgraph_data, layout=layout)

File ~\.virtualenvs\tda-UtggsFXo\lib\site-packages\kmapper\plotlyviz.py:393, in plotly_graph(kmgraph, graph_layout, colorscale, showscale, factor_size, edge_linecolor, edge_linewidth, node_linecolor, node_linewidth)
    390 hover_text = [node["name"] for node in kmgraph["nodes"]]
    391 color_vals = [node["color"] for node in kmgraph["nodes"]]
    392 node_size = np.array(
--> 393     [factor_size * node["size"] for node in kmgraph["nodes"]], dtype=np.int
    394 )
    395 Xn, Yn, Xe, Ye = _get_plotly_data(links, layt)
    397 edge_trace = dict(
    398     type="scatter",
    399     x=Xe,
   (...)
    403     hoverinfo="none",
    404 )

File ~\.virtualenvs\tda-UtggsFXo\lib\site-packages\numpy\__init__.py:305, in __getattr__(attr)
    300     warnings.warn(
    301         f"In the future `np.{attr}` will be defined as the "
    302         "corresponding NumPy scalar.", FutureWarning, stacklevel=2)
    304 if attr in __former_attrs__:
--> 305     raise AttributeError(__former_attrs__[attr])
    307 # Importing Tester requires importing all of UnitTest which is not a
    308 # cheap import Since it is mainly used in test suits, we lazy import it
    309 # here to save on the order of 10 ms of import time for most users
    310 #
    311 # The previous way Tester was imported also had a side effect of adding
    312 # the full `numpy.testing` namespace
    313 if attr == 'testing':

AttributeError: module 'numpy' has no attribute 'int'.
`np.int` was a deprecated alias for the builtin `int`. To avoid this error in existing code, use `int` by itself. Doing this will not modify any behavior and is safe. When replacing `np.int`, you may wish to use e.g. `np.int64` or `np.int32` to specify the precision. If you wish to review your current use, check the release note link for additional information.
The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
    https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations

In [5]: import numpy as np

In [6]: np.__version__
Out[6]: '1.24.2'

In [7]: import plotly

In [8]: plotly.__version__
Out[8]: '5.13.0'