#NEWLINE# def testAggregateMinMax( self ) : #NEWLINE# #INDENT# ' Test aggregation: min/max (combined) ' #NEWLINE# period = self . period #NEWLINE# assertEqual = self . assertEqual #NEWLINE# totals = period . aggregate ( [ S3TimeSeriesFact ( 'min' , 'base' ) , S3TimeSeriesFact ( 'max' , 'base' ) ] ) #NEWLINE# expected_rows = { #NEWLINE# #INDENT# 'A' : [ 10 , 80 ] , #NEWLINE# 'B' : [ 30 , 200 ] , #NEWLINE# 'C' : [ 50 , 400 ] , #NEWLINE# #UNINDENT# } #NEWLINE# rows = period . rows #NEWLINE# assertEqual ( set ( rows . keys ( ) ) , set ( expected_rows . keys ( ) ) ) #NEWLINE# for ( k , v ) in rows . items ( ) : #NEWLINE# #INDENT# assertEqual ( v , expected_rows . get ( k ) , msg = ( 'Row %s: %s != %s' % ( k , v , expected_rows . get ( k ) ) ) ) #NEWLINE# #UNINDENT# expected_cols = { #NEWLINE# #INDENT# 1 : [ 10 , 300 ] , #NEWLINE# 2 : [ 20 , 100 ] , #NEWLINE# 3 : [ 40 , 400 ] , #NEWLINE# #UNINDENT# } #NEWLINE# cols = period . cols #NEWLINE# assertEqual ( set ( cols . keys ( ) ) , set ( expected_cols . keys ( ) ) ) #NEWLINE# for ( k , v ) in cols . items ( ) : #NEWLINE# #INDENT# assertEqual ( v , expected_cols . get ( k ) , msg = ( 'Column %s: %s != %s' % ( k , v , expected_cols . get ( k ) ) ) ) #NEWLINE# #UNINDENT# expected_matrix = { #NEWLINE# #INDENT# ( 'A' , 1 ) : [ 10 , 70 ] , #NEWLINE# ( 'A' , 2 ) : [ 20 , 80 ] , #NEWLINE# ( 'B' , 2 ) : [ 30 , 100 ] , #NEWLINE# ( 'B' , 3 ) : [ 40 , 200 ] , #NEWLINE# ( 'C' , 1 ) : [ 50 , 300 ] , #NEWLINE# ( 'C' , 2 ) : [ 60 , 60 ] , #NEWLINE# ( 'C' , 3 ) : [ 400 , 400 ] , #NEWLINE# #UNINDENT# } #NEWLINE# matrix = period . matrix #NEWLINE# assertEqual ( set ( matrix . keys ( ) ) , set ( expected_matrix . keys ( ) ) ) #NEWLINE# for ( k , v ) in matrix . items ( ) : #NEWLINE# #INDENT# assertEqual ( v , expected_matrix . get ( k ) , msg = ( 'Cell %s: %s != %s' % ( k , v , expected_matrix . get ( k ) ) ) ) #NEWLINE# #UNINDENT# expected_totals = [ 10 , 400 ] #NEWLINE# assertEqual ( period . totals , expected_totals ) #NEWLINE# assertEqual ( totals , expected_totals )