CobayaSampler / cobaya

Code for Bayesian Analysis
http://cobaya.readthedocs.io/en/latest/
Other
128 stars 127 forks source link

Using modified classy code #228

Closed runburg closed 2 years ago

runburg commented 2 years ago

Hi,

So I'm trying to use a modified version of CLASS with Cobaya. I have the modified version of CLASS compiled and working with the python wrapper (I can import from a python file and set new parameters and compute cosmologies with these modified components). As far as I understand it, this version of classy has been installed globally (since I can import classy from my python script and get the correct version.

However, when I try and use cobaya, I get

Error in Class: Class did not read input parameter(s): ***my new parameters***

even though the output says

[classy] Importing *auto-installed* CLASS (but defaulting to *global*).

I'm sure this is an easy solve but any help would be much appreciated! Thanks!

JesusTorrado commented 2 years ago

Hi @runburg

That's a tricky one. Unless you give classy a path property in the input, Cobaya prefers the auto-installed one over the global one. The design idea was that most of the time users would be specifying paths to their modified versions, since they may have more than one around.

You have two options:

Closing since it's not a bug, but please do update us here, and feel free to re-open if it feels appropriate.

runburg commented 2 years ago

Hi, I'm still struggling with this...I've tried to set the path property but I haven't figured out which path to use to make this work. I was just assuming I should point it to the path of the folder with the classy cython .so file but this is apparently not working.

Where should I be pointing cobaya to?

JesusTorrado commented 2 years ago

Try the base folder (e.g. the first level on which you have cloned the repo). Cobaya will (should) find the actual library from there (see https://github.com/CobayaSampler/cobaya/blob/1fdbb581385a959ee1f2e072db4f18149eda8694/cobaya/theories/classy/classy.py#L501). Do let me know otherwise.

runburg commented 2 years ago

Okay this worked thanks! I was trying to point to the library directly. Pointing to the base folder of the CLASS installation worked.

IamSreeman commented 2 years ago

@runburg can you specify how you gave the path? Is it like this?

theory:
  classy:
    path: '/home/sreeman/class_public'
    extra_args:
      non linear: hmcode
      nonlinear_min_k_max: 20
      N_ncdm: 1
      N_ur: 2.0328
runburg commented 2 years ago

Yes that looks right if class_public is your modified CLASS code.

IamSreeman commented 2 years ago

@runburg Ok thanks. Now it looks like it is working. My error was initially I didn't give those ''.