Skip to content

[WIP] Some test refactoring #322

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

Closed
wants to merge 1 commit into from

Conversation

massich
Copy link
Contributor

@massich massich commented Aug 17, 2017

Reference Issue

What does this implement/fix? Explain your changes.

Any other comments?

@pep8speaks
Copy link

pep8speaks commented Aug 17, 2017

Hello @massich! Thanks for updating the PR.

Cheers ! There are no PEP8 issues in this Pull Request. 🍻

Comment last updated on August 18, 2017 at 08:19 Hours UTC

@glemaitre glemaitre changed the title [RFC] Some test refactoring [WIP] Some test refactoring Aug 18, 2017
@glemaitre
Copy link
Member

I am fine with factorizing some tests. I put it WIP. Change to MRG once that you made a pass on the tests which might be factorized.

@massich
Copy link
Contributor Author

massich commented Aug 18, 2017

The changed tests are a single test not multiple therefore are written with an assert within a for. Give it a read.

cc: @glemaitre

@glemaitre
Copy link
Member

glemaitre commented Aug 18, 2017

They were a single test before as well. The difference is that you knew which line was failing but I hope that pytest will tell you the values of score_func and expected_values so it is fine.

@codecov
Copy link

codecov bot commented Aug 18, 2017

Codecov Report

Merging #322 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@          Coverage Diff          @@
##           master   #322   +/-   ##
=====================================
  Coverage      98%    98%           
=====================================
  Files          66     66           
  Lines        3860   3860           
=====================================
  Hits         3783   3783           
  Misses         77     77

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f02c565...bd0981f. Read the comment docs.

@massich
Copy link
Contributor Author

massich commented Aug 18, 2017

Just to have it somewhere (do not comment)

def test_ncr_check_threshold_cleaning_parameter():
    error_regex = "'threshold_cleaning' is a value between 0 and 1"
    for th in [-10, 10]:
        with raises(ValueError, match=error_regex):
            NeighbourhoodCleaningRule(threshold_cleaning=th).fit_sample(X, Y)
    for th in [0, 0.2, 1.]:
        with raises(None):
            NeighbourhoodCleaningRule(threshold_cleaning=th).fit_sample(X, Y)

also test_ratio_float_error():

def test_ratio_minority_under_sampling():
    error_regex = "'ratio'='majority' cannot be used with under-sampler."
    with raises(ValueError, match=error_regex):
        check_ratio('minority', np.array([1, 2, 3]), 'under-sampling')

def test_ratio_majority_over_sampling():
    error_regex = "'ratio'='majority' cannot be used with over-sampler."
    with raises(ValueError, match=error_regex):
        check_ratio('majority', np.array([1, 2, 3]), 'over-sampling')

The errors with the following regex smote needs to be a SMOTE are really wierd.

@massich
Copy link
Contributor Author

massich commented Mar 19, 2018

This PR was a place to play with pytest. But now pytest has been in imbalanced-learn for while. What do you guys want to do with it?

BTW, still no consensus regarding with raises(None)

@glemaitre
Copy link
Member

We should still update the tests such that they are parametrize and use properly pytest.
Regarding raises(None) I don't think that this is an issue for the moment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants