Refactor: Fix missing imports, scope issues, and remove hardcoded weather data in plotting script - #199
Open
lavjeetrai wants to merge 1 commit into
Open
Refactor: Fix missing imports, scope issues, and remove hardcoded weather data in plotting script#199lavjeetrai wants to merge 1 commit into
lavjeetrai wants to merge 1 commit into
Conversation
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.
Summary:
This PR refactors the route visualization script to resolve runtime errors and improve its flexibility as a command-line tool.
Before: The script failed to execute due to missing
matplotlibandgraphicsimports. It also relied heavily on global variables (likefigurefile) inside the plotting functions, which broke modularity. Furthermore, weather data and map bounding boxes were hardcoded in the__main__block, limiting the tool's reusability. It also contained redundantif/elselogic in theplot_power_vs_dist_ratiosfunction that executed the same code regardless of the condition.After: * Imports & Scope Fixes: Added missing imports and refactored plotting functions to accept
figurefileas an explicit argument, eliminatingNameErrorexceptions and global scope reliance.argparseparameters (--departure-time,--plot-time,--time-forecast,--bbox), preserving the original values as defaults. Users can now define these dynamically without modifying the script.Dependencies:
No new external dependencies were introduced, though
matplotlib.pyplotis now explicitly imported and required for this script to run.PR Checklist:
In the context of this PR, I: