Comparing an array of arrays element-wise and shallow to None
This post has NOT been accepted by the mailing list yet.
I have object array of arrays, which I compare element-wise to None in various places:
>>> a =
array([array([0, 1, 2, 3, 4]), None, nan, array([0, 1, 2, 3, 4, 5]), None],
FutureWarning: comparison to `None` will result in an elementwise object comparison in the future.
So far, I always ignored the warning, for lack of an idea how to resolve it.
Now, with Numpy 1.13, I have to resolve the issue, because it fails with:
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
It seem that the numpy.equal is applied to each inner array, returning a Boolean array for each element, which cannot be coerced to a single Boolean.
gives the desired result, but feels a bit clumsy.
Is there a cleaner, efficient way to do an element-wise (but shallow) comparison?
Thank you and best regards,
Martin Gfeller, Swisscom