#NEWLINE# def initialize( self , originalTimeSeries , calculatedTimeSeries ) : #NEWLINE# #INDENT# 'Initializes the ErrorMeasure.\n\n        During initialization, all :py:meth:`BaseErrorMeasure.local_error()` are calculated.\n\n        :param TimeSeries originalTimeSeries:    TimeSeries containing the original data.\n        :param TimeSeries calculatedTimeSeries:    TimeSeries containing calculated data.\n            Calculated data is smoothed or forecasted data.\n\n        :return:    Return :py:const:`True` if the error could be calculated, :py:const:`False`\n            otherwise based on the minimalErrorCalculationPercentage.\n        :rtype: boolean\n\n        :raise:    Raises a :py:exc:`StandardError` if the error measure is initialized multiple times.\n        ' #NEWLINE# if ( 0 < len ( self . _errorValues ) ) : #NEWLINE# #INDENT# raise StandardError ( 'An ErrorMeasure can only be initialized once.' ) #NEWLINE# #UNINDENT# if isinstance ( self . _historyLength , float ) : #NEWLINE# #INDENT# self . _historyLength = int ( ( ( self . _historyLength * len ( originalTimeSeries ) ) / 100.0 ) ) #NEWLINE# #UNINDENT# originalTimeSeries . sort_timeseries ( ) #NEWLINE# calculatedTimeSeries . sort_timeseries ( ) #NEWLINE# self . _historicMeans = self . _get_historic_means ( originalTimeSeries ) #NEWLINE# append = self . _errorValues . append #NEWLINE# appendDates = self . _errorDates . append #NEWLINE# local_error = self . local_error #NEWLINE# minCalcIdx = ( self . _historyLength + 1 ) #NEWLINE# for orgPair in originalTimeSeries [ minCalcIdx : ] : #NEWLINE# #INDENT# for calcIdx in xrange ( minCalcIdx , len ( calculatedTimeSeries ) ) : #NEWLINE# #INDENT# calcPair = calculatedTimeSeries [ calcIdx ] #NEWLINE# if ( calcPair [ 0 ] != orgPair [ 0 ] ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# append ( local_error ( orgPair [ 1 : ] , calcPair [ 1 : ] ) ) #NEWLINE# appendDates ( orgPair [ 0 ] ) #NEWLINE# #UNINDENT# #UNINDENT# if ( len ( filter ( ( lambda item : ( item is not None ) ) , self . _errorValues ) ) < ( self . _minimalErrorCalculationPercentage * len ( originalTimeSeries ) ) ) : #NEWLINE# #INDENT# self . _errorValues = [ ] #NEWLINE# self . _errorDates = [ ] #NEWLINE# self . _historicMeans = [ ] #NEWLINE# return False #NEWLINE# #UNINDENT# return True