From 2d98b97ae0bca38b465f5c07a0fae6238c9b7dc1 Mon Sep 17 00:00:00 2001 From: Mihai Cara Date: Wed, 7 Feb 2024 02:41:30 -0500 Subject: [PATCH] Add unit test for pixel inversion with small image --- drizzle/tests/test_overlap_calc.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drizzle/tests/test_overlap_calc.py b/drizzle/tests/test_overlap_calc.py index eaa1ec8..32c12a9 100644 --- a/drizzle/tests/test_overlap_calc.py +++ b/drizzle/tests/test_overlap_calc.py @@ -1,5 +1,6 @@ import pytest from math import sqrt +from itertools import product import numpy as np @@ -70,6 +71,17 @@ def test_invert_pixmap(): assert np.allclose(xyin, [xr, yr], atol=0.05) +def test_invert_small_pixmap(): + yin, xin = np.indices((2, 2), dtype=float) + pixmap = np.dstack([xin, yin]) + + test_coords = list(product(*(2 * [[-0.5, 1.5]]))) + + for xr, yr in test_coords: + xyin = invert_pixmap(pixmap, [xr, yr], [[-0.5, 1.5], [-0.5, 1.5]]) + assert np.allclose(xyin, [xr, yr], atol=0.05) + + def test_poly_intersection_with_self(): p = [(0, 0), (1, 0), (1, 1), (0, 1)]