This commit is contained in:
@@ -7,10 +7,10 @@ from slic.utils.npy import *
|
||||
|
||||
@pytest.mark.parametrize("start, stop, step, expected", [
|
||||
(0, 5, 1, [0, 1, 2, 3, 4, 5]),
|
||||
(5, 0, -1, [5, 4, 3, 2, 1, 0]),
|
||||
(5, 0, -1, [0, 1, 2, 3, 4, 5]),
|
||||
(1, 2, 3/10, [1, 4/3, 5/3, 2]),
|
||||
(-2, 2, 3/2, [-2, -2/3, 2/3, 2]),
|
||||
(5/2, 1/2, -2/5, [5/2, 21/10, 17/10, 13/10, 9/10, 1/2])
|
||||
(5/2, 1/2, -2/5, [1/2, 9/10, 13/10, 17/10, 21/10, 5/2])
|
||||
])
|
||||
def test_nice_arange(start, stop, step, expected):
|
||||
np.testing.assert_allclose(nice_arange(start, stop, step), expected)
|
||||
@@ -24,6 +24,7 @@ def test_nice_arange(start, stop, step, expected):
|
||||
(2, 2, 3, np.array([2., 2., 2., 2.])), # constant start = stop
|
||||
(3, 0, 3, np.array([3., 2., 1., 0.])), # decreasing
|
||||
(0, 1, 0, np.array([0.])), # edge case: 0 intervals → 1 point
|
||||
(-2, 2, 3, np.array([-2, -2/3, 2/3, 2])),
|
||||
])
|
||||
def test_nice_linspace(start, stop, num, expected):
|
||||
np.testing.assert_allclose(nice_linspace(start, stop, num), expected)
|
||||
|
||||
Reference in New Issue
Block a user