【发布时间】:2013-03-14 04:25:48
【问题描述】:
我在python中写了一个函数如下:
from bisect import basect_left
def find(i):
a=[1,2,3]
return bisect_left(a,i);
我希望这个函数接受迭代作为输入并生成迭代作为输出。特别是我正在使用 numpy 并且我希望能够使用 linspace 作为输入和 获取此代码的输出:
import matplotlib.pyplot as plt
t=scipy.linspace(0,10,100)
plt.plot(t,find(t))
更新!!!: 我意识到我得到的错误是:
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
这是从bisect 库中为bisect_left 提供的。我怎么解决这个问题?
谢谢。
【问题讨论】:
标签: python function matplotlib iteration range