Repository navigation
test: name why orix Misorientation.reduce misses the smallest angle - #43
Merged
Merged
Conversation
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
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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()takesend * M * startfor each symmetry pair and stops at the first one insideOrientationRegion.from_symmetry(start, end). That zone's distinguished points arestart.outer(end)= start . end. Thesmallest angle of
end * M * startlies in the Voronoi cell of the identity among end . start, the inverse set. The twosets 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 pairwhose 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.pyalso records orix own loop on the zone from (end, start) and asserts it is theminimum on every draw. The regenerated fixture only gains two fields per draw; every existing field is unchanged.
OrixMisorientationTestscompares 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.
Misorientation.swiftanddocs/open-items.mdname the cause. Reporting it upstream is leftto the owner.
Tests
OrixMisorientationTestsred before the pin regeneration (missing fields), green after: worst angle 3.9e-15, reducedmatrix 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