#NEWLINE# def _get_jensen_shannon_core( Ks , dim , ns ) : #NEWLINE# #INDENT# min_n = np . min ( ns ) #NEWLINE# max_n = np . max ( ns ) #NEWLINE# min_K = np . min ( Ks ) #NEWLINE# max_K = np . max ( Ks ) #NEWLINE# i_bounds = [ np . inf , ( - np . inf ) ] #NEWLINE# def add_i( i ) : #NEWLINE# #INDENT# if ( i < i_bounds [ 0 ] ) : #NEWLINE# #INDENT# i_bounds [ 0 ] = i #NEWLINE# #UNINDENT# if ( i > i_bounds [ 1 ] ) : #NEWLINE# #INDENT# i_bounds [ 1 ] = i #NEWLINE# #UNINDENT# #UNINDENT# for n in [ max_n , min_n ] : #NEWLINE# #INDENT# for m in [ max_n , min_n ] : #NEWLINE# #INDENT# base = ( ( ( 2 * n ) - 1 ) / ( ( n + m ) - 1 ) ) #NEWLINE# for M in [ max_K , min_K ] : #NEWLINE# #INDENT# add_i ( ( base * M ) ) #NEWLINE# add_i ( ( ( base * M ) * ( m / n ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# min_i = int ( np . floor ( i_bounds [ 0 ] ) ) #NEWLINE# if ( min_i <= 0 ) : #NEWLINE# #INDENT# raise ValueError ( 'have i = 0 possible; K is too small...' ) #NEWLINE# #UNINDENT# digamma_vals = psi ( np . arange ( min_i , int ( ( np . ceil ( i_bounds [ 1 ] ) + 1 ) ) ) ) #NEWLINE# return ( partial ( _jensen_shannon_core , Ks , dim , min_i , digamma_vals ) , max_K )