-
Notifications
You must be signed in to change notification settings - Fork 114
Add design matrix panel for parameters preview #8910
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
Conversation
b47bd57
to
25111b6
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #8910 +/- ##
==========================================
- Coverage 91.70% 91.59% -0.11%
==========================================
Files 343 344 +1
Lines 21235 21294 +59
==========================================
+ Hits 19473 19504 +31
- Misses 1762 1790 +28
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
65b1a97
to
372aaab
Compare
def __init__(self, ensemble_size: int, run_path: str, notifier: ErtNotifier): | ||
def __init__( | ||
self, | ||
analysis_config: AnalysisConfig, |
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.
Do we need the entire analysisconfig, or only designmatrix?
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.
Good question and I have thought about it and decided on using the entire config:
- other panels get the entire analysisconfig too and thus it makes the api more uniform
- when doing the validation ( not there yet), we might to access more of the configs
@@ -78,6 +83,23 @@ def __init__(self, ensemble_size: int, run_path: str, notifier: ErtNotifier): | |||
) | |||
layout.addRow("Active realizations", self._active_realizations_field) | |||
|
|||
design_matrix = analysis_config.design_matrix | |||
dm_param_button = QPushButton("Show parameters") |
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.
Can we rename dm_param_button
to show_dm_param_button
?
if design_matrix is not None: | ||
if design_matrix.design_matrix_df is None: | ||
design_matrix.read_design_matrix() | ||
if ( | ||
design_matrix.design_matrix_df is not None | ||
and not design_matrix.design_matrix_df.empty | ||
): | ||
viewer = DesignMatrixPanel(design_matrix.design_matrix_df) | ||
viewer.setMinimumHeight(500) | ||
viewer.setMinimumWidth(1000) | ||
viewer.adjustSize() | ||
viewer.exec_() | ||
|
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.
Can we add
if design_matrix is None:
return
and remove the indentation?
) -> None: | ||
super().__init__(parent) | ||
|
||
self.setWindowTitle("Design matrix parameters viewer") |
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.
Should we have the title as viewer or preview?
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.
What do you mean by title?
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.
Can we change:
self.setWindowTitle("Design matrix parameters viewer")
to
self.setWindowTitle("Design matrix parameters preview")
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.
Right, from this it sounds you are fine with both 😄
Should we have the title as viewer or preview?
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.
Yes, we can keep it as viewer 👌
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.
Just change it to: f"Design matrix parameters from {filename}"
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.
Even better :)
"design_matrix_entry", | ||
(True, False), | ||
) | ||
def test_that_design_matrix_show_parameters_button_is_enabled( |
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.
Here we are also testing that the button should be disabled, but I cannot think of a better name.
Maybe we can add to the test that when you push the button, the design matrix param viewer should pop up?
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.
Hm, like in another test or inside this one?
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.
We should really keep the unit tests at a unit level, but here I would test it in the same one. Then we would get to test the button visibility and the click functionality. We could call the test test_design_matrix_show_parameters_button
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.
I'd need to create a pandas frame and it'd become integration I think. But maybe it's still fine to have as unit though 🤷
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.
Ah, you are right. Let's keep it as is.
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.
Ah, you are right. Let's keep it as is.
I'll give it a go 😸
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 very good! See minor nitpicking 🚠
button_layout.addStretch() # Add stretch to push the button to the left | ||
|
||
layout.addRow("Design Matrix", button_layout) | ||
if design_matrix is not None: |
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.
I propose to only make the button if design_matrix exist, then it will be less confusion what this new but disabled thing is. And so only people that have actually set DESIGN_MATRIX
will see this option at all.
But can of course be up for discussion.
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.
I agree^
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.
Hm, I made it on purpose mainly due to testing. But could be done though.
) -> None: | ||
super().__init__(parent) | ||
|
||
self.setWindowTitle("Design matrix parameters viewer") |
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.
I would propose to include the xlsx filename in the title, for instance Parameters from some_file.xlsx
.
with patch.object( | ||
DesignMatrix, "design_matrix_df", design_matrix_df | ||
), patch.object(DesignMatrix, "xls_filename", Path(xls_filename)): | ||
qtbot.mouseClick(show_dm_parameters, Qt.LeftButton) |
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.
Can we also assert the new component is showing?
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.
I have removed it
- Button to show the parameters is shown when design_matrix is present - Add test for design matrix show parameters button
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.
LGTM!
Issue
Resolves #8825
Now it's rebased
Approach
Add a QDialog that shows pd.DataFrame as QTableView
(Screenshot of new behavior in GUI if applicable)
git rebase -i main --exec 'pytest tests/ert/unit_tests -n logical -m "not integration_test"'
)When applicable