I am learning HoloViews currently and wanted to reproduce the Chord-Example from the Homepage:
http://holoviews.org/gallery/demos/bokeh/route_chord.html
I copied the lines per line into my jupyter-nb and get always an error this line:
chord = hv.Chord((route_counts, nodes), ['SourceID', 'DestinationID'], ['Stops'])
The error message is:
TypeError Traceback (most recent call last)
~\AppData\Local\Continuum\anaconda3\lib\site-packages\numpy\core\function_base.py in linspace(start, stop, num, endpoint, retstep, dtype, axis)
116 try:
--> 117 num = operator.index(num)
118 except TypeError:
TypeError: 'numpy.float64' object cannot be interpreted as an integer
During handling of the above exception, another exception occurred:
TypeError Traceback (most recent call last)
<ipython-input-13-b727deae3660> in <module>
----> 1 chord = hv.Chord((route_counts, nodes), ['SourceID', 'DestinationID'], ['Stops'])
2
~\AppData\Local\Continuum\anaconda3\lib\site-packages\holoviews\element\graphs.py in __init__(self, data, kdims, vdims, compute, **params)
768 if compute:
769 self._nodes = nodes
--> 770 chord = layout_chords(self)
771 self._nodes = chord.nodes
772 self._edgepaths = chord.edgepaths
~\AppData\Local\Continuum\anaconda3\lib\site-packages\param\parameterized.py in __new__(class_, *args, **params)
2810 inst = class_.instance()
2811 inst.param._set_name(class_.__name__)
-> 2812 return inst.__call__(*args,**params)
2813
2814 def __call__(self,*args,**kw):
~\AppData\Local\Continuum\anaconda3\lib\site-packages\holoviews\core\operation.py in __call__(self, element, **kwargs)
162 elif 'streams' not in kwargs:
163 kwargs['streams'] = self.p.streams
--> 164 return element.apply(self, **kwargs)
165
166
~\AppData\Local\Continuum\anaconda3\lib\site-packages\holoviews\core\accessors.py in __call__(self, function, streams, link_inputs, dynamic, **kwargs)
108 if hasattr(function, 'dynamic'):
109 inner_kwargs['dynamic'] = False
--> 110 return function(self._obj, **inner_kwargs)
111 elif self._obj._deep_indexable:
112 mapped = []
~\AppData\Local\Continuum\anaconda3\lib\site-packages\holoviews\core\operation.py in __call__(self, element, **kwargs)
159 for k, el in element.items()])
160 elif isinstance(element, ViewableElement):
--> 161 return self._apply(element)
162 elif 'streams' not in kwargs:
163 kwargs['streams'] = self.p.streams
~\AppData\Local\Continuum\anaconda3\lib\site-packages\holoviews\core\operation.py in _apply(self, element, key)
119 for hook in self._preprocess_hooks:
120 kwargs.update(hook(self, element))
--> 121 ret = self._process(element, key)
122 for hook in self._postprocess_hooks:
123 ret = hook(self, ret, **kwargs)
~\AppData\Local\Continuum\anaconda3\lib\site-packages\holoviews\element\graphs.py in _process(self, element, key)
677 n_conn = weights_of_areas[i]
678 p0, p1 = points[i], points[i+1]
--> 679 angles = np.linspace(p0, p1, n_conn)
680 coords = list(zip(np.cos(angles), np.sin(angles)))
681 all_areas.append(coords)
<__array_function__ internals> in linspace(*args, **kwargs)
~\AppData\Local\Continuum\anaconda3\lib\site-packages\numpy\core\function_base.py in linspace(start, stop, num, endpoint, retstep, dtype, axis)
119 raise TypeError(
120 "object of type {} cannot be safely interpreted as an integer."
--> 121 .format(type(num)))
122
123 if num < 0:
TypeError: object of type <class 'numpy.float64'> cannot be safely interpreted as an integer.
Any help is highly appreciated.
Best
As requested:
print((type(route_counts), type(nodes)))
print((route_counts.dtypes))
(<class 'pandas.core.frame.DataFrame'>, <class 'holoviews.core.data.Dataset'>)
SourceID int64
DestinationID int64
Stops int64
dtype: object
Packages and versions:
holoviews 1.12.7 py_0 pyviz
pandas 1.0.0 py37h47e9c7a_0
numpy 1.18.1 py37h93ca92e_0
bokeh 1.4.0 py37_0
Tried the downloaded notebook and got the same error message.
This is a bug. There's a problem handling numpy 1.18.1.
I tried this with numpy 1.17.4 and had no problem.
When I upgraded to 1.18.1 I also got this error.
As you can see in your error message, the error is caused by this line in holoviews:
angles = np.linspace(p0, p1, n_conn)
Created an issue:
https://github.com/holoviz/holoviews/issues/4223
Turns out, there was already an issue:
https://github.com/holoviz/holoviews/issues/4209