From 73f8b595043626c6233ad94d47c37507320accc2 Mon Sep 17 00:00:00 2001 From: Sylvester Kaczmarek <16242628+sylvesterkaczmarek@users.noreply.github.com> Date: Tue, 27 Oct 2026 14:52:45 +0000 Subject: [PATCH 1/2] Refine HSL gradient regression test structure Signed-off-by: Sylvester Kaczmarek <16242628+sylvesterkaczmarek@users.noreply.github.com> --- dm_pix/_src/color_conversion_test.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/dm_pix/_src/color_conversion_test.py b/dm_pix/_src/color_conversion_test.py index eeac27e..86387a0 100644 --- a/dm_pix/_src/color_conversion_test.py +++ b/dm_pix/_src/color_conversion_test.py @@ -326,13 +326,16 @@ def test_mixed_image_values_and_gradients(self, compiled): ] ) expected = expected[:, [0, 2, 1]].reshape(image.shape) - np.testing.assert_allclose(f(image), expected, rtol=2e-6, atol=2e-7) - self.assertTrue(np.isfinite(gradient(image)).all()) + + actual = f(image) + actual_gradient = gradient(image) + + np.testing.assert_allclose(actual, expected, rtol=2e-6, atol=2e-7) + self.assertTrue(np.isfinite(actual_gradient).all()) def test_chromatic_gradients_match_finite_differences(self): - x = jnp.array([0.2, 0.6, 0.9]) + x64 = np.asarray(jnp.array([0.2, 0.6, 0.9]), dtype=np.float64) numerical = np.zeros((3, 3)) - x64 = np.asarray(x).astype(np.float64) for index in range(3): delta = np.zeros(3) delta[index] = 1e-5 @@ -340,7 +343,7 @@ def test_chromatic_gradients_match_finite_differences(self): lower = np.array(colorsys.rgb_to_hls(*(x64 - delta)))[[0, 2, 1]] numerical[:, index] = (upper - lower) / (2e-5) np.testing.assert_allclose( - jax.jacrev(color_conversion.rgb_to_hsl)(x), + jax.jacrev(color_conversion.rgb_to_hsl)(jnp.asarray(x64)), numerical, rtol=2e-5, atol=1e-6, From 2881e2314f99af3c7e2481e955450a165fabe489 Mon Sep 17 00:00:00 2001 From: Sylvester Kaczmarek <16242628+sylvesterkaczmarek@users.noreply.github.com> Date: Tue, 27 Oct 2026 23:06:15 +0000 Subject: [PATCH 2/2] Fix chromatic gradient test after upstream sync --- dm_pix/_src/color_conversion_test.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dm_pix/_src/color_conversion_test.py b/dm_pix/_src/color_conversion_test.py index 9fb859f..bd36749 100644 --- a/dm_pix/_src/color_conversion_test.py +++ b/dm_pix/_src/color_conversion_test.py @@ -357,7 +357,8 @@ def test_mixed_image_values_and_gradients(self): @chex.all_variants def test_chromatic_gradients_match_finite_differences(self): - x64 = np.asarray(jnp.array([0.2, 0.6, 0.9]), dtype=np.float64) + x = jnp.array([0.2, 0.6, 0.9]) + x64 = np.asarray(x, dtype=np.float64) numerical = np.zeros((3, 3)) for index in range(3): delta = np.zeros(3)