Thank you for your tips. I was not aware of the possible problems with len.
> There is no way to test all of the cases (empty sequence, empty array,
> None) in the same way. Usually, it's a bad idea to conflate the three.
I agree that this should be avoided. However, there are cases in which it is not possible or hard. My case is that I get some extra data to add to my plots from a database. The dataset may be undefined (which means None), empty array or empty list. In all cases the data should not be plotted. If I want to test for all the cases, my program becomes quite complex.
In fact, Python provides False values for most empty objects, but NumPy seems to ignore this. It might be a good idea to have a helper function which handles all objects consistently.
Yours,
Bartosz