How do I test if a numpy array is empty. I have problem if the there is only one element with value 0. If I do
a = np.array([0])
a.any()
results is False while
a = np.array([1])
a.any()
is True
So how do I check np.array has no elements?
len(a) == 1to capture the only element with value 0. Better perhaps to usea.size != 0sizemakes most sense. But why why do you need to check this? Is this a 1d array? How is it created?bool(np.array([]))suggests usingarray.size > 0.