I'm trying to write a function that accepts either a float OR an array of floats, and handles both of them using the same lines of code. For example, I want to return the float itself if it's a float, and the sum of the array of floats if it's an array. Something like this
def func(a):
return np.sum(a)
and have both func(1.2) return 1.2, and func(np.array([1.2,1.3,1.4]) return 3.9.