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