Skip to content

Commit

Permalink
Common entry-widget for MainGui and SFCalculatorUI
Browse files Browse the repository at this point in the history
* create deadtime entry widget

Signed-off-by: Jose Borreguero <[email protected]>

* add default pull request template

Signed-off-by: Jose Borreguero <[email protected]>

* deadtime_entry for the sf_calculator

Signed-off-by: Jose Borreguero <[email protected]>

* deadtime
 options for the main GUI

Signed-off-by: Jose Borreguero <[email protected]>

* deadtime
 unit tests for DeadTimeEntryPoint

Signed-off-by: Jose Borreguero <[email protected]>

* deadtime
 unit tests for SFCalculator.apply_deadtime_update

Signed-off-by: Jose Borreguero <[email protected]>

* deadtime
 unit tests for SFCalculator.show_dead_time_dialog

Signed-off-by: Jose Borreguero <[email protected]>

* tyring different string to fool flake8

Signed-off-by: Jose Borreguero <[email protected]>

* tyring different string to fool flake8

Signed-off-by: Jose Borreguero <[email protected]>

* tyring different string to fool flake8

Signed-off-by: Jose Borreguero <[email protected]>

* test for file not in the data server

Signed-off-by: Jose Borreguero <[email protected]>

* QtCore.Qt. instead of Qt.

Signed-off-by: Jose Borreguero <[email protected]>

* ignore silly errors by mypy

Signed-off-by: Jose Borreguero <[email protected]>

* ignore silly errors by mypy

Signed-off-by: Jose Borreguero <[email protected]>

* unit tests for MainGui.apply_deadtime_update and for MainGui.show_deadtime_settings

Signed-off-by: Jose Borreguero <[email protected]>

* ammend the pull-request template

Signed-off-by: Jose Borreguero <[email protected]>

---------

Signed-off-by: Jose Borreguero <[email protected]>
  • Loading branch information
jmborr authored Apr 28, 2024
1 parent afa1750 commit b1e4ae1
Show file tree
Hide file tree
Showing 17 changed files with 1,073 additions and 287 deletions.
8 changes: 0 additions & 8 deletions .github/PULL_REQUEST_TEMPLATE/pull_request_template.md

This file was deleted.

37 changes: 37 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# References
- EWM #
<!-- Links to related issues or pull requests -->

# Description of the changes:
<!-- description here. -->

# Manual test for the reviewer
Before running the manual tests, install the conda environment and install the source in editable mode
```bash
> conda env create --solver libmamba --name refred-dev --file ./environment.yml
> conda activate refred-dev
(refred-dev)> pip install -e .
```
Start RefRed GUI
```bash
(refred-dev)> PYTHONPATH=$(pwd):$PYTHONPATH ./scripts/start_refred.py
```
Or run tests
```bash
(refred-dev)> pytest test/unit/RefRed/test_main.py
```

# Check list for the reviewer
- [ ] I have verified the proposed changes
- [ ] Author included tests for the proposed changes
- [ ] best software practices
+ [ ] clearly named variables (better to be verbose in variable names)
+ [ ] code comments explaining the intent of code blocks
+ [ ] new functions and classes detailed docstrings, parameters documented
- [ ] All tests are passing
- [ ] Documentation is up to date

# Check list for the author
- [ ] I have added tests for my changes
- [ ] I have updated the documentation accordingly
- [ ] I included a link to IBM EWM Story or Defect
2 changes: 1 addition & 1 deletion RefRed/configuration/loading_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def populate_main_gui_general_settings(self):
o_scaling_factor_widget.set_enabled(status=scaling_factor_flag)

use_dead_time = str2bool(self.getNodeValue(node_0, 'dead_time_correction'))
self.parent.ui.deadtime_checkbox.setChecked(use_dead_time)
self.parent.ui.deadtime_entry.applyCheckBox.setChecked(use_dead_time)

def getMetadataObject(self, node) -> LConfigDataset:
r"""Populate an instance of type LConfigDataset using the information contained in one of the
Expand Down
8 changes: 1 addition & 7 deletions RefRed/initialization/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,7 @@ def __init__(self, parent):

# This is the angle offset box, which is no longer needed
# but kept for advanced usage
self.parent.ui.groupBox_4.setVisible(False)

# This is the TOF steps, which we also don't need at the moment
self.parent.ui.eventTofBins.setVisible(False)
self.parent.ui.label_33.setVisible(False)
self.parent.ui.label_29.setVisible(False)

self.parent.ui.AngleOffsetGroupBox.setVisible(False)
self.parent.ui.sf_button.setChecked(True)

# Select the `DATA` tab as the currently active one
Expand Down
41 changes: 41 additions & 0 deletions RefRed/interfaces/deadtime_entry.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# third party imports
from qtpy.QtWidgets import QGroupBox, QHBoxLayout, QCheckBox, QPushButton


class DeadTimeEntryPoint(QGroupBox):
def __init__(self, title='Dead Time Correction'):
super().__init__(title)
self.initUI()

def initUI(self):
# Set the stylesheet for the group box to have a border
self.setStyleSheet(
"QGroupBox {"
" border: 1px solid gray;"
" border-radius: 5px;"
" margin-top: 1ex;" # space above the group box
"} "
"QGroupBox::title {"
" subcontrol-origin: margin;"
" subcontrol-position: top center;" # align the title to the center
" padding: 0 3px;"
"}"
)

self.applyCheckBox = QCheckBox('Apply', self)
self.applyCheckBox.stateChanged.connect(self.toggleSettingsButton)
self.settingsButton = QPushButton('Settings', self)
self.settingsButton.setEnabled(self.applyCheckBox.isChecked()) # enabled if we use the correction

# Create a horizontal layout for the checkbox and settings button
hbox = QHBoxLayout()
hbox.addWidget(self.applyCheckBox)
hbox.addWidget(self.settingsButton)
hbox.addStretch(1) # This adds a stretchable space after the button (optional)

# Set the layout for the group box
self.setLayout(hbox)

def toggleSettingsButton(self, state):
# Enable the settings button if the checkbox is checked, disable otherwise
self.settingsButton.setEnabled(state)
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,14 @@ def __init__(self, parent: QWidget):
self.ui = load_ui(ui_filename="deadtime_settings.ui", baseinstance=self)
self.options = self.get_state_from_form()

def set_state(self, apply_correction, paralyzable, dead_time, tof_step):
def set_state(self, paralyzable, dead_time, tof_step):
"""
Store options and populate the form
:param apply_correction: If True, dead time correction will be applied
:param paralyzable: If True, a paralyzable correction will be used
:param dead_time: Value of the dead time in micro second
:param tof_step: TOF binning in micro second
"""
self.ui.apply_correction.setChecked(apply_correction)
self.ui.use_paralyzable.setChecked(paralyzable)
self.ui.dead_time_value.setValue(dead_time)
self.ui.dead_time_tof.setValue(tof_step)
Expand All @@ -32,7 +31,6 @@ def get_state_from_form(self):
Read the options from the form.
"""
options = {}
options['apply_correction'] = self.ui.apply_correction.isChecked()
options['paralyzable'] = self.ui.use_paralyzable.isChecked()
options['dead_time'] = self.ui.dead_time_value.value()
options['tof_step'] = self.ui.dead_time_tof.value()
Expand Down
76 changes: 22 additions & 54 deletions RefRed/interfaces/deadtime_settings.ui
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,22 @@
<rect>
<x>0</x>
<y>0</y>
<width>472</width>
<height>214</height>
<width>428</width>
<height>150</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>439</width>
<height>150</height>
</size>
</property>
<property name="windowTitle">
<string>Dead Time Settings</string>
</property>
Expand All @@ -22,43 +34,6 @@
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QCheckBox" name="apply_correction">
<property name="text">
<string/>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Enable/Disable background subtraction&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Apply dead time correction</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
Expand All @@ -73,6 +48,12 @@
</item>
<item>
<widget class="QLabel" name="label_3">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Use two background regions to estimate the background under the peak&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
Expand Down Expand Up @@ -183,8 +164,8 @@
</property>
<property name="maximumSize">
<size>
<width>130</width>
<height>16777215</height>
<width>0</width>
<height>100</height>
</size>
</property>
<property name="decimals">
Expand All @@ -203,19 +184,6 @@
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
Expand Down
Loading

1 comment on commit b1e4ae1

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GitLab pipeline for refred-dev has been submitted for this commit: "https://code.ornl.gov/sns-hfir-scse/deployments/conda-legacy-deploy/-/pipelines/559688"

Please sign in to comment.