def counts(x, v):
 idx = np.digitize(x, v)
 try:
  return np.bincount(idx, minlength=len(v))
 except:
  bc = np.bincount(idx)
  return np.r_[(bc, np.zeros((len(v) - len(bc))))]

def counts ( x , v ) : idx = np . digitize ( x , v ) try : return np . bincount ( idx , minlength = len ( v ) ) except : bc = np . bincount ( idx ) return np . r_ [ ( bc , np . zeros ( ( len ( v ) - len ( bc ) ) ) ) ]
counts the number of elements of x that fall within the grid points v notes using np .