Skip to content

Commit

Permalink
Add tests in view for the new plot options (#43)
Browse files Browse the repository at this point in the history
* calculate cos^2 - sin^2 in model

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* add test

* math optimization

* comments in test

* add unit tests

* get rid ()

* pre-commit fix

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Andrei Savici <[email protected]>
  • Loading branch information
3 people authored Feb 17, 2025
1 parent f1704cf commit 75dbd9c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/hyspecppt/hppt/experiment_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
alpha + subscript_s,
"cos" + square + alpha + subscript_s,
"(1+cos" + square + alpha + subscript_s + ")/2",
"(cos" + square + alpha + subscript_s + "-sin" + square + alpha + subscript_s + ")",
"cos" + square + alpha + subscript_s + "-sin" + square + alpha + subscript_s,
]

# default parameters
Expand Down
23 changes: 23 additions & 0 deletions tests/hppt_view/test_basegui.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,26 @@ def test_selector_widget(qtbot):

assert selector_widget.powder_rb.text() == "Po&wder"
assert selector_widget.sc_rb.text() == "Single C&rystal"


def test_combo_box_plot_options():
"""Test the combo box text are set correctly"""
# unicode
alpha = "\u03b1"
square = "\u00b2"
subscript_s = "\u209b"

ExpWidget = hppt_view.ExperimentWidget()
ExpWidget.initializeCombo(PLOT_TYPES)
assert ExpWidget.Type_combobox.currentText() == alpha + subscript_s
ExpWidget.Type_combobox.setCurrentIndex(1)
assert ExpWidget.Type_combobox.currentText() == "cos" + square + alpha + subscript_s

ExpWidget.Type_combobox.setCurrentIndex(2)
assert ExpWidget.Type_combobox.currentText() == "(1+cos" + square + alpha + subscript_s + ")/2"

ExpWidget.Type_combobox.setCurrentIndex(3)
assert (
ExpWidget.Type_combobox.currentText()
== "cos" + square + alpha + subscript_s + "-sin" + square + alpha + subscript_s
)

0 comments on commit 75dbd9c

Please sign in to comment.