#NEWLINE# def _compute( self , data_1 , data_2 ) : #NEWLINE# #INDENT# if ( np . any ( ( data_1 < 0 ) ) or np . any ( ( data_2 < 0 ) ) ) : #NEWLINE# #INDENT# warnings . warn ( 'Additive Chi^2 kernel requires data to be strictly positive!' ) #NEWLINE# #UNINDENT# kernel = np . zeros ( ( data_1 . shape [ 0 ] , data_2 . shape [ 0 ] ) ) #NEWLINE# for d in range ( data_1 . shape [ 1 ] ) : #NEWLINE# #INDENT# column_1 = data_1 [ : , d ] . reshape ( ( - 1 ) , 1 ) #NEWLINE# column_2 = data_2 [ : , d ] . reshape ( ( - 1 ) , 1 ) #NEWLINE# kernel += ( ( 2 * ( column_1 * column_2 . T ) ) / ( column_1 + column_2 . T ) ) #NEWLINE# #UNINDENT# return kernel