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

Refactored codebase for improved clarity and readability #2

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

Georges-Procurified
Copy link

@Georges-Procurified Georges-Procurified commented Oct 16, 2024

Hello! I want to start by saying I love this project—it's been incredibly useful to me! I would love to contribute by performing some refactoring and cleanup to make the code more intuitive and self-documenting.

Here’s a summary of the changes I made:

  • Renamed variables and function parameters to more descriptive alternatives.
  • Split up larger helper functions into smaller, more manageable ones, and updated their names for clarity.
  • Moved utility and helper functions from fractional_indexing.py into separate modules for better organization.
  • Updated the test file to align with the new import paths and renamed exceptions.

All changes were tested locally, and I'm happy to report that 100% of the tests passed, maintaining the original functionality.

I’d love to know how I can contribute these changes back to the project. Could you guide me through the process?

Looking forward to your response!

Best regards,
Georges

Reordered the functions to follow a chronological order
Refactor and improve code readability for order key generation

- Improved function and variable naming for clarity (e.g., renamed `a`, `b`, `x`, `i` to `start_key`, `end_key`, `integer_str`, `integer_length`).
- Added comprehensive and consistent docstrings to all functions, providing better explanations for inputs, outputs, and behavior.
- Refactored `midpoint` logic to simplify complex calculations, improving readability and modularity.
- Broke down parts of `increment_integer` and `decrement_integer` into clearer steps.
- Applied input validation for functions to ensure robustness and better error handling (e.g., added checks in `generate_key_between`).
- Simplified redundant checks for `None` values across multiple functions by consolidating logic.
- Enhanced error messages in `OrderKeyError` for better debugging clarity.
- Applied type hints consistently across all functions.
- Added type hints across all functions
- renamed parameter n to number_of_keys
- renamed function midpoint to find_middle_key
- moved helper functions out of main fractional_indexing.py
- updated tests.py with new imports and error name
- moved handlers to main due to circular imports
- adjusted imports to be local, not relative
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.

1 participant