Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-124: use cosmology.api over the cosmology package #397

Draft
wants to merge 20 commits into
base: main
Choose a base branch
from

Conversation

paddyroddy
Copy link
Member

Closes #124. Use the improved cosmology.api package throughout the code.

Closes #124. Use the improved `cosmology.api` package throughout the
code.
@paddyroddy paddyroddy added enhancement New feature or request dependencies Pull requests that update a dependency file science Science improvement or question labels Nov 7, 2024
@paddyroddy paddyroddy self-assigned this Nov 7, 2024
@@ -49,6 +49,7 @@ docs = [
]
examples = [
"camb",
"cosmology",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cosmology is still used in the notebooks currently

@@ -31,14 +31,14 @@ def shells() -> list[RadialWindow]:


@pytest.fixture
def cosmo() -> Cosmology:
def cosmo() -> StandardCosmology:
class MockCosmology:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've changed the mock to match the names from cosmology.api, hence the noqa

Comment on lines 18 to 20
Intrinsic alignments
--------------------
.. autofunction:: kappa_ia_nla
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have reverted #21 as I believe it is broken/needs testing. Don't want to waste time porting.

def ef(self, z: npt.NDArray[np.float64]) -> npt.NDArray[np.float64]:
return (self.omega_m * (1 + z) ** 3 + 1 - self.omega_m) ** 0.5
def H_over_H0(self, z: npt.NDArray[np.float64]) -> npt.NDArray[np.float64]: # noqa: N802
return (self.Omega_m0 * (1 + z) ** 3 + 1 - self.Omega_m0) ** 0.5

def xm(
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no equivalently named function in cosmology.api. In practice, this would be

cosmology.api.Standard.Cosmology.transverse_comoving_distance(z) / (cosmology.api.CosmologyConstantsNamespace.c / cosmology.api.Standard.Cosmology.H0)

Comment on lines +334 to +335
x2 = self.x3
self.x3 = self.cosmo.transverse_comoving_distance(self.z3) / hubble_length
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've split these so the line isn't really long

@paddyroddy paddyroddy added the blocked The issue or pull request is blocked by something label Nov 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked The issue or pull request is blocked by something dependencies Pull requests that update a dependency file enhancement New feature or request science Science improvement or question
Projects
None yet
Development

Successfully merging this pull request may close these issues.

use cosmology API instead of deprecated cosmology package
1 participant