Python newbie here, I'm struggling to find the right idiom for applying a function over an array.
I want to compute an associated Legendre polynomial from -1 to 1,
import scipy.special as sc
m = 0
n = 2
z = 0.5
sc.lpmn(m, n, z)
That's all good, but the function isn't vectorised over z. How do I apply it (efficiently) to an array of values? Here's my attempt at using a comprehension, assuming I need to loop one way or another
import numpy as np
z = np.linspace(-1,1,20)
result = [sc.lpmn(0, 2, z[i])[0][0] for i in enumerate(z)]