fix: scope basis unit conversion to touched atom(s) (spec §5.2) - #208
Closed
timurbazhirov wants to merge 1 commit into
Closed
Conversation
commitMovedAtoms_/addAtom/cloneSelectedAtoms placed a touched atom's coordinate by flipping the whole basis to Cartesian and back around the mutation - Basis.toCartesian()/toCrystal() round-trip every atom's coordinate via mapArrayInPlace, not just the touched one, so spec §5.2's "untouched atoms preserved bit-for-bit because they are never re-derived" claim didn't fully hold in the implementation. Convert only the touched point(s) directly via basis.cell.convertPointToCrystal/convertPointToCartesian instead, so untouched atoms' coordinate entries are genuinely never read or rewritten and each edit does O(touched) matrix work instead of O(n). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
5 tasks
This was referenced Aug 12, 2026
Member
Author
|
Closing — consolidated into #216 (then #214 on top). Verified contained: this PR's head The branch Generated by Claude Code |
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.
Summary
commitMovedAtoms_/addAtom/cloneSelectedAtomsplaced a touched atom's coordinate by flipping the whole basis to Cartesian and back (basis.toCartesian()/toCrystal()) around the mutation.Basis.toCartesian/toCrystalround-trip every atom's coordinate viamapArrayInPlace, not just the touched one — so spec §5.2's "untouched atoms preserved bit-for-bit because they are never re-derived" claim didn't fully hold in the implementation, even though it was invisible in practice (Basisrounds every coordinate toCell.roundPrecision, 9 decimals, on serialize, which absorbs a single round-trip's float noise for any reasonably-conditioned cell — verified directly against@mat3ra/made, including deliberately ill-conditioned lattices).basis.cell.convertPointToCrystal/convertPointToCartesianinstead, at all three call sites. Untouched atoms' coordinate entries are now genuinely never read or rewritten, and each edit does O(touched) matrix work instead of O(n).plan/interactive-editor-spec-plan.md's "Chained PR stack" section for the full writeup.Test plan
"Basis unit-conversion scoped to touched atoms (spec §5.2)"intests/__tests__/mixins/interactive_structure_editor.js: 3 tests spy on the ephemeral basis instanceapplyBasisDelta_builds per commit (scoped to that instance, not the sharedBasisprototype, since the wave legitimately callstoCartesian/toCrystalelsewhere for unrelated reasons) proving no whole-basis round-trip happens; 3 more assert untouched atoms' coordinates stay exactly unchanged and a moved atom's committed crystal coordinate round-trips to its exact dragged Cartesian position.git stashof just the source change).tsc --noEmitclean.npm run lintclean (0 errors; only pre-existingno-explicit-anywarnings matching this file's established convention).npm run buildclean.🤖 Generated with Claude Code