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

Alternative query integral image #426

Closed
wants to merge 6 commits into from
Closed
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
30 changes: 30 additions & 0 deletions test/test_hits.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import pytest
import numpy as np
from wordcloud.query_integral_image import test_c_search_for_space as c_search_for_space


shape_x = 100
shape_y = 100


@pytest.fixture
def integral_image():
return np.zeros((shape_x, shape_y), dtype=np.uint32)


# Add any additional tests here using the format:
# ('test_name', {'word_x':val, 'word_y': val, 'expected_hits': val})
# they will be collected by the fixture function
_test_hit_parameters = [('small word', {'word_x': 10, 'word_y': 10, 'expected_hits': 8100}),
('maximum sized word', {'word_x': shape_x - 1, 'word_y': shape_y - 1, 'expected_hits': 1}),
('oversized word', {'word_x': shape_x + 1, 'word_y': shape_y + 1, 'expected_hits': 0})]


@pytest.fixture(params=[p[1] for p in _test_hit_parameters], ids=[p[0] for p in _test_hit_parameters])
def test_hit_parameters(request):
return request.param


def test_hits_equals_expected(integral_image, test_hit_parameters):
value = c_search_for_space(integral_image, test_hit_parameters['word_x'], test_hit_parameters['word_y'])
assert value == test_hit_parameters['expected_hits']
7 changes: 6 additions & 1 deletion test/test_wordcloud_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,12 @@ def test_cli_regexp_invalid(tmp_text_file, capsys):
@pytest.mark.parametrize("command,expected_output, expected_exit_code", [
("wordcloud_cli --help", "usage: wordcloud_cli", 0),
("python -m wordcloud --help", "usage: __main__", 0),
("python %s/../wordcloud/wordcloud_cli.py --help" % os.path.dirname(__file__), "To execute the CLI", 1),
("python" + os.path.join(
"%s",
"..",
"wordcloud",
"wordcloud_cli.py --help"
) % os.path.dirname(__file__), "To execute the CLI", 1),
])
def test_cli_as_executable(command, expected_output, expected_exit_code, tmpdir, capfd, no_cover_compat):

Expand Down
Loading