Skip to content

fix(dpa-adapt): resolve pre-commit ruff errors and descriptor hook accumulator - #48

Merged
zhaiwenxi merged 1 commit into
zhaiwenxi:masterfrom
zirenjin:master
Jun 25, 2026
Merged

fix(dpa-adapt): resolve pre-commit ruff errors and descriptor hook accumulator#48
zhaiwenxi merged 1 commit into
zhaiwenxi:masterfrom
zirenjin:master

Conversation

@zirenjin

Copy link
Copy Markdown

Add type annotations across the dpa_adapt library (ANN), replace print() with logging in example scripts (T201), annotate mutable class defaults with ClassVar (RUF012), replace legacy np.random.rand with Generator API (NPY002), escape regex metacharacters in pytest match patterns (RUF043), fix implicit Optional annotations (RUF013), ambiguous unicode (RUF002), zip() strict= (B905), docstring formatting (D301/D400), dict() → literal (C408), and TC003 import placement.

Also fix _DescriptorExtraction._resolve_descriptor_hook_model to prefer atomic_model over dp_model. dp_model delegates set_eval_descriptor_hook and eval_descriptor to atomic_model but lacks the eval_descriptor_list attribute, so _clear_accumulator was a no-op. Descriptors from systems with different atom counts accumulated across forward passes, causing torch.concat to fail with "Expected size 5 but got size 4".

…k accumulator

Add type annotations across the dpa_adapt library (ANN), replace print()
with logging in example scripts (T201), annotate mutable class defaults
with ClassVar (RUF012), replace legacy np.random.rand with Generator API
(NPY002), escape regex metacharacters in pytest match patterns (RUF043),
fix implicit Optional annotations (RUF013), ambiguous unicode (RUF002),
zip() strict= (B905), docstring formatting (D301/D400), dict() → literal
(C408), and TC003 import placement.

Also fix _DescriptorExtraction._resolve_descriptor_hook_model to prefer
atomic_model over dp_model. dp_model delegates set_eval_descriptor_hook
and eval_descriptor to atomic_model but lacks the eval_descriptor_list
attribute, so _clear_accumulator was a no-op. Descriptors from systems
with different atom counts accumulated across forward passes, causing
torch.concat to fail with "Expected size 5 but got size 4".
@zhaiwenxi
zhaiwenxi merged commit dd91555 into zhaiwenxi:master Jun 25, 2026
58 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants