What about checking the type of input inside the function and adapt it ?
def f(x): # for float or np.array if type(x) is float: x = x * np.ones(1) while np.max(x)>1e-5: x = x/2 return x