Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport PR #6095 on branch v0.19.x (Preserve backwards compatibility for channel_axis parameter in transform functions) #6100

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 17 additions & 1 deletion skimage/feature/tests/test_basic_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,23 @@

@pytest.mark.parametrize('edges', (False, True))
@pytest.mark.parametrize('texture', (False, True))
def test_multiscale_basic_features(edges, texture):
def test_multiscale_basic_features_gray(edges, texture):
img = np.zeros((20, 20))
img[:10] = 1
img += 0.05 * np.random.randn(*img.shape)
features = multiscale_basic_features(img, edges=edges, texture=texture)

n_sigmas = 6
intensity = True
assert features.shape[-1] == (
n_sigmas * (int(intensity) + int(edges) + 2 * int(texture))
)
assert features.shape[:-1] == img.shape[:]


@pytest.mark.parametrize('edges', (False, True))
@pytest.mark.parametrize('texture', (False, True))
def test_multiscale_basic_features_rgb(edges, texture):
img = np.zeros((20, 20, 3))
img[:10] = 1
img += 0.05 * np.random.randn(*img.shape)
Expand Down
2 changes: 1 addition & 1 deletion skimage/transform/pyramids.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def pyramid_reduce(image, downscale=2, sigma=None, order=1,
@utils.deprecate_multichannel_kwarg(multichannel_position=6)
def pyramid_expand(image, upscale=2, sigma=None, order=1,
mode='reflect', cval=0, multichannel=False,
preserve_range=False, *, channel_axis=-1):
preserve_range=False, *, channel_axis=None):
"""Upsample and then smooth image.

Parameters
Expand Down
3 changes: 1 addition & 2 deletions skimage/transform/tests/test_pyramids.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ def test_pyramid_expand_rgb_deprecated_multichannel():

def test_pyramid_expand_gray():
rows, cols = image_gray.shape
out = pyramids.pyramid_expand(image_gray, upscale=2,
channel_axis=None)
out = pyramids.pyramid_expand(image_gray, upscale=2)
assert_array_equal(out.shape, (rows * 2, cols * 2))


Expand Down
6 changes: 2 additions & 4 deletions skimage/transform/tests/test_warps.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,7 @@ def test_rescale():
# same scale factor
x = np.zeros((5, 5), dtype=np.double)
x[1, 1] = 1
scaled = rescale(x, 2, order=0,
channel_axis=None, anti_aliasing=False, mode='constant')
scaled = rescale(x, 2, order=0, anti_aliasing=False, mode='constant')
ref = np.zeros((10, 10))
ref[2:4, 2:4] = 1
assert_array_almost_equal(scaled, ref)
Expand All @@ -189,8 +188,7 @@ def test_rescale():
x = np.zeros((5, 5), dtype=np.double)
x[1, 1] = 1

scaled = rescale(x, (2, 1), order=0,
channel_axis=None, anti_aliasing=False, mode='constant')
scaled = rescale(x, (2, 1), order=0, anti_aliasing=False, mode='constant')
ref = np.zeros((10, 5))
ref[2:4, 1] = 1
assert_array_almost_equal(scaled, ref)
Expand Down