我想返回兩個值之間的python numpy數組中所有值的索引。這裏是我的代碼:如何返回numpy數組中兩個數字之間的值索引
inEllipseIndFar = np.argwhere(excessPathLen * 2 < ePL < excessPathLen * 3)
但它返回一個錯誤:
inEllipseIndFar = np.argwhere((excessPathLen * 2 < ePL < excessPathLen * 3).all())
ValueError: The truth value of an array with more than one element is ambiguous. Use
a.any() or a.all()
我想知道是否有這樣做沒有通過數組進行迭代的方式。謝謝!
出於好奇,「True/False」數組的乘法與邏輯連接之間是否有區別? – Hooked 2014-11-06 18:48:41
@Hooked - 並非如此,但我發現複合邏輯語句更具可讀性 – JoshAdel 2014-11-06 18:51:40