Client code:
model = LogEntropyModel(corpus=data_corpus, normalize=True)
Referenced code:
https://github.com/RaRe-Technologies/gensim/blob/44ea7931c916349821aa1c717fbf7e90fb138297/gensim/models/logentropy_model.py#L115
Exception thrown:
File "/anaconda3/lib/python3.7/site-packages/gensim/models/logentropy_model.py", line 76, in __init__
self.initialize(corpus)
File "/anaconda3/lib/python3.7/site-packages/gensim/models/logentropy_model.py", line 115, in initialize
if doc_no2 != doc_no:
UnboundLocalError: local variable 'doc_no2' referenced before assignment
Looks like a programming bug to me. doc_no2 should be initialized to zero, in case the corpus/generator is empty (which is what this block is actually testing).
Thanks for reporting.
I can try to patch it. I'll update and cut a PR when ready. Cheers!
@piskvorky, Here's the PR for the simple patch:
@paulrigor The existing tests pass.
Can you please add a new unit test to cover the bug you fixed? The test should fail without your change, and pass once your change is in place.
Most helpful comment
@paulrigor The existing tests pass.
Can you please add a new unit test to cover the bug you fixed? The test should fail without your change, and pass once your change is in place.