Skip to content

Commit cbc86b8

Browse files
committed
improve docs and type hints
1 parent 8903089 commit cbc86b8

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

bayesflow/simulators/lambda_simulator.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from collections.abc import Callable, Sequence, Mapping
1+
from collections.abc import Callable, Sequence
22

33
import numpy as np
44

@@ -12,13 +12,13 @@
1212
class LambdaSimulator(Simulator):
1313
"""Implements a simulator based on a sampling function."""
1414

15-
def __init__(self, sample_fn: Callable[[Sequence[int]], Mapping[str, any]], *, is_batched: bool = False):
15+
def __init__(self, sample_fn: Callable[[Sequence[int]], dict[str, any]], *, is_batched: bool = False):
1616
"""
1717
Initialize a simulator based on a simple callable function
1818
1919
Parameters
2020
----------
21-
sample_fn : Callable[[Sequence[int]], Mapping[str, any]]
21+
sample_fn : Callable[[Sequence[int]], dict[str, any]]
2222
A function that generates samples. It should accept `batch_shape` as its first argument
2323
(if `is_batched=True`), followed by keyword arguments.
2424
is_batched : bool, optional

bayesflow/simulators/model_comparison_simulator.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from collections.abc import Sequence
1+
from collections.abc import Callable, Sequence
22
import numpy as np
33

44
from bayesflow.types import Shape
@@ -22,10 +22,10 @@ def __init__(
2222
p: Sequence[float] = None,
2323
logits: Sequence[float] = None,
2424
use_mixed_batches: bool = True,
25-
shared_simulator: Simulator | FunctionType = None,
25+
shared_simulator: Simulator | Callable[[Sequence[int]], dict[str, any]] = None,
2626
):
2727
"""
28-
Initialize a multi-model simulator that can generate data for mixture / model comparison problems.
28+
Initialize a multimodel simulator that can generate data for mixture / model comparison problems.
2929
3030
Parameters
3131
----------
@@ -40,7 +40,7 @@ def __init__(
4040
use_mixed_batches : bool, optional
4141
If True, samples in a batch are drawn from different models. If False, the entire batch
4242
is drawn from a single model chosen according to the model probabilities. Default is True.
43-
shared_simulator : Simulator or FunctionType, optional
43+
shared_simulator : Simulator or Callable, optional
4444
A shared simulator whose outputs are passed to all model simulators. If a function is
4545
provided, it is wrapped in a `LambdaSimulator` with batching enabled.
4646
"""

0 commit comments

Comments
 (0)