code: def find_bin(self, x):
          x = np.asarray(x).flatten()
          right = np.digitize(x, self.bins, right=True)
          if right.max() == len(self.bins):
              right[right == len(self.bins)] = len(self.bins) - 1
          return right