feat: support natom padding in deepmd/npy/mixed format#932
feat: support natom padding in deepmd/npy/mixed format#932wanghan-iapcm merged 2 commits intodeepmodeling:develfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## devel #932 +/- ##
==========================================
+ Coverage 86.27% 86.37% +0.09%
==========================================
Files 86 86
Lines 8032 8086 +54
==========================================
+ Hits 6930 6984 +54
Misses 1102 1102 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Merging this PR will not alter performance
|
📝 WalkthroughWalkthroughAdds padding support for DeepMD mixed-format: systems can be padded with virtual atoms (type -1) to a target atom count, grouped by padded size, then virtual atoms are stripped when assembling per-group data. Exposes atom_numb_pad through the plugin and adds tests for padding and per-atom data preservation. Changes
Sequence DiagramsequenceDiagram
participant User as User/API
participant MixSystem as mix_system()
participant PadTo as _pad_to()
participant Grouping as Grouping Logic
participant StripVirtual as _strip_virtual_atoms()
participant Storage as Mixed Format Output
User->>MixSystem: call mix_system(..., atom_numb_pad)
MixSystem->>PadTo: pad each system to target natoms
PadTo-->>MixSystem: padded system (virtual atoms type -1)
MixSystem->>Grouping: group systems by padded count
Grouping->>StripVirtual: for each group, strip virtual atoms
StripVirtual-->>Grouping: per-group stripped data
Grouping->>Storage: write grouped mixed-format subfolders by padded count
Storage-->>User: on-disk mixed-format with grouped subdirectories
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 3 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
No actionable comments were generated in the recent review. 🎉 🧹 Recent nitpick comments
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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@dpdata/deepmd/mixed.py`:
- Around line 92-146: In _strip_virtual_atoms, remove the unused local variable
`reserved` (it is never referenced) and update the function docstring return
section to match the actual returns (the function returns three items:
atom_types, coords, and extra_data/stripped) — replace the current four-return
description that lists `real_mask` with a corrected three-value description and
use consistent names (`atom_types`, `coords`, `extra_data` or `stripped`) to
match the actual return tuple and the callers that unpack three values.
🧹 Nitpick comments (1)
tests/test_deepmd_mixed.py (1)
797-899: Consider setting a random seed for reproducibility.The
fparamandaparamarrays are generated withnp.random.random(lines 838–846) without a fixed seed. While unlikely to cause issues in practice, pinningnp.random.seed(...)at the top ofsetUpmakes failures easier to reproduce.
Summary by CodeRabbit
New Features
Tests