Skip to content

Commit 676b0cd

Browse files
committed
Update doc [skip ci]
1 parent 212af40 commit 676b0cd

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

bayesflow/adapters/transforms/nan_to_num.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,14 @@ class NanToNum(Transform):
1313
1414
Parameters
1515
----------
16-
default_value : float
17-
Value to substitute wherever data is NaN.
18-
return_mask : bool, default=False
19-
If True, a mask array will be returned under a new key.
20-
mask_prefix : str, default='mask_'
21-
Prefix for the mask key in the output dictionary.
16+
key : str
17+
The variable key to look for in the simulation data dict.
18+
default_value : float, optional
19+
Value to substitute wherever data is NaN. Default is 0.0.
20+
return_mask : bool, optional
21+
If True, a mask array will be returned under a new key. Default is False.
22+
mask_prefix : str, optional
23+
Prefix for the mask key in the output dictionary. Default is 'mask_'.
2224
"""
2325

2426
def __init__(self, key: str, default_value: float = 0.0, return_mask: bool = False, mask_prefix: str = "mask"):
@@ -81,10 +83,10 @@ def inverse(self, data: dict[str, any], **kwargs) -> dict[str, any]:
8183
values = data[self.key]
8284

8385
if not self.return_mask:
84-
values[values == self.default_value] = np.nan # we assume default_value is not in data
86+
# assumes default_value is not in nan
87+
values[values == self.default_value] = np.nan
8588
else:
8689
mask_array = data[self.mask_key].astype(bool)
87-
# Put NaNs where mask is 0
8890
values[~mask_array] = np.nan
8991

9092
data[self.key] = values

0 commit comments

Comments
 (0)