From 45e624b676985981d77dc607778b9996b1c07306 Mon Sep 17 00:00:00 2001 From: pancan21 <75097835+pancan21@users.noreply.github.com> Date: Mon, 17 Nov 2025 16:08:54 +0100 Subject: [PATCH] Change is_diff check to use is_diff.any() Previous implementation using list of boolean values resulted in ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all() I assume using any() instead of all() is the intended behavior. --- tensordict/_td.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensordict/_td.py b/tensordict/_td.py index 57529590d..73dd4d800 100644 --- a/tensordict/_td.py +++ b/tensordict/_td.py @@ -2579,7 +2579,7 @@ def _set_at_str(self, key, value, idx, *, validated, non_blocking: bool): ignore_lock=True, ) is_diff = dest[idx].tolist() != value.tolist() - if is_diff: + if is_diff.any(): dest_val = dest.maybe_to_stack() dest_val[idx] = value if dest_val is not dest: