def removeComp(self, k):
    if k < 0 or k >= self.K:
      msg = 'Bad compID. Expected [0, %d], got %d' % (self.K-1, k)
      raise IndexError(msg)
    if self.K <= 1:
      raise ValueError('Cannot remove final component.')
    self.K -= 1
    for key in self._FieldDims:
      arr = getattr(self,key)
      dims = self._FieldDims[key]
      if dims is not None:
        for dimID,name in enumerate(dims):
          if name == 'K':
            arr = np.delete(arr, k, axis=dimID)
        self.setField(key, arr, dims)


  ######################################################### Set component 
  #########################################################
Updates self in-place to remove component "k"
dataset/ETHPy150Open daeilkim/refinery/refinery/bnpy/bnpy-dev/bnpy/suffstats/ParamBag.py/ParamBag.removeComp