0
如果你有下面的代码:通行证元素索引
import numpy as np
def myFunction(element, index):
print element, index
myVector = np.vectorize(myFunction)
myVector(myArray, currentElementIndex)
- 你怎么能传递numpy的矢量化
currentElementIndex
值myFunction()
?
在此先感谢!
编辑:我不太确定我应该在哪里得到应用myFunction()
的当前项目的索引。我知道如何传递一个数组元素,但不是索引。
编辑:更新与实际的代码:
import numpy as npy
def getHashValue(character, index):
return (ord(character) - ord('a')) ** (index + 1)
def getNameHash(name):
hashValue = getHashValue
hashValue = npy.vectorize(hashValue)
hashValue(shortName)
return
你真的想做什么?问题在哪里? (我真的不明白你的问题) – jorgeca
嗯,我不确定我应该在哪里得到'myFunction()'应用到的当前项目的索引。我知道如何传递一个数组元素,但不是索引。 –
你能告诉我们你在做什么(一个最小的工作示例),你想要发生什么?你的代码如何不给你'myFunction'正在被应用的项目?这正是它要打印的内容。 – jorgeca