<s> from numpy . testing import assert_equal , assert_almost_equal <EOL> import numpy as np <EOL> from skimage . measure import profile_line <EOL> image = np . arange ( <NUM_LIT:100> ) . reshape ( ( <NUM_LIT:10> , <NUM_LIT:10> ) ) . astype ( np . float ) <EOL> def test_horizontal_rightward ( ) : <EOL> prof = profile_line ( image , ( <NUM_LIT:0> , <NUM_LIT:2> ) , ( <NUM_LIT:0> , <NUM_LIT:8> ) , order = <NUM_LIT:0> ) <EOL> expected_prof = np . arange ( <NUM_LIT:2> , <NUM_LIT:9> ) <EOL> assert_equal ( prof , expected_prof ) <EOL> def test_horizontal_leftward ( ) : <EOL> prof = profile_line ( image , ( <NUM_LIT:0> , <NUM_LIT:8> ) , ( <NUM_LIT:0> , <NUM_LIT:2> ) , order = <NUM_LIT:0> ) <EOL> expected_prof = np . arange ( <NUM_LIT:8> , <NUM_LIT:1> , - <NUM_LIT:1> ) <EOL> assert_equal ( prof , expected_prof ) <EOL> def test_vertical_downward ( ) : <EOL> prof = profile_line ( image , ( <NUM_LIT:2> , <NUM_LIT:5> ) , ( <NUM_LIT:8> , <NUM_LIT:5> ) , order = <NUM_LIT:0> ) <EOL> expected_prof = np . arange ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT:10> ) <EOL> assert_equal ( prof , expected_prof ) <EOL> def test_vertical_upward ( ) : <EOL> prof = profile_line ( image , ( <NUM_LIT:8> , <NUM_LIT:5> ) , ( <NUM_LIT:2> , <NUM_LIT:5> ) , order = <NUM_LIT:0> ) <EOL> expected_prof = np . arange ( <NUM_LIT> , <NUM_LIT:15> , - <NUM_LIT:10> ) <EOL> assert_equal ( prof , expected_prof ) <EOL> def test_45deg_right_downward ( ) : <EOL> prof = profile_line ( image , ( <NUM_LIT:2> , <NUM_LIT:2> ) , ( <NUM_LIT:8> , <NUM_LIT:8> ) , order = <NUM_LIT:0> ) <EOL> expected_prof = np . array ( [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] ) <EOL> assert_almost_equal ( prof , expected_prof ) <EOL> def test_45deg_right_downward_interpolated ( ) : <EOL> prof = profile_line ( image , ( <NUM_LIT:2> , <NUM_LIT:2> ) , ( <NUM_LIT:8> , <NUM_LIT:8> ) , order = <NUM_LIT:1> ) <EOL> expected_prof = np . linspace ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT:10> ) <EOL> assert_almost_equal ( prof , expected_prof ) <EOL> def test_45deg_right_upward ( ) : <EOL> prof = profile_line ( image , ( <NUM_LIT:8> , <NUM_LIT:2> ) , ( <NUM_LIT:2> , <NUM_LIT:8> ) , order = <NUM_LIT:1> ) <EOL> expected_prof = np . arange ( <NUM_LIT> , <NUM_LIT> , - <NUM_LIT:6> ) <EOL> assert_almost_equal ( prof , expected_prof ) <EOL> def test_45deg_left_upward ( ) : <EOL> prof = profile_line ( image , ( <NUM_LIT:8> , <NUM_LIT:8> ) , ( <NUM_LIT:2> , <NUM_LIT:2> ) , order = <NUM_LIT:1> ) <EOL> expected_prof = np . arange ( <NUM_LIT> , <NUM_LIT> , - <NUM_LIT> / <NUM_LIT:3> ) <EOL> assert_almost_equal ( prof , expected_prof ) <EOL> def test_45deg_left_downward ( ) : <EOL> prof = profile_line ( image , ( <NUM_LIT:2> , <NUM_LIT:8> ) , ( <NUM_LIT:8> , <NUM_LIT:2> ) , order = <NUM_LIT:1> ) <EOL> expected_prof = np . arange ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT:6> ) <EOL> assert_almost_equal ( prof , expected_prof ) <EOL> def test_pythagorean_triangle_right_downward ( ) : <EOL> prof = profile_line ( image , ( <NUM_LIT:1> , <NUM_LIT:1> ) , ( <NUM_LIT:7> , <NUM_LIT:9> ) , order = <NUM_LIT:0> ) <EOL> expected_prof = np . array ( [ <NUM_LIT:11> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] ) <EOL> assert_equal ( prof , expected_prof ) <EOL> def test_pythagorean_triangle_right_downward_interpolated ( ) : <EOL> prof = profile_line ( image , ( <NUM_LIT:1> , <NUM_LIT:1> ) , ( <NUM_LIT:7> , <NUM_LIT:9> ) , order = <NUM_LIT:1> ) <EOL> expected_prof = np . linspace ( <NUM_LIT:11> , <NUM_LIT> , <NUM_LIT:11> ) <EOL> assert_almost_equal ( prof , expected_prof ) <EOL> pyth_image = np . zeros ( ( <NUM_LIT:6> , <NUM_LIT:7> ) , np . float ) <EOL> line = ( ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:3> , <NUM_LIT:4> ) , ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT:5> ) ) <EOL> below = ( ( <NUM_LIT:2> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT:4> , <NUM_LIT:5> ) , ( <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT:4> ) ) <EOL> above = ( ( <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:3> ) , ( <NUM_LIT:2> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT:5> , <NUM_LIT:6> ) ) <EOL> pyth_image [ line ] = <NUM_LIT> <EOL> pyth_image [ below ] = <NUM_LIT> <EOL> pyth_image [ above ] = <NUM_LIT> <EOL> def test_pythagorean_triangle_right_downward_linewidth ( ) : <EOL> prof = profile_line ( pyth_image , ( <NUM_LIT:1> , <NUM_LIT:1> ) , ( <NUM_LIT:4> , <NUM_LIT:5> ) , linewidth = <NUM_LIT:3> , order = <NUM_LIT:0> ) <EOL> expected_prof = np . ones ( <NUM_LIT:6> ) <EOL> assert_almost_equal ( prof , expected_prof ) <EOL> def test_pythagorean_triangle_right_upward_linewidth ( ) : <EOL> prof = profile_line ( pyth_image [ : : - <NUM_LIT:1> , : ] , ( <NUM_LIT:4> , <NUM_LIT:1> ) , ( <NUM_LIT:1> , <NUM_LIT:5> ) , <EOL> linewidth = <NUM_LIT:3> , order = <NUM_LIT:0> ) <EOL> expected_prof = np . ones ( <NUM_LIT:6> ) <EOL> assert_almost_equal ( prof , expected_prof ) <EOL> def test_pythagorean_triangle_transpose_left_down_linewidth ( ) : <EOL> prof = profile_line ( pyth_image . T [ : , : : - <NUM_LIT:1> ] , ( <NUM_LIT:1> , <NUM_LIT:4> ) , ( <NUM_LIT:5> , <NUM_LIT:1> ) , <EOL> linewidth = <NUM_LIT:3> , order = <NUM_LIT:0> ) <EOL> expected_prof = np . ones ( <NUM_LIT:6> ) <EOL> assert_almost_equal ( prof , expected_prof ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> from numpy . testing import run_module_suite <EOL> run_module_suite ( ) </s>
