diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 50aa14b..a8f808a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -32,14 +32,14 @@ repos: - id: text-unicode-replacement-char - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.1.9" + rev: "v0.2.0" hooks: - id: ruff args: - --fix - repo: https://github.com/psf/black - rev: 23.12.1 + rev: 24.1.1 hooks: - id: black additional_dependencies: [toml] diff --git a/docs/conf.py b/docs/conf.py index 7bf9002..7492196 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -5,7 +5,6 @@ https://www.sphinx-doc.org/en/master/usage/configuration.html """ - import pathlib import sys from importlib import import_module @@ -23,6 +22,7 @@ def get_authors() -> set[str]: ------- set[str] The authors. + """ authors: set[str] = set() cfg = pathlib.Path(__file__).parent.parent / "pyproject.toml" diff --git a/src/cosmology/compat/classy/_standard.py b/src/cosmology/compat/classy/_standard.py index 5a248d9..9bd4de6 100644 --- a/src/cosmology/compat/classy/_standard.py +++ b/src/cosmology/compat/classy/_standard.py @@ -114,6 +114,7 @@ def Omega_m(self, z: InputT, /) -> Array: ----- This does not include neutrinos, even if non-relativistic at the redshift of interest; see `Onu`. + """ return np.asarray(self._cosmo_fn["Om_m"](z)) @@ -132,6 +133,7 @@ def Omega_b(self, z: InputT, /) -> Array: ------ ValueError If ``Ob0`` is `None`. + """ raise NotImplementedError @@ -184,6 +186,7 @@ def Omega_dm(self, z: InputT, /) -> Array: ----- This does not include neutrinos, even if non-relativistic at the redshift of interest. + """ raise NotImplementedError @@ -272,12 +275,10 @@ def age(self, z: InputT, /) -> Array: # Comoving distance @overload - def comoving_distance(self, z: InputT, /) -> Array: - ... + def comoving_distance(self, z: InputT, /) -> Array: ... @overload - def comoving_distance(self, z1: InputT, z2: InputT, /) -> Array: - ... + def comoving_distance(self, z1: InputT, z2: InputT, /) -> Array: ... def comoving_distance(self, z1: InputT, z2: InputT | None = None, /) -> Array: r"""Comoving line-of-sight distance :math:`d_c(z)` in Mpc. @@ -297,6 +298,7 @@ def comoving_distance(self, z1: InputT, z2: InputT | None = None, /) -> Array: ------- Array The comoving distance :math:`d_c` in Mpc. + """ z1, z2 = (0, z1) if z2 is None else (z1, z2) return self._cosmo_fn["comoving_distance"](z2) - self._cosmo_fn[ @@ -304,12 +306,10 @@ def comoving_distance(self, z1: InputT, z2: InputT | None = None, /) -> Array: ](z1) @overload - def transverse_comoving_distance(self, z: InputT, /) -> Array: - ... + def transverse_comoving_distance(self, z: InputT, /) -> Array: ... @overload - def transverse_comoving_distance(self, z1: InputT, z2: InputT, /) -> Array: - ... + def transverse_comoving_distance(self, z1: InputT, z2: InputT, /) -> Array: ... def transverse_comoving_distance( self, z1: InputT, z2: InputT | None = None, / @@ -333,6 +333,7 @@ def transverse_comoving_distance( ------- Array The comoving transverse distance :math:`d_M` in Mpc. + """ raise NotImplementedError @@ -359,12 +360,10 @@ def _comoving_volume_negative(self, z: InputT, /) -> Array: return term1 * (term2 - 1.0 / np.sqrt(np.abs(self.Omega_k0)) * np.arcsin(term3)) @overload - def comoving_volume(self, z: InputT, /) -> Array: - ... + def comoving_volume(self, z: InputT, /) -> Array: ... @overload - def comoving_volume(self, z1: InputT, z2: InputT, /) -> Array: - ... + def comoving_volume(self, z1: InputT, z2: InputT, /) -> Array: ... def comoving_volume(self, z1: InputT, z2: InputT | None = None, /) -> Array: r"""Comoving volume in cubic Mpc. @@ -406,12 +405,10 @@ def differential_comoving_volume(self, z: InputT, /) -> Array: # Proper @overload - def proper_distance(self, z: InputT, /) -> Array: - ... + def proper_distance(self, z: InputT, /) -> Array: ... @overload - def proper_distance(self, z1: InputT, z2: InputT, /) -> Array: - ... + def proper_distance(self, z1: InputT, z2: InputT, /) -> Array: ... def proper_distance(self, z1: InputT, z2: InputT | None = None, /) -> Array: r"""Proper distance :math:`d` in Mpc. @@ -432,16 +429,15 @@ def proper_distance(self, z1: InputT, z2: InputT | None = None, /) -> Array: ------- Array The proper distance :math:`d` in Mpc. + """ raise NotImplementedError @overload - def proper_time(self, z: InputT, /) -> Array: - ... + def proper_time(self, z: InputT, /) -> Array: ... @overload - def proper_time(self, z1: InputT, z2: InputT, /) -> Array: - ... + def proper_time(self, z1: InputT, z2: InputT, /) -> Array: ... def proper_time(self, z1: InputT, z2: InputT | None = None, /) -> Array: r"""Proper time :math:`t` in Gyr. @@ -461,18 +457,17 @@ def proper_time(self, z1: InputT, z2: InputT | None = None, /) -> Array: ------- Array The proper time :math:`t` in Gyr. + """ raise NotImplementedError # ---------------------------------------------- @overload - def lookback_distance(self, z: InputT, /) -> Array: - ... + def lookback_distance(self, z: InputT, /) -> Array: ... @overload - def lookback_distance(self, z1: InputT, z2: InputT, /) -> Array: - ... + def lookback_distance(self, z1: InputT, z2: InputT, /) -> Array: ... def lookback_distance(self, z1: InputT, z2: InputT | None = None, /) -> Array: r"""Lookback distance :math:`d_T` in Mpc. @@ -492,16 +487,15 @@ def lookback_distance(self, z1: InputT, z2: InputT | None = None, /) -> Array: ------- Array The lookback distance :math:`d_T` in Mpc. + """ raise NotImplementedError @overload - def lookback_time(self, z: InputT, /) -> Array: - ... + def lookback_time(self, z: InputT, /) -> Array: ... @overload - def lookback_time(self, z1: InputT, z2: InputT, /) -> Array: - ... + def lookback_time(self, z1: InputT, z2: InputT, /) -> Array: ... def lookback_time(self, z1: InputT, z2: InputT | None = None, /) -> Array: """Lookback time in Gyr. @@ -522,6 +516,7 @@ def lookback_time(self, z1: InputT, z2: InputT | None = None, /) -> Array: ------- Array The lookback time in Gyr. + """ raise NotImplementedError @@ -529,12 +524,10 @@ def lookback_time(self, z1: InputT, z2: InputT | None = None, /) -> Array: # Angular diameter @overload - def angular_diameter_distance(self, z: InputT, /) -> Array: - ... + def angular_diameter_distance(self, z: InputT, /) -> Array: ... @overload - def angular_diameter_distance(self, z1: InputT, z2: InputT, /) -> Array: - ... + def angular_diameter_distance(self, z1: InputT, z2: InputT, /) -> Array: ... def angular_diameter_distance( self, z1: InputT, z2: InputT | None = None, / @@ -563,6 +556,7 @@ def angular_diameter_distance( .. [1] Weinberg, 1972, pp 420-424; Weedman, 1986, pp 421-424. .. [2] Weedman, D. (1986). Quasar astronomy, pp 65-67. .. [3] Peebles, P. (1993). Principles of Physical Cosmology, pp 325-327. + """ if z2 is not None: raise NotImplementedError @@ -572,12 +566,10 @@ def angular_diameter_distance( # Luminosity distance @overload - def luminosity_distance(self, z: InputT, /) -> Array: - ... + def luminosity_distance(self, z: InputT, /) -> Array: ... @overload - def luminosity_distance(self, z1: InputT, z2: InputT, /) -> Array: - ... + def luminosity_distance(self, z1: InputT, z2: InputT, /) -> Array: ... def luminosity_distance(self, z1: InputT, z2: InputT | None = None, /) -> Array: """Redshift-dependent luminosity distance :math:`d_L` in Mpc. @@ -601,6 +593,7 @@ def luminosity_distance(self, z1: InputT, z2: InputT | None = None, /) -> Array: References ---------- .. [1] Weinberg, 1972, pp 420-424; Weedman, 1986, pp 60-62. + """ if z2 is not None: raise NotImplementedError diff --git a/src/cosmology/compat/classy/constants.py b/src/cosmology/compat/classy/constants.py index 64e5ff4..eeb606a 100644 --- a/src/cosmology/compat/classy/constants.py +++ b/src/cosmology/compat/classy/constants.py @@ -6,7 +6,6 @@ - G: Gravitational constant G in pc km2 s-2 Msol-1. """ - import numpy as np from cosmology.compat.classy._core import Array diff --git a/tests/classy/test_extras.py b/tests/classy/test_extras.py index 415849a..9979ede 100644 --- a/tests/classy/test_extras.py +++ b/tests/classy/test_extras.py @@ -28,9 +28,7 @@ def test_critical_density0(self, wrapper, cosmo): Test that the wrapper's critical_density0 is the same as critical_density0. """ - expect = ( - 3e6 * constants.c**2 * cosmo.Hubble(0) ** 2 / (8 * np.pi * constants.G) - ) + expect = 3e6 * constants.c**2 * cosmo.Hubble(0) ** 2 / (8 * np.pi * constants.G) assert np.allclose(wrapper.critical_density0, expect) assert isinstance(wrapper.critical_density0, np.ndarray)