def test_to_polar_non_numeric_vector(self):
     v = ('a', 'theta')
     with self.assertRaises(
             TypeError,
             msg=
             'should raise TypeError when passing non-numeric polar vector'
     ):
         to_polar(v)
Example #2
0
 def new_function(v):
     x, y, z = v
     vector_length, vector_angle = to_polar((x, y))
     new_vector_angle = vector_angle + angle
     new_x, new_y = to_cartesian((vector_length, new_vector_angle))
     return (new_x, new_y, z)
 def test_to_polar_happy_path(self):
     v = (1, 1)
     to_polar_actual_result = to_polar(v)
     to_polar_expected_result = (sqrt(2), pi / 4)
     self.assertEqual(to_polar_actual_result, to_polar_expected_result,
                      'to_cartesian should match')
 def test_to_polar_non_2d_vector(self):
     v = (1, 0, 0)
     with self.assertRaises(
             TypeError,
             msg='should raise TypeError when passing non-2d polar vector'):
         to_polar(v)