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

Refactor core.transforms.generate_transforms() for ease of reading #148

Merged
merged 8 commits into from
Aug 28, 2024

Conversation

riley-harper
Copy link
Contributor

@riley-harper riley-harper commented Aug 27, 2024

Closes #141.

This PR refactors the core.transforms.generate_transforms() function by pulling out several functions defined within this larger function. The previous format with nested functions was difficult to read because generate_transforms() was several hundred lines long and because some of the nested functions closed over variables in generate_transforms(). After the refactor, some of the functions are still pretty long, but the module is much more navigable than before.

I've pulled the nested functions out as private functions in the core.transforms module. The public API of this module should not change at all with this change, and there shouldn't be any functionality changes either.

During the refactor, I also discovered the skip attribute which is available to all feature selection transforms. I added some tests for it and added it to the documentation.

Copy link

@ccdavis ccdavis left a comment

Choose a reason for hiding this comment

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

Makes sense to me. If the helper functions rely on state from the enclosing scope or it's not clear if they can be victims of side-effects or cause side-effects, they need to be improved. Making them into pure (or more pure) private functions makes is a good move.

@riley-harper riley-harper merged commit 914d58a into main Aug 28, 2024
6 checks passed
@riley-harper riley-harper deleted the refactor_core_transforms branch August 28, 2024 20:24
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.

Refactor and document the core/transforms.py module
2 participants