Skip to content

Commit

Permalink
Let process_text() return a dict.
Browse files Browse the repository at this point in the history
  • Loading branch information
mkcor committed Apr 7, 2016
1 parent 740b3e0 commit 907b62a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
9 changes: 9 additions & 0 deletions test/test_wordcloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,15 @@ def test_single_color_func_grey():
assert_equal(red_function(random_state=random), 'rgb(56, 56, 56)')


def test_process_text():
# test that process function returns a dict
wc = WordCloud(max_words=50)
result = wc.process_text(THIS)

# check for proper return type
assert_true(isinstance(result, dict))


def check_parameters():
# check that parameters are actually used
pass
4 changes: 2 additions & 2 deletions wordcloud/wordcloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ def process_text(self, text):
first = max(d2.items(), key=item1)[0]
d3[first] = sum(d2.values())

return d3.items()
return d3

def generate_from_text(self, text):
"""Generate wordcloud from text.
Expand All @@ -439,7 +439,7 @@ def generate_from_text(self, text):
self
"""
words = self.process_text(text)
self.generate_from_frequencies(words)
self.generate_from_frequencies(words.items())
return self

def generate(self, text):
Expand Down

0 comments on commit 907b62a

Please sign in to comment.