Repository navigation
feat: add molify.repeat to tile periodic boxes with their connectivity - #131
Conversation
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (4)
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughAdds and exports ChangesPeriodic Structure Repetition
Priority: ⬇️ Low Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Feature Merge Risk: ⚪ Minimal · up to The new repetition API has no identified issue requiring a fix before merge. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The change remains an in-process molecular-data transformation, with no demonstrated new privileged or externally reachable execution path. Its main design considerations are metadata consistency, failure containment, and memory growth for large repetition requests. Dependency copy semantics and concurrent input mutation were not fully verified. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 3.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 30 functions across 3 files. (1 skipped: 1 unsupported.)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
molify.repeat(atoms, rep) delegates the geometry to ase.Atoms.repeat and rebuilds info['connectivity'] and info['original_index'] for the repeated structure. Each bond links atom i to the nearest periodic image of atom j, so bonds across the cell boundary connect neighbouring copies; bond orders are kept. Image shifts come from ase.geometry.find_mic, which covers triclinic cells and partial periodicity. Invalid rep values, an original_index of the wrong length and bond indices outside the structure raise ValueError. The packmol docs gain a "Repeating a Box" section. Closes #129 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- raise ValueError for self-bonds and for bonds at least half the smallest periodic cell height long, such as the Si primitive cell - store bond orders as Python float, also after an extxyz round trip - remove info['smiles'] from the repeated structure, as pack does - validate rep with np.broadcast_to and read bonds inside _tile_bonds - check each tiled bond order against its source bond, run the triclinic test for rep 1, 2, (2, 1, 1), (1, 2, 3), and cover empty connectivity Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- check each bond against half the shortest vector of the Minkowski-reduced periodic lattice, so sheared bases of ordinary cells repeat - treat pbc along a zero-length cell vector as non-periodic - accept rep as one integer or exactly three integers - tile connectivity after atoms.repeat - test sheared cells, distance-based connectivity with None bond orders, Python int original_index, the plain ase result without connectivity, and the public export Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
70e2b87 to
e24d00e
Compare
|
@coderabbitai review |
✅ Action performedReview finished.
|
What changed
New
molify.repeat(atoms, rep) -> ase.Atomsinsrc/molify/repeat.py, exported frommolifyand listed in__all__.It calls
atoms.repeat(rep)for the geometry and rebuilds the index-basedinfoentries:connectivity: each bond(i, j, order)links atomito the nearest periodic image of atomj. Image shifts come fromase.geometry.find_micpluscell.scaled_positions, which covers triclinic cells and partial pbc. Apbcaxis with a zero-length cell vector counts as non-periodic. Indices are Pythonintand bond orders PythonfloatorNone, also after an extxyz round trip.original_index: tiled so that atomkgets the entry of source atomk % n.smilesis removed, as formolify.packboxes. Otherinfokeys follow ase. Atoms withoutconnectivityget a plain ase repeat.Explicit
ValueErrorfor:rep(0, negative, float, string, a length other than three). ase returns an empty structure or crashes for these.original_indexof the wrong length.Numpy integer
repvalues are accepted. Extxyz ndarray inputs work.docs/source/packmol_tools.ipynbhas a new "Repeating a Box" section with captured output.Why
ase.Atoms.repeattiles per-atom arrays and copiesinfoas is. On a wrapped 36-atom box,box.repeat((2, 1, 1))kept 30 bonds where 60 are expected, andase2rdkitreturned 42 fragments where 12 are expected. A staleoriginal_indexmadease2networkxraiseIndexError.Test evidence
tests/test_repeat.pyhas 20 tests (37 cases). They check against an independent oracle: the edges ofase2networkx(molify.repeat(atoms, rep))must equal the distance-based edges ofatoms.repeat(rep)with the stored bonds removed. Cases:1,2,(2, 1, 1),(1, 2, 3)b = (3L, L, 0)of a cubic boxpbc=Truealong its zero-length third vectorNonebond ordersoriginal_index,numpyints inoriginal_index, dropped, flattened orfloat(None)bond orders, a missing periodic mask, and a missing self-bond or bond-length check.uv run pytest -q -p no:cacheprovider: 501 passed.uvx prek --all-files: clean.ase2x.py,smiles2x.pyandcli.pyare untouched.Closes #129
🤖 Generated with Claude Code
Summary by CodeRabbit
repeatto repeat a periodic structure along one or more cell directions while preserving its connectivity, including bonds across periodic boundaries and bond orders.