Skip to content

Commit 5e6e90b

Browse files
committed
[NullBackend] Clean up docstrings
1 parent 18536b8 commit 5e6e90b

File tree

1 file changed

+21
-10
lines changed

1 file changed

+21
-10
lines changed

mcbackend/backends/null.py

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
"""
2-
This backend holds draws in memory, managing them via NumPy arrays.
2+
This backend simply discards draws. There are not stored in memory.
3+
This can be used in situations where we want to run an MCMC but not permanently
4+
store its output.
35
"""
46

7+
# Code-wise, a NullChain is essentially just a NumpyChain without the underlying data array.
8+
59
from typing import Dict, List, Mapping, Optional, Sequence, Tuple
610

711
import numpy
@@ -12,19 +16,26 @@
1216
from .numpy import grow_append
1317

1418
class NullChain(Chain):
15-
"""Stores value draws in NumPy arrays and can pre-allocate memory."""
19+
"""A null storage: discards values immediately and allocates no memory.
1620
17-
def __init__(self, cmeta: ChainMeta, rmeta: RunMeta, *, preallocate: int=0) -> None:
18-
"""Creates a null storage for draws from a chain: will gobble outputs without storing them
21+
Use cases are
22+
23+
- Online computations: Draws are used and discarded immediately, allowing for much larger sample spaces.
24+
- Profiling: To use as a baseline, to measure compute time & memory before allocating memory for draws.
25+
Comparing with another backend would then show how much overhead it adds.
1926
20-
Use cases are
27+
Since draws are not stored, only a subset of the `Chain` interface is supported:
2128
22-
- Online computations: Draws are used and discarded immediately, allowing for much larger sample spaces.
23-
- Profiling: To use as a baseline, to measure compute time & memory before allocating memory for draws.
24-
Comparing with another backend would then show how much overhead it adds.
29+
- Supported: `__len__`, `append`, `get_stats`, `get_stats_at`
30+
- Not supported: `get_draws`, `get_draws_at`
2531
26-
.. Todo:: Allow to optionally store sampling stats.
27-
.. Todo:: Allow to retrieve the most recent draw?
32+
.. Todo:: Option to also sampling stats?
33+
.. Todo:: Allow retrieving the most recent draw?
34+
35+
"""
36+
37+
def __init__(self, cmeta: ChainMeta, rmeta: RunMeta, *, preallocate: int) -> None:
38+
"""Creates a null storage for draws from a chain: will gobble outputs without storing them
2839
2940
Parameters
3041
----------

0 commit comments

Comments
 (0)