77# pylint: disable=invalid-name # Allows short reference names like x, y, ...
88# guitest: show
99
10+ import numpy as np
1011import pytest
1112from guidata .qthelpers import exec_dialog , qt_app_context
1213
@@ -70,7 +71,7 @@ def test_line_profile() -> None:
7071 sig = cpi .compute_line_profile (ima , param )
7172 assert sig is not None
7273 assert len (sig .y ) == width
73- exp = ima .data [row , :]
74+ exp = np . array ( ima .data [row , :], dtype = float )
7475 check_array_result ("Horizontal line profile" , sig .y , exp )
7576
7677 # Test vertical line profile
@@ -79,7 +80,7 @@ def test_line_profile() -> None:
7980 sig = cpi .compute_line_profile (ima , param )
8081 assert sig is not None
8182 assert len (sig .y ) == height
82- exp = ima .data [:, col ]
83+ exp = np . array ( ima .data [:, col ], dtype = float )
8384 check_array_result ("Vertical line profile" , sig .y , exp )
8485
8586
@@ -97,7 +98,7 @@ def test_segment_profile() -> None:
9798 sig = cpi .compute_segment_profile (ima , param )
9899 assert sig is not None
99100 assert len (sig .y ) == min (row2 , height - 1 ) - max (row1 , 0 ) + 1
100- exp = ima .data [10 :200 , 20 ]
101+ exp = np . array ( ima .data [10 :200 , 20 ], dtype = float )
101102 check_array_result ("Segment profile" , sig .y , exp )
102103
103104
@@ -116,20 +117,20 @@ def test_average_profile() -> None:
116117 sig = cpi .compute_average_profile (ima , param )
117118 assert sig is not None
118119 assert len (sig .y ) == col2 - col1 + 1
119- exp = ima .data [row1 : row2 + 1 , col1 : col2 + 1 ].mean (axis = 0 )
120+ exp = np . array ( ima .data [row1 : row2 + 1 , col1 : col2 + 1 ].mean (axis = 0 ), dtype = float )
120121 check_array_result ("Horizontal average profile" , sig .y , exp )
121122
122123 # Test vertical average profile
123124 param .direction = "vertical"
124125 sig = cpi .compute_average_profile (ima , param )
125126 assert sig is not None
126127 assert len (sig .y ) == min (row2 , height - 1 ) - max (row1 , 0 ) + 1
127- exp = ima .data [row1 : row2 + 1 , col1 : col2 + 1 ].mean (axis = 1 )
128+ exp = np . array ( ima .data [row1 : row2 + 1 , col1 : col2 + 1 ].mean (axis = 1 ), dtype = float )
128129 check_array_result ("Vertical average profile" , sig .y , exp )
129130
130131
131132if __name__ == "__main__" :
132- test_profile_unit ()
133+ # test_profile_unit()
133134 test_line_profile ()
134135 test_segment_profile ()
135136 test_average_profile ()
0 commit comments