From 8bf3329e9248edd057e13b17e21dfc91966408c8 Mon Sep 17 00:00:00 2001 From: mcDandy Date: Tue, 20 Jan 2026 23:34:12 +0100 Subject: [PATCH] ruff fix --- tests/test_guider_math.py | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/tests/test_guider_math.py b/tests/test_guider_math.py index abb7061..b82b9a0 100644 --- a/tests/test_guider_math.py +++ b/tests/test_guider_math.py @@ -13,7 +13,7 @@ class MockGuider: self.model_patcher.model_dtype = lambda: torch.float32 self.original_conds = {} self.model_options = {} - + def __call__(self, x, sigma, model_options={}, seed=None): return torch.full_like(x, self.value) @@ -24,34 +24,34 @@ class TestMathGuider(unittest.TestCase): g1 = MockGuider(2.0) G = {"G0": g0, "G1": g1} F = {"F0": 0.5} - + # Expression: Average G0 and G1 expr = "G0 * 0.5 + G1 * 0.5" - + math_guider = MathGuider(G, F, expr) - + # Pseudo input x = torch.zeros((1, 4, 16, 16)) sigma = torch.tensor(1.0) - + # Call result = math_guider(x, sigma) - + # Expected: 1.0 * 0.5 + 2.0 * 0.5 = 1.5 self.assertTrue(torch.allclose(result, torch.tensor(1.5))) - + def test_math_guider_aliases(self): g0 = MockGuider(10.0) G = {"G0": g0} F = {"F0": 2.0} - + # a = G0, w = F0 expr = "a + w" - + math_guider = MathGuider(G, F, expr) x = torch.zeros((1, 4, 8, 8)) sigma = torch.tensor(1.0) - + result = math_guider(x, sigma) self.assertTrue(torch.allclose(result, torch.tensor(12.0))) @@ -61,11 +61,11 @@ class TestMathGuider(unittest.TestCase): G = {"G0": g0} F = {} math_guider = MathGuider(G, F, "G0") - + # Check if the property exists and matches g0's patcher self.assertIsNotNone(math_guider.model_patcher) self.assertEqual(math_guider.model_patcher, g0.model_patcher) - + def test_math_guider_model_patcher_missing(self): # Verify behavior when input guiders don't have model_patcher (e.g. None or broken) g0 = MockGuider(1.0) @@ -80,19 +80,19 @@ class TestMathGuider(unittest.TestCase): sigmas = torch.tensor([10.0, 5.0, 0.0]) g0 = MockGuider(1.0) G = {"G0": g0} - + math_guider = MathGuider(G, {}, "current_step / steps") math_guider.sigmas = sigmas # sets sigmas directly for testing - + # Step 0: sigma = 10.0 x = torch.zeros((1, 1, 1, 1)) res0 = math_guider(x, torch.tensor(10.0)) self.assertTrue(torch.allclose(res0, torch.tensor(0.0 / 2.0))) - + # Step 1: sigma = 5.0 res1 = math_guider(x, torch.tensor(5.0)) self.assertTrue(torch.allclose(res1, torch.tensor(1.0 / 2.0))) - + # Intermediate sigma should find closest res_near = math_guider(x, torch.tensor(4.8)) self.assertTrue(torch.allclose(res_near, torch.tensor(1.0 / 2.0)))