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

Unit tests for different subsamples #468

Merged
merged 5 commits into from
Jun 26, 2024

Conversation

BaptisteCalot
Copy link
Collaborator

@BaptisteCalot BaptisteCalot commented Jun 20, 2024

Description

This PR aims to create unit tests to verify that the train and test sets of the split method from Subsample and BlockBootstrap classes are different even though the random state is the same

Fix issue #290

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

  • 2 unit tests

Checklist : OK

  • I have read the contributing guidelines
  • I have updated the HISTORY.rst and AUTHORS.rst files
  • Linting passes successfully : make lint
  • Typing passes successfully : make type-check
  • Unit tests pass successfully : make tests
  • Coverage is 100% : make coverage
  • Documentation builds successfully : make doc

Copy link
Collaborator

@LacombeLouis LacombeLouis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this PR! Great! @BaptisteCalot
Note that the outputs should be of the same style in MAPIE. So the correction should not be applied here but rather directly in the original file. Note that you should make sure that if they are changes, we should consider why they occur and if they can be resolved without forcing the typing.

mapie/tests/test_subsample.py Outdated Show resolved Hide resolved
length=length, random_state=0)
trains = [x[0] for x in cv.split(X)]
tests = [x[1] for x in cv.split(X)]
for i in range(n_resamplings):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't forget to use combinations instead of the loop! :)

)
trains2 = [x[0] for x in list(cv2.split(X))]
tests2 = [x[1] for x in list(cv2.split(X))]
np.testing.assert_array_equal(trains1, trains2)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather have the same test i.e. assert_equal also here

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (614293e) to head (d8bf01e).
Report is 499 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##            master      #468    +/-   ##
==========================================
  Coverage   100.00%   100.00%            
==========================================
  Files           39        41     +2     
  Lines         4616      5106   +490     
  Branches       487       871   +384     
==========================================
+ Hits          4616      5106   +490     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@BaptisteCalot BaptisteCalot merged commit a8f80a6 into master Jun 26, 2024
8 checks passed
@BaptisteCalot BaptisteCalot deleted the 290-unit-tests-for-different-subsamples branch June 26, 2024 12:11
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