Skip to content

Commit

Permalink
Add tests for word cloud (save_wordcloud)
Browse files Browse the repository at this point in the history
  • Loading branch information
sergioburdisso committed Jun 12, 2021
1 parent acaeaa2 commit b3e53dc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pyss3/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1582,7 +1582,7 @@ def save_wordcloud(self, cat, top_n=100, n_grams=1, path=None, size=1024,

ilen = n_grams - 1

if top_n < 1 or not vocabularies_out[ilen]:
if not vocabularies_out[ilen]:
Print.info("\t[ empty word could: no %d-grams to be shown ]" % n_grams)
return

Expand Down
12 changes: 12 additions & 0 deletions tests/test_pyss3.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,18 @@ def test_pyss3_ss3(mockers):
perform_tests_on(clf.cv, 0, "video games", "science&technology")
perform_tests_on(clf.gv, 0, "video games", "science&technology")

# world cloud tests
with pytest.raises(pyss3.InvalidCategoryError):
clf.save_wordcloud("xxx")
with pytest.raises(ValueError):
clf.save_wordcloud("sports", top_n=0)
with pytest.raises(ValueError):
clf.save_wordcloud("sports", n_grams=0)
with pytest.raises(ValueError):
clf.save_wordcloud("sports", size=0)
clf.save_wordcloud("science&technology", n_grams=3) # empty cloud
clf.save_wordcloud("science&technology", plot=True)

# cv_m=STR_NORM_GV, sg_m=STR_XAI
clf = SS3(
s=.45, l=.5, p=1, a=0, name="test-norm-gv-sn-xai",
Expand Down

0 comments on commit b3e53dc

Please sign in to comment.