-
Notifications
You must be signed in to change notification settings - Fork 7
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: ♻️ Refactor DataFramePlot methods to improve clarity #1639
Conversation
Review changes with SemanticDiff. Analyzed 1 of 1 files. Overall, the semantic diff is 17% smaller than the GitHub diff.
|
Reviewer's Guide by SourceryThis pull request refactors the DataFramePlot class in the spectrafit/plugins/notebook.py file to improve code clarity and maintainability. The changes include breaking down large methods into smaller, more focused ones, improving naming conventions, and enhancing code readability. Class diagram for refactored DataFramePlot methodsclassDiagram
class DataFramePlot {
+plot_2dataframes(args_plot: PlotAPI, df_1: pd.DataFrame, df_2: Optional[pd.DataFrame])
+plot_dataframe(args_plot: PlotAPI, df: pd.DataFrame)
+plot_global_fit(args_plot: PlotAPI, df: pd.DataFrame)
+plot_metric(args_plot: PlotAPI, df_metric: pd.DataFrame, bar_criteria: Union[str, List[str]], line_criteria: Union[str, List[str]])
+update_layout_axes(fig: Figure, args_plot: PlotAPI, height: int)
+title_text(name: str, unit: Optional[str]) str
+get_minor(args_plot: PlotAPI) Dict[str, Union[str, bool]]
-_plot_single_dataframe(args_plot: PlotAPI, df: pd.DataFrame) Figure
-_plot_two_dataframes(args_plot: PlotAPI, df_1: pd.DataFrame, df_2: pd.DataFrame) Figure
-_create_residual_plot(df: pd.DataFrame, args_plot: PlotAPI) Figure
-_create_fit_plot(df: pd.DataFrame, args_plot: PlotAPI) Figure
-_update_plot_layout(fig: Figure, args_plot: PlotAPI, df_2_provided: bool)
}
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 @Anselmoo - I've reviewed your changes and they look great!
Here's what I looked at during the review
- 🟡 General issues: 2 issues found
- 🟢 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.
color_discrete_sequence=[args_plot.color.residual], | ||
) | ||
|
||
def _create_fit_plot(self, df: pd.DataFrame, args_plot: PlotAPI) -> Figure: |
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.
suggestion: Extract color and line dash mapping logic
The color and line dash mapping logic in this method could be extracted into a separate method. This would reduce code duplication and make it easier to maintain and update these mappings in the future.
def _create_fit_plot(self, df: pd.DataFrame, args_plot: PlotAPI) -> Figure:
"""Create the fit plot."""
color_dash_mapping = self._get_color_dash_mapping(args_plot)
return self._plot_fit(df, args_plot, color_dash_mapping)
def _get_color_dash_mapping(self, args_plot: PlotAPI) -> dict:
"""Get color and line dash mapping."""
return {
'color': args_plot.color,
'dash': args_plot.dash
}
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1639 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 44 44
Lines 4468 4492 +24
=========================================
+ Hits 4468 4492 +24
Flags with carried forward coverage won't be shown. Click here to find out more.
|
|
All PR-Submissions:
Pull Requests for the same
update/change?
New ✨✨ Feature-Submissions:
Changes to ⚙️ Core-Features:
us to include them?
Summary by Sourcery
Refactor the DataFramePlot class to enhance code clarity by breaking down the plot_2dataframes method into smaller, more manageable methods, and improve documentation for better understanding of the class's functionality.
Enhancements: