lesgourg / class_public

Public repository of the Cosmic Linear Anisotropy Solving System (master for the most recent version of the standard code; GW_CLASS to include Cosmic Gravitational Wave Background anisotropies; classnet branch for acceleration with neutral networks; ExoCLASS branch for exotic energy injection; class_matter branch for FFTlog)
223 stars 292 forks source link

Python Wrapper on Catalina: Segmentation Fault #463

Open ShazAlvi opened 2 years ago

ShazAlvi commented 2 years ago

After I had issue #462 , I was able import classy in Python27 in a conda environment with gcc-11 installed with home-brew At the moment. I am having issue getting additional quantities like (tCl. mPk etc.) defined in output, however I can get the background quantities. So the following code works perfectly,

import matplotlib.pyplot as plt
from classy import Class

MyClass = Class()
params = {'output': '','omega_b': 0.022383, 'omega_cdm': 0.1201, 'ln10^{10}A_s': 3.044, 'n_s': 0.96605, '100*theta_s': 1.04090, 'tau_reio': 0.0543}
MyClass.set(params)
MyClass.compute()
Bck_Quantity = MyClass.get_background()
plt.loglog(Bck_Quantity['z'], Bck_Quantity['(.)rho_cdm'])
plt.show()

But, adding 'tCl' to the output list returns a segmentation fault, so the following does not work.

import matplotlib.pyplot as plt
from classy import Class

MyClass = Class()
params = {'output': 'tCl','omega_b': 0.022383, 'omega_cdm': 0.1201, 'ln10^{10}A_s': 3.044, 'n_s': 0.96605, '100*theta_s': 1.04090, 'tau_reio': 0.0543}
MyClass.set(params)
MyClass.compute()
Bck_Quantity = MyClass.get_background()
plt.loglog(Bck_Quantity['z'], Bck_Quantity['(.)rho_cdm'])
plt.show()

But if I only ask for background module in MyClass.compute (MyClass.compute(['background'])), everything works again as when tCl is not asked.

I am unable to triangulate why this is happening. I have only recently started working on Mac. On Ubuntu this code works like a charm.

Edit: Just want to add to the previous message that in Ipython the same code works perfectly and I am able to get the tt spectra as expect.

ThomasTram commented 2 years ago

Hi Try to disable --fast-math in the Makefile.

Cheers, Thomas

ShazAlvi commented 2 years ago

Hi Thomas,

Thanks for your suggestion. The option did not help in solving the problem. I still get the same error.

ShazAlvi commented 2 years ago

Hi Thomas,

Just want to add that the same code works fine in IPython. However when the python file is run on the editor or on the terminal it gives a segmentation error.