<s> import unittest <EOL> from pycast . common . timeseries import TimeSeries <EOL> from pycast . errors . geometricmeanabsolutepercentageerror import GeometricMeanAbsolutePercentageError <EOL> import math <EOL> class GeometricMeanAbsolutePercentageErrorTest ( unittest . TestCase ) : <EOL> """<STR_LIT>""" <EOL> def local_error_test ( self ) : <EOL> orgValues = [ <NUM_LIT:11> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] <EOL> calValues = [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] <EOL> gmape = GeometricMeanAbsolutePercentageError ( ) <EOL> for idx in xrange ( len ( orgValues ) ) : <EOL> res = ( ( math . fabs ( calValues [ idx ] - orgValues [ idx ] ) ) / orgValues [ idx ] ) * <NUM_LIT:100> <EOL> assert str ( res ) [ : <NUM_LIT:6> ] == str ( gmape . local_error ( [ orgValues [ idx ] ] , [ calValues [ idx ] ] ) ) [ : <NUM_LIT:6> ] <EOL> def error_calculation_test ( self ) : <EOL> """<STR_LIT>""" <EOL> dataOrg = [ [ <NUM_LIT:1> , <NUM_LIT:1> ] , [ <NUM_LIT:2> , <NUM_LIT:2> ] , [ <NUM_LIT:3> , <NUM_LIT:3> ] , [ <NUM_LIT:4> , <NUM_LIT:4> ] , [ <NUM_LIT:5> , <NUM_LIT:5> ] , [ <NUM_LIT:6> , <NUM_LIT:6> ] , [ <NUM_LIT:7> , <NUM_LIT:8> ] , [ <NUM_LIT> , <NUM_LIT:5> ] , [ <NUM_LIT:8> , <NUM_LIT:0> ] , [ <NUM_LIT:9> , <NUM_LIT:10> ] ] <EOL> dataCalc = [ [ <NUM_LIT:1> , <NUM_LIT:3> ] , [ <NUM_LIT:2> , <NUM_LIT:5> ] , [ <NUM_LIT:3> , <NUM_LIT:0> ] , [ <NUM_LIT:4> , <NUM_LIT:3> ] , [ <NUM_LIT:5> , <NUM_LIT:6> ] , [ <NUM_LIT> , <NUM_LIT:6> ] , [ <NUM_LIT:7> , <NUM_LIT:3> ] , [ <NUM_LIT> , <NUM_LIT:5> ] , [ <NUM_LIT:8> , <NUM_LIT:0> ] , [ <NUM_LIT:9> , <NUM_LIT:9> ] ] <EOL> tsOrg = TimeSeries . from_twodim_list ( dataOrg ) <EOL> tsCalc = TimeSeries . from_twodim_list ( dataCalc ) <EOL> gmape = GeometricMeanAbsolutePercentageError ( ) <EOL> gmape . initialize ( tsOrg , tsCalc ) <EOL> assert str ( gmape . get_error ( ) ) [ : <NUM_LIT:6> ] == "<STR_LIT>" <EOL> error = gmape . get_error ( startDate = <NUM_LIT:1> , endDate = <NUM_LIT:9> ) <EOL> assert str ( error ) [ : <NUM_LIT:6> ] == "<STR_LIT>" , "<STR_LIT>" % error </s>
