Skip to content

Commit c02ccb6

Browse files
committed
[no ci] add docstrings to Adapter, minor formatting
Part of #340.
1 parent a8c9d73 commit c02ccb6

File tree

10 files changed

+304
-22
lines changed

10 files changed

+304
-22
lines changed

bayesflow/adapters/adapter.py

Lines changed: 272 additions & 0 deletions
Large diffs are not rendered by default.

bayesflow/adapters/transforms/broadcast.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,21 @@ class Broadcast(Transform):
1717
1818
Parameters
1919
----------
20-
keys: sequence of str,
20+
keys : sequence of str,
2121
Input a list of strings, where the strings are the names of data variables.
22-
expand: str or int or tuple, optional
22+
to : str
23+
Name of the data variable to broadcast to.
24+
expand : str or int or tuple, optional
2325
Where should new dimensions be added to match the number of dimensions in `to`?
2426
Can be "left", "right", or an integer or tuple containing the indices of the new dimensions.
2527
The latter is needed if we want to include a dimension in the middle, which will be required
2628
for more advanced cases. By default we expand left.
27-
28-
exclude: int or tuple, optional
29+
exclude : int or tuple, optional
2930
Which dimensions (of the dimensions after expansion) should retain their size,
3031
rather than being broadcasted to the corresponding dimension size of `to`?
3132
By default we exclude the last dimension (usually the data dimension) from broadcasting the size.
33+
squeeze : int or tuple, optional
34+
Axis to squeeze after broadcasting.
3235
3336
Examples
3437
--------

bayesflow/adapters/transforms/concatenate.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ class Concatenate(Transform):
1616
1717
Parameters
1818
----------
19-
keys: sequence of str,
19+
keys : sequence of str,
2020
Input a list of strings, where the strings are the names of data variables.
21-
into: str
21+
into : str
2222
A string telling the network how to use the variables named in keys.
23-
axis: int, optional
24-
integer specifing along which axis to concatonate the keys. The last axis is used by default.
23+
axis : int, optional
24+
Along which axis to concatenate the keys. The last axis is used by default.
2525
2626
Examples
2727
--------

bayesflow/adapters/transforms/constrain.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,22 @@ class Constrain(ElementwiseTransform):
2323
* : str
2424
String containing the name of the data variable to be transformed e.g. "sigma". See examples below.
2525
26-
lower: int or float or np.darray, optional
26+
lower : int or float or np.darray, optional
2727
Lower bound for named data variable.
28-
upper: int or float or np.darray, optional
28+
upper : int or float or np.darray, optional
2929
Upper bound for named data variable.
30-
method: str, optional
30+
method : str, optional
3131
Method by which to shrink the network predictions space to specified bounds. Choose from
3232
- Double bounded methods: sigmoid, expit, (default = sigmoid)
3333
- Lower bound only methods: softplus, exp, (default = softplus)
3434
- Upper bound only methods: softplus, exp, (default = softplus)
35-
inclusive: {'both', 'lower', 'upper', 'none'}, optional
35+
inclusive : {'both', 'lower', 'upper', 'none'}, optional
3636
Indicates which bounds are inclusive (or exclusive).
3737
- "both" (default): Both lower and upper bounds are inclusive.
3838
- "lower": Lower bound is inclusive, upper bound is exclusive.
3939
- "upper": Lower bound is exclusive, upper bound is inclusive.
4040
- "none": Both lower and upper bounds are exclusive.
41-
epsilon: float, optional
41+
epsilon : float, optional
4242
Small value to ensure inclusive bounds are not violated.
4343
Current default is 1e-15 as this ensures finite outcomes
4444
with the default transformations applied to data exactly at the boundaries.

bayesflow/adapters/transforms/drop.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class Drop(Transform):
1616
1717
Parameters
1818
----------
19-
keys: sequence of str
19+
keys : sequence of str
2020
Names of data variables that should be dropped
2121
2222
Examples

bayesflow/adapters/transforms/expand_dims.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ class ExpandDims(ElementwiseTransform):
1313
"""
1414
Expand the shape of an array.
1515
16+
Parameters
17+
----------
18+
keys : str or Sequence of str
19+
The names of the variables to expand.
20+
axis : int or tuple
21+
The axis to expand.
22+
1623
Examples
1724
--------
1825
shape (3,) array:

bayesflow/adapters/transforms/keep.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class Keep(Transform):
1616
1717
Parameters
1818
----------
19-
keys: sequence of str
19+
keys : sequence of str
2020
The names of kept data variables as strings.
2121
2222
Examples

bayesflow/adapters/transforms/lambda_transform.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ class LambdaTransform(ElementwiseTransform):
1616
1717
Parameters
1818
----------
19-
forward: callable, no lambda
19+
forward : callable, no lambda
2020
Function to transform the data in the forward pass.
2121
For the adapter to be serializable, this function has to be serializable
2222
as well (see Notes). Therefore, only proper functions and no lambda
2323
functions should be used here.
24-
inverse: callable, no lambda
24+
inverse : callable, no lambda
2525
Function to transform the data in the inverse pass.
2626
For the adapter to be serializable, this function has to be serializable
2727
as well (see Notes). Therefore, only proper functions and no lambda

bayesflow/adapters/transforms/rename.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ class Rename(Transform):
1313
1414
Parameters
1515
----------
16-
from_key: str
16+
from_key : str
1717
Variable name that should be renamed
18-
to_key: str
18+
to_key : str
1919
New variable name
2020
2121
Examples

bayesflow/adapters/transforms/standardize.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ class Standardize(ElementwiseTransform):
2020
----------
2121
mean : int or float, optional
2222
Specify a mean if known but will be estimated from data when not provided
23-
std: int or float, optional
23+
std : int or float, optional
2424
Specify a standard devation if known but will be estimated from data when not provided
25-
axis: int, optional
25+
axis : int, optional
2626
A specific axis along which standardization should take place. By default
2727
standardization happens individually for each dimension
28-
momentum: float in (0,1)
28+
momentum : float in (0,1)
2929
The momentum during training
3030
"""
3131

0 commit comments

Comments
 (0)