令人困惑的python语法错误

时间:2015-11-24 20:15:45

标签: python

这是随机模拟的一部分:

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

当我运行程序时,终端显示以下消息:

我完全感到困惑,那条线怎么会出错呢?我认为所有其他部分都编码良好。另外,我也不能在那行之前打印任何东西(作为调试器),这很奇怪。提前谢谢!

1 个答案:

答案 0 :(得分:5)

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

中的

括号不匹配。 4 * (,但只有3 * )