Skip to content

Commit

Permalink
Merge pull request #59 from UBC-MDS/increase_coverage
Browse files Browse the repository at this point in the history
Increase coverage
  • Loading branch information
topspinj authored Mar 10, 2018
2 parents d9239a5 + a803cb9 commit f9f9e83
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 10 deletions.
17 changes: 7 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,28 +73,25 @@ python -m pytest tests/test_forward_selection.py

$ py.test --cov=pypunisher tests/

============================================================================ test session starts =============================================================================
platform darwin -- Python 3.6.3, pytest-3.4.1, py-1.5.2, pluggy-0.6.0
...
plugins: cov-2.5.1
collected 12 items
collected 13 items

tests/test_backward_selection.py . [ 8%]
tests/test_criterion.py .... [ 41%]
tests/test_forward_selection.py . [ 50%]
tests/test_selection.py ...... [100%]
...

---------- coverage: platform darwin, python 3.6.3-final-0 -----------
Name Stmts Miss Cover
---------------------------------------------------------------
pypunisher/__init__.py 2 0 100%
pypunisher/__init__.py 4 0 100%
pypunisher/_checks.py 19 1 95%
pypunisher/metrics/__init__.py 1 0 100%
pypunisher/metrics/criterion.py 28 3 89%
pypunisher/selection_engines/__init__.py 2 0 100%
pypunisher/selection_engines/_utils.py 20 4 80%
pypunisher/selection_engines/selection.py 90 15 83%
pypunisher/selection_engines/_utils.py 20 2 90%
pypunisher/selection_engines/selection.py 90 11 88%
---------------------------------------------------------------
TOTAL 162 23 86%
TOTAL 164 17 90%
```

## Contributors:
Expand Down
21 changes: 21 additions & 0 deletions tests/test_selection.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,18 @@ class Model(object):

forward_output = forward()

# Run using the other parameter option
forward_output += forward(n_features=1, min_change=None)

# Force the backward selection algorithm to
# select the single feature it thinks is most predictive.
# If implemented correctly, `backward()` should be able to
# identify `TRUE_BEST_FEATURE` as predictive.
backward_output = backward(n_features=1)

# Run using the other parameter option
backward_output += backward(min_change=0.0001, n_features=None)


# -----------------------------------------------------------------------------
# Test outputs: Type
Expand All @@ -97,6 +103,21 @@ def test_bsel_output_type():
output_type(backward_output)


# -----------------------------------------------------------------------------
# Test `n_features`
# -----------------------------------------------------------------------------


def test_n_features():
"""
Test various version of n_features
"""
for n_features in (10000, -1.0):
with pytest.raises(ValueError): # should raise
backward(n_features=n_features)
backward(n_features=0.5) # this should not raise


# -----------------------------------------------------------------------------
# Test outputs: Selection of the Predictive Feature
# -----------------------------------------------------------------------------
Expand Down

0 comments on commit f9f9e83

Please sign in to comment.