I have an old function named old_func that takes as input two positional arguments, x and y. The input of the function was written like this using a tuple as the input:
def old_func(position):
x, y = position
return x**2 + y**2
I now want a quick and easy way of calling the function over a grid of values:
xx = numpy.linspace(0, 1, 100)
yy = numpy.linspace(0, 1, 100)
X, Y = numpy.meshgrid(xx, yy)
array_positions = (X,Y)
old_fun(array_positions)
The intent is that each operation on x in the function is done on all of the X and the same for y. I tried vectorizing the function using numpy.vectorize but that does not work. I prefer not to change the function to accept NumPy arrays because that will take too long.