【发布时间】:2012-12-05 14:51:37
【问题描述】:
我想做这样的事情:
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,
但是我将如何让它与一个 numpy 数组一起工作呢?数组将是 a、b 和 c 将是单个数字。
我知道 numpy.where,但我只是不明白如何让它像这段代码那样执行。
【问题讨论】:
标签: python arrays if-statement numpy function