From f8c64494e8a074de169a33e25665a9cda3368cc3 Mon Sep 17 00:00:00 2001 From: Seth Rothschild Date: Tue, 25 Sep 2018 15:47:59 -0400 Subject: [PATCH] Release v0.0.4 (#34) * fix the longstanding `plotting.dendrogram` display bug * incorporate `learning` into the `Dendrogram.score_at_point` method in `selection` * added unit tests for `selection` (coverage is roughly 86%) * landing page for docs is `index.html` * modify the documentation structure * update the package metadata --- henchman/__init__.py | 2 +- meta.yaml | 2 +- setup.cfg | 2 +- setup.py | 2 +- tests/test_selection.py | 29 +++++++++++++++++++++-------- tox.ini | 6 ++++-- upload.sh | 1 + 7 files changed, 30 insertions(+), 14 deletions(-) diff --git a/henchman/__init__.py b/henchman/__init__.py index 784527f..faa8961 100644 --- a/henchman/__init__.py +++ b/henchman/__init__.py @@ -11,4 +11,4 @@ __author__ = '''Feature Labs Team''' __email__ = 'team@featurelabs.com' -__version__ = '0.0.3' +__version__ = '0.0.4' diff --git a/meta.yaml b/meta.yaml index 24bf2a3..0a53ac3 100644 --- a/meta.yaml +++ b/meta.yaml @@ -1,6 +1,6 @@ package: name: henchman - version: "0.0.3" + version: "0.0.4" source: path: ../henchman diff --git a/setup.cfg b/setup.cfg index c8b74e3..19f7e01 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.0.3 +current_version = 0.0.4 commit = True tag = True diff --git a/setup.py b/setup.py index 8d7017a..86e6e8e 100644 --- a/setup.py +++ b/setup.py @@ -49,6 +49,6 @@ test_suite='tests', tests_require=test_requirements, url='https://github.com/featurelabs/henchman', - version='0.0.3.1', + version='0.0.4', zip_safe=False, ) diff --git a/tests/test_selection.py b/tests/test_selection.py index 5bf9e30..c9fb134 100644 --- a/tests/test_selection.py +++ b/tests/test_selection.py @@ -12,12 +12,14 @@ from sklearn.ensemble import RandomForestClassifier from sklearn.metrics import accuracy_score + @pytest.fixture(scope="module") def Xy(): X = pd.read_csv('./tests/sample_data/sample_fm_enc.csv') y = X.pop('label') return X, y + @pytest.fixture(scope="module") def fit_dend(Xy): X, y = Xy @@ -43,25 +45,32 @@ def test_dend_fit(fit_dend): assert selector.edges is not None assert selector.graphs is not None + def test_dend_set_params(fit_dend): threshlist = fit_dend.threshlist fit_dend.set_params(threshlist=None) - assert fit_dend.threshlist == None + assert fit_dend.threshlist is None fit_dend.threshlist = threshlist + def test_dend_features_at_step(fit_dend): assert len(fit_dend.features_at_step(48)) == 79 + def test_dend_find_set_of_size(fit_dend, capsys): assert fit_dend.find_set_of_size(80) == 6 - + + def test_dend_score_at_point(Xy, fit_dend): X, y = Xy - scores, fit_model = fit_dend.score_at_point(X, y, RandomForestClassifier(random_state=0), accuracy_score, 2) + scores, fit_model = fit_dend.score_at_point(X, y, + RandomForestClassifier(random_state=0), + accuracy_score, 2) assert len(scores) == 1 assert scores[0] - .866666 < .00001 + def test_dend_shuffle_all(fit_dend): keys_1 = set(fit_dend.graphs[1].keys()) fit_dend.shuffle_all_representatives() @@ -72,25 +81,28 @@ def test_dend_shuffle_all(fit_dend): def test_dend_shuffle_score_at_point(Xy, fit_dend): X, y = Xy keys_1 = set(fit_dend.graphs[1].keys()) - scores, _ = fit_dend.shuffle_score_at_point(X, y, RandomForestClassifier(), - accuracy_score, 2, 2) + scores, _ = fit_dend.shuffle_score_at_point(X, y, RandomForestClassifier(), + accuracy_score, 2, 2) assert set(fit_dend.graphs[1].keys()) != keys_1 assert len(scores) == 2 + def test_dend_transform(Xy, fit_dend, capsys): X, y = Xy X_new_1 = fit_dend.transform(X, 99) out1, _ = capsys.readouterr() X_new_2 = fit_dend.transform(X, 50) out2, _ = capsys.readouterr() - + assert X_new_1.shape[1] == int(out1[10:12]) assert X_new_2.shape[1] == int(out2[-3:-1]) + def test_dend_plot(fit_dend): show(dendrogram(fit_dend), static=True) show(dendrogram(fit_dend)) + def test_build_edges(capsys): fake_sel = selection.Dendrogram() fake_sel.adj = np.asarray(range(501)) @@ -98,16 +110,17 @@ def test_build_edges(capsys): output, _ = capsys.readouterr() split_output = output.split('\n') - + real_line_1 = 'Calculating more than 500 graphs' real_line_2 = 'You can pass max_threshes as a kwarg to Dendrogram' assert split_output[0] == real_line_1 assert split_output[1] == real_line_2 + def test_build_graphs_exit(): fake_sel = selection.Dendrogram() fake_sel.threshlist = [1, 2] - fake_sel.edges = [[(0, 1)], [(1, 2), (0, 1)]] + fake_sel.edges = [[(0, 1)], [(1, 2), (0, 1)]] fake_sel.graphs = [{0: {0, 1}, 2: {2}}, {0: {0, 1, 2}}] fake_sel._build_graphs() diff --git a/tox.ini b/tox.ini index 04e5e44..3201791 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py27, py36, py37, flake8 +envlist = flake8, py27, py36, py37 [travis] python = @@ -10,7 +10,9 @@ python = [testenv:flake8] basepython = python deps = flake8 -commands = flake8 henchman +commands = + flake8 henchman + flake8 tests [testenv] setenv = diff --git a/upload.sh b/upload.sh index 42a1c66..88bc552 100755 --- a/upload.sh +++ b/upload.sh @@ -2,6 +2,7 @@ versions="linux-64 win-64 osx-64" make clean +conda build . python setup.py sdist python setup.py bdist_wheel twine upload dist/* -r pypi