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

test: create unit tests for MapReduce #300

Closed

Conversation

bk958178
Copy link
Contributor

@bk958178 bk958178 commented Dec 21, 2023

PR Type

  • Tests

Description

Unit tests for MapReduce() class, in ReductionStrategy() in reduction.py.

How Has This Been Tested?

TODO. Tests currently failing due to missing dependencies

Does this PR introduce a breaking change?

No

Screenshots

Checklist before requesting a review

  • I have made sure that my PR is not a duplicate.
  • My code follows the style guidelines of this project.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have performed a self-review of my code.
  • I have made corresponding changes to the documentation.
  • My changes generate no new warnings.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.
  • Any dependent changes have been merged and published in downstream modules.

@bk958178 bk958178 requested a review from tp832944 December 21, 2023 20:58
Copy link
Contributor

@tp832944 tp832944 left a comment

Choose a reason for hiding this comment

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

@bk958178 This tests the interface as I expect it. Good work! I've thought of one more easily testable part of the algorithm.

strategy = cr.MapReduce(num_points=10, leaf_size=20)
coreset = cc.RandomSample()
coreset.original_data = orig_data
strategy.reduce(coreset)
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we add a check that the recursive call is working correctly please? MapReduce._reduce_recursive should be called at least twice.

I'm sure there's some complicated mocking that could make the number of calls and what is sent to each call deterministic. If you can quickly work out how to do it, great; otherwise, don't worry.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good call adding this check.
I think we can do this with .call_count. See my latest commit. Thanks in advance for re-reviewing!

Copy link
Contributor

Choose a reason for hiding this comment

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

That's the principle of what I wanted, but I think you need to patch _reduce_recursive before you can do this. https://docs.python.org/3/library/unittest.mock.html#unittest.mock.patch

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've patched the method. Thanks in advance for re-re-reviewing 🎾

@bk958178 bk958178 requested a review from tp832944 December 22, 2023 10:37
strategy = cr.MapReduce(num_points=10, leaf_size=20)
coreset = cc.RandomSample()
coreset.original_data = orig_data
strategy.reduce(coreset)
Copy link
Contributor

Choose a reason for hiding this comment

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

That's the principle of what I wanted, but I think you need to patch _reduce_recursive before you can do this. https://docs.python.org/3/library/unittest.mock.html#unittest.mock.patch

Base automatically changed from feature/create_data_reduction_abc to feature/oop_106 January 3, 2024 11:02
@bk958178 bk958178 requested a review from tp832944 January 3, 2024 12:33
@tp832944 tp832944 linked an issue Jan 4, 2024 that may be closed by this pull request
@bk958178 bk958178 changed the base branch from feature/oop_106 to feature/updates_for_tests_310 January 4, 2024 15:11
@bk958178
Copy link
Contributor Author

bk958178 commented Jan 9, 2024

This PR is closing as it is outdated. The up-to-date PR for testing MapReduce is #317

@bk958178 bk958178 closed this Jan 9, 2024
@tp832944 tp832944 deleted the feature/test_map_reduce branch January 16, 2024 17:29
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.

Write tests for MapReduce
2 participants