If you have the following code :
import numpy as np
def myFunction(element, index):
print element, index
myVector = np.vectorize(myFunction)
myVector(myArray, currentElementIndex)
- How can you pass the
currentElementIndexvalue tomyFunction()in Numpy vectorization ?
Thanks in advance !
EDIT : I'm not really sure of where I should get the index of the current item to which myFunction() is applied to. I know how to pass an array element, but not the index.
EDIT : Updated with the actual code :
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
myFunctionis being applied to? That's exactly what it'll print.