ValueError for comparison of np.arrays
<p>I have a list of lists of np.arrays, representing islands > island > geodesic point on the island.</p>

<p>I'm trying to use:</p>

<pre><code>if not groups:
    createNewGroup(point)
else:
    for group in groups:
        if point in group:
            continue
    else:
        createNewGroup(point)
</code></pre>

<p>The first island is being created correctly, but for the second island I am getting this error:</p>

<pre><code>File "A2.py", line 371, in findIslands
if point in group:
ValueError: The truth value of an array with more than 
one element is ambiguous. Use a.any() or a.all()
</code></pre>

<p>I've researched this error and am trying to understand how this applies to my situation, and have tried applying <code>.any()</code> and <code>.all()</code> to <code>point</code> but I am getting the same error regardless.</p>

<p>I'm trying to check if the current geodesic point is already in the list of lists for any of the islands.  Point is multidimensional and I think that's where the issue is coming from.</p>

<p>This error arises when a boolean array is used in a scalar context, such as an <code>if</code> statement.  Or maybe in the  <code>in</code> part of the expression.</p>

<p>Is <code>point</code> an array, and <code>group</code> a list of arrays?</p>

<p>In general <code>in</code> is not a good test when working with arrays.</p>

<p>To get more help print <code>point</code>, <code>group</code>, <code>point in group</code>.  Or at least their type, shape and dtype.</p>

<p>Make a small list of <code>point</code>, and focus on to perform an <code>in</code> test or equivalent.  How do you tell whether one equals another?  <code>point1 == point2</code>?</p>

python numpy