Skip to content

Commit

Permalink
Improve docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
camposandro committed Jul 18, 2024
1 parent 2489bfe commit 5575c9b
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 23 deletions.
18 changes: 11 additions & 7 deletions src/corrgi/corrgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,16 @@ def compute_autocorrelation(
"""Calculates the auto-correlation for a catalog.
Args:
catalog (Catalog): The catalog.
random (Catalog): A random samples catalog.
catalog (Catalog): The galaxies catalog (D).
random (Catalog): A random samples catalog (R).
corr_type (type[Correlation]): The corrgi class corresponding to the type of
correlation (AngularCorrelation, RedshiftCorrelation, or ProjectedCorrelation).
**kwargs (dict): The arguments for the creation of the correlation instance.
Returns:
A numpy array with the result of the auto-correlation, using the natural estimator.
A numpy array with the result of the auto-correlation, according to the estimator
provided in the correlation kwargs. More information on how to set up the input parameters
in https://gundam.readthedocs.io/en/latest/introduction.html#set-up-input-parameters.
"""
correlation = corr_type(**kwargs)
correlation.validate([catalog, random])
Expand All @@ -32,15 +34,17 @@ def compute_crosscorrelation(
"""Computes the cross-correlation between two catalogs.
Args:
left (Catalog): Left catalog for the cross-correlation.
right (Catalog): Right catalog for the cross-correlation.
random (Catalog): A random samples catalog.
left (Catalog): Left catalog for the cross-correlation (D).
right (Catalog): Right catalog for the cross-correlation (C).
random (Catalog): A random samples catalog (R).
corr_type (type[Correlation]): The corrgi class corresponding to the type of
correlation (AngularCorrelation, RedshiftCorrelation, or ProjectedCorrelation).
**kwargs (dict): The arguments for the creation of the correlation instance.
Returns:
A numpy array with the result of the cross-correlation, using the natural estimator.
A numpy array with the result of the cross-correlation, according to the estimator
provided in the correlation kwargs. More information on how to set up the input parameters
in https://gundam.readthedocs.io/en/latest/introduction.html#set-up-input-parameters.
"""
correlation = corr_type(**kwargs)
correlation.validate([left, right, random])
Expand Down
10 changes: 5 additions & 5 deletions src/corrgi/estimators/davis_peebles_estimator.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@ class DavisPeeblesEstimator(Estimator):
def compute_autocorrelation_counts(
self, catalog: Catalog, random: Catalog
) -> list[np.ndarray, np.ndarray, np.ndarray | int]:
"""Computes the auto-correlation counts for the provided catalog (`DD/RR - 1`)"""
"""Computes the auto-correlation counts for the provided catalog"""
raise NotImplementedError()

Check warning on line 18 in src/corrgi/estimators/davis_peebles_estimator.py

View check run for this annotation

Codecov / codecov/patch

src/corrgi/estimators/davis_peebles_estimator.py#L18

Added line #L18 was not covered by tests

def compute_crosscorrelation_counts(
self, left: Catalog, right: Catalog, random: Catalog
) -> list[np.ndarray, np.ndarray, np.ndarray | int]:
) -> list[np.ndarray, np.ndarray]:
"""Computes the cross-correlation counts for the provided catalog.
Args:
left (Catalog): A left galaxy samples catalog.
right (Catalog): A right galaxy samples catalog.
random (Catalog): A random samples catalog.
left (Catalog): A left galaxy samples catalog (D).
right (Catalog): A right galaxy samples catalog (C).
random (Catalog): A random samples catalog (R).
Returns:
The CD and CR counts for the DP estimator.
Expand Down
14 changes: 7 additions & 7 deletions src/corrgi/estimators/estimator.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ def compute_auto_estimate(self, catalog: Catalog, random: Catalog) -> np.ndarray
"""Computes the auto-correlation for this estimator.
Args:
catalog (Catalog): The catalog of galaxy samples.
random (Catalog): The catalog of random samples.
catalog (Catalog): The catalog of galaxy samples (D).
random (Catalog): The catalog of random samples (R).
Returns:
The statistical estimate of the auto-correlation function, as a numpy array.
Expand All @@ -39,9 +39,9 @@ def compute_cross_estimate(self, left: Catalog, right: Catalog, random: Catalog)
"""Computes the cross-correlation for this estimator.
Args:
left (Catalog): The left catalog of galaxy samples.
right (Catalog): The right catalog of galaxy samples.
random (Catalog): The catalog of random samples.
left (Catalog): The left catalog of galaxy samples (D).
right (Catalog): The right catalog of galaxy samples (C).
random (Catalog): The catalog of random samples (R).
Returns:
The statistical estimate of the cross-correlation function, as a numpy array.
Expand All @@ -65,7 +65,7 @@ def compute_autocorrelation_counts(
@abstractmethod
def compute_crosscorrelation_counts(
self, left: Catalog, right: Catalog, random: Catalog
) -> list[np.ndarray, np.ndarray, np.ndarray]:
) -> list[np.ndarray, np.ndarray]:
"""Computes the cross-correlation counts (CD, CR)."""
raise NotImplementedError()

Check warning on line 70 in src/corrgi/estimators/estimator.py

View check run for this annotation

Codecov / codecov/patch

src/corrgi/estimators/estimator.py#L70

Added line #L70 was not covered by tests

Expand Down Expand Up @@ -102,7 +102,7 @@ def _get_cross_args(
counts_cr: np.ndarray,
) -> list:
"""Returns the args for the cross-correlation estimator routine"""
counts_bdd = self.correlation.get_bdd_counts() # TODO: Change this
counts_bdd = self.correlation.get_bdd_counts()
args = [num_galaxies, num_random, counts_cd, counts_bdd, counts_cr]
if isinstance(self.correlation, ProjectedCorrelation):
# The projected routines require an additional parameter
Expand Down
4 changes: 2 additions & 2 deletions src/corrgi/estimators/natural_estimator.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ def compute_autocorrelation_counts(
"""Computes the auto-correlation counts for the provided catalog (`DD/RR - 1`).
Args:
catalog (Catalog): A galaxy samples catalog.
random (Catalog): A random samples catalog.
catalog (Catalog): A galaxy samples catalog (D).
random (Catalog): A random samples catalog (R).
Returns:
The DD, RR and DR counts for the natural estimator.
Expand Down
4 changes: 2 additions & 2 deletions tests/corrgi/test_projected.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def test_pccf_counts_with_weights_are_correct(
pcf_gals1_weight_catalog,
pcf_rans_weight_catalog,
pccf_cd_counts_with_weights,
pccf_cr_counts_with_weight,
pccf_cr_counts_with_weights,
pcf_params,
):
estimator = DavisPeeblesEstimator(
Expand All @@ -93,4 +93,4 @@ def test_pccf_counts_with_weights_are_correct(
pcf_gals_weight_catalog, pcf_gals1_weight_catalog, pcf_rans_weight_catalog
)
npt.assert_allclose(counts_cd, pccf_cd_counts_with_weights, rtol=1e-3)
npt.assert_allclose(counts_cr, pccf_cr_counts_with_weight, rtol=2e-3)
npt.assert_allclose(counts_cr, pccf_cr_counts_with_weights, rtol=2e-3)

0 comments on commit 5575c9b

Please sign in to comment.