fix(dpa-adapt): resolve pre-commit ruff errors and descriptor hook accumulator - #48
Merged
Merged
Conversation
…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".
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.
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".