What is the significance of the underscore suffixing in int_
, float_
, etc.?
If you're unsure if your variable is scalar, list, or array, using the ones with "_" will ensure your code will work regardless (if that's the behavior you intended). See the example code below.
import numpy as np
scalar = 3
L1 = [3]
L2 = [1, 2, 3]
np.float(scalar) # okay
np.float(L1) # breaks (TypeError)
np.float(L2) # breaks (TypeError)
np.float_(scalar) # okay
np.float_(L1) # okay
np.float_(L2) # okay