Skip to content

Commit 0591391

Browse files
committed
Merge branch 'dev' into feat-serializable-custom-transform
2 parents 8fdfde9 + bc4fac9 commit 0591391

File tree

2 files changed

+8
-16
lines changed

2 files changed

+8
-16
lines changed

bayesflow/adapters/adapter.py

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -247,16 +247,13 @@ def apply(
247247
248248
Parameters
249249
----------
250-
forward: callable, no lambda
251-
Function to transform the data in the forward pass.
252-
For the adapter to be serializable, this function has to be serializable
253-
as well (see Notes). Therefore, only proper functions and no lambda
254-
functions should be used here.
255-
inverse: callable, no lambda
256-
Function to transform the data in the inverse pass.
257-
For the adapter to be serializable, this function has to be serializable
258-
as well (see Notes). Therefore, only proper functions and no lambda
259-
functions should be used here.
250+
forward : str or np.ufunc
251+
The name of the NumPy function to use for the forward transformation.
252+
inverse : str or np.ufunc, optional
253+
The name of the NumPy function to use for the inverse transformation.
254+
By default, the inverse is inferred from the forward argument for supported methods.
255+
You can find the supported methods in
256+
:py:const:`~bayesflow.adapters.transforms.NumpyTransform.INVERSE_METHODS`.
260257
predicate : Predicate, optional
261258
Function that indicates which variables should be transformed.
262259
include : str or Sequence of str, optional
@@ -265,12 +262,6 @@ def apply(
265262
Names of variables to exclude from the transform.
266263
**kwargs : dict
267264
Additional keyword arguments passed to the transform.
268-
269-
Notes
270-
-----
271-
Important: This is only serializable if the forward and inverse functions are serializable.
272-
This most likely means you will have to pass the scope that the forward and inverse functions are contained in
273-
to the `custom_objects` argument of the `deserialize` function when deserializing this class.
274265
"""
275266
transform = FilterTransform(
276267
transform_constructor=NumpyTransform,

bayesflow/adapters/transforms/numpy_transform.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class NumpyTransform(ElementwiseTransform):
1717
The name of the NumPy function to apply in the inverse transformation.
1818
"""
1919

20+
#: Dict of `np.ufunc` that support automatic selection of their inverse.
2021
INVERSE_METHODS = {
2122
np.arctan: np.tan,
2223
np.exp: np.log,

0 commit comments

Comments
 (0)