From aae38aed61cf05c501e104089c1a825083ddb944 Mon Sep 17 00:00:00 2001 From: Chris Dumas Date: Thu, 22 Oct 2026 07:30:14 +0000 Subject: [PATCH] Fix image compare tensor selection --- dumas_image_nodes.py | 5 ++++- tests/test_dumas_image_nodes.py | 6 ++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/dumas_image_nodes.py b/dumas_image_nodes.py index c4f7752..b740ec2 100644 --- a/dumas_image_nodes.py +++ b/dumas_image_nodes.py @@ -127,7 +127,10 @@ class DumasImageCompareNode: path.parent.mkdir(parents=True, exist_ok=True) _image_to_pil(image[0]).save(path) images.append({"filename": path.name, "subfolder": "", "type": "temp", "slot": slot}) - return {"ui": {"images": images}, "result": (image2 or image1,)} + # Tensors cannot be used as Python booleans when they contain more + # than one value. Select the second slot by presence explicitly. + result = image2 if image2 is not None else image1 + return {"ui": {"images": images}, "result": (result,)} class DumasSaveImageNode: diff --git a/tests/test_dumas_image_nodes.py b/tests/test_dumas_image_nodes.py index f91e3b1..378de0b 100644 --- a/tests/test_dumas_image_nodes.py +++ b/tests/test_dumas_image_nodes.py @@ -86,6 +86,12 @@ class DumasImageNodeTests(unittest.TestCase): second["ui"]["images"][0]["filename"], ) + def test_compare_uses_second_tensor_without_boolean_coercion(self): + image1 = FakeBatch() + image2 = FakeBatch() + result = self.nodes.DumasImageCompareNode().compare_images(image1, image2) + self.assertIs(result["result"][0], image2) + def test_load_folder_node_has_expected_outputs(self): self.assertEqual( self.nodes.DumasLoadImagesFolderNode.RETURN_NAMES,