Skip to content

Commit

Permalink
Release v0.0.4 (#34)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Seth-Rothschild authored Sep 25, 2018
1 parent db28131 commit f8c6449
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 14 deletions.
2 changes: 1 addition & 1 deletion henchman/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@

__author__ = '''Feature Labs Team'''
__email__ = 'team@featurelabs.com'
__version__ = '0.0.3'
__version__ = '0.0.4'
2 changes: 1 addition & 1 deletion meta.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package:
name: henchman
version: "0.0.3"
version: "0.0.4"

source:
path: ../henchman
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.0.3
current_version = 0.0.4
commit = True
tag = True

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
29 changes: 21 additions & 8 deletions tests/test_selection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand All @@ -72,42 +81,46 @@ 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))
fake_sel._build_edges(None)

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()

Expand Down
6 changes: 4 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py27, py36, py37, flake8
envlist = flake8, py27, py36, py37

[travis]
python =
Expand All @@ -10,7 +10,9 @@ python =
[testenv:flake8]
basepython = python
deps = flake8
commands = flake8 henchman
commands =
flake8 henchman
flake8 tests

[testenv]
setenv =
Expand Down
1 change: 1 addition & 0 deletions upload.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f8c6449

Please sign in to comment.