Skip to content

refactor!: drop unused public API and split PhaseVectorMatching.swift - #34

Merged
Paullo9 merged 2 commits into
mainfrom
issue-19-dead-code-split
Oct 29, 2026
Merged

Paullo9 merged 2 commits into
mainfrom
issue-19-dead-code-split

Conversation

@Paullo9

@Paullo9 Paullo9 commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

Requested by Paul

From the 27 Oct audit (#19):

  • Removed Misorientation.mapIntoSymmetryReducedZone() and PhaseVectorResult.inPlaneDegrees. Neither mac4DSTEM nor macTEM uses them (checked their sources).
  • package: LinearScale.compactShellLabel(_:) (tests only).
  • Deprecated: OrientationMapAnalysis.patternInPlaneAnglePlane(_:) (one test, no consumer).
  • Kept: IndexingDisplay.refusalText / isAccepted and the 0.10.0 additions.
  • Internal: ReflectionList.families() passes Policy.effectiveFamilyTolerance, which had no use before. The value is unchanged because families(of:) sanitises it again.
  • Split, move only: PhaseVectorMatching.swift (1879 lines) now keeps the method header, vector conversion, nearest and score, the whole-scan map and disk claims (442 lines). The value types are in PhaseVectorTypes.swift, the zone-axis and matrix-orientation fits in PhaseVectorMatcher+ZoneAxisFit.swift, and classification, the known-variants rule and the orientation relationship in PhaseVectorMatcher+Classify.swift. The tests are split the same way: PhaseVectorMatchingTests+Classify.swift extends the same suite and keeps all 43 tests. A sorted line diff shows every moved line is unchanged. No source file is over 1500 lines.

No numbers change. The fast unit target, the consumer check, SwiftLint and SwiftFormat all pass locally.

Migration

  • Misorientation.mapIntoSymmetryReducedZone(): use reduce().
  • PhaseVectorResult.inPlaneDegrees: convert inPlaneRotationRad (inPlaneRotationRad * 180 / .pi).
  • LinearScale.compactShellLabel(_:) is no longer public. Copy the four lines if you need them.
  • OrientationMapAnalysis.patternInPlaneAnglePlane(_:) is deprecated and will be removed in a later minor. Compute it from inPlaneAnglePlane and mirroredPlane: subtract 0.5 where mirrored, then wrap to [0, 1).

Fixes #19

🤖 Generated with Claude Code

Removes Misorientation.mapIntoSymmetryReducedZone() (an alias of reduce())
and PhaseVectorResult.inPlaneDegrees, neither used by mac4DSTEM or macTEM.
LinearScale.compactShellLabel(_:) becomes package (tests only);
OrientationMapAnalysis.patternInPlaneAnglePlane(_:) is deprecated.
ReflectionList.families() now passes Policy.effectiveFamilyTolerance, the
property that had no use (same value: families(of:) sanitises again).

PhaseVectorMatching.swift (1879 lines) is split, move only: value types to
PhaseVectorTypes.swift, the zone-axis and matrix-orientation fits to
PhaseVectorMatcher+ZoneAxisFit.swift, one-pattern classification, the
known-variants rule and the orientation relationship to
PhaseVectorMatcher+Classify.swift. The matching tests split the same way
(PhaseVectorMatchingTests+Classify.swift, an extension of the same suite).
Every moved line is unchanged; no number moves.

Done: issue #19's removals, deprecations and the split; no source file over
1500 lines. Next: release-please ships it as 0.11.0 with the Migration lines.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Paullo9 Paullo9 self-assigned this Oct 29, 2026
@Paullo9

Paullo9 commented Oct 29, 2026

Copy link
Copy Markdown
Contributor Author

Second review (public API)

Verdict: cleared. The remaining notes are nits, and none blocks the merge.

Reviewed at head 06469f3 against base 1560723. This was a read-only review. CI (test, lint, private refs) is green and no build was run here.

1. Removed, narrowed and deprecated symbols: no consumer uses them

I searched origin/main of mac4DSTEM, macTEM, MacEMUI, SpectroKit, CuboKit, ImagoKit, SimulatoKit and FormatoKit, plus DiffractoKit's own Sources, Tests, tools and docs at the PR head:

  • Misorientation.mapIntoSymmetryReducedZone(): no hits outside the historical CHANGELOG 0.10.0 entry.
  • PhaseVectorResult.inPlaneDegrees: no hits anywhere.
  • LinearScale.compactShellLabel(_:) (Sources/DiffractoGeometry/LinearScaleAssignment.swift:195, now package): used only by Tests/DiffractoGeometryTests/LinearScaleAssignmentTests.swift:122-125. Tests in the same package can still reach it. tools/consumer-check does not use it.
  • OrientationMapAnalysis.patternInPlaneAnglePlane(_:) (Sources/DiffractoOrientation/OrientationMapAnalysis.swift:60, deprecated): used only by Tests/DiffractoOrientationTests/ACOMMatcherTests.swift:768.

2. The split is move-only

  • The sorted, whitespace-normalised lines of the old PhaseVectorMatching.swift and of the four new source files are the same multiset, with these exceptions:
    • the removed inPlaneDegrees line;
    • the new file headers;
    • the import lines;
    • the two extension PhaseVectorMatcher { and closing } lines.
  • The test files give the same result (header, imports, extension PhaseVectorMatchingTests {). There are 43 @Test before and 24 + 19 = 43 after.
  • git diff --color-moved=plain --color-moved-ws=allow-indentation-change confirms that every other line moves as a contiguous block, so nothing was reordered inside a function. No access modifier changed.
  • ReflectionList.families() (Sources/DiffractoCore/ReflectionList.swift:260) now passes policy.effectiveFamilyTolerance. That is defined at :124 as isFinite && >= 0 ? value : 0, the same rule families(of:...) applies at :268. The value is identical for every input, NaN and negative included.

3. Migration, title and parity

  • The title refactor!: is correct. bump-minor-pre-major: true is set, so this gives 0.11.0, not 1.0.0.
  • The Migration paragraph is accurate:
    • mapIntoSymmetryReducedZone() was exactly reduce().
    • inPlaneDegrees was inPlaneRotationRad * 180 / .pi.
    • The patternInPlaneAnglePlane recipe ("subtract 0.5 where mirrored, wrap to [0, 1)") matches the implementation at OrientationMapAnalysis.swift:63-65.
  • docs/parity.md: the misorientation row drops mapIntoSymmetryReducedZone(), and the mirror-plane row marks patternInPlaneAnglePlane as deprecated. No number or tolerance changed, which is consistent with "no numbers change".

Nits (no change needed for this PR)

  • NOTICE:89 still names PhaseVectorMatching.swift as the home of the vector-matching method and of the .knownVariants rule. That rule now lives in PhaseVectorMatcher+Classify.swift. Consider listing the split files (PhaseVectorMatching.swift, PhaseVectorMatcher+ZoneAxisFit.swift, PhaseVectorMatcher+Classify.swift) so the Thronsen attribution covers the code it describes.
  • Tests/DiffractoOrientationTests/ACOMMatcherTests.swift:768 calls the now-deprecated function, which adds a deprecation warning to the test build. It goes away when the function is removed.
  • Consumer comment, outside this repo: mac4DSTEM mac4DSTEM/Session/PhaseMappingProduct.swift:251 (and :11, NOTICE:244) points to PhaseVectorMatching.swift "The known-variants rule". That rule is now in PhaseVectorMatcher+Classify.swift. Worth a one-line fix when mac4DSTEM re-pins to 0.11.

🤖 Generated with Claude Code

…lds without a warning

NOTICE now points the Thronsen-attributed .knownVariants rule at
PhaseVectorMatcher+Classify.swift. The mirror-plane test calls the deprecated
patternInPlaneAnglePlane through a protocol witness, so it keeps checking the
same values without a test-build warning.

Done: the two review nits on #34. Next: Paul merges #34.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Paullo9
Paullo9 merged commit 8acda80 into main Oct 29, 2026
6 checks passed
@Paullo9
Paullo9 deleted the issue-19-dead-code-split branch October 29, 2026 14:21
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.

Dead code, unused public API and the PhaseVectorMatching split

1 participant