#NEWLINE# def compute_bin_efficiencies( y_score , bin_indices , cut , sample_weight , minlength = None ) : #NEWLINE# #INDENT# 'Efficiency of bin = total weight of (signal) events that passed the cut\n    in the bin / total weight of signal events in the bin.\n    Returns small negative number for empty bins' #NEWLINE# y_score = column_or_1d ( y_score ) #NEWLINE# assert ( len ( y_score ) == len ( sample_weight ) == len ( bin_indices ) ) , 'different size' #NEWLINE# if ( minlength is None ) : #NEWLINE# #INDENT# minlength = ( numpy . max ( bin_indices ) + 1 ) #NEWLINE# #UNINDENT# bin_total = numpy . bincount ( bin_indices , weights = sample_weight , minlength = minlength ) #NEWLINE# passed_cut = ( y_score > cut ) #NEWLINE# bin_passed_cut = numpy . bincount ( bin_indices [ passed_cut ] , weights = sample_weight [ passed_cut ] , minlength = minlength ) #NEWLINE# return ( bin_passed_cut / numpy . maximum ( bin_total , 1 ) )