-
Notifications
You must be signed in to change notification settings - Fork 15
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: improvementfactor #1416
Conversation
Reviewer's Guide by SourceryThis pull request refactors the No diagrams generated as the changes look simple and do not need a visual representation. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @weibullguy - I've reviewed your changes and they look great!
Here's what I looked at during the review
- 🟢 General issues: all looks good
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Does this PR introduce a breaking change?
Summary of Changes
Feature Enhancement: Dynamic Handling of User Floats in calculate_improvement Function
This PR refactors the calculate_improvement function to dynamically handle any number of user_float_X values passed as keyword arguments (kwargs). Previously, the function was limited to handling exactly 5 user_float_X values. Now, it can accommodate an arbitrary number of user_float_X inputs, improving flexibility.
Key Changes:
Dynamic Collection of user_float_X Values:
The function now iterates over all kwargs that start with user_float_ and collects them dynamically. This allows for greater flexibility in the number of inputs.
Multiplication of All User Floats:
The function multiplies all user_float_X values together, no longer being restricted to a fixed set of 5 user floats.
Default to 1.0:
If no user_float_X values are passed, the function defaults to multiplying by 1.0, ensuring the weight calculation remains valid.
Error Handling for Non-Numeric Values:
The function raises a ValueError if any of the user_float_X values are not numeric (int or float), ensuring robust input validation.
Additional Improvements:
Removed the need for #type: ignore by validating and converting inputs more explicitly.
Simplified the calculation logic by dynamically iterating over the floats in kwargs.
Tests Added:
Added test cases to ensure the function correctly handles various numbers of user_float_X inputs (e.g., 2, 5, or no floats).
Added validation tests to check that non-numeric user_float_X values raise appropriate exceptions.
Pull Request Checklist
Code Style
Static Checks
this PR.
Tests
Chores
this PR. These problem areas have been decorated with an ISSUE: # comment.
Summary by Sourcery
Refactor the calculate_improvement function to dynamically handle any number of user_float_X values, enhancing flexibility and input validation. Add comprehensive tests to ensure correct functionality and robust error handling.
New Features:
Enhancements:
Tests: