It's well-known that == on numpy arrays returns an array rather than a bool, but this is very inconvenient at times.
>>> [np.zeros(4)] == [np.zeros(4)]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
In my case, I have a huge structure of nested dicts, lists, etc, which occasionally contains numpy arrays. The fact that they can potentially contain numpy arrays means that == can't be used for comparisons since it will occasionally throw exceptions, so instead I need to traverse it manually. This is slow, verbose, and just overall annoying. Is there any better workaround?