#NEWLINE# def prune_datapoints( series , max_datapoints , start , end ) : #NEWLINE# #INDENT# time_range = ( end - start ) #NEWLINE# points = ( time_range // series . step ) #NEWLINE# if ( seconds_per_point < points ) : #NEWLINE# #INDENT# values_per_point = int ( math . ceil ( ( float ( points ) / float ( max_datapoints ) ) ) ) #NEWLINE# seconds_per_point = ( values_per_point * series . step ) #NEWLINE# nudge = ( ( seconds_per_point + ( series . start % series . step ) ) - ( series . start % seconds_per_point ) ) #NEWLINE# series . start += nudge #NEWLINE# values_to_lose = ( nudge // series . step ) #NEWLINE# del series [ : ( values_to_lose - 1 ) ] #NEWLINE# series . consolidate ( values_per_point ) #NEWLINE# step = seconds_per_point #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# step = series . step #NEWLINE# #UNINDENT# timestamps = range ( series . start , ( series . end + series . step ) , step ) #NEWLINE# datapoints = zip ( series , timestamps ) #NEWLINE# return { #NEWLINE# #INDENT# 'target' : series . name , #NEWLINE# 'datapoints' : datapoints , #NEWLINE# #UNINDENT# }