Skip to content

Commit

Permalink
Add flrw attrs and meths reference
Browse files Browse the repository at this point in the history
Signed-off-by: nstarman <[email protected]>
  • Loading branch information
nstarman committed Jan 19, 2023
1 parent 0077ad6 commit 165666f
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 60 deletions.
64 changes: 64 additions & 0 deletions src/cosmology/api/flrw.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,70 @@
__all__: list[str] = []


FLRW_ATTRIBUTES = frozenset( # TODO: public scope this
(
"H0",
"Om0",
"Ode0",
"Tcmb0",
"Neff",
"m_nu",
"Ob0",
"scale_factor0",
"h",
"hubble_distance",
"hubble_time",
"Otot0",
"Odm0",
"Ok0",
"Ogamma0",
"Onu0",
"rho_critical0",
"rho_tot0",
"rho_m0",
"rho_de0",
"rho_b0",
"rho_dm0",
"rho_k0",
"rho_gamma0",
"rho_nu0",
)
)
FLRW_METHODS = frozenset( # TODO: public scope this
(
"scale_factor",
"H",
"efunc",
"inv_efunc",
"Otot",
"Om",
"Ob",
"Odm",
"Ok",
"Ode",
"Ogamma",
"Onu",
"rho_critical",
"rho_tot",
"rho_m",
"rho_de",
"rho_k",
"rho_b",
"rho_dm",
"rho_gamma",
"rho_nu",
"age",
"lookback_time",
"comoving_distance",
"comoving_transverse_distance",
"comoving_volume",
"differential_comoving_volume",
"angular_diameter_distance",
"luminosity_distance",
)
)


@runtime_checkable
class FLRWAPIConformant(CosmologyAPIConformant, Protocol):
"""Cosmology API Protocol for FLRW-like cosmologies.
Expand Down
65 changes: 5 additions & 60 deletions tests/api/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
FLRWAPIConformantWrapper,
)
from cosmology.api._array_api.array import ArrayAPIConformant as Array
from cosmology.api.flrw import FLRW_ATTRIBUTES, FLRW_METHODS

# ==============================================================================
# Library API
Expand Down Expand Up @@ -112,71 +113,15 @@ def _return_1arg(self, z: Array, /) -> Array:


@pytest.fixture(scope="session")
def flrw_attrs() -> set[str]:
def flrw_attrs() -> frozenset[str]:
"""The FLRW API atributes."""
return {
"H0",
"Om0",
"Ode0",
"Tcmb0",
"Neff",
"m_nu",
"Ob0",
"scale_factor0",
"h",
"hubble_distance",
"hubble_time",
"Otot0",
"Odm0",
"Ok0",
"Ogamma0",
"Onu0",
"rho_critical0",
"rho_tot0",
"rho_m0",
"rho_de0",
"rho_b0",
"rho_dm0",
"rho_k0",
"rho_gamma0",
"rho_nu0",
}
return FLRW_ATTRIBUTES


@pytest.fixture(scope="session")
def flrw_meths() -> set[str]:
def flrw_meths() -> frozenset[str]:
"""The FLRW API methods."""
return {
"scale_factor",
"H",
"efunc",
"inv_efunc",
"Otot",
"Om",
"Ob",
"Odm",
"Ok",
"Ode",
"Ogamma",
"Onu",
"rho_critical",
"rho_tot",
"rho_m",
"rho_de",
"rho_k",
"rho_b",
"rho_dm",
"rho_gamma",
"rho_nu",
"age",
"lookback_time",
"comoving_distance",
"comoving_transverse_distance",
"comoving_volume",
"differential_comoving_volume",
"angular_diameter_distance",
"luminosity_distance",
}
return FLRW_METHODS


@pytest.fixture(scope="session")
Expand Down

0 comments on commit 165666f

Please sign in to comment.