According to Numpy's argmax documentation, the first argument we pass to np.argmax
must be an array.
If the array is an empty list, we get a ValueError Exception
:
import numpy as np
print(np.argmax([]))
ValueError: attempt to get argmax of an empty sequence
However, if we pass None
as the first argument to np.argmax
, we get 0
as the output.
import numpy as np
print(np.argmax(None))
0
I find it odd that when it is passed an array (albeit empty but an array nonetheless) to np.argmax
we get an Exception but when it is passed NOT an array (None
) the program runs without error.
My questions:
- Why does it not return an Exception since
None
is not an array? - Why does it return 0?