Skip to content

test: name why orix Misorientation.reduce misses the smallest angle - #43

Merged
Paullo9 merged 2 commits into
mainfrom
issue-13-orix-reduce
Oct 31, 2026
Merged

Paullo9 merged 2 commits into
mainfrom
issue-13-orix-reduce

Conversation

@Paullo9

@Paullo9 Paullo9 commented Oct 31, 2026

Copy link
Copy Markdown
Contributor

Requested by Paul · project thread

Part of #13 (the reduce() disagreement). Remaining: the Orientation API gaps (separate PR).

Cause

orix 0.15.0 Misorientation.reduce() takes end * M * start for each symmetry pair and stops at the first one inside
OrientationRegion.from_symmetry(start, end). That zone's distinguished points are start.outer(end) = start . end. The
smallest angle of end * M * start lies in the Voronoi cell of the identity among end . start, the inverse set. The two
sets agree only when the product set is a group (for example when one group normalises the other). For 432 with 622 and
23 with 3 they differ: on some draws no equivalent lies inside the zone and the loop falls through to its last pair, on
others it stops at a larger angle inside the wrong zone.

What would refute it: failures that persist with the zone built as from_symmetry(end, start), or failures on a pair
whose product set is a group. Experiment against orix 0.15.0, 300 draws on each of 15 pairs: orix wrong on 9 (432/622),
9 (622/432), 36 (23/3), 29 (3/23), 10 (432/3) draws and on none of the 10 pairs whose product is a group; the same orix
loop with the zone from (end, start) is wrong on 0 draws of every pair. An independent re-run (200 fresh draws) agreed.

Change

The kit already returns the smallest angle, which is what orix documents. No kit numerics change.

  • tools/pins/orix/misorientation-pins.py also records orix own loop on the zone from (end, start) and asserts it is the
    minimum on every draw. The regenerated fixture only gains two fields per draw; every existing field is unchanged.
  • OrixMisorientationTests compares the kit with that orix loop on every draw (angle atol 1e-4, orix test tolerance;
    reduced matrix 1e-9 where the minimum is unique) instead of a brute-force fallback where orix is not minimal.
  • The DEVIATION note in Misorientation.swift and docs/open-items.md name the cause. Reporting it upstream is left
    to the owner.

Tests

  • OrixMisorientationTests red before the pin regeneration (missing fields), green after: worst angle 3.9e-15, reduced
    matrix 5.6e-16; orix shipped reduce above the minimum on 4 pinned draws.
  • swift test -c release --skip DiffractoKitParityTests: 170 tests green.

🤖 Generated with Claude Code

Paullo9 and others added 2 commits October 31, 2026 02:48
The orix misorientation pins gain orderedZoneAngle and orderedZoneReduced per draw: orix 0.15.0 runs its own
Misorientation.reduce loop with OrientationRegion.from_symmetry(end, start) instead of (start, end). The script
asserts that this returns the smallest angle on every draw. Every existing field of the fixture is unchanged
(same seed, same draws); the file only gains the two fields.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
orix 0.15.0 takes end * M * start and stops at the first one inside OrientationRegion.from_symmetry(start, end),
whose distinguished points are start . end. The smallest angle of end * M * start lies in the Voronoi cell of the
identity among end . start, the inverse set. The two agree only when the product set is a group; for 432 with 622
and 23 with 3 the zone holds no equivalent on some draws and the loop falls through to its last pair. With the zone
built as from_symmetry(end, start) the same orix loop returns the smallest angle on every draw.

The kit already returns the smallest angle; the parity test now compares it with that orix loop on every draw
(angle atol 1e-4, the orix test tolerance; reduced matrix 1e-9 where the minimum is unique) instead of falling back
to brute force where orix is not minimal. The DEVIATION note and docs/open-items.md name the cause.

Done: the reduce disagreement is diagnosed and pinned. Next: the Orientation API gaps of the same issue.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Paullo9 Paullo9 self-assigned this Oct 31, 2026
@Paullo9
Paullo9 merged commit 7354509 into main Oct 31, 2026
6 checks passed
@Paullo9
Paullo9 deleted the issue-13-orix-reduce branch October 31, 2026 09:41
Paullo9 added a commit that referenced this pull request Oct 31, 2026
#43 landed on main as a squash. docs/open-items.md conflicted on the orix API gaps item: kept this branch rewrite (from_euler, dot, dotOuter and distanceMatrix for one group are held). The diff against main equals the diff this PR had against #43.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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