Skip to content

Commit

Permalink
Merge pull request #271 from eodole/dev
Browse files Browse the repository at this point in the history
Final adapter Documentation
  • Loading branch information
paul-buerkner authored Dec 11, 2024
2 parents 1a0997f + 9f77043 commit 6449a92
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
5 changes: 5 additions & 0 deletions bayesflow/adapters/transforms/filter_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ def __call__(self, key: str, value: np.ndarray, inverse: bool) -> bool:

@serializable(package="bayesflow.adapters")
class FilterTransform(Transform):
"""
Implements a transform that applies a different transform on a subset of the data. Used by other transforms and
base adapter class.
"""

def __init__(
self,
*,
Expand Down
18 changes: 18 additions & 0 deletions bayesflow/adapters/transforms/rename.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,24 @@

@serializable(package="bayesflow.adapters")
class Rename(Transform):
"""
Transform to rename keys in data dictionary. Useful to rename variables to match those required by
approximator. This transform can only rename one variable at a time.
Parameters:
- from_key: str of variable name that should be renamed
- to_key: str representing new name
Example:
adapter = (
bf.adapters.Adapter()
# rename the variables to match the required approximator inputs
.rename("theta", "inference_variables")
.rename("x", "inference_conditions")
)
"""

def __init__(self, from_key: str, to_key: str):
super().__init__()
self.from_key = from_key
Expand Down

0 comments on commit 6449a92

Please sign in to comment.