Skip to content

Commit

Permalink
change args of _validate_is_deltasigma_sigma_c
Browse files Browse the repository at this point in the history
  • Loading branch information
m-aguena committed Jul 13, 2023
1 parent 36d2858 commit 37df96e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
8 changes: 4 additions & 4 deletions clmm/dataops/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
16 changes: 9 additions & 7 deletions clmm/utils/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

0 comments on commit 37df96e

Please sign in to comment.