Skip to content
Open
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
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ci:

repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.16.0
rev: v0.16.6
hooks:
- id: ruff-check
args: ["--fix"]
Expand Down
3 changes: 1 addition & 2 deletions docs/usage/backend.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,7 @@ from the adapter:
# example_host
@backend_class
class Neighborhood:
def __init__(self, data, *, n_neighbors=15):
...
def __init__(self, data, *, n_neighbors=15): ...
```

```python
Expand Down
11 changes: 7 additions & 4 deletions docs/usage/host.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ independently in the same process.
distributions, use `distributions`:

```python
trusted_backends={
trusted_backends = {
"example_accel": {
"aliases": ["example", "accelerated"],
"package": "example-host-accel",
Expand Down Expand Up @@ -112,6 +112,7 @@ supported.
# example_host/analysis.py
from example_host._backends import backend_dispatch


@backend_dispatch
def compute_score(data, *, method="fast", n_jobs=None, copy=False):
"""Compute a score.
Expand Down Expand Up @@ -157,6 +158,7 @@ another decorator that generates the constructor or modifies the class.
# example_host/models.py
from example_host._backends import backend_class


@backend_class
class Neighborhood:
def __init__(self, data, *, n_neighbors=15):
Expand All @@ -175,9 +177,9 @@ class Neighborhood:
Construction follows the same selection order as function dispatch:

```python
Neighborhood(data) # active setting, CPU by default
Neighborhood(data, backend="example") # backend class for this instance
Neighborhood(data, backend="cpu") # host class for this instance
Neighborhood(data) # active setting, CPU by default
Neighborhood(data, backend="example") # backend class for this instance
Neighborhood(data, backend="cpu") # host class for this instance
```

The `backend` selector is consumed by the decorator and is not forwarded to
Expand Down Expand Up @@ -235,6 +237,7 @@ _b._dispatcher.discover() # so autodoc sees merged signatures
```python
# in IDE startup, test setup, or anywhere else that introspects:
from example_host._backends import _dispatcher

_dispatcher.discover()
```

Expand Down