1313
1414# guitest: show
1515
16+ from __future__ import annotations
17+
18+ from typing import Literal
19+
1620import numpy as np
1721from guidata .qthelpers import qt_app_context
1822
2226from plotpy .tools import DisplayCoordsTool
2327
2428
25- def test_pixel_coords () :
29+ def test_pixel_coords (image_type : Literal [ "standard" , "xy" ] = "standard" ) -> None :
2630 """Testing image pixel coordinates"""
27- title = test_pixel_coords .__doc__
31+ title = test_pixel_coords .__doc__ + f" ( { image_type } image)"
2832 data = ptd .gen_2d_gaussian (20 , np .uint8 , x0 = - 10 , y0 = - 10 , mu = 7 , sigma = 10.0 )
2933 with qt_app_context (exec_loop = True ):
30- image = make .image (data , interpolation = "nearest" )
34+ if image_type == "xy" :
35+ x = np .linspace (0.0 , 10.0 , data .shape [1 ], dtype = float )
36+ y = np .linspace (0.0 , 10.0 , data .shape [0 ], dtype = float ) ** 2 / 10.0
37+ image = make .xyimage (x , y , data , interpolation = "nearest" )
38+ else :
39+ image = make .image (data , interpolation = "nearest" )
3140 text = "First pixel should be centered on (0, 0) coordinates"
3241 label = make .label (text , (1.0 , 1.0 ), (0 , 0 ), "L" )
3342 rect = make .rectangle (5.0 , 5.0 , 10.0 , 10.0 , "Rectangle" )
@@ -42,4 +51,5 @@ def test_pixel_coords():
4251
4352
4453if __name__ == "__main__" :
45- test_pixel_coords ()
54+ test_pixel_coords ("standard" )
55+ test_pixel_coords ("xy" )
0 commit comments