Custom CLASS builds¶
Use any classy build (AxiCLASS, Hi-CLASS, CLASS-EFT, a modified fork) without touching the installed one.
Selecting the build¶
Precedence, highest first:
--classy PATHonclass-e generate- the
CLASS_E_CLASSYenvironment variable theory.classy.pathin the YAML- the
classyinstalled in the environment
PATH can be a CLASS source tree, a site-packages or build/lib.* directory containing classy, or the compiled classy*.so itself.
The choice is propagated to the worker processes, so every chunk uses the same build.
Building CLASS with Python support¶
cd /path/to/CLASS
make clean && make
python setup.py build # creates build/lib.<platform>-<python>/classy*.so
The build must match the Python version running class-e.
From Python¶
The class-e functions that run CLASS (get_observables, compute_cosmology, compute_dataset) use the selected build. Without an explicit choice, the first CLASS run uses CLASS_E_CLASSY if it is set, and the installed classy otherwise. To choose a build in code, or to honour a YAML's theory.classy.path, select it before the first run (a process holds one CLASS):
from class_e.core.boltzmann import classy_info, resolve_classy_path, select_classy
from class_e.utils.yml import load_yaml
# either the CLI's precedence (--classy, CLASS_E_CLASSY, theory.classy.path, installed) ...
select_classy(*resolve_classy_path(model_data=load_yaml("configs/ede-axiclass.yaml")))
# ... or a build by path: select_classy("/path/to/AxiCLASS")
print(classy_info()) # version, file and where the choice came from
For CLASS's own Class from a given build:
from class_e.utils import load_class_from_path
Class = load_class_from_path("/path/to/AxiCLASS")
cosmo = Class()
Troubleshooting¶
| Message | Cause and fix |
|---|---|
No directories starting with 'lib' were found |
CLASS was not built. Run python setup.py build inside the CLASS directory. |
Could not import classy module |
The build targets another Python version. Rebuild with the interpreter you run class-e with. |
No suitable compiled import path found |
build/lib.* exists but contains no .so, .pyd or .dylib. Rebuild and check the compiler output. |