Skip to content

Commit b8b6875

Browse files
committed
run linter
1 parent 2931ff9 commit b8b6875

File tree

6 files changed

+44
-40
lines changed

6 files changed

+44
-40
lines changed

bayesflow/adapters/transforms/as_set.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@
55

66
class AsSet(ElementwiseTransform):
77
"""
8-
The `.as_set(["x", "y"])` transform indicates that both `x` and `y` are treated as sets.
9-
That is, their values will be treated as *exchangable* such that they will imply the same inference regardless of the values' order.
10-
This would be useful in a linear regression context where we can index the observations in arbitrary order and always get the same regression line.
8+
The `.as_set(["x", "y"])` transform indicates that both `x` and `y` are treated as sets.
9+
That is, their values will be treated as *exchangable* such that they will imply
10+
the same inference regardless of the values' order.
11+
This is useful, for example, in a linear regression context where we can index
12+
the observations in arbitrary order and always get the same regression line.
13+
14+
Useage:
1115
12-
Useage:
13-
1416
adapter = (
1517
bf.Adapter()
1618
.as_set(["x", "y"])

bayesflow/adapters/transforms/concatenate.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313
@serializable(package="bayesflow.adapters")
1414
class Concatenate(Transform):
1515
"""Concatenate multiple arrays into a new key.
16-
Parameters:
16+
Parameters:
1717
18-
keys:
18+
keys:
1919
20-
into:
20+
into:
2121
2222
"""
2323

bayesflow/adapters/transforms/constrain.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,33 +16,35 @@
1616
@serializable(package="bayesflow.adapters")
1717
class Constrain(ElementwiseTransform):
1818
"""
19-
Constrains neural network predictions of a data variable to specificied bounds.
20-
21-
Parameters:
22-
String containing the name of the data variable to be transformed e.g. "sigma". See examples below.
19+
Constrains neural network predictions of a data variable to specificied bounds.
2320
24-
Named Parameters:
21+
Parameters:
22+
String containing the name of the data variable to be transformed e.g. "sigma". See examples below.
23+
24+
Named Parameters:
2525
lower: Lower bound for named data variable.
2626
upper: Upper bound for named data variable.
27-
method: Method by which to shrink the network predictions space to specified bounds. Choose from
27+
method: Method by which to shrink the network predictions space to specified bounds. Choose from
2828
- Double bounded methods: sigmoid, expit, (default = sigmoid)
2929
- Lower bound only methods: softplus, exp, (default = softplus)
3030
- Upper bound only methods: softplus, exp, (default = softplus)
31-
3231
3332
34-
Examples:
35-
Let sigma be the standard deviation of a normal distribution, then sigma should always be greater than zero.
3633
37-
Useage:
34+
Examples:
35+
Let sigma be the standard deviation of a normal distribution,
36+
then sigma should always be greater than zero.
37+
38+
Useage:
3839
adapter = (
3940
bf.Adapter()
4041
.constrain("sigma", lower=0)
4142
)
4243
43-
Suppose p is the parameter for a binomial distribution where p must be in [0,1] then we would constrain the neural network to estimate p in the following way
44+
Suppose p is the parameter for a binomial distribution where p must be in [0,1]
45+
then we would constrain the neural network to estimate p in the following way.
4446
45-
Usage:
47+
Usage:
4648
adapter = (
4749
bf.Adapter()
4850
.constrain("p", lower=0, upper=1, method = "sigmoid")

bayesflow/adapters/transforms/convert_dtype.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@
1111
@serializable(package="bayesflow.adapters")
1212
class ConvertDType(ElementwiseTransform):
1313
"""
14-
Default transform used to convert all floats from float64 to float32 to be in line with keras framework.
14+
Default transform used to convert all floats from float64 to float32 to be in line with keras framework.
1515
"""
16+
1617
def __init__(self, from_dtype: str, to_dtype: str):
1718
super().__init__()
1819

bayesflow/adapters/transforms/keep.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,35 +12,35 @@
1212
@serializable(package="bayesflow.adapters")
1313
class Keep(Transform):
1414
"""
15-
Name the data parameters that should be kept for futher calculation.
15+
Name the data parameters that should be kept for futher calculation.
1616
17-
Parameters:
17+
Parameters:
1818
19-
cls: tuple containing the names of kept data variables as strings.
19+
cls: tuple containing the names of kept data variables as strings.
2020
21-
Useage:
21+
Useage:
2222
2323
Two moons simulator generates data for priors alpha, r and theta as well as observation data x.
24-
We are interested only in theta and x, to keep only theta and x we should use the following;
24+
We are interested only in theta and x, to keep only theta and x we should use the following;
2525
2626
adapter = (
2727
bf.adapters.Adapter()
28-
29-
# drop data from unneeded priors alpha, and r
28+
# only keep theta and x
3029
.keep(("theta", "x"))
3130
)
3231
33-
Example:
34-
>>> a = [1,2,3,4]
35-
>>> b = [[1,2],[3,4]]
36-
>>> c = [[5,6,7,8]]
37-
>>> dat = dict(a=a,b=b,c =c)
38-
# Here we want to only keep elements b and c
39-
>>> keeper = bf.adapters.transforms.Keep(("b","c"))
32+
Example:
33+
>>> a = [1, 2, 3, 4]
34+
>>> b = [[1, 2], [3, 4]]
35+
>>> c = [[5, 6, 7, 8]]
36+
>>> dat = dict(a=a, b=b, c=c)
37+
# Here we want to only keep elements b and c
38+
>>> keeper = bf.adapters.transforms.Keep(("b", "c"))
4039
>>> keeper.forward(dat)
4140
{'b': [[1, 2], [3, 4]], 'c': [[5, 6, 7, 8]]}
4241
4342
"""
43+
4444
def __init__(self, keys: Sequence[str]):
4545
self.keys = keys
4646

bayesflow/adapters/transforms/to_array.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,19 @@
1313
class ToArray(ElementwiseTransform):
1414
"""
1515
Checks provided data for any non-arrays and converts them to numpy arrays.
16-
This ensures all data is in a format suitable for training.
16+
This ensures all data is in a format suitable for training.
1717
18-
Example:
18+
Example:
1919
>>> ta = bf.adapters.transforms.ToArray()
20-
>>> a = [1,2,3,4]
20+
>>> a = [1, 2, 3, 4]
2121
>>> ta.forward(a)
2222
array([1, 2, 3, 4])
23-
>>> b = [[1,2],[3,4]]
23+
>>> b = [[1, 2], [3, 4]]
2424
>>> ta.forward(b)
2525
array([[1, 2],
2626
[3, 4]])
2727
"""
2828

29-
3029
def __init__(self):
3130
super().__init__()
3231
self.original_type = None

0 commit comments

Comments
 (0)