#NEWLINE# def hamming( a , b ) : #NEWLINE# #INDENT# if ( ( a . dtype == np . bool ) and ( b . dtype == bool ) ) : #NEWLINE# #INDENT# return ( a ^ b ) . sum ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( a . dtype == np . ubyte ) and ( b . dtype == np . ubyte ) ) : #NEWLINE# #INDENT# return hamming_table [ ( a ^ b ) ] . sum ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise NotImplementedError ( 'Unsupported array types %s and %s' , a . dtype , b . dtype )