@@ -224,7 +224,13 @@ def test_pixel_to_metric(self):
224224 y_metric_expected = (float (parameters .imy ) / 2.0 - y_pixel ) * parameters .pix_y
225225
226226 # call the function to get actual output metric coordinates
227- metric = arr_pixel_to_metric (np .array ([x_pixel , y_pixel ]), parameters )
227+ metric = arr_pixel_to_metric (
228+ np .atleast_2d (np .array ([x_pixel , y_pixel ], dtype = np .int32 )),
229+ parameters .imx ,
230+ parameters .imy ,
231+ parameters .pix_x ,
232+ parameters .pix_y
233+ )
228234
229235 # check if the actual output matches the expected output
230236 assert metric [:, 0 ] == x_metric_expected
@@ -251,23 +257,33 @@ def setUp(self):
251257
252258 def test_transforms_regress (self ):
253259 """Transformed values are as before."""
254- input_pos = np .full ((3 , 2 ), 100.0 )
255-
256- correct_output_pixel_to_metric = [
260+ correct_output_pixel_to_metric = np .array (
261+ [
257262 [- 8181.0 , 6657.92 ],
258263 [- 8181.0 , 6657.92 ],
259264 [- 8181.0 , 6657.92 ],
260- ]
261- correct_output_metric_to_pixel = [
265+ ])
266+ correct_output_metric_to_pixel = np . array ( [
262267 [646.60066007 , 505.81188119 ],
263268 [646.60066007 , 505.81188119 ],
264269 [646.60066007 , 505.81188119 ],
265- ]
270+ ])
271+
272+ input_pos = np .full ((3 , 2 ), 100 , dtype = np .int32 )
273+
266274
267275 # Test when passing a list
268- output = arr_pixel_to_metric (input_pos , self .control )
276+ output = arr_pixel_to_metric (
277+ input_pos ,
278+ self .control .imx ,
279+ self .control .imy ,
280+ self .control .pix_x ,
281+ self .control .pix_y
282+ )
269283 np .testing .assert_array_almost_equal (output , correct_output_pixel_to_metric )
270284
285+
286+ input_pos = np .full ((3 , 2 ), 100 , dtype = np .float64 )
271287 output = arr_metric_to_pixel (input_pos , self .control )
272288 np .testing .assert_array_almost_equal (output , correct_output_metric_to_pixel )
273289
@@ -278,21 +294,28 @@ def test_transforms(self):
278294 cpar .set_pixel_size ((0.1 , 0.1 ))
279295
280296 metric_pos = np .array ([[1.0 , 1.0 ], [- 10.0 , 15.0 ], [20.0 , - 30.0 ]])
281- pixel_pos = np .array ([[650.0 , 490.0 ], [540.0 , 350.0 ], [840.0 , 800.0 ]] )
297+ pixel_pos = np .array ([[650 , 490 ], [540 , 350 ], [840 , 800 ]], dtype = np . int32 )
282298
283299 np .testing .assert_array_almost_equal (
284- pixel_pos , arr_metric_to_pixel (metric_pos , cpar )
300+ pixel_pos ,
301+ arr_metric_to_pixel (
302+ metric_pos ,
303+ cpar )
285304 )
286305 np .testing .assert_array_almost_equal (
287- metric_pos , arr_pixel_to_metric (pixel_pos , cpar )
306+ metric_pos , arr_pixel_to_metric (pixel_pos ,
307+ cpar .imx ,
308+ cpar .imy ,
309+ cpar .pix_x ,
310+ cpar .pix_y )
288311 )
289312
290313 def test_brown_affine_regress (self ):
291314 """Test that the brown affine transform gives the same results as before."""
292315 input_vec = np .full ((3 , 2 ), 100.0 )
293316 output = np .zeros ((3 , 2 ))
294- correct_output_corr = [[100.0 , 100.0 ], [100.0 , 100.0 ], [100.0 , 100.0 ]]
295- correct_output_dist = [[100.0 , 100.0 ], [100.0 , 100.0 ], [100.0 , 100.0 ]]
317+ correct_output_corr = np . array ( [[100.0 , 100.0 ], [100.0 , 100.0 ], [100.0 , 100.0 ]])
318+ correct_output_dist = np . array ( [[100.0 , 100.0 ], [100.0 , 100.0 ], [100.0 , 100.0 ]])
296319
297320 # Test when passing an array for output
298321 for i in range (3 ):
@@ -322,11 +345,11 @@ def test_brown_affine(self):
322345 cal = Calibration ()
323346 cal .set_pos ([0.0 , 0.0 , 40.0 ])
324347 cal .set_angles ([0.0 , 0.0 , 0.0 ])
325- cal .set_primary_point ([0.0 , 0.0 , 10.0 ])
348+ cal .set_primary_point (np . array ( [0.0 , 0.0 , 10.0 ]) )
326349 cal .set_glass_vec (np .r_ [0.0 , 0.0 , 20.0 ])
327- cal .set_radial_distortion ([ 0 , 0 , 0 ] )
328- cal .set_decentering ([ 0 , 0 ] )
329- cal .set_affine_trans ([1 , 0 ] )
350+ cal .set_radial_distortion (np . zeros ( 3 ,) )
351+ cal .set_decentering (np . zeros ( 2 ,) )
352+ cal .set_affine_trans (np . array ( [1 ,0 ]) )
330353
331354 # reference metric positions:
332355 ref_pos = np .array ([[0.1 , 0.1 ], [1.0 , - 1.0 ], [- 10.0 , 10.0 ]])
@@ -357,9 +380,9 @@ def test_full_correction(self):
357380 cal .set_angles (np .r_ [0.0 , 0.0 , 0.0 ])
358381 cal .set_primary_point (np .r_ [0.0 , 0.0 , 10.0 ])
359382 cal .set_glass_vec (np .r_ [0.0 , 0.0 , 20.0 ])
360- cal .set_radial_distortion ([ 0 , 0 , 0 ] )
361- cal .set_decentering ([ 0 , 0 ] )
362- cal .set_affine_trans ([1 , 0 ])
383+ cal .set_radial_distortion (np . zeros ( 3 ,) )
384+ cal .set_decentering (np . zeros ( 2 ,) )
385+ cal .set_affine_trans (np . array ( [1 , 0 ]) )
363386
364387 # reference metric positions:
365388 # Note the last value is different than in test_brown_affine() because
0 commit comments