From 94239aeb928a44a4d582c7cd5e7eed49057f4d6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paul-Christian=20B=C3=BCrkner?= Date: Tue, 3 Dec 2024 02:52:00 +0200 Subject: [PATCH] adapter: use rename inside of concatenate transform if appropriate (#264) --- bayesflow/adapters/adapter.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/bayesflow/adapters/adapter.py b/bayesflow/adapters/adapter.py index 0e1c68466..bbe072840 100644 --- a/bayesflow/adapters/adapter.py +++ b/bayesflow/adapters/adapter.py @@ -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