#NEWLINE# def smoothing_test( self ) : #NEWLINE# #INDENT# ' Test if the smoothing works correctly' #NEWLINE# data = [ 362.0 , 385.0 , 432.0 , 341.0 , 382.0 , 409.0 , 498.0 , 387.0 , 473.0 , 513.0 , 582.0 , 474.0 , 544.0 , 582.0 , 681.0 , 557.0 , 628.0 , 707.0 , 773.0 , 592.0 , 627.0 , 725.0 , 854.0 , 661.0 ] #NEWLINE# tsSrc = TimeSeries . from_twodim_list ( zip ( range ( len ( data ) ) , data ) ) #NEWLINE# expected = [ [ 0.0 , 362.0 ] , [ 1.0 , 379.93673257607463 ] , [ 2.0 , 376.86173719924875 ] , [ 3.0 , 376.0203652542205 ] , [ 4.0 , 408.21988583215574 ] , [ 5.0 , 407.16235446485433 ] , [ 6.0 , 430.0950666716297 ] , [ 7.0 , 429.89797609228435 ] , [ 8.0 , 489.4888959723074 ] , [ 9.0 , 507.8407281475308 ] , [ 10.0 , 506.3556647249702 ] , [ 11.0 , 523.9422448655133 ] , [ 12.0 , 556.0311543025242 ] , [ 13.0 , 573.6520991970604 ] , [ 14.0 , 590.2149136780341 ] , [ 15.0 , 611.8813425659495 ] , [ 16.0 , 637.0393967524727 ] , [ 17.0 , 684.6600411792656 ] , [ 18.0 , 675.9589298142507 ] , [ 19.0 , 659.0266828674846 ] , [ 20.0 , 644.0903317144154 ] , [ 21.0 , 690.4507762388047 ] , [ 22.0 , 735.3219292023371 ] , [ 23.0 , 737.9752345691215 ] ] #NEWLINE# hwm = HoltWintersMethod ( 0.7556 , 1e-07 , 0.9837 , 4 , valuesToForecast = 0 ) #NEWLINE# initialA_2 = hwm . computeA ( 2 , tsSrc ) #NEWLINE# assert ( initialA_2 == 510.5 ) , ( 'Third initial A_2 should be 510.5, but it %d' % initialA_2 ) #NEWLINE# initialTrend = hwm . initialTrendSmoothingFactors ( tsSrc ) #NEWLINE# assert ( initialTrend == 9.75 ) , ( 'Initial Trend should be 9.75 but is %d' % initialTrend ) #NEWLINE# resTS = tsSrc . apply ( hwm ) #NEWLINE# expectedTS = TimeSeries . from_twodim_list ( expected ) #NEWLINE# assert ( len ( resTS ) == len ( expectedTS ) ) #NEWLINE# assert ( resTS == expectedTS ) , 'Smoothing result not correct.'