def getComp(self, k, doCollapseK1=True):
    if k < 0 or k >= self.K:
      raise IndexError('Bad compID. Expected [0, %d] but provided %d' % (self.K-1, k))
    cPB = ParamBag(K=1, D=self.D, doCollapseK1=doCollapseK1)
    for key in self._FieldDims:
      arr = getattr(self,key)
      dims = self._FieldDims[key]
      if dims is not None:
        if self.K == 1:
          cPB.setField(key, arr, dims=dims)
        else:
          singleArr = arr[k]
          if doCollapseK1:
            cPB.setField(key, singleArr, dims=dims)
          elif singleArr.ndim == 0:
            cPB.setField(key, singleArr[np.newaxis], dims=dims)
          else:
            cPB.setField(key, singleArr[np.newaxis,:], dims=dims)
      else:
        cPB.setField(key, arr)
    return cPB


  ######################################################### Add bags together
  #########################################################
Returns ParamBag object for component "k" of self.
dataset/ETHPy150Open daeilkim/refinery/refinery/bnpy/bnpy-dev/bnpy/suffstats/ParamBag.py/ParamBag.getComp