定义值时一致"Invalid Syntax Error"

Consistent "Invalid Syntax Error" when defining values

我正在制作一个常量列表,其中一个常量正好等于一个结构化数组。此值用于另一个会产生一些问题的常量。

路径='/users/unsername/Desktop/untitledfolder/pythonfiles/MSII_phasespace/'

os.chdir( path )
data = np.load('msii_phasespace.npy',mmap_mode='r')
# data.size: 167197
# data.shape: (167197,)
# data.dtype: dtype([('x', '<f4'), ('y', '<f4'), ('z', '<f4'),
  # ('velx', '<f4'), ('vely', '<f4'), ('velz', '<f4'), ('m200', '<f4')])



## Constants
# Assuming the mean density is close to the critical density of the universe
rho_m = 3.3e-14 # kg km^-3
# rho_0 = 0.27 * 10**((-1)*26) km m^-3 // current density  
M = data[:] # kg // Mass of dark matter haloes
R = ((3*M)/((rho_m)*4*(np.pi))**(1.0/3.0) # Km // Radius of sphere 
# k = 0.001 # Mpc h^-1 // Wave Dispersion relation 
k = (0.02) # Mpc^-1 // Current best normalization scale
delt_c = 1.686 # Critical overdensity of spherical collapse.
h = 73 # km s^-1 Mpc^-1 // Hubbles Constant in the simulation 
e = 2.718281 # Eulers number
T_CMB = 2.725 # k // Temperature of present Cosmic Microwave Background             
Omega_m = 0.27 # Mass density of current time by WMAP, z = 0 

保留 R 显示之后的值,例如 k 和 delt_c 会出现 Invalid Syntax 错误。当我消除 R 值时,它会消除所有错误。我怎样才能解决这个问题?我认为罪魁祸首是我的 M = data[:]

您在定义 M 的行中遗漏了一个右括号。替换

((3*M)/((rho_m)*4*(np.pi))**(1.0/3.0)

((3*M)/((rho_m)*4*(np.pi))**(1.0/3.0)) # missed closing bracket at end of line