code: def _do_lumping(self):
          
          c = copy.deepcopy(self.countsmat_)
          if self.sliding_window:
              c *= self.lag_time
  
          c, macro_map, statesKeep = self._filterFunc(c)
  
          w = np.array(c.sum(axis=1)).flatten()
          w[statesKeep] += 1
  
          unmerged = np.zeros(w.shape[0], dtype=np.int8)
          unmerged[statesKeep] = 1
  
          # get nonzero indices in upper triangle
          indRecalc = self._getInds(c, statesKeep)
          dMat = np.zeros(c.shape, dtype=np.float32)
  
          i = 0
          nCurrentStates = statesKeep.shape[0]
  
          self.bayesFactors = {}
  
          dMat, minX, minY = self._calcDMat(c, w, indRecalc, dMat,
                                           statesKeep, unmerged)
  
          while nCurrentStates > self.n_macrostates:
              c, w, indRecalc, dMat, macro_map, statesKeep, unmerged, minX, minY = self._mergeTwoClosestStates(
                  c, w, indRecalc, dMat, macro_map,
                  statesKeep, minX, minY, unmerged)
  
              nCurrentStates -= 1
  
              if self.save_all_maps:
                  saved_map = copy.deepcopy(macro_map)
                  self.map_dict[nCurrentStates] = saved_map
  
              if nCurrentStates - 1 == self.n_macrostates:
                  self.microstate_mapping_ = macro_map
docs: Do the BACE lumping.