diff --git a/clmm/theory/ccl.py b/clmm/theory/ccl.py index 86b10f0e4..2bcdb4500 100644 --- a/clmm/theory/ccl.py +++ b/clmm/theory/ccl.py @@ -95,12 +95,12 @@ def __init__( self.set_cosmo(None) def _use_projected_quad(self, use_quad): - if hasattr(self.hdpm, '_projected_quad'): + if hasattr(self.hdpm, 'projected_quad'): self.hdpm_opts["einasto"]["projected_quad"] = use_quad self._update_halo_density_profile() else: raise NotImplementedError( - "_projected_quad is not available on this version of CCL.") + "projected_quad is not available on this version of CCL.") # Functions implemented by child class diff --git a/tests/test_theory.py b/tests/test_theory.py index 526e865b8..422308434 100644 --- a/tests/test_theory.py +++ b/tests/test_theory.py @@ -341,6 +341,18 @@ def test_profiles(modeling_data, profile_init): assert_raises( ValueError, mod.eval_excess_surface_density, 1e-12, cfg["SIGMA_PARAMS"]["z_cl"] ) + if mod.backend == "ccl" and profile_init == "einasto": + if hasattr(mod.hdpm, 'projected_quad'): + mod.use_projected_quad(True) + assert_allclose( + mod.eval_surface_density( + cfg["SIGMA_PARAMS"]["r_proj"], cfg["SIGMA_PARAMS"]["z_cl"], verbose=True + ), + cfg["numcosmo_profiles"]["Sigma"], + reltol*1e-1, + ) + delattr(mod.hdpm, "projected_quad") + assert_raises(NotImplementedError, mod.use_projected_quad, True) # Functional interface tests # alpha_ein is None unless testing Einasto with the NC and CCL backend diff --git a/tests/test_theory_parent.py b/tests/test_theory_parent.py index c57d3c0f3..09bc8fa3a 100644 --- a/tests/test_theory_parent.py +++ b/tests/test_theory_parent.py @@ -21,6 +21,7 @@ def test_unimplemented(modeling_data): assert_raises(NotImplementedError, mod._update_halo_density_profile) assert_raises(NotImplementedError, mod._set_einasto_alpha, 0.5) assert_raises(NotImplementedError, mod._get_einasto_alpha) + assert_raises(NotImplementedError, mod._use_projected_quad, True) assert_raises(NotImplementedError, mod.eval_3d_density, [0.3], 0.3) assert_raises(NotImplementedError, mod.eval_surface_density, [0.3], 0.3) assert_raises(NotImplementedError, mod.eval_mean_surface_density, [0.3], 0.3) @@ -91,6 +92,16 @@ def test_instantiate(modeling_data): assert_raises(ValueError, mod.set_halo_density_profile, halo_profile_model="bla") assert_raises(ValueError, mod.set_halo_density_profile, massdef="blu") + if theo.be_nick in ["nc", "ccl"]: + mod.set_halo_density_profile(massdef="virial") + assert_equal(mod.massdef, "virial") + + # reset + mod.massdef = "mean" + + mod.massdef = "virial" + assert_equal(mod.massdef, "virial") + if theo.be_nick == "nc": import gi @@ -150,3 +161,18 @@ def test_einasto(modeling_data): mod.eval_reduced_tangential_shear(0.1, 0.1, 0.5, verbose=True) mod.eval_magnification(0.1, 0.1, 0.5, verbose=True) mod.eval_magnification_bias(0.1, 2, 0.1, 0.5, verbose=True) + + +def test_use_projected_quad(modeling_data): + """Test use_projected_quad method""" + mod = theo.Modeling() + assert_raises(NotImplementedError, mod.use_projected_quad, True) + + if theo.be_nick == "ccl": + assert_raises(NotImplementedError, mod.use_projected_quad, True) + mod.set_halo_density_profile("hernquist") + assert_raises(NotImplementedError, mod.use_projected_quad, True) + mod.set_halo_density_profile("einasto") + mod.use_projected_quad(True) + else: + assert_raises(NotImplementedError, mod.use_projected_quad, True)