Skip to content

Commit

Permalink
adapter: use rename inside of concatenate transform if appropriate (#264
Browse files Browse the repository at this point in the history
)
  • Loading branch information
paul-buerkner authored Dec 3, 2024
1 parent 24e70aa commit 94239ae
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions bayesflow/adapters/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,11 @@ def clear(self):
self.transforms = []
return self

def concatenate(self, keys: Sequence[str], *, into: str, axis: int = -1):
def concatenate(self, keys: str | Sequence[str], *, into: str, axis: int = -1):
if isinstance(keys, str):
# this is a common mistake, and also passes the type checker since str is a sequence of characters
raise ValueError("Keys must be a sequence of strings. To rename a single key, use the `rename` method.")

transform = Concatenate(keys, into=into, axis=axis)
transform = Rename(keys, to_key=into)
else:
transform = Concatenate(keys, into=into, axis=axis)
self.transforms.append(transform)
return self

Expand Down

0 comments on commit 94239ae

Please sign in to comment.