@@ -557,3 +557,31 @@ def test_calc_surface_orientation_special():
557557 # in a modulo-360 sense.
558558 np .testing .assert_allclose (np .round (out ['surface_azimuth' ], 4 ) % 360 ,
559559 expected_azimuths , rtol = 1e-5 , atol = 1e-5 )
560+
561+
562+ @pytest .mark .parametrize ('shape' , [(3 , 5 ), (1 , 7 ), (4 , 1 ), (2 , 3 , 4 )])
563+ def test_calc_surface_orientation_2d (shape ):
564+ # Regression test for GH#2747: calc_surface_orientation must accept
565+ # tracker_theta of arbitrary rank, not just 1-D. Compare the >1-D result
566+ # to the 1-D result computed on the flattened input.
567+ rotations_flat = np .linspace (- 90 , 90 , int (np .prod (shape )))
568+ rotations_nd = rotations_flat .reshape (shape )
569+
570+ out_1d = tracking .calc_surface_orientation (rotations_flat ,
571+ axis_tilt = 20 ,
572+ axis_azimuth = 180 )
573+ out_nd = tracking .calc_surface_orientation (rotations_nd ,
574+ axis_tilt = 20 ,
575+ axis_azimuth = 180 )
576+
577+ assert out_nd ['surface_tilt' ].shape == shape
578+ assert out_nd ['surface_azimuth' ].shape == shape
579+ np .testing .assert_allclose (out_nd ['surface_tilt' ].reshape (- 1 ),
580+ out_1d ['surface_tilt' ])
581+ np .testing .assert_allclose (out_nd ['surface_azimuth' ].reshape (- 1 ),
582+ out_1d ['surface_azimuth' ])
583+
584+ # _unit_normal must preserve the input rank, appending a trailing axis
585+ # of length 3.
586+ unorm = tracking ._unit_normal (180. , 20. , rotations_nd )
587+ assert unorm .shape == shape + (3 ,)
0 commit comments