<s> from numpy . testing import assert_array_equal , assert_raises , run_module_suite <EOL> from skimage import data <EOL> from skimage . transform import pyramids <EOL> image = data . astronaut ( ) <EOL> image_gray = image [ ... , <NUM_LIT:0> ] <EOL> def test_pyramid_reduce_rgb ( ) : <EOL> rows , cols , dim = image . shape <EOL> out = pyramids . pyramid_reduce ( image , downscale = <NUM_LIT:2> ) <EOL> assert_array_equal ( out . shape , ( rows / <NUM_LIT:2> , cols / <NUM_LIT:2> , dim ) ) <EOL> def test_pyramid_reduce_gray ( ) : <EOL> rows , cols = image_gray . shape <EOL> out = pyramids . pyramid_reduce ( image_gray , downscale = <NUM_LIT:2> ) <EOL> assert_array_equal ( out . shape , ( rows / <NUM_LIT:2> , cols / <NUM_LIT:2> ) ) <EOL> def test_pyramid_expand_rgb ( ) : <EOL> rows , cols , dim = image . shape <EOL> out = pyramids . pyramid_expand ( image , upscale = <NUM_LIT:2> ) <EOL> assert_array_equal ( out . shape , ( rows * <NUM_LIT:2> , cols * <NUM_LIT:2> , dim ) ) <EOL> def test_pyramid_expand_gray ( ) : <EOL> rows , cols = image_gray . shape <EOL> out = pyramids . pyramid_expand ( image_gray , upscale = <NUM_LIT:2> ) <EOL> assert_array_equal ( out . shape , ( rows * <NUM_LIT:2> , cols * <NUM_LIT:2> ) ) <EOL> def test_build_gaussian_pyramid_rgb ( ) : <EOL> rows , cols , dim = image . shape <EOL> pyramid = pyramids . pyramid_gaussian ( image , downscale = <NUM_LIT:2> ) <EOL> for layer , out in enumerate ( pyramid ) : <EOL> layer_shape = ( rows / <NUM_LIT:2> ** layer , cols / <NUM_LIT:2> ** layer , dim ) <EOL> assert_array_equal ( out . shape , layer_shape ) <EOL> def test_build_gaussian_pyramid_gray ( ) : <EOL> rows , cols = image_gray . shape <EOL> pyramid = pyramids . pyramid_gaussian ( image_gray , downscale = <NUM_LIT:2> ) <EOL> for layer , out in enumerate ( pyramid ) : <EOL> layer_shape = ( rows / <NUM_LIT:2> ** layer , cols / <NUM_LIT:2> ** layer ) <EOL> assert_array_equal ( out . shape , layer_shape ) <EOL> def test_build_laplacian_pyramid_rgb ( ) : <EOL> rows , cols , dim = image . shape <EOL> pyramid = pyramids . pyramid_laplacian ( image , downscale = <NUM_LIT:2> ) <EOL> for layer , out in enumerate ( pyramid ) : <EOL> layer_shape = ( rows / <NUM_LIT:2> ** layer , cols / <NUM_LIT:2> ** layer , dim ) <EOL> assert_array_equal ( out . shape , layer_shape ) <EOL> def test_build_laplacian_pyramid_gray ( ) : <EOL> rows , cols = image_gray . shape <EOL> pyramid = pyramids . pyramid_laplacian ( image_gray , downscale = <NUM_LIT:2> ) <EOL> for layer , out in enumerate ( pyramid ) : <EOL> layer_shape = ( rows / <NUM_LIT:2> ** layer , cols / <NUM_LIT:2> ** layer ) <EOL> assert_array_equal ( out . shape , layer_shape ) <EOL> def test_check_factor ( ) : <EOL> assert_raises ( ValueError , pyramids . _check_factor , <NUM_LIT> ) <EOL> assert_raises ( ValueError , pyramids . _check_factor , - <NUM_LIT:2> ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> run_module_suite ( ) </s>
