From c07576f6e79d84d15f43d65bbf207a93a0892cf8 Mon Sep 17 00:00:00 2001 From: Jammy2211 Date: Wed, 22 Jul 2026 09:46:43 +0100 Subject: [PATCH] test(interpolator): cover empty-instances IndexError guard The guard added in c8511b553 shipped without a test. Adds a numpy-only regression test asserting LinearInterpolator([]) raises a clear IndexError on a between-samples query rather than an index-out-of-range. Closes part of #1411 Co-Authored-By: Claude Opus 4.8 --- test_autofit/interpolator/test_interpolator.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test_autofit/interpolator/test_interpolator.py b/test_autofit/interpolator/test_interpolator.py index d0c750334..fa6e82649 100644 --- a/test_autofit/interpolator/test_interpolator.py +++ b/test_autofit/interpolator/test_interpolator.py @@ -13,6 +13,14 @@ def test_trivial(): assert result is instance +def test_no_instances(): + interpolator = af.LinearInterpolator([]) + + with pytest.raises(IndexError, match="no instances"): + # noinspection PyStatementEffect + interpolator[interpolator.t == 1.5] + + @pytest.fixture(name="linear_interpolator") def make_linear_interpolator(instances): return af.LinearInterpolator(instances)