示例#1
0
    def test_fit_angle_in_deg_range_scalar(self):
        angles = np.random.rand(10) + random.choice([-500.0, 500.0])
        correct_angles = fit_angle_in_deg_range(angles)

        for i, angle in enumerate(correct_angles):
            if angle < 0.0 or angle > 360.0:
                assert False

            if round(math.cos(float(math.radians(angle))), 5) != round(math.cos(math.radians(angles[i])), 5) or\
               round(math.sin(float(math.radians(angle))), 5) != round(math.sin(math.radians(angles[i])), 5):
                assert False
示例#2
0
    def test_fit_angle_in_diff_deg_range_matrix(self):
        angles = np.random.rand(3, 10) + random.choice([-500.0, 500.0])
        correct_angles = fit_angle_in_deg_range(angles,
                                                max_angle=180.0,
                                                min_angle=-180.0)

        for i in range(correct_angles.shape[0]):
            for j, angle in enumerate(correct_angles[i]):
                if angle < -180.0 or angle > 180.0:
                    assert False

                if round(math.cos(float(math.radians(angle))), 5) != round(math.cos(math.radians(angles[i, j])), 5) or\
                   round(math.sin(float(math.radians(angle))), 5) != round(math.sin(math.radians(angles[i, j])), 5):
                    assert False
示例#3
0
 def test_fit_angle_in_deg_range_min_is_greater_than_max(self):
     with pytest.raises(ValueError):
         angles = np.random.rand(10)
         fit_angle_in_deg_range(angles, min_angle=180.0, max_angle=-180.0)
示例#4
0
 def test_fit_angle_in_deg_range_wrong_range(self):
     with pytest.raises(ValueError):
         angles = np.random.rand(10)
         fit_angle_in_deg_range(angles, min_angle=180.0, max_angle=0.0)