Update tests/test_utils_npy.py
Run CI Tests / test (push) Successful in 1m1s

This commit is contained in:
2025-08-10 22:24:07 +02:00
parent cf3c3f1faf
commit 0caf9e5109
+10 -7
View File
@@ -36,19 +36,22 @@ def test_nice_linspace(start, stop, num, expected):
(0, 5, 2, True, np.array([0., 2., 4.])), # basic
(0, 5, 2, False, np.array([0., 2.])), # no endpoint
(-1, 2, 1.5, True, np.array([-1.5, 0., 1.5])) # step doesn't fit exactly
(-1, 2, -1.5, True, np.array([-1.5, 0., 1.5])),
( 5, 0, -2, True, np.array([ 4., 2., 0.])),
])
def test_nice_steps_centered(start, stop, step, endpoint, expected):
np.testing.assert_allclose(nice_steps_centered(start, stop, step, endpoint), expected)
@pytest.mark.parametrize("start, stop, step, endpoint, expected", [
(0, 5, 2, True, np.array([0., 2., 4., 6.])), # Normal case with endpoint overshooting
(0, 5, 2, False, np.array([0., 2., 4.])), # No endpoint
(-1, 2, 1.5, True, np.array([-1., 0.5, 2.])), # Needs fractional alignment to include stop
(-1, 2, 1.5, False, np.array([-1., 0.5])), # Same range but no endpoint
(-2, 1, 1.2, True, np.array([-2., -0.8, 0.4, 1.6])), # Step overshoots
(5, 0, -2, True, np.array([5., 3., 1., -1.])), # Backward steps with overshoot
(5, 0, -2, False, np.array([5., 3., 1.])), # No endpoint, backward
(0, 5, 2, True, np.array([0., 2., 4.])),
(0, 5, 2, False, np.array([0., 2.])),
(-1, 2, 1.5, True, np.array([-1., 0.5, 2.])),
(-1, 2, 1.5, False, np.array([-1., 0.5])),
(-2, 1, 1.2, True, np.array([-2., -0.8, 0.4])),
(5, 0, -2, True, np.array([5., 3., 1.])),
(5, 0, -2, False, np.array([5., 3.])),
])
def test_nice_steps_left_aligned(start, stop, step, endpoint, expected):
np.testing.assert_allclose(nice_steps_left_aligned(start, stop, step, endpoint), expected)