Search code examples
pythonarrayssyntaxinvalid-argument

Consistent "Invalid Syntax Error" when defining values


I'm a making a list of constants in which one of the constants is exactly equal to a structured array. This value is used in another constant that creates a few problems.

path = '/users/unsername/Desktop/untitled folder/python files/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 

Keeping R shows the the values after, like k and delt_c to have a Invalid Syntax error. When i eliminated the R value, it'll remove all errors. How can I fix this? I think the main culprit is my M = data[:] value


Solution

  • You missed a closing bracket in the line defining M. Replace

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

    with

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