#NEWLINE# def average_shifts( events ) : #NEWLINE# #INDENT# events = [ e for e in events if ( not e . linked ) ] #NEWLINE# shifts = [ x . shift for x in events ] #NEWLINE# weights = [ ( 1 - x . diff ) for x in events ] #NEWLINE# avg = np . average ( shifts , weights = weights ) #NEWLINE# for e in events : #NEWLINE# #INDENT# e . set_shift ( avg , e . diff ) #NEWLINE# #UNINDENT# return avg