-
Notifications
You must be signed in to change notification settings - Fork 9
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
base: main
Are you sure you want to change the base?
Changes from all commits
2455fe0
e600795
0621f3d
cf52194
88428cb
2b8912f
96b7030
c4221b3
187063a
16087c8
0a83b2e
663f80a
c8e5ddd
55854dc
d88aa44
44011dc
ff590a9
c7745ef
83f6c12
d5e47ac
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,6 @@ | |
transform_cls, | ||
) | ||
from glass.galaxies import ( | ||
_kappa_ia_nla, | ||
galaxy_shear, | ||
gaussian_phz, | ||
redshifts, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,7 +21,7 @@ classifiers = [ | |
"Typing :: Typed", | ||
] | ||
dependencies = [ | ||
"cosmology>=2022.10.9", | ||
"cosmology.api>=0.1.0", | ||
"gaussiancl>=2022.10.21", | ||
"healpix>=2022.11.1", | ||
"healpy>=1.15.0", | ||
|
@@ -51,6 +51,7 @@ docs = [ | |
] | ||
examples = [ | ||
"camb", | ||
"cosmology", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
"glass.ext.camb", | ||
"jupyter", | ||
"matplotlib", | ||
|
@@ -157,6 +158,7 @@ lint.isort = {known-first-party = [ | |
], sections = {"cosmo" = [ | ||
"camb", | ||
"cosmology", | ||
"cosmology.api", | ||
]}} | ||
lint.per-file-ignores = {"__init__.py" = [ | ||
"F401", # unused-import | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,7 @@ | |
from glass.shells import RadialWindow | ||
|
||
if typing.TYPE_CHECKING: | ||
from cosmology import Cosmology | ||
from cosmology.api import StandardCosmology | ||
|
||
|
||
@pytest.fixture | ||
|
@@ -31,20 +31,21 @@ def shells() -> list[RadialWindow]: | |
|
||
|
||
@pytest.fixture | ||
def cosmo() -> Cosmology: | ||
def cosmo() -> StandardCosmology[npt.NDArray[np.float64], npt.NDArray[np.float64]]: | ||
class MockCosmology: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've changed the mock to match the names from |
||
@property | ||
def omega_m(self) -> float: | ||
def Omega_m0(self) -> float: # noqa: N802 | ||
return 0.3 | ||
|
||
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( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is no equivalently named function in cosmology.api.Standard.Cosmology.transverse_comoving_distance(z) / (cosmology.api.CosmologyConstantsNamespace.c / cosmology.api.Standard.Cosmology.H0) |
||
self, | ||
z: npt.NDArray[np.float64], | ||
z2: npt.NDArray[np.float64] | None = None, | ||
) -> npt.NDArray[np.float64]: | ||
"""Dimensionless transverse comoving distance.""" | ||
if z2 is None: | ||
return np.array(z) * 1000 | ||
return (np.array(z2) - np.array(z)) * 1000 | ||
|
@@ -97,7 +98,7 @@ def test_deflect_many(rng: np.random.Generator) -> None: | |
|
||
def test_multi_plane_matrix( | ||
shells: list[RadialWindow], | ||
cosmo: Cosmology, | ||
cosmo: StandardCosmology[npt.NDArray[np.float64], npt.NDArray[np.float64]], | ||
rng: np.random.Generator, | ||
) -> None: | ||
mat = multi_plane_matrix(shells, cosmo) | ||
|
@@ -119,7 +120,7 @@ def test_multi_plane_matrix( | |
|
||
def test_multi_plane_weights( | ||
shells: list[RadialWindow], | ||
cosmo: Cosmology, | ||
cosmo: StandardCosmology[npt.NDArray[np.float64], npt.NDArray[np.float64]], | ||
rng: np.random.Generator, | ||
) -> None: | ||
w_in = np.eye(len(shells)) | ||
|
There was a problem hiding this comment.
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