nodes: 0, module; 1, function_definition; 2, function_name:_calculate_values_to_forecast; 3, parameters; 4, block; 5, identifier:self; 6, identifier:timeSeries; 7, expression_statement; 8, comment:# do not set anything, if it is not required; 9, if_statement; 10, comment:# check the TimeSeries for correctness; 11, if_statement; 12, if_statement; 13, expression_statement; 14, expression_statement; 15, expression_statement; 16, comment:"""Calculates the number of values, that need to be forecasted to match the goal set in forecast_until.
  
          This sets the parameter "valuesToForecast" and should be called at the beginning of the :py:meth:`BaseMethod.execute` implementation.
  
          :param TimeSeries timeSeries:    Should be a sorted and normalized TimeSeries instance.
  
          :raise:    Raises a :py:exc:`ValueError` if the TimeSeries is either not normalized or sorted.
          """; 17, comparison_operator:self._forecastUntil is None; 18, block; 19, not_operator; 20, block; 21, not_operator; 22, block; 23, assignment; 24, assignment; 25, call; 26, attribute; 27, None; 28, return_statement; 29, call; 30, raise_statement; 31, call; 32, raise_statement; 33, identifier:timediff; 34, binary_operator:timeSeries[-1][0] - timeSeries[-2][0]; 35, identifier:forecastSpan; 36, binary_operator:self._forecastUntil - timeSeries[-1][0]; 37, attribute; 38, argument_list; 39, identifier:self; 40, identifier:_forecastUntil; 41, attribute; 42, argument_list; 43, call; 44, attribute; 45, argument_list; 46, call; 47, subscript; 48, subscript; 49, attribute; 50, subscript; 51, identifier:self; 52, identifier:set_parameter; 53, string:"valuesToForecast"; 54, binary_operator:int(forecastSpan / timediff) + 1; 55, identifier:timeSeries; 56, identifier:is_sorted; 57, identifier:ValueError; 58, argument_list; 59, identifier:timeSeries; 60, identifier:is_normalized; 61, identifier:ValueError; 62, argument_list; 63, subscript; 64, integer:0; 65, subscript; 66, integer:0; 67, identifier:self; 68, identifier:_forecastUntil; 69, subscript; 70, integer:0; 71, call; 72, integer:1; 73, string:"timeSeries has to be sorted."; 74, string:"timeSeries has to be normalized."; 75, identifier:timeSeries; 76, unary_operator; 77, identifier:timeSeries; 78, unary_operator; 79, identifier:timeSeries; 80, unary_operator; 81, identifier:int; 82, argument_list; 83, integer:1; 84, integer:2; 85, integer:1; 86, binary_operator:forecastSpan / timediff; 87, identifier:forecastSpan; 88, identifier:timediff
code: def _calculate_values_to_forecast(self, timeSeries):
          """Calculates the number of values, that need to be forecasted to match the goal set in forecast_until.
  
          This sets the parameter "valuesToForecast" and should be called at the beginning of the :py:meth:`BaseMethod.execute` implementation.
  
          :param TimeSeries timeSeries:    Should be a sorted and normalized TimeSeries instance.
  
          :raise:    Raises a :py:exc:`ValueError` if the TimeSeries is either not normalized or sorted.
          """
          # do not set anything, if it is not required
          if self._forecastUntil is None:
              return
  
          # check the TimeSeries for correctness
          if not timeSeries.is_sorted():
              raise ValueError("timeSeries has to be sorted.")
          if not timeSeries.is_normalized():
              raise ValueError("timeSeries has to be normalized.")
  
          timediff = timeSeries[-1][0] - timeSeries[-2][0]
          forecastSpan = self._forecastUntil - timeSeries[-1][0]
  
          self.set_parameter("valuesToForecast", int(forecastSpan / timediff) + 1)