TypeError: 'numpy.ndarray' object is not callable in Python
Dung Do Tien
Aug 14 2021
179
Hello friends,
I have a small project with Python 3.8.2 and I want to calculate distances of two pointers.
distances = np.zeros(points.shape[0])
for i in range(len(distances)):
distances[i] = distances(p, points[i])
but I get an error TypeError: 'numpy.ndarray' object is not callable.
TypeError Traceback (most recent call last)
<ipython-input-45-a46653deacff> in <module>
4 #we're going to loop all over the points we have
5 for i in range(len(distances)):
----> 6 distances[i] = distances(p, points[i])
TypeError: 'numpy.ndarray' object is not callable
I really don't know how can I fix it?
Have 1 answer(s) found.
-
P-6
PTJ312 Aug 14 2021
The error TypeError: 'numpy.ndarray' object is not callable means that you tried to call a
NumPy
array as a function. You can change as below:distances[i]
=
distances[p, points[i]]
* Type maximum 2000 characters.
* All comments have to wait approved before display.
* Please polite comment and respect questions and answers of others.