def test_arc_from_base_params(self): for crt_data in self.arc_data: for param_names in self.base_arc_params: crt_params = dict([x for x in crt_data.items() if x[0] in param_names]) arc = Arc(verify=False, **crt_params) # print "******************************" # print "param_names: ", param_names # print "crt_params: ", crt_params # print "******************************" # print arc arc.verify() # print arc for name, expected_value in crt_data.items(): if hasattr(arc, name): expected_value = Arc.wrap_param(name, expected_value) actual_value = getattr(arc, name) self.assertTrue( np.allclose(expected_value, actual_value), msg="Wrong value for {}, expected: {}, found: {}".format( name, expected_value, actual_value ) )
def test_central_angle(self): angle_checks = ( ("1, 1, 1", "-1, -1, -1", "0.5, 0.5, 0.5", 0), ("1, 1, 1", "1, 1, 1", "2,2,2", 2.0 * math.pi), ("1, 0.5, 0.5", "-1, 1, 1", "0, 1.5, 1.5", math.pi), ([1.0/math.sqrt(2), 0.5, 0.5], "0, 0, 0.5", "0, 0, 0", 4*math.pi/3), ("0, 0, 0", "0, 0, 0.5", [1.0/math.sqrt(2), 0.5, 0.5], 5*math.pi/3), ) for x in angle_checks: angle = Arc.central_angle(start_point=x[0], end_point=x[1], arc_point=x[2]) self.assertAlmostEqual( x[3], angle, places=10, msg="Check failed for: {}; result is: {}".format(x, angle) )
def test_arc_param_calculation(self): for crt_data in self.arc_data: for param_names in self.base_arc_params: crt_params = dict([x for x in crt_data.items() if x[0] in param_names]) for name in Arc.calc_function_map: arc = Arc(verify=False, **crt_params) actual_value = getattr(arc, name) if name in crt_data: expected_value = Arc.wrap_param(name, crt_data[name]) self.assertTrue( np.allclose(expected_value, actual_value), msg="Wrong value for {}, expected: {}, found: {}".format( name, expected_value, actual_value ) )