First of all, locate where in the code you are getting the error (the line number). This error occurs when you are assigning a boolean True or False to an array such as [1, 5, 3, 2, 1]. This logically can’t be done, so instead you must look at the individual elements inside the array. For instance:
if all(item == 5 for item in array)
print 'all good'
Thank you for the answer, i understood your point but i don’t understand why a boolean is assigned to my array
(the error occurs line : fig = ff.create_streamline(X, Y, u,v,arrow_scale=.1) )
Did you fix it in your code or in the create_streamline code? I am having this issue as well and it definitely happens within create_streamline, see below. This change seems to fix it:
import plotly.figure_factory as ff
import numpy as np
x,y = np.meshgrid(np.arange(0, 2, .2), np.arange(0, 2, .2))
u = np.cos(x)*y
v = np.sin(x)*y
fig = ff.create_streamline(x, y, u, v, arrow_scale=.1)
~/.virtualenvs/onbeach/local/lib/python3.7/site-packages/plotly/figure_factory/_streamline.py in create_streamline(x, y, u, v, density, angle, arrow_scale, **kwargs)
112 utils.validate_equal_length(x, y)
113 utils.validate_equal_length(u, v)
--> 114 validate_streamline(x, y)
115 utils.validate_positive_scalars(density=density, arrow_scale=arrow_scale)
116
~/.virtualenvs/onbeach/local/lib/python3.7/site-packages/plotly/figure_factory/_streamline.py in validate_streamline(x, y)
26 raise ImportError("FigureFactory.create_streamline requires numpy")
27 for index in range(len(x) - 1):
---> 28 if ((x[index + 1] - x[index]) - (x[1] - x[0])) > 0.0001:
29 raise exceptions.PlotlyError(
30 "x must be a 1 dimensional, " "evenly spaced array"
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()