I’d like to do something like this:
def fun(a,b,c):
if (a<b**2) & (a<b*c):
result = a/math.pi
elif (a<b**2) & (a>=b*c):
result = b*2/math.pi
elif (a>=b**2) & (a<b*c):
result = c*exp(1)
elif (a>=b**2) & (a>=b*c):
result = a*b*c*math.pi
return result,
but how would I go about getting it to work with a numpy array? The array would be a, b and c would be single numbers.
I’m aware of numpy.where but I just don’t see how I could get it to perform like this bit of code does.
You could nest a few
np.where, and broadcasting should take care of mixing the arrays and the numbers smoothly:For example: