gregversteeg / corex_topic

Hierarchical unsupervised and semi-supervised topic models for sparse count data with CorEx
Apache License 2.0
626 stars 119 forks source link

[Warning] ResourceWarning: unclosed file #42

Open zafercavdar opened 4 years ago

zafercavdar commented 4 years ago

Definition

After saving and loading with pickle, file descriptors are not closed.

How to reproduce

...
from corextopic import corextopic

corex_model = corextopic.Corex(n_hidden=10, verbose=True, max_iter=200)
corex_model.fit(corpus, words=words)

path = "path/to/corex_model.pkl"
corex_model.save(path, ensure_compatibility=False)

> ResourceWarning: unclosed file <_io.BufferedWriter name='path/to/corex_model.pkl'>

loaded_model = corextopic.load(path)
> ResourceWarning: unclosed file <_io.BufferedReader name='path/to/corex_model.pkl'>