diff --git a/clmm/dataops/__init__.py b/clmm/dataops/__init__.py index 82b61b20e..00865b0d1 100644 --- a/clmm/dataops/__init__.py +++ b/clmm/dataops/__init__.py @@ -133,7 +133,7 @@ def compute_tangential_and_cross_components( names=("Ra", "Dec", "Shear1", "Shear2"), prefix="Tangential- and Cross- shape components sources", ) - _validate_is_deltasigma_sigma_c(locals()) + _validate_is_deltasigma_sigma_c(is_deltasigma, sigma_c) elif np.iterable(ra_source): ra_source_, dec_source_, shear1_, shear2_ = ( np.array(col) for col in [ra_source, dec_source, shear1, shear2] @@ -248,8 +248,8 @@ def compute_galaxy_weights( Parameters ---------- is_deltasigma: bool - If `True`, the tangential and cross components returned are multiplied by Sigma_crit. - It requires `sigma_c` argument. Results in units of :math:`M_\odot\ Mpc^{-2}` + If `False`, weights are computed for shear, else weights are computed for + :math:`\Delta \Sigma`. sigma_c : None, array_like Critical (effective) surface density in units of :math:`M_\odot\ Mpc^{-2}`. Used only when is_deltasigma=True. @@ -292,7 +292,7 @@ def compute_galaxy_weights( names=("shape_component1", "shape_component2"), prefix="Shape components sources", ) - _validate_is_deltasigma_sigma_c(locals()) + _validate_is_deltasigma_sigma_c(is_deltasigma, sigma_c) # computing w_ls_geo w_ls_geo = 1.0 diff --git a/clmm/utils/validation.py b/clmm/utils/validation.py index f08e2ad86..f4a322002 100644 --- a/clmm/utils/validation.py +++ b/clmm/utils/validation.py @@ -209,16 +209,18 @@ def _validate_dec(loc, dec_name, is_array): validate_argument(loc, dec_name, v_type, argmin=-90, eqmin=True, argmax=90, eqmax=True) -def _validate_is_deltasigma_sigma_c(loc): - """ "Validate the compatibility between is_deltasigma and sigma_c arguments. +def _validate_is_deltasigma_sigma_c(is_deltasigma, sigma_c): + r""" "Validate the compatibility between is_deltasigma and sigma_c arguments. Parameters ---------- - loc: dict - Dictionary with all input arguments. Should be locals(). + is_deltasigma: bool + If `False`, values are computed for shear, else they are computed for :math:`\Delta \Sigma`. + sigma_c : None, array_like + Critical (effective) surface density in units of :math:`M_\odot\ Mpc^{-2}`. """ - if loc["is_deltasigma"] and loc["sigma_c"] is None: + if is_deltasigma and sigma_c is None: raise TypeError("sigma_c (=None) must be provided when is_deltasigma=True") - if not loc["is_deltasigma"] and loc["sigma_c"] is not None: - raise TypeError(f"sigma_c (={loc['sigma_c']}) be provided when is_deltasigma=False") + if not is_deltasigma and sigma_c is not None: + raise TypeError(f"sigma_c (={sigma_c}) be provided when is_deltasigma=False")