我想返回两个值之间的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