#NEWLINE# def periodic_diff( x1 , x2 , L , periodic ) : #NEWLINE# #INDENT# diff = ( x1 - x2 ) #NEWLINE# if periodic : #NEWLINE# #INDENT# if ( diff > ( L / 2 ) ) : #NEWLINE# #INDENT# diff -= L #NEWLINE# #UNINDENT# if ( diff < ( ( - L ) / 2 ) ) : #NEWLINE# #INDENT# diff += L #NEWLINE# #UNINDENT# #UNINDENT# return diff