I have an array like the following and I want to check whether the values in it are in self.pList or not: Here is my point which is an array and I pass it as an argument to addPoint function:
[403.53 273.79]
Here is self.pList:
[array([766.13, 389.14])]
def addPoint(self,point):
print('self.pList in addPoint')
print(self.pList)
if point not in self.pList:
self.pList.append(point)
self.X.append(point[0])
self.Y.append(point[1])
, however it shows me the following error:
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
what I have tried is:
def addPoint(self,point):
print('self.pList in addPoint')
print(self.pList)
if point.any() not in self.pList:
self.pList.append(point)
self.X.append(point[0])
self.Y.append(point[1])
also:
def addPoint(self,point):
print('self.pList in addPoint')
print(self.pList)
if point.all() not in self.pList:
self.pList.append(point)
self.X.append(point[0])
self.Y.append(point[1])
But it still has error!