From 17b70c421ab0d6e60cc0402748a65f9e7a9bb709 Mon Sep 17 00:00:00 2001 From: Jedrzej Kosinski Date: Sun, 4 Aug 2024 21:08:43 -0500 Subject: [PATCH] Add additional type check in len wrapper hack to prevent issues with Tensors in list --- adv_control/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adv_control/utils.py b/adv_control/utils.py index 30746fe..8ece2db 100644 --- a/adv_control/utils.py +++ b/adv_control/utils.py @@ -39,7 +39,7 @@ def wrapper_len_factory(orig_len: Callable) -> Callable: def wrapper_len(*args, **kwargs): cond_or_uncond = args[0] real_length = orig_len(*args, **kwargs) - if real_length > 0 and type(cond_or_uncond) == list and (cond_or_uncond[0] in [0, 1]): + if real_length > 0 and type(cond_or_uncond) == list and isinstance(cond_or_uncond[0], int) and (cond_or_uncond[0] in [0, 1]): try: to_return = IntWithCondOrUncond(real_length) setattr(to_return, "cond_or_uncond", cond_or_uncond)