Firstly, sorry if this is in fact a duplicate - I have spent the last three hours attempting to solve this problem and haven't been able to find any solution.
Problem
I am using lists to represent coordinates as [x, y]. I want to find out if a list of coordinates does not contain a specified coordinate. For example, if I have the list of coordinates [[3.3, 4.4], [5.5, 6.6]] and the coordinate [1.1, 2.2], I want a return of True, because the coordinate is not in the list of coordinates.
It may be worth noting that the list of coordinates is generated using the OpenCV functions cv2.findContours(), cv2.minAreaRect() and finally cv2.boxPoints() which results in a list of lists. These coordinates are stored in a dict and accessed from there; calling a print() of the coordinates gives me the coordinates in the format [array([3.3, 4.4], dtype=float32), array([5.5, 6.6], dtype=float32)] as opposed to the format [[3.3, 4.4], [5.5, 6.6]] which is given when I print() the coordinates straight after finding them with cv2.boxPoints().
What I have tried
I have tried to use the answer to this question but I get the error ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all().
The code for that attempt looks like this:
for coordinate in box:
if coordinate not in specialCoordinates:
# operations go here
I then attempted to use the answer to this question about a.all() but I get the same error.
The code for that attempt looks like this:
for coordinate in box:
if not all(coordinate == special for special in specialCoordinates):
# operations go here
I also tried this:
for coordinate in box:
if all(coordinate != special for special in specialCoordinates):
# operations go here
Additional information
The format mentioned above if coordinate not in specialCoordinates works when I try the following in the Python 2.7 interpreter:
Python 2.7.15 (v2.7.15:ca079a3ea3, Apr 30 2018, 16:30:26) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> a = [[3.3, 4.4], [5.5, 6.6]]
>>> b = [1.1, 2.2]
>>> b not in a
True