コード例 #1
0
ファイル: test_wordle.py プロジェクト: domdfcoding/wordle
def test_github_repo(tmp_pathplus, image_regression: ImageRegressionFixture):
    w = Wordle(random_state=5678)

    w.generate_from_git(
        "https://github.com/domdfcoding/domdf_python_tools",
        outfile=tmp_pathplus / "git_wordcloud.svg",
        sha="de815f593718e16c031bc70e9c24b5635c3144dc",
    )
    export_wordcloud(w, outfile=tmp_pathplus / "git_wordcloud.png")

    image_regression.check((tmp_pathplus / "git_wordcloud.png").read_bytes(),
                           diff_threshold=3.5)

    # The results should be different for a different commit
    w.generate_from_git(
        "https://github.com/domdfcoding/domdf_python_tools",
        outfile=tmp_pathplus / "git_wordcloud.svg",
        sha="c30106567a27a17a5bd1339409ca22b6d425a25f",
    )
    export_wordcloud(w, outfile=tmp_pathplus / "git_wordcloud.png")

    with pytest.raises(AssertionError,
                       match="Difference between images too high"):
        image_regression.check(
            (tmp_pathplus / "git_wordcloud.png").read_bytes(),
            diff_threshold=3.5)
コード例 #2
0
ファイル: test_wordle.py プロジェクト: domdfcoding/wordle
def test_github_repo_exclude_words(tmp_pathplus,
                                   image_regression: ImageRegressionFixture):
    w = Wordle(random_state=5678)

    w.generate_from_git("https://github.com/domdfcoding/domdf_python_tools",
                        outfile=tmp_pathplus / "git_wordcloud.svg",
                        sha="de815f593718e16c031bc70e9c24b5635c3144dc",
                        exclude_words=["assert", "def", "self"])
    export_wordcloud(w, outfile=tmp_pathplus / "git_wordcloud.png")

    image_regression.check((tmp_pathplus / "git_wordcloud.png").read_bytes(),
                           diff_threshold=3.5)
コード例 #3
0
ファイル: test_wordle.py プロジェクト: domdfcoding/wordle
def test_c_source_file(
    tmp_pathplus,
    image_regression: ImageRegressionFixture,
    counter_regression: CounterRegressionFixture,
):
    w = Wordle(random_state=5678)

    src_file = examples_dir / "example.c"
    outfile = tmp_pathplus / "c_wordcloud.png"

    w.generate_from_file(src_file, outfile=tmp_pathplus / "c_wordcloud.svg")
    export_wordcloud(w, outfile=outfile)

    image_regression.check(outfile.read_bytes())
    counter_regression.check(frequency_from_file(src_file))
コード例 #4
0
ファイル: test_wordle.py プロジェクト: domdfcoding/wordle
def test_python_source_file(
    tmp_pathplus,
    image_regression: ImageRegressionFixture,
    counter_regression: CounterRegressionFixture,
):
    w = Wordle(random_state=5678)

    outfile = tmp_pathplus / "python_wordcloud.png"

    source_url = RequestsURL(
        "https://raw.githubusercontent.com/domdfcoding/wordle")
    source_url = source_url / "76797ba8b641b38fe1bed0801f0af248b793b59e/wordle/__init__.py"
    (tmp_pathplus / "source.py").write_bytes(source_url.get().content)

    w.generate_from_file(tmp_pathplus / "source.py",
                         outfile=tmp_pathplus / "python_wordcloud.svg")
    export_wordcloud(w, outfile=outfile)

    image_regression.check(outfile.read_bytes())
    counter_regression.check(frequency_from_file(tmp_pathplus / "source.py"))
コード例 #5
0
ファイル: python.py プロジェクト: domdfcoding/wordle
"""
Create a wordcloud from a single Python source file
"""

# stdlib
import pathlib

# this package
from wordle import Wordle, export_wordcloud

filename = pathlib.Path('.').absolute().parent / "wordle/__init__.py"

w = Wordle(random_state=5678)
w.generate_from_file(filename, outfile="python_wordcloud.svg")
export_wordcloud(w, outfile="python_wordcloud.png")
コード例 #6
0
ファイル: c_source_file.py プロジェクト: domdfcoding/wordle
"""
Create a wordcloud from a single C source file
"""

# this package
from wordle import Wordle, export_wordcloud

w = Wordle(random_state=5678)
w.generate_from_file("example.c", outfile="c_wordcloud.svg")
export_wordcloud(w, outfile="c_wordcloud.png")
コード例 #7
0
"""
Create a wordcloud from the Folium git repository.

https://github.com/python-visualization/folium
"""

# this package
from wordle import Wordle, export_wordcloud

w = Wordle(random_state=5678)
w.generate_from_git("https://github.com/python-visualization/folium",
                    outfile="folium_wordcloud.svg")
export_wordcloud(w, outfile="folium_wordcloud.png")