简体   繁体   English

令人困惑的python无效语法错误

[英]Confusing python invalid syntax error

This is part of a stochastic simulation: 这是随机模拟的一部分:

elif (D(dist(x, y, z)) > Dp): ### if passing to a region with lower diffusion constant
            rcross = np.sqrt(Dp/D(dist(x, y, z)))
            rd_nb = rd.uniform(0,1)
            if (Dp == 0.001): # in this case, the particle must be reflected
                s = para(x, y, z, R, dx, dy, dz)
                xc = x + s*dx
                yc = y + s*dy
                zc = z + s*dz

            x = 2*xc - xp
            y = 2*yc - yp           
            z = 2*zc - zp
            # position.append(x)
            t = t + delta_t
            #time.append(t)

        else: 
            if (rd_nb < rcross): # cross!
                s = para(x, y, z, rc, dx, dy, dz)
                xc = x + s*dx
                yc = y + s*dy
                zc = z + s*dz

                sqrt_delta_t1 = (xc - x)/(np.sqrt(2*D(dist(x, y, z))*xix)
                sqrt_delta_t2 = np.sqrt(delta_t) - sqrt_delta_t1

When I run the program, terminal displays the following message: 当我运行该程序时,终端显示以下消息:

I am completely confused, how should that line be an error? 我完全感到困惑,那一行应该怎么走? I think all other parts are well coded. 我认为所有其他部分的编码都很好。 In addition, I cannot print anything (as a debugger) before that line either, which is weird. 另外,我也不能在该行之前打印任何内容(作为调试器),这很奇怪。 Thank you in advance! 先感谢您!

in (np.sqrt(2*D(dist(x, y, z))*xix) (np.sqrt(2*D(dist(x, y, z))*xix)

the parentheses do not match. 括号不匹配。 4 * ( , but only 3 * ) 4 * ( ,但只有3 * )

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM