Skip to content

Commit 4218b70

Browse files
committed
included TypeError to force users to only subsample one dataset at a time
1 parent 504344b commit 4218b70

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

bayesflow/adapters/adapter.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ def one_hot(self, keys: str | Sequence[str], num_classes: int):
545545
return self
546546

547547
def random_subsample(self,
548-
keys: str | Sequence[str],
548+
key: str | Sequence[str],
549549
*,
550550
sample_size: int | float,
551551
axis: int=-1,
@@ -566,8 +566,13 @@ def random_subsample(self,
566566
Additional keyword arguments passed to the transform.
567567
568568
"""
569-
if isinstance(keys, str):
570-
keys = [keys]
569+
570+
571+
if isinstance(key, Sequence[str]) and len(keys) >1:
572+
TypeError("`key` should be either a string or a list of length one. Only one dataset may be modified at a time.")
573+
574+
if isinstance(key, str):
575+
keys = [key]
571576

572577
transform = MapTransform(
573578
transform_map={
@@ -688,7 +693,7 @@ def to_array(
688693
include : str or Sequence of str, optional
689694
Names of variables to include in the transform.
690695
exclude : str or Sequence of str, optional
691-
Names of variables to exclude from the transform.
696+
Names of variabxles to exclude from the transform.
692697
**kwargs : dict
693698
Additional keyword arguments passed to the transform.
694699
"""

0 commit comments

Comments
 (0)