Skip to content
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

Add type stubs for python code #34

Merged
merged 1 commit into from
Jan 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ ignore = [
"COM812", # Incompatible with ruff-format
"ISC001", # Incompatible with ruff-format
"RET504", # Unnecessary asignment before return
"PYI021", # Docstrings should not be included in stubs
]

[tool.ruff.lint.per-file-ignores]
Expand Down
Empty file added python/rebop/py.typed
Empty file.
38 changes: 38 additions & 0 deletions python/rebop/rebop.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import xarray

class Gillespie:
"""Reaction system composed of species and reactions."""

def add_reaction(
self,
/,
rate: float,
reactants: list[str],
products: list[str],
reverse_rate: float | None = None,
) -> None:
"""Add a Law of Mass Action reaction to the system.

The forward reaction rate is `rate`, while `reactants` and `products` are
lists of respectively reactant names and product names.
Add the reverse reaction with the rate `reverse_rate` if it is not `None`.
"""

def nb_reactions(self, /) -> int:
"""Number of reactions currently in the system."""

def nb_species(self, /) -> int:
"""Number of species currently in the system."""

def run(
self,
init: dict[str, int],
tmax: float,
nb_steps: int,
seed: int | None = None,
) -> xarray.Dataset:
"""Run the system until `tmax` with `nb_steps` steps.

The initial configuration is specified in the dictionary `init`.
Returns an xarray Dataset.
"""