brinckmann / montepython_public

Public repository for the Monte Python Code
MIT License
93 stars 80 forks source link

Issue on type Ia SNe likelihoods (JLA and Pantheon) when using Python3 (MontePython v3.3) #181

Closed rodrigovonmarttens closed 3 years ago

rodrigovonmarttens commented 3 years ago

It seems that the type Ia SNe likelihoods (JLA and Pantheon) are not compatible with Python3. I'm using MontePython version 3.3.

MontePython works fine when using with Python2, however, with Python3, when I enter the following command:

python montepython/MontePython.py run -p input/jla.param -o chains/

it returns the following error:

Traceback (most recent call last): File "montepython/MontePython.py", line 40, in sys.exit(run()) File "/Users/rodrigovonmarttens/Codes/montepython_public/montepython/run.py", line 31, in run cosmo, data, command_line, success = safe_initialisation( File "/Users/rodrigovonmarttens/Codes/montepython_public/montepython/run.py", line 191, in safe_initialisation cosmo, data, command_line, success = initialise(custom_command) File "/Users/rodrigovonmarttens/Codes/montepython_public/montepython/initialise.py", line 67, in initialise data = Data(command_line, path) File "/Users/rodrigovonmarttens/Codes/montepython_public/montepython/data.py", line 356, in init self.initialise_likelihoods(self.experiments) File "/Users/rodrigovonmarttens/Codes/montepython_public/montepython/data.py", line 483, in initialise_likelihoods exec("self.lkl['%s'] = %s('%s/%s.data',\ File "", line 1, in File "/Users/rodrigovonmarttens/Codes/montepython_public/montepython/likelihoods/JLA/init.py", line 64, in init self.C00 = self.read_matrix(self.mag_covmat_file) File "/Users/rodrigovonmarttens/Codes/montepython_public/montepython/likelihood_class.py", line 2500, in read_matrix matrix = read_table(path).as_matrix().reshape((length, length)) File "/Users/rodrigovonmarttens/anaconda3/lib/python3.8/site-packages/pandas/core/generic.py", line 5460, in getattr return object.getattribute(self, name) AttributeError: 'DataFrame' object has no attribute 'as_matrix'

I need to use Python3 because of other data I'm using, so, is it possible to arrange these likelihoods to be compatible with Python3?

brinckmann commented 3 years ago

@schoeneberg This seems up your alley, Nils. Any suggestions? Thanks a lot!

Best, Thejs

Uendert commented 3 years ago

Hi all,

I've fixed this by changing the code line 2500 in the montepython/likelihood_class.py file, as follow:

- matrix = read_table(path).as_matrix().reshape((length, length)) + matrix = read_table(path).to_numpy().reshape((length, length))

Best, Uendert

dchooper commented 3 years ago

Hi,

This bugfix is in the pipeline and will be included in a forthcoming release.

Best, Deanna