#NEWLINE# def _get_center_of_mass( com , span , halflife , alpha ) : #NEWLINE# #INDENT# valid_count = len ( [ x for x in [ com , span , halflife , alpha ] if ( x is not None ) ] ) #NEWLINE# if ( valid_count > 1 ) : #NEWLINE# #INDENT# raise ValueError ( 'com, span, halflife, and alpha are mutually exclusive' ) #NEWLINE# #UNINDENT# if ( com is not None ) : #NEWLINE# #INDENT# if ( com < 0 ) : #NEWLINE# #INDENT# raise ValueError ( 'com must satisfy: com >= 0' ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( span is not None ) : #NEWLINE# #INDENT# if ( span < 1 ) : #NEWLINE# #INDENT# raise ValueError ( 'span must satisfy: span >= 1' ) #NEWLINE# #UNINDENT# com = ( ( span - 1 ) / 2.0 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( halflife is not None ) : #NEWLINE# #INDENT# if ( halflife <= 0 ) : #NEWLINE# #INDENT# raise ValueError ( 'halflife must satisfy: halflife > 0' ) #NEWLINE# #UNINDENT# decay = ( 1 - np . exp ( ( np . log ( 0.5 ) / halflife ) ) ) #NEWLINE# com = ( ( 1 / decay ) - 1 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( alpha is not None ) : #NEWLINE# #INDENT# if ( ( com <= 0 ) or ( alpha > 1 ) ) : #NEWLINE# #INDENT# raise ValueError ( 'alpha must satisfy: 0 < alpha <= 1' ) #NEWLINE# #UNINDENT# com = ( ( 1.0 - alpha ) / alpha ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise ValueError ( 'Must pass one of com, span, halflife, or alpha' ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# return float ( com )