Skip to content

Commit

Permalink
fixed saving bug #91
Browse files Browse the repository at this point in the history
  • Loading branch information
ddangelov committed Dec 10, 2020
1 parent c899af8 commit c23e9a0
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
author = 'Dimo Angelov'

# The full version, including alpha/beta/rc tags
release = '1.0.18'
release = '1.0.19'


# -- General configuration ---------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
setuptools.setup(
name="top2vec",
packages=["top2vec"],
version="1.0.18",
version="1.0.19",
author="Dimo Angelov",
author_email="dimo.angelov@gmail.com",
description="Top2Vec learns jointly embedded topic, document and word vectors.",
Expand Down
2 changes: 1 addition & 1 deletion top2vec/Top2Vec.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ def save(self, file):
self.document_index = None

# serialize word index so that it can be saved
if self.word_indexed:
if self.words_indexed:
temp = tempfile.NamedTemporaryFile(mode='w+b')
self.word_index.save_index(temp.name)
self.serialized_word_index = temp.read()
Expand Down
2 changes: 1 addition & 1 deletion top2vec/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from top2vec.Top2Vec import Top2Vec

__version__ = '1.0.18'
__version__ = '1.0.19'
9 changes: 9 additions & 0 deletions top2vec/tests/test_top2vec.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from top2vec import Top2Vec
from sklearn.datasets import fetch_20newsgroups
import numpy as np
import tempfile

# get 20 newsgroups data
newsgroups_train = fetch_20newsgroups(subset='all', remove=('headers', 'footers', 'quotes'))
Expand Down Expand Up @@ -457,3 +458,11 @@ def test_similar_words_index(top2vec_model):

# check that words are returned in decreasing order
assert all(word_scores[i] >= word_scores[i + 1] for i in range(len(word_scores) - 1))


@pytest.mark.parametrize('top2vec_model', models)
def test_similar_words_index(top2vec_model):
temp = tempfile.NamedTemporaryFile(mode='w+b')
top2vec_model.save(temp.name)
Top2Vec.load(temp.name)
temp.close()

0 comments on commit c23e9a0

Please sign in to comment.