Skip to content

Commit

Permalink
[pre-commit.ci] pre-commit autoupdate (#96)
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

* update PR labeler

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Nathaniel Starkman <[email protected]>
  • Loading branch information
pre-commit-ci[bot] and nstarman authored Feb 7, 2024
1 parent 6dd914c commit 4f24ff2
Show file tree
Hide file tree
Showing 25 changed files with 113 additions and 142 deletions.
24 changes: 14 additions & 10 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
# Infrastructure Labels
Infrastructure:
- .github/**/*
- .pre-commit-config.yaml
- .readthedocs.yml
- .gitignore
- pyproject.toml
- setup.cfg
- changed-files:
- any-glob-to-any-file:
- .github/**/*
- .pre-commit-config.yaml
- .readthedocs.yml
- .gitignore
- pyproject.toml
- setup.cfg

GitHub:
- .github/**/*
- changed-files:
- any-glob-to-any-file:
- .github/**/*

# Docs Labels
Docs:
- docs/**/*
- changed-files:
- any-glob-to-any-file:
- docs/**/*
24 changes: 0 additions & 24 deletions .github/workflows/label_pr.yml

This file was deleted.

24 changes: 24 additions & 0 deletions .github/workflows/labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: "Pull Request Labeler"

on:
issues:
types:
- opened
pull_request_target:
types:
- opened

jobs:
labeler:
permissions:
contents: read
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4 # Uploads repository content to the runner
with:
repository: "cosmology-api/cosmology.api"
- uses: actions/labeler@v5
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
sync-labels: true
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,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
7 changes: 4 additions & 3 deletions docs/_ext/sphinx_ext_autosummary_context.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Monkey-patching autosummary to emit the autosummary-gather-context event."""

from __future__ import annotations

from inspect import signature
Expand Down Expand Up @@ -45,9 +46,9 @@ def setup(app: Sphinx) -> None:
app.disconnect(listener_id)
else:
# patch generate_autosummary_docs to call the wrapper above
generate_autosummary_docs.__globals__[
"generate_autosummary_content"
] = generate_autosummary_content_with_context
generate_autosummary_docs.__globals__["generate_autosummary_content"] = (
generate_autosummary_content_with_context
)

# register the new event
app.add_event("autosummary-gather-context")
6 changes: 2 additions & 4 deletions docs/dev/new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,10 @@ As an example, let's look at the base :class:`~cosmology.api.Cosmology` protocol
name: str | None
@property
def __cosmology_namespace__(self):
...
def __cosmology_namespace__(self): ...
@property
def constants(self):
...
def constants(self): ...
.. Sybil doesn't have the __name__ in globals
.. skip: start
Expand Down
11 changes: 5 additions & 6 deletions docs/dev/wrapping.rst
Original file line number Diff line number Diff line change
Expand Up @@ -184,16 +184,15 @@ Array API will work. For this example we will add support for
def transverse_comoving_distance(
self, z1: InputT, z2: InputT | None = None
) -> Array:
... # up to you to implement this
) -> Array: ... # up to you to implement this
def comoving_volume(self, z1: InputT, z2: InputT | None = None) -> Array:
... # up to you to implement this
def comoving_volume(
self, z1: InputT, z2: InputT | None = None
) -> Array: ... # up to you to implement this
def differential_comoving_volume(
self, z1: InputT, z2: InputT | None = None
) -> Array:
... # up to you to implement this
) -> Array: ... # up to you to implement this
Great! Now we have a wrapper that implements the base Cosmology API and supports
Expand Down
9 changes: 3 additions & 6 deletions docs/introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -214,17 +214,14 @@ describe any of the Array libraries.
class Array(Protocol):
@property
def shape(self) -> tuple[int, ...]:
...
def shape(self) -> tuple[int, ...]: ...
@property
def dtype(self) -> Any:
...
def dtype(self) -> Any: ...
...
def __add__(self, other: "Array") -> "Array":
...
def __add__(self, other: "Array") -> "Array": ...
Applying this to our ``add`` function, we get the following.
Expand Down
6 changes: 2 additions & 4 deletions docs/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,7 @@ The attribute-related interfaces have only the return-type parameter.
class HasOmegaDE0(Protocol[Array]):
@property
def Omega_de0(self) -> Array:
...
def Omega_de0(self) -> Array: ...
The method-related interfaces have both parameters.
Expand All @@ -160,8 +159,7 @@ The method-related interfaces have both parameters.
.. code-block:: python
class HasOmegaDE(Protocol[Array, InputT]):
def Omega_de(self, z: InputT) -> Array:
...
def Omega_de(self, z: InputT) -> Array: ...
Now we can build the correct ``hubble_constant`` function, e.g. that operates on
Expand Down
1 change: 1 addition & 0 deletions docs/tests/test_arrays.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test Array."""

from __future__ import annotations

import array
Expand Down
1 change: 1 addition & 0 deletions src/cosmology/api/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""The Cosmology API standard."""

from __future__ import annotations

from cosmology.api._components import (
Expand Down
8 changes: 3 additions & 5 deletions src/cosmology/api/_array_api/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,11 +194,9 @@ def __rshift__(self: Self, other: int | Self, /) -> Self:

def __setitem__(
self: Self,
key: int
| slice
| EllipsisType
| tuple[int | slice | EllipsisType, ...]
| Array,
key: (
int | slice | EllipsisType | tuple[int | slice | EllipsisType, ...] | Array
),
value: float | bool | Self,
/,
) -> None:
Expand Down
1 change: 1 addition & 0 deletions src/cosmology/api/_array_api/dtype.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@ def __eq__(self: DType, other: DType, /) -> bool:
-------
out: bool
a boolean indicating whether the data type objects are equal.
"""
...
26 changes: 8 additions & 18 deletions src/cosmology/api/_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ class HasOmegaTot0(Protocol[Array]):
@property
def Omega_tot0(self) -> Array:
r"""Omega total; the total density/critical density at z=0."""
...


@runtime_checkable
Expand All @@ -35,8 +34,8 @@ def Omega_tot(self, z: InputT, /) -> Array:
Returns
-------
Array
"""
...


@runtime_checkable
Expand All @@ -58,7 +57,6 @@ class HasOmegaK0(Protocol[Array]):
@property
def Omega_k0(self) -> Array:
r"""Omega curvature; the effective curvature density/critical density at z=0."""
...


@runtime_checkable
Expand All @@ -76,8 +74,8 @@ def Omega_k(self, z: InputT, /) -> Array:
Returns
-------
Array
"""
...


@runtime_checkable
Expand All @@ -99,7 +97,6 @@ class HasOmegaM0(Protocol[Array]):
@property
def Omega_m0(self) -> Array:
r"""Omega matter; the matter density/critical density at z=0."""
...


@runtime_checkable
Expand All @@ -122,8 +119,8 @@ def Omega_m(self, z: InputT, /) -> Array:
-----
This does not include neutrinos, even if non-relativistic at the
redshift of interest; see `Omega_nu`.
"""
...


@runtime_checkable
Expand All @@ -145,7 +142,6 @@ class HasOmegaB0(Protocol[Array]):
@property
def Omega_b0(self) -> Array:
r"""Omega baryon; the baryon density/critical density at z=0."""
...


@runtime_checkable
Expand All @@ -163,8 +159,8 @@ def Omega_b(self, z: InputT, /) -> Array:
Returns
-------
Array
"""
...


@runtime_checkable
Expand All @@ -186,7 +182,6 @@ class HasOmegaNu0(Protocol[Array]):
@property
def Omega_nu0(self) -> Array:
r"""Omega neutrino; the neutrino density/critical density at z=0."""
...


@runtime_checkable
Expand All @@ -204,8 +199,8 @@ def Omega_nu(self, z: InputT, /) -> Array:
Returns
-------
Array
"""
...


@runtime_checkable
Expand All @@ -215,7 +210,6 @@ class HasNeff(Protocol[Array]):
@property
def Neff(self) -> Array:
r"""Effective number of neutrino species."""
...


@runtime_checkable
Expand All @@ -225,7 +219,6 @@ class HasMNu(Protocol[Array]):
@property
def m_nu(self) -> tuple[Array, ...]:
r"""Neutrino mass(es) in eV."""
...


@runtime_checkable
Expand All @@ -249,7 +242,6 @@ class HasOmegaDE0(Protocol[Array]):
@property
def Omega_de0(self) -> Array:
r"""Omega dark energy; the dark energy density/critical density at z=0."""
...


@runtime_checkable
Expand All @@ -267,8 +259,8 @@ def Omega_de(self, z: InputT, /) -> Array:
Returns
-------
Array
"""
...


@runtime_checkable
Expand All @@ -286,7 +278,6 @@ class HasOmegaDM0(Protocol[Array]):
@property
def Omega_dm0(self) -> Array:
r"""Omega dark matter; the dark matter density/critical density at z=0."""
...


@runtime_checkable
Expand All @@ -309,8 +300,8 @@ def Omega_dm(self, z: InputT, /) -> Array:
-----
This does not include neutrinos, even if non-relativistic at the
redshift of interest.
"""
...


@runtime_checkable
Expand All @@ -332,7 +323,6 @@ class HasOmegaGamma0(Protocol[Array]):
@property
def Omega_gamma0(self) -> Array:
r"""Omega gamma; the photon density/critical density at z=0."""
...


@runtime_checkable
Expand All @@ -350,8 +340,8 @@ def Omega_gamma(self, z: InputT, /) -> Array:
Returns
-------
Array
"""
...


@runtime_checkable
Expand Down
1 change: 1 addition & 0 deletions src/cosmology/api/_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class CosmologyConstantsNamespace(Protocol):
When used in a runtime check, `isinstance` will only look for the existence
of objects, not details like their type. For example, ``c`` should be in
units of kilometers per second, but `isinstance` will not check this.
"""

@property
Expand Down
Loading

0 comments on commit 4f24ff2

Please sign in to comment.