Skip to content

Commit

Permalink
[pre-commit.ci] pre-commit autoupdate (#19)
Browse files Browse the repository at this point in the history
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/astral-sh/ruff-pre-commit: v0.1.9 → v0.2.0](astral-sh/ruff-pre-commit@v0.1.9...v0.2.0)
- [github.com/psf/black: 23.12.1 → 24.1.1](psf/black@23.12.1...24.1.1)

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
pre-commit-ci[bot] authored Feb 8, 2024
1 parent fa702aa commit 628087f
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 43 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
https://www.sphinx-doc.org/en/master/usage/configuration.html
"""


import pathlib
import sys
from importlib import import_module
Expand All @@ -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"
Expand Down
65 changes: 29 additions & 36 deletions src/cosmology/compat/classy/_standard.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand All @@ -132,6 +133,7 @@ def Omega_b(self, z: InputT, /) -> Array:
------
ValueError
If ``Ob0`` is `None`.
"""
raise NotImplementedError

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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.
Expand All @@ -297,19 +298,18 @@ 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[
"comoving_distance"
](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, /
Expand All @@ -333,6 +333,7 @@ def transverse_comoving_distance(
-------
Array
The comoving transverse distance :math:`d_M` in Mpc.
"""
raise NotImplementedError

Expand All @@ -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.
Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -522,19 +516,18 @@ def lookback_time(self, z1: InputT, z2: InputT | None = None, /) -> Array:
-------
Array
The lookback time in Gyr.
"""
raise NotImplementedError

# ----------------------------------------------
# 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, /
Expand Down Expand Up @@ -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
Expand All @@ -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.
Expand All @@ -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
Expand Down
1 change: 0 additions & 1 deletion src/cosmology/compat/classy/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions tests/classy/test_extras.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 628087f

Please sign in to comment.