r = float(args.radius) l_output = args.output if l_output == "square": print("""Calculation of the side length of a square containing the same area as a selected circle.""") calc_square = True elif l_output == "pentagon": print("""Calculation of the side length of a pentagon containing the same area as a selected circle.""") calc_square = False else: sys.exit("No further output objects have been implemented \ yet! Aborting...") return r, calc_square if __name__ == "__main__": """Main function that drives the calculation.""" # Get the input parameters r, calc_square = parse_command_line() # Calculate the area of the given circle ac = tf.area_circ(r) if calc_square: # Get the side length of the square with same area a_square = tf.side_square(ac) else: # Get the side length of the pentagon with same area a_pentagon = tf.side_pentagon(ac)
def test_area_circ(): """Test the area values against a reference for r >= 0.""" assert tf.area_circ(1) == np.pi, "should return pi" assert tf.area_circ(0) == 0 assert tf.area_circ(2.1) == np.pi * 2.1**2
def test_area_circ(myinput, myref): """Test the area values against a reference for r >= 0.""" print(myinput) assert tf.area_circ(myinput) == myref
def test_values(): """Make sure value errors are recognized for area_circ.""" with pytest.raises(ValueError): tf.area_circ(-5)
def test_area_circ(self): """Test the area values against a reference for r >= 0.""" self.assertEqual(tf.area_circ(1), np.pi) self.assertEqual(tf.area_circ(0), 0) self.assertEqual(tf.area_circ(2.1), np.pi * 2.1**2)