def get_bin_number(bins, val): 
	""" 
	Gets the bin number of a value in a binspace 

	Parameters 
	========== 
	bins :: list 
		The bin edges 
	val :: real number 
		The value to get the bin number for 

	Returns 
	======= 
	The bin number of the test value. -1 if it is not within the binspace 
	""" 
	for i in range(len(bins) - 1): 
		if bins[i] <= val <= bins[i + 1]: return i 
	return -1