在Cython中使用lambda函数时出错

Ran*_*l J 6 python cython

我正在尝试使用Cython来加速一段代码.当我使用lambda函数时,Cython会给出一个错误,上面写着"Expected a identifier或literal".据我所知,lambda函数在Cython 0.13中得到支持.我在这一点上不正确吗?如果它们确实受到支持,我是否需要做一些其他事情而不是我在这里实施它们?

def f(e_1, e_2, rho):
    """Bivariate Normal pdf with mean zero, unit variances, and correlation coefficient rho."""
    return (1.0 / (2.0 * pi * sqrt(1 - rho**2))) * exp(-(1.0 / (2*(1 - rho**2))) * (e_1**2 + e_2**2 - 2*rho*e_1*e_2))

def P_zero(b_10, b_11, b_20, b_21, rho, gamma, x):
    """Returns the probability of observing zero entrants in a market by numerically
    integrating out the unobserved firm-specific profit shocks."""
    h_z = lambda e_1: -inf
    g_z = lambda e_1: -b_10 - b_11*x[0] - gamma*x[1]
    I   = lambda e_1, e_2: f(e_1, e_2, rho)
    return dblquad(I, -inf, (-b_20 - b_21*x[0] - gamma*x[2]), h_z, g_z)[0]
Run Code Online (Sandbox Code Playgroud)

raz*_*tia 2

在我看来,除非您在其他地方定义了,否则您应该h_z = lambda e_1: -inf进行更改。h_z = lambda e_1: -float('inf')inf