I wrote the following code:
import numpy as np
a = np.array([0.1])
assert a!=[]
this returned false. Why is this the case? How do I check an array is non-empty?
I wrote the following code:
import numpy as np
a = np.array([0.1])
assert a!=[]
this returned false. Why is this the case? How do I check an array is non-empty?
Well, [] is an empty Python list object, while np.array([0.1]) is a numpy array. You can't really compare the two as you have done; a better way would be to access the size property of the numpy array (also mentioned here).
a = np.array([0.1])
assert a.size != 0