Skip to content

Change GUI to show angles to 0.1°#951

Merged
alexdewar merged 2 commits intomainfrom
subdegree
Mar 30, 2026
Merged

Change GUI to show angles to 0.1°#951
alexdewar merged 2 commits intomainfrom
subdegree

Conversation

@alexdewar
Copy link
Copy Markdown
Collaborator

Description

Jon has asked for more precision in the angles you can use in the GUI and suggested 0.1° should be enough. Make this change.

We only need to update the frontend, as the backend already supports setting the angle to a float.

This is the thing I asked Copilot to do in our session this morn, which it seemed to manage in one pass. I've tested the GUI (I created a measure script and ran it) and it now works with fractional angles as expected. There could be some bugs lurking when we try it on real hardware, but it seems ok to me.

Closes #932.

Type of change

  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Documentation (non-breaking change that adds or improves the documentation)
  • Optimisation (non-breaking, back-end change that speeds up the code)

Key checklist

  • Pre-commit hooks run successfully (pre-commit run -a)
  • All tests pass (pytest)
  • The documentation builds without warnings (mkdocs build -s)
  • Check the GUI still works (if relevant)
  • Check the code works with actual hardware (if relevant)
  • Check the pyinstaller-built executable works (if relevant)

Further checks

  • Code is commented, particularly in hard-to-understand areas
  • Tests have been added or an issue has been opened to tackle that in the future. (Indicate issue here: # (issue))

Jon has asked for more precision in the angles you can use in the GUI and suggested 0.1°
should be enough. Make this change.

We only need to update the frontend, as the backend already supports setting the angle
to a `float`.

Closes #932.
Copilot AI review requested due to automatic review settings March 27, 2026 13:02
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 27, 2026

Codecov Report

❌ Patch coverage is 92.30769% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 87.28%. Comparing base (d9142dd) to head (7d8a12d).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
src/frog/gui/measure_script/sequence_widget.py 83.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #951      +/-   ##
==========================================
+ Coverage   87.27%   87.28%   +0.01%     
==========================================
  Files          69       69              
  Lines        3623     3627       +4     
==========================================
+ Hits         3162     3166       +4     
  Misses        461      461              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the GUI to allow users to input and view mirror angles with 0.1° precision (issue #932), aligning the frontend with the backend’s existing float-angle support.

Changes:

  • Replace integer-only angle inputs with QDoubleSpinBox controls configured for 0.1° steps and one decimal place.
  • Update displayed angle formatting across the GUI from whole degrees to one decimal place.
  • Adjust GUI tests to reflect the new fractional-angle behaviour and formatting.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/frog/gui/stepper_motor_view.py Switches target angle input to QDoubleSpinBox, formats position display to 0.1°, updates preset-name matching logic.
src/frog/gui/measure_script/sequence_widget.py Updates “Add instruction” angle input to 0.1° precision and displays sequence angles to one decimal place.
src/frog/gui/measure_script/script_run_dialog.py Updates “Moving to …” status text to show angles to one decimal place.
tests/gui/test_stepper_motor_view.py Updates expectations for float angle values and 0.1° formatted display strings.
tests/gui/measure_script/test_sequence_widget.py Updates GOTO angle tests to use floats and removes now-redundant manual clamping expectations.
tests/gui/measure_script/test_script_run_dialog.py Updates expected angle string formatting to one decimal place.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +99 to 104
text = f"{moved_to:.1f}°"
if preset := next(
(k for k, v in self.angle_presets.items() if round(v) == round(moved_to)),
(k for k, v in self.angle_presets.items() if abs(v - moved_to) <= 0.05),
None,
):
text += f" ({preset})"
Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

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

Preset name matching can become inconsistent with the displayed angle at the rounding boundary. For example, if moved_to is 180.05, the label will display 180.1° but will still match a 180.0 preset because the tolerance check uses <= 0.05. Consider matching presets based on the same 0.1° rounding used for display (e.g. compare rounded-to-1dp values, or ensure the formatted moved_to equals the formatted preset value) so the preset name is only shown when it agrees with what the user sees.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Hmm, it's true that users can now specify a preset to be a non-integer value since we made the positions of the hot and cold BBs configurable.

That said, I think it's probably fine if it displays this message when the position is approximately the same.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yeah, sounds fair to me

Copy link
Copy Markdown
Contributor

@dc2917 dc2917 left a comment

Choose a reason for hiding this comment

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

Looks good to me!

@alexdewar alexdewar merged commit d2753c5 into main Mar 30, 2026
11 checks passed
@alexdewar alexdewar deleted the subdegree branch March 30, 2026 12:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow users to specify angles to a sub-degree level

3 participants