mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-16 11:21:25 +08:00
Add support for non-unit step
This commit is contained in:
@@ -38,9 +38,6 @@ def _verify_picture_index(index):
|
||||
if isinstance(dim_slice, int):
|
||||
index[i] = dim_slice = slice(dim_slice, dim_slice + 1)
|
||||
|
||||
if dim_slice.step is not None and dim_slice.step != 1:
|
||||
raise IndexError("Only a step size of 1 is supported")
|
||||
|
||||
return tuple(index)
|
||||
|
||||
|
||||
|
||||
@@ -205,6 +205,14 @@ def test_negative_slice():
|
||||
assert pic[0, -3:] == pic[0, n - 3:]
|
||||
|
||||
|
||||
def test_getitem_with_step():
|
||||
h, w = 5, 5
|
||||
array = _array_2d_to_RGB(np.linspace(0, 255, h * w).reshape(h, w))
|
||||
pic = novice.Picture(array=array)
|
||||
sliced_pic = pic[::2, ::2]
|
||||
assert sliced_pic == novice.Picture(array=array[::2, ::2])
|
||||
|
||||
|
||||
@raises(IndexError)
|
||||
def test_1d_getitem_raises():
|
||||
pic = novice.Picture.from_size((1, 1))
|
||||
@@ -229,12 +237,6 @@ def test_3d_setitem_raises():
|
||||
pic[1, 2, 3] = 0
|
||||
|
||||
|
||||
@raises(IndexError)
|
||||
def test_getitem_with_step_raises():
|
||||
pic = novice.Picture.from_size((3, 3))
|
||||
pic[::2, ::2]
|
||||
|
||||
|
||||
@raises(IndexError)
|
||||
def test_out_of_bounds_indexing():
|
||||
pic = novice.open(SMALL_IMAGE_PATH)
|
||||
|
||||
Reference in New Issue
Block a user