Skip to content

Commit

Permalink
test: fix old tests
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielaBreitman committed Jul 19, 2024
1 parent d3efecd commit 00a4b4c
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 40 deletions.
114 changes: 76 additions & 38 deletions src/py21cmemu/properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,44 +7,6 @@
import numpy as np


USER_PARAMS = {
"BOX_LEN": 250,
"DIM": 512,
"HII_DIM": 128,
"USE_FFTW_WISDOM": True,
"HMF": 1,
"USE_RELATIVE_VELOCITIES": False,
"POWER_SPECTRUM": 0,
"N_THREADS": 1,
"PERTURB_ON_HIGH_RES": False,
"NO_RNG": False,
"USE_INTERPOLATION_TABLES": True,
"FAST_FCOLL_TABLES": False,
"USE_2LPT": True,
"MINIMIZE_MEMORY": False,
}

COSMO_PARAMS = {
"SIGMA_8": 0.82,
"hlittle": 0.6774,
"OMm": 0.3075,
"OMb": 0.0486,
"POWER_INDEX": 0.97,
}

FLAG_OPTIONS = {
"USE_HALO_FIELD": False,
"USE_MINI_HALOS": False,
"USE_MASS_DEPENDENT_ZETA": True,
"SUBCELL_RSD": True,
"INHOMO_RECO": True,
"USE_TS_FLUCT": True,
"M_MIN_in_Mass": False,
"PHOTON_CONS": True,
"FIX_VCB_AVG": False,
}


class EmulatorProperties:
"""A class that contains the properties of the emulator."""

Expand Down Expand Up @@ -89,6 +51,43 @@ def __init__(self):
self.UVLFs_err = all_emulator_numbers["UVLFs_err"]
self.UVLFs_logerr = all_emulator_numbers["UVLFs_logerr"]

USER_PARAMS = {
"BOX_LEN": 250,
"DIM": 512,
"HII_DIM": 128,
"USE_FFTW_WISDOM": True,
"HMF": 1,
"USE_RELATIVE_VELOCITIES": False,
"POWER_SPECTRUM": 0,
"N_THREADS": 1,
"PERTURB_ON_HIGH_RES": False,
"NO_RNG": False,
"USE_INTERPOLATION_TABLES": True,
"FAST_FCOLL_TABLES": False,
"USE_2LPT": True,
"MINIMIZE_MEMORY": False,
}

COSMO_PARAMS = {
"SIGMA_8": 0.82,
"hlittle": 0.6774,
"OMm": 0.3075,
"OMb": 0.0486,
"POWER_INDEX": 0.97,
}

FLAG_OPTIONS = {
"USE_HALO_FIELD": False,
"USE_MINI_HALOS": False,
"USE_MASS_DEPENDENT_ZETA": True,
"SUBCELL_RSD": True,
"INHOMO_RECO": True,
"USE_TS_FLUCT": True,
"M_MIN_in_Mass": False,
"PHOTON_CONS": True,
"FIX_VCB_AVG": False,
}

self.flag_options = FLAG_OPTIONS
self.user_params = USER_PARAMS
self.cosmo_params = COSMO_PARAMS
Expand Down Expand Up @@ -119,6 +118,45 @@ def __init__(self):
self.mean_errors = np.load(
here / "models/radio_background/median_test_errors.npz"
)
USER_PARAMS = {
"BOX_LEN": 250,
"DIM": 512,
"HII_DIM": 128,
"USE_FFTW_WISDOM": True,
"HMF": 1,
"USE_RELATIVE_VELOCITIES": False,
"POWER_SPECTRUM": 0,
"N_THREADS": 1,
"PERTURB_ON_HIGH_RES": False,
"NO_RNG": False,
"USE_INTERPOLATION_TABLES": True,
"FAST_FCOLL_TABLES": False,
"USE_2LPT": True,
"MINIMIZE_MEMORY": False,
}

COSMO_PARAMS = {
"SIGMA_8": 0.82,
"hlittle": 0.6774,
"OMm": 0.3075,
"OMb": 0.0486,
"POWER_INDEX": 0.97,
}

FLAG_OPTIONS = {
"USE_HALO_FIELD": False,
"USE_MINI_HALOS": False,
"USE_MASS_DEPENDENT_ZETA": True,
"SUBCELL_RSD": True,
"INHOMO_RECO": True,
"USE_TS_FLUCT": True,
"M_MIN_in_Mass": False,
"PHOTON_CONS": True,
"FIX_VCB_AVG": False,
}
self.flag_options = FLAG_OPTIONS
self.user_params = USER_PARAMS
self.cosmo_params = COSMO_PARAMS


def emulator_properties(emulator: str = "default") -> EmulatorProperties:
Expand Down
10 changes: 8 additions & 2 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,21 @@ def test_output(tmp_path):

def test_properties():
"""Test that the properties are loaded correctly."""
from py21cmemu.properties import emulator_properties as properties
from py21cmemu.properties import emulator_properties

properties = emulator_properties()
properties.limits

properties = emulator_properties(emulator="radio_background")
properties.logTr_mean


def test_inputs():
"""Test that we perform parameter normalization properly."""
from py21cmemu import EmulatorInput
from py21cmemu.properties import emulator_properties as properties
from py21cmemu.properties import emulator_properties

properties = emulator_properties()

emu_in = EmulatorInput()
limits = properties.limits.copy()
Expand Down

0 comments on commit 00a4b4c

Please sign in to comment.