-
Notifications
You must be signed in to change notification settings - Fork 110
Refactored faceting logic in dlgPICSARainfall class #10044
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 faceting logic in dlgPICSARainfall class #10044
Conversation
Summary of ChangesHello @Rockjunior, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request focuses on refactoring the faceting logic within the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
|
Fixes #10035 |
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.
Code Review
This pull request refactors the faceting logic, which is a good step towards improving code clarity. However, a significant amount of old code has been commented out. It is better to remove dead code to improve readability and maintainability, relying on version control to access historical code. I've left several comments suggesting the removal of this commented-out code. Additionally, I found a high-severity bug in the AddRemoveGroupBy method where the grouping for facet_grid is missing, which would lead to incorrect plots. I've provided a suggestion to fix this issue.
| Select Case ucrInputStation.GetText() | ||
| Case strFacetWrap | ||
| GetParameterValue(clsFacetOperator) | ||
| Case strFacetCol, strFacetColAll | ||
| GetParameterValue(clsFacetColOp) | ||
| Case strFacetRow, strFacetRowAll | ||
| GetParameterValue(clsFacetRowOp) | ||
| 'Case strFacetCol, strFacetColAll | ||
| ' GetParameterValue(clsVarsFunction) | ||
| 'Case strFacetRow, strFacetRowAll | ||
| ' GetParameterValue(clsFacetRowOp) | ||
| End Select |
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.
The grouping logic for facet_grid seems to be missing after the refactoring. When using facet_grid (i.e., for strFacetCol or strFacetRow), the faceting variable should be added to clsGroupByFunction to ensure that summary statistics are calculated per facet. Without this, summaries like mean lines will be calculated globally across all facets, leading to incorrect plots. The commented-out code suggests this was intended but incomplete, possibly due to a type mismatch with GetParameterValue.
Select Case ucrInputStation.GetText()
Case strFacetWrap
GetParameterValue(clsFacetOperator)
Case strFacetCol, strFacetColAll, strFacetRow, strFacetRowAll
If Not ucrReceiverFacetBy.IsEmpty Then
clsGroupByFunction.AddParameter(clsGroupByFunction.iParameterCount, ucrReceiverFacetBy.GetVariableNames(bWithQuotes:=False), bIncludeArgumentName:=False)
End If
End Select
instat/dlgPICSARainfall.vb
Outdated
| 'Private clsFacetRowOp As New ROperator | ||
| 'Private clsFacetColOp As New ROperator |
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.
instat/dlgPICSARainfall.vb
Outdated
| 'clsFacetRowOp = New ROperator | ||
| 'clsFacetColOp = New ROperator |
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.
instat/dlgPICSARainfall.vb
Outdated
| 'clsFacetRowOp.SetOperation("+") | ||
| 'clsFacetRowOp.bBrackets = False | ||
| 'clsFacetColOp.SetOperation("+") | ||
| 'clsFacetColOp.bBrackets = False |
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.
instat/dlgPICSARainfall.vb
Outdated
| clsFacetOperator.bForceIncludeOperation = True | ||
| clsFacetOperator.bBrackets = False | ||
| clsFacetFunction.AddParameter("facets", clsROperatorParameter:=clsFacetOperator, iPosition:=0) | ||
| 'clsFacetFunction.AddParameter("facets", clsROperatorParameter:=clsFacetOperator, iPosition:=0) |
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.
instat/dlgPICSARainfall.vb
Outdated
| 'clsFacetColOp.RemoveParameterByName("col" & ucrInputStation.Name) | ||
| 'clsFacetRowOp.RemoveParameterByName("row" & ucrInputStation.Name) |
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.
instat/dlgPICSARainfall.vb
Outdated
| Case strFacetCol, strFacetColAll | ||
| ucrReceiverFacetBy.ChangeParameterName("col" & ucrInputStation.Name) | ||
| ucrReceiverFacetBy.SetRCode(clsFacetColOp) | ||
| 'ucrReceiverFacetBy.SetRCode(clsFacetColOp) |
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.
instat/dlgPICSARainfall.vb
Outdated
| Case strFacetRow, strFacetRowAll | ||
| ucrReceiverFacetBy.ChangeParameterName("row" & ucrInputStation.Name) | ||
| ucrReceiverFacetBy.SetRCode(clsFacetRowOp) | ||
| 'ucrReceiverFacetBy.SetRCode(clsFacetRowOp) |
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.
instat/dlgPICSARainfall.vb
Outdated
| 'If bRow OrElse bRowAll Then | ||
| ' 'clsFacetOperator.AddParameter("left", clsROperatorParameter:=clsFacetRowOp, iPosition:=0) | ||
| 'ElseIf (bCol OrElse bColAll) AndAlso bWrap = False Then | ||
| ' clsFacetOperator.AddParameter("left", ".", iPosition:=0) | ||
| 'Else | ||
| ' clsFacetOperator.RemoveParameterByName("left") | ||
| 'End If | ||
|
|
||
| 'If bCol OrElse bColAll Then | ||
| ' clsFacetOperator.AddParameter("right", clsROperatorParameter:=clsFacetColOp, iPosition:=1) | ||
| 'ElseIf (bRow OrElse bRowAll) AndAlso bWrap = False Then | ||
| ' clsFacetOperator.AddParameter("right", ".", iPosition:=1) | ||
| 'Else | ||
| ' clsFacetOperator.RemoveParameterByName("right") | ||
| 'End If |
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.
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.
@anastasia-mbithe can you review this? It is to check that the plot works now for the PICSA rainfall graph when teh facet option is row, column, row + o, and column + o
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.
Looks good! Only issue I'm finding is when "none" is selected. At the moment it runs ggplot2::facet_wrap(), but actually we want to run nothing. We want to remove that function entirely, rather than the parameter value.
…d parameters and simplifying facet handling
Fixed Now |
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.
@Rockjunior nice! Works well and looks good to me. Good stuff.
@anastasia-mbithe I believe you were reviewing earlier. Are you happy or do you have any comments?
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.
This looks good.
Streamlined the faceting logic by removing unused operators and consolidating facet parameters. This enhances code clarity and maintainability.