Skip to content

Commit

Permalink
Rename backend to use_backend; Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hsinfan1996 committed Jul 19, 2024
1 parent b3b8d78 commit 97b48c7
Showing 1 changed file with 66 additions and 16 deletions.
82 changes: 66 additions & 16 deletions tests/test_theory.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,37 +346,37 @@ def test_profiles(modeling_data, profile_init):
2.5e-2,
)
assert_allclose(
mod.eval_mean_surface_density(
mod.eval_surface_density(
cfg["SIGMA_PARAMS"]["r_proj"], cfg["SIGMA_PARAMS"]["z_cl"], r_mis=0.1,
verbose=True)[-40:],
(cfg["numcosmo_profiles"]["Sigma"] + cfg["numcosmo_profiles"]["DeltaSigma"])[-40:],
8.5e-3,
verbose=True, use_backend=True)[-40:],
cfg["numcosmo_profiles"]["Sigma"][-40:],
2.5e-2,
)
assert_allclose(
mod.eval_excess_surface_density(
mod.eval_mean_surface_density(
cfg["SIGMA_PARAMS"]["r_proj"], cfg["SIGMA_PARAMS"]["z_cl"], r_mis=0.1,
verbose=True)[-40:],
cfg["numcosmo_profiles"]["DeltaSigma"][-40:],
3e-2
)
assert_allclose(
mod.eval_surface_density(
cfg["SIGMA_PARAMS"]["r_proj"], cfg["SIGMA_PARAMS"]["z_cl"], r_mis=0.1,
verbose=True, backend=True)[-40:],
cfg["numcosmo_profiles"]["Sigma"][-40:],
2.5e-2,
(cfg["numcosmo_profiles"]["Sigma"] + cfg["numcosmo_profiles"]["DeltaSigma"])[-40:],
8.5e-3,
)
assert_allclose(
mod.eval_mean_surface_density(
cfg["SIGMA_PARAMS"]["r_proj"], cfg["SIGMA_PARAMS"]["z_cl"], r_mis=0.1,
verbose=True, backend=True)[-40:],
verbose=True, use_backend=True)[-40:],
(cfg["numcosmo_profiles"]["Sigma"] + cfg["numcosmo_profiles"]["DeltaSigma"])[-40:],
8.5e-3,
)
assert_allclose(
mod.eval_excess_surface_density(
cfg["SIGMA_PARAMS"]["r_proj"], cfg["SIGMA_PARAMS"]["z_cl"], r_mis=0.1,
verbose=True, backend=False)[-40:],
verbose=True)[-40:],
cfg["numcosmo_profiles"]["DeltaSigma"][-40:],
2.5e-2
)
assert_allclose(
mod.eval_excess_surface_density(
cfg["SIGMA_PARAMS"]["r_proj"], cfg["SIGMA_PARAMS"]["z_cl"], r_mis=0.1,
verbose=True, use_backend=False)[-40:],
cfg["numcosmo_profiles"]["DeltaSigma"][-40:],
2.5e-2
)
Expand Down Expand Up @@ -422,6 +422,56 @@ def test_profiles(modeling_data, profile_init):
reltol,
)

if mod.backend == "nc":
assert_allclose(
theo.compute_surface_density(
cosmo=cosmo, **cfg["SIGMA_PARAMS"], alpha_ein=alpha_ein, verbose=True,
r_mis=0.1
)[-40:],
cfg["numcosmo_profiles"]["Sigma"][-40:],
2.5e-2,
)
assert_allclose(
theo.compute_surface_density(
cosmo=cosmo, **cfg["SIGMA_PARAMS"], alpha_ein=alpha_ein, verbose=True,
r_mis=0.1, use_backend=True
)[-40:],
cfg["numcosmo_profiles"]["Sigma"][-40:],
2.5e-2,
)
assert_allclose(
theo.compute_mean_surface_density(
cosmo=cosmo, **cfg["SIGMA_PARAMS"], alpha_ein=alpha_ein, verbose=True,
r_mis=0.1
)[-40:],
(cfg["numcosmo_profiles"]["Sigma"] + cfg["numcosmo_profiles"]["DeltaSigma"])[-40:],
8.5e-3,
)
assert_allclose(
theo.compute_mean_surface_density(
cosmo=cosmo, **cfg["SIGMA_PARAMS"], alpha_ein=alpha_ein, verbose=True,
r_mis=0.1, use_backend=True
)[-40:],
(cfg["numcosmo_profiles"]["Sigma"] + cfg["numcosmo_profiles"]["DeltaSigma"])[-40:],
8.5e-3,
)
assert_allclose(
theo.compute_excess_surface_density(
cosmo=cosmo, **cfg["SIGMA_PARAMS"], alpha_ein=alpha_ein, verbose=True,
r_mis=0.1
)[-40:],
cfg["numcosmo_profiles"]["DeltaSigma"][-40:],
2.5e-2,
)
assert_allclose(
theo.compute_excess_surface_density(
cosmo=cosmo, **cfg["SIGMA_PARAMS"], alpha_ein=alpha_ein, verbose=True,
r_mis=0.1, use_backend=True
)[-40:],
cfg["numcosmo_profiles"]["DeltaSigma"][-40:],
2.5e-2,
)

# Test use_projected_quad
if mod.backend == "ccl" and profile_init == "einasto":
if hasattr(mod.hdpm, 'projected_quad'):
Expand Down

0 comments on commit 97b48c7

Please sign in to comment.