Refactor redundant SDG score rounding in aurora_api.py#42
Open
Tech-Psycho95 wants to merge 1 commit into
Open
Conversation
Replaced redundant float-to-string conversion with Python's built-in round() function for better readability, efficiency, and maintainability. No functional changes to output. Co-authored-by: Copilot <copilot@github.com> Signed-off-by: Tech-Psycho95 <shivamsingh.smn@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR addresses the issue of inefficient SDG score rounding in
backend/aurora_api.py. The current implementation uses a verbose and redundant method to round scores to three decimal places, which has been refactored to use Python's built-inround()function for improved code quality.Changes Made
backend/aurora_api.py(around line 75)sdg_predictions[sdg_name] = float(f"{float(score):.3f}")sdg_predictions[sdg_name] = round(score, 3)Why This Change?
The original code was unnecessarily complex and inefficient. By switching to
round(score, 3), it achieved:Testing
round(0.123456, 3)produces0.123).Closes #41
Checklist