good catch, this will also affect picking the top topics - should it return
an empty list?


On Sun, Jan 5, 2014 at 11:21 AM, jesterhazy <notifications@github.com>wrote:

> In gensim/models/hdpmodel.py:
>
> > -
> > +    def inference(self,chunk):
> > +        lda_alpha = self.lda_alpha
> > +        lda_beta = self.lda_beta
> > +        if not (isinstance(lda_alpha,np.ndarray) and isinstance(lda_beta,np.ndarray)):
> > +            raise RuntimeError("corpus must be trained to perform inference")
> > +        try:
> > +            _ = len(chunk)
> > +        except:
> > +            chunk = list(chunk)
> > +        if len(chunk) > 1:
> > +            logger.debug("performing inference on a chunk of %i documents"%len(chunk))
> > +
> > +        gamma = np.zeros((len(chunk),lda_beta.shape[0]))
> > +        for d, doc in enumerate(chunk):
> > +            ids = np.array([ i for i , _ in doc ])
>
> Need to add "if len(doc) > 0:" here. If corpus has had vocabulary
> reduction, there may be some 0 length docs passed in here, which cause an
> exception in lda_e_step. Seems reasonable to leave gamma with zeros for
> this case.
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/piskvorky/gensim/pull/153/files#r8655875>
> .
>