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)
230 stars 285 forks source link

Specify class directory #350

Closed taladi closed 1 year ago

taladi commented 4 years ago

Is it possible to specify class directory in order to run two versions of class in the same code?

ThomasTram commented 4 years ago

Yes it is. You can use

import sys
sys.path.insert(1, '<FIRST_PATH_TO_CLASS>/python/build/lib.macosx-10.9-x86_64-3.7')
import classy as classy_first
# Check that it worked:
print(classy_first.__file__)
sys.path.insert(1, '<SECOND_PATH_TO_CLASS>/python/build/lib.macosx-10.9-x86_64-3.7')
import classy as classy_second
# Check that it worked:
print(classy_second.__file__)

The folder in the python/build folder will have different names, but you can code your way out of that.

Cheers, Thomas