Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using --colormap has no effect #661

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions test/test_wordcloud_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,6 @@ def test_check_duplicate_color_error(tmpdir, tmp_text_file):
cli.parse_args(['--color', 'red', '--colormask', str(color_mask_file), '--text', str(tmp_text_file)])


def test_parse_args_defaults_to_random_color(tmp_text_file):
args, text, image_file = cli.parse_args(['--text', str(tmp_text_file)])
assert args['color_func'] == wc.random_color_func


def test_unicode_text_file():
unicode_file = os.path.join(os.path.dirname(__file__), "unicode_text.txt")
args, text, image_file = cli.parse_args(['--text', unicode_file])
Expand Down
4 changes: 2 additions & 2 deletions wordcloud/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from .wordcloud import (WordCloud, STOPWORDS, random_color_func,
from .wordcloud import (WordCloud, STOPWORDS, random_color_func, colormap_color_func,
get_single_color_func)
from .color_from_image import ImageColorGenerator

__all__ = ['WordCloud', 'STOPWORDS', 'random_color_func',
__all__ = ['WordCloud', 'STOPWORDS', 'random_color_func', 'colormap_color_func',
'get_single_color_func', 'ImageColorGenerator',
'__version__']

Expand Down
2 changes: 1 addition & 1 deletion wordcloud/wordcloud_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,9 @@ def parse_args(arguments):
mask = args.pop('mask')
args['mask'] = np.array(Image.open(mask))

color_func = wc.random_color_func
colormask = args.pop('colormask')
color = args.pop('color')
color_func = wc.colormap_color_func(args['colormap'])
if colormask:
image = np.array(Image.open(colormask))
color_func = wc.ImageColorGenerator(image)
Expand Down