nodes: 0, module; 1, function_definition; 2, function_name:_linear_interp; 3, parameters; 4, block; 5, identifier:curve; 6, identifier:test_x; 7, default_parameter; 8, expression_statement; 9, expression_statement; 10, for_statement; 11, identifier:round_result; 12, False; 13, comment:"""
      Take a series of points and interpolate between them at ``test_x``.
  
      Args:
          curve (list[tuple]): A list of ``(x, y)`` points sorted in
              nondecreasing ``x`` value. If multiple points have the same
              ``x`` value, all but the last will be ignored.
          test_x (float): The ``x`` value to find the ``y`` value of
  
      Returns:
          float: The ``y`` value of the curve at ``test_x``
          if ``round_result is False``
  
          int: if ``round_result is True`` or the result is a whole number,
          the ``y`` value of the curve at ``test_x`` rounded to the
          nearest whole number.
  
      Raises:
          ProbabilityUndefinedError: if ``test_x`` is out of the
              domain of ``curve``
  
      Example:
          >>> curve = [(0, 0), (2, 1)]
          >>> _linear_interp(curve, 0.5)
          0.25
          >>> _linear_interp(curve, 0.5, round_result=True)
          0
      """; 14, assignment; 15, identifier:index; 16, call; 17, comment:# Ignore points which share an x value with the following point; 18, block; 19, else_clause; 20, identifier:index; 21, integer:0; 22, identifier:range; 23, argument_list; 24, if_statement; 25, if_statement; 26, block; 27, binary_operator:len(curve) - 1; 28, comparison_operator:curve[index][0] == curve[index + 1][0]; 29, block; 30, comparison_operator:curve[index][0] <= test_x <= curve[index + 1][0]; 31, block; 32, raise_statement; 33, call; 34, integer:1; 35, subscript; 36, subscript; 37, continue_statement; 38, subscript; 39, identifier:test_x; 40, subscript; 41, expression_statement; 42, expression_statement; 43, expression_statement; 44, if_statement; 45, identifier:ProbabilityUndefinedError; 46, identifier:len; 47, argument_list; 48, subscript; 49, integer:0; 50, subscript; 51, integer:0; 52, subscript; 53, integer:0; 54, subscript; 55, integer:0; 56, assignment; 57, assignment; 58, assignment; 59, identifier:round_result; 60, block; 61, else_clause; 62, identifier:curve; 63, identifier:curve; 64, identifier:index; 65, identifier:curve; 66, binary_operator:index + 1; 67, identifier:curve; 68, identifier:index; 69, identifier:curve; 70, binary_operator:index + 1; 71, identifier:slope; 72, parenthesized_expression; 73, identifier:y_intercept; 74, binary_operator:curve[index][1] - (slope * curve[index][0]); 75, identifier:result; 76, binary_operator:(slope * test_x) + y_intercept; 77, return_statement; 78, block; 79, identifier:index; 80, integer:1; 81, identifier:index; 82, integer:1; 83, binary_operator:(curve[index + 1][1] - curve[index][1]) /
                       (curve[index + 1][0] - curve[index][0]); 84, subscript; 85, parenthesized_expression; 86, parenthesized_expression; 87, identifier:y_intercept; 88, call; 89, if_statement; 90, parenthesized_expression; 91, parenthesized_expression; 92, subscript; 93, integer:1; 94, binary_operator:slope * curve[index][0]; 95, binary_operator:slope * test_x; 96, identifier:int; 97, argument_list; 98, call; 99, block; 100, else_clause; 101, binary_operator:curve[index + 1][1] - curve[index][1]; 102, binary_operator:curve[index + 1][0] - curve[index][0]; 103, identifier:curve; 104, identifier:index; 105, identifier:slope; 106, subscript; 107, identifier:slope; 108, identifier:test_x; 109, call; 110, attribute; 111, argument_list; 112, return_statement; 113, block; 114, subscript; 115, subscript; 116, subscript; 117, subscript; 118, subscript; 119, integer:0; 120, identifier:round; 121, argument_list; 122, identifier:result; 123, identifier:is_integer; 124, call; 125, return_statement; 126, subscript; 127, integer:1; 128, subscript; 129, integer:1; 130, subscript; 131, integer:0; 132, subscript; 133, integer:0; 134, identifier:curve; 135, identifier:index; 136, identifier:result; 137, identifier:int; 138, argument_list; 139, identifier:result; 140, identifier:curve; 141, binary_operator:index + 1; 142, identifier:curve; 143, identifier:index; 144, identifier:curve; 145, binary_operator:index + 1; 146, identifier:curve; 147, identifier:index; 148, identifier:result; 149, identifier:index; 150, integer:1; 151, identifier:index; 152, integer:1
code: def _linear_interp(curve, test_x, round_result=False):
      """
      Take a series of points and interpolate between them at ``test_x``.
  
      Args:
          curve (list[tuple]): A list of ``(x, y)`` points sorted in
              nondecreasing ``x`` value. If multiple points have the same
              ``x`` value, all but the last will be ignored.
          test_x (float): The ``x`` value to find the ``y`` value of
  
      Returns:
          float: The ``y`` value of the curve at ``test_x``
          if ``round_result is False``
  
          int: if ``round_result is True`` or the result is a whole number,
          the ``y`` value of the curve at ``test_x`` rounded to the
          nearest whole number.
  
      Raises:
          ProbabilityUndefinedError: if ``test_x`` is out of the
              domain of ``curve``
  
      Example:
          >>> curve = [(0, 0), (2, 1)]
          >>> _linear_interp(curve, 0.5)
          0.25
          >>> _linear_interp(curve, 0.5, round_result=True)
          0
      """
      index = 0
      for index in range(len(curve) - 1):
          # Ignore points which share an x value with the following point
          if curve[index][0] == curve[index + 1][0]:
              continue
          if curve[index][0] <= test_x <= curve[index + 1][0]:
              slope = ((curve[index + 1][1] - curve[index][1]) /
                       (curve[index + 1][0] - curve[index][0]))
              y_intercept = curve[index][1] - (slope * curve[index][0])
              result = (slope * test_x) + y_intercept
              if round_result:
                  return int(round(result))
              else:
                  if result.is_integer():
                      return int(result)
                  else:
                      return result
      else:
          raise ProbabilityUndefinedError