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

add flake8 to test dir #20

Merged
merged 1 commit into from
Aug 20, 2023
Merged
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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -36,7 +36,7 @@ lint:
$(python) -m isort --settings-file=setup.cfg pyBigKinds/ test/

format:
$(python) -m flake8 --config=setup.cfg pyBigKinds/
$(python) -m flake8 --config=setup.cfg pyBigKinds/ test/
$(python) -m pylint --rcfile=.pylintrc pyBigKinds/

test:
4 changes: 3 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -41,7 +41,9 @@ max-complexity = 18
select = B,C,E,F,W,T4,B9
extend-ignore = E203, W503
ignore = E203,E226,E251,E501,E722,F821,W503,W605
per-file-ignores = __init__.py:F401,F403,F405
per-file-ignores =
__init__.py:F401,F403,F405
test/*:F403,F405
exclude =

[isort]
Binary file modified test/test.xlsx
Binary file not shown.
4 changes: 4 additions & 0 deletions test/test_base.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# pylint: disable=F403
# pylint: disable=F405

import pandas as pd
import pytest

@@ -9,6 +12,7 @@ def dataframe():
df = pd.read_excel("test/test.xlsx")
return df


def test_header_remover(dataframe):
ans = header_remover(dataframe)
assert ans[0] == " 한반도 긴장 높인 북한의 군사정찰위성 발사 규탄한다"
2 changes: 1 addition & 1 deletion test/test_preprocessing.py
Original file line number Diff line number Diff line change
@@ -35,7 +35,7 @@ def test_tfidf(dataframe):
def test_tfidf_vector(dataframe):
vector = tfidf_vector(dataframe)
assert type(vector) == np.ndarray
assert vector.shape == (31,2160)
assert vector.shape == (31, 2160)


def test_normalize_vector(dataframe):
11 changes: 7 additions & 4 deletions test/test_representation.py
Original file line number Diff line number Diff line change
@@ -11,47 +11,50 @@ def vector():
vector = tfidf_vector(df)
return vector


@pytest.fixture(scope="module")
def dataframe():
df = pd.read_excel("test/test.xlsx")
return df


def test_press_counter(dataframe):
counter = press_counter(dataframe)
assert counter.columns[0] == '언론사'
assert counter.columns[1] == '기사'
assert counter['기사'].max() == counter['기사'][0]


def test_pca(vector):
pca_df = pca(vector)

assert pca_df.columns[0] == 'component 0'
assert pca_df.columns[1] == 'component 1'
assert pca_df.shape == (31,2)
assert pca_df.shape == (31, 2)


def test_nmf(vector):
nmf_df = nmf(vector)

assert nmf_df.columns[0] == 'component 0'
assert nmf_df.columns[1] == 'component 1'
assert nmf_df.shape == (31,2)
assert nmf_df.shape == (31, 2)


def test_t_sne(vector):
tsne_df = t_sne(vector, 100)

assert tsne_df.columns[0] == 'component 0'
assert tsne_df.columns[1] == 'component 1'
assert tsne_df.shape == (31,2)
assert tsne_df.shape == (31, 2)


def test_lsa(vector):
lsa_df = lsa(vector)

assert lsa_df.columns[0] == 'component 0'
assert lsa_df.columns[1] == 'component 1'
assert lsa_df.shape == (31,2)
assert lsa_df.shape == (31, 2)


def test_kmeans(vector):
2 changes: 2 additions & 0 deletions test/test_visualization.py
Original file line number Diff line number Diff line change
@@ -10,10 +10,12 @@ def vector():
vector = tfidf_vector(df)
return vector


def test_keywords_wordcloud(vector):
with pytest.raises(TypeError):
keywords_wordcloud(vector, "press")


def test_top_words(vector):
with pytest.raises(TypeError):
top_words(vector, "press")