Skip to content

[GUI] Let edit boxes half a pixel apart in MATLAB land on neighbouring pixels - #1059

Merged
arnodelorme merged 44 commits into
developfrom
agent/issue-875-geometry-half-pixel-edits
Dec 1, 2026
Merged

arnodelorme merged 44 commits into
developfrom
agent/issue-875-geometry-half-pixel-edits

Conversation

@arnodelorme

Copy link
Copy Markdown
Collaborator

tests/test_gui_geometry.py::test_drawn_dialog_has_matlab_rows_and_aligned_edit_boxes fails on GitHub's Ubuntu runner for pop_newtimef and pop_newtimef.continuous since #994 added these two cases (assert 504 == 505). It passes on jamming, where the MATLAB references were measured.

Cause. The test takes two edit boxes as "at the same position" when MATLAB places them less than half a pixel apart, and then asks EEGPrep for exactly the same pixel. In the pop_newtimef reference the edit boxes start at 493.415 and 493.905 pixels: they are 0.49 pixel apart, not equal. With the window width the runner's fonts give, the two starts round to 504 and 505.

Change. Edit boxes that are exactly aligned in MATLAB must still start on the same pixel. Edit boxes that MATLAB places a fraction of a pixel apart may start on neighbouring pixels. No source code changes.

Tests. tests/test_gui_geometry.py: 256 passed on jamming (Linux), 174 passed and 82 skipped on macOS (the pixel checks only run on Linux). The failing case itself only shows on the GitHub runner, so its Ubuntu job is the real check.

Part of #875

🤖 Generated with Claude Code

# Conflicts:
#	docs/source/user_guide/study_workflows.rst
#	tests/test_study_measures.py

@claude claude Bot left a comment

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.

⚠️ Code review skipped — your organization has no extra usage available to pay for this review.

If your organization's extra usage balance is empty, an organization admin can add extra usage credits at claude.ai/admin-settings/usage. If its monthly spend limit was reached, an admin can raise it on the same page. If neither applies, contact Anthropic support.

Once extra usage is available, someone with write access to this repository can comment @claude review on this pull request to trigger a review.

@claude

claude Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @arnodelorme's task in 27s —— View job


🤖 Review of #1059

  • Pre-review gate (open, not a draft, no earlier review; checked-out HEAD 0af8cc5 matches the PR head)
  • Read AGENTS.md §Testing and tests/test_gui_geometry.py
  • Review passes: AGENTS.md compliance, conventions, correctness

Verdict: looks good. I found no blocking or important issues.

What I checked

  • Correctness. The old check had two thresholds that didn't match. It treated MATLAB edit boxes less than 0.5 px apart as aligned, then asked for exactly the same pixel in Qt. Two starts that are 0.49 px apart, such as 493.415 and 493.905, can land on either side of a rounding boundary once the window scales them, so the test failed depending on font metrics. The new check keeps exact equality for edit boxes that are truly aligned (apart < 1e-6) and allows a ±1 px difference only for sub-pixel gaps. Scaling the 0.49 px gap by the window ratio (about 504/493.4 ≈ 1.02) still gives less than 1 px, so the two rounded starts can never be 2 px apart. The <= 1 limit is tight.
  • Tolerance policy (AGENTS.md). This is not a loosened tolerance hiding a mismatch. The old assertion claimed more than the MATLAB reference shows. Boxes that are exactly aligned, which is the case that catches real layout regressions, are still checked exactly.
  • Scope. The change touches only the test, with no runtime or numerical effect, so no MATLAB reference run is needed.

Nits (optional)

  1. tests/test_gui_geometry.py:348: the comment above the loop still says edit boxes that start at the same position in MATLAB "start at the same position here". With the new branch, something like "exactly aligned MATLAB edit boxes share a pixel; sub-pixel offsets may differ by one pixel" would describe what the test now does.
  2. 1e-6 is a magic number. It works for MATLAB's float serialization, since the file already notes values like 24.000000000000014. Using round(apart, 12) == 0, as the control_height check above does, would keep the style consistent.

The real check is still the Ubuntu CI job for pop_newtimef and pop_newtimef.continuous, as the PR body says.

@arnodelorme arnodelorme left a comment

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.

This review was written by an AI assistant during a nightly check, not by Arno.

Code review

  • Overall assessment: Safe to merge.
  • Highest-risk area: Edit box alignment threshold in tests/test_gui_geometry.py.
  • Merge recommendation: Safe to merge once Linux CI passes.

Blocking

None.

Important

None.

Nits

None.

Test gaps

None.

EEGLAB parity notes

None.

Checked all 82 reference dialog geometries in tools/gui_geometry/reference/, _FigureLayout.setGeometry rounding in src/eegprep/functions/guifunc/qt.py, EEGLAB parity with pop_newtimef.m ([0.975, 1.27] vs [1, 0.3, ...]), and AGENTS.md compliance. Truly aligned MATLAB edit boxes (apart < 1e-6 across all recorded cases) still require exact pixel equality (<= 0), while the 0.49 pixel offset in pop_newtimef and pop_newtimef.continuous stays below 1 pixel after dialog width scaling and can differ by at most 1 pixel after integer rounding.

Tests run locally on macOS at commit 0af8cc5cee86e678c69648bb52004b3cc8627bc9: PYTHONPATH=<worktree>/src:<worktree> .venv/bin/python -m pytest <worktree>/tests/test_gui_geometry.py gave 174 passed, 82 skipped in 12.43s (the pixel placement test runs only on Linux).

arnodelorme and others added 10 commits December 1, 2026 09:43
[GUI] Match the pop_dipfit_headmodel dialog on configured MRI data
[GUI] Match the pop_leadfield dialog on configured MRI data
[GUI] Match the pop_dipfit_settings dialog on configured MRI data
[GUI] Match the pop_dipfit_nonlinear dialog on configured MRI data
Keep develop's PUBLIC_CALLS table and add the two pop_runica cases,
keep both documentation paragraphs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
[GUI] Run the ERP image MATLAB pixel gap check on Linux only
pop_precomp: Restore separate channel and component precomputation dialogs
pop_clustedit: Restore cluster editing actions and content-sized rows
Keep the reviewed one-pixel tolerance and develop's pop_runica test.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@arnodelorme
arnodelorme merged commit 1aabd18 into develop Dec 1, 2026
4 checks passed
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.

1 participant