deepmodeling / deepmd-kit

A deep learning package for many-body potential energy representation and molecular dynamics
https://docs.deepmodeling.com/projects/deepmd/
GNU Lesser General Public License v3.0
1.41k stars 486 forks source link

chore: replace `reduciable` with `reducible` #3888

Closed njzjz closed 1 week ago

njzjz commented 2 weeks ago

Fix the spelling as suggested by https://github.com/deepmodeling/deepmd-kit/pull/3867#discussion_r1642260309.

Summary by CodeRabbit

These changes improve the clarity and correctness of the codebase, ensuring that attribute names are consistent and accurately reflect their intended functionality.

coderabbitai[bot] commented 2 weeks ago
Walkthrough ## Walkthrough This update corrects a typo across multiple files in the `deepmd` codebase, specifically changing the attribute name `reduciable` to `reducible`. This correction ensures consistency in the codebase and affects logic related to the reducibility of various output variables in models, fitting procedures, inferences, and tests. ## Changes | File or Group of Files | Change Summary | |-----------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------| | `deepmd/dpmodel/atomic_model/base_atomic_model.py` | Corrected the `reduciable` attribute to `reducible` in `atomic_output_def`. | | `deepmd/dpmodel/atomic_model/linear_atomic_model.py`, …/pairtab_atomic_model.py | Corrected the `reduciable` attribute to `reducible` in fitting output definitions. | | `deepmd/dpmodel/fitting/dipole_fitting.py`, …/invar_fitting.py`, …/polarizability_fitting.py` | Corrected the `reduciable` attribute to `reducible` for differentiation-related variables and output definitions. | | `deepmd/dpmodel/model/transform_output.py` | Changed `reduciable` to `reducible` within functions affecting output transformation. | | `deepmd/dpmodel/output_def.py` | Corrected `reduciable` to `reducible` across the class `OutputVariableDef` and related functions. | | `deepmd/infer/deep_dos.py`, …/deep_polar.py`, …/deep_pot.py`, …/deep_tensor.py` | Corrected `reduciable` to `reducible` within the `output_def` functions for various inference tasks. | | `deepmd/pt/model/atomic_model/base_atomic_model.py` | Changed `reduciable` to `reducible` in `atomic_output_def`. | | `deepmd/pt/model/atomic_model/linear_atomic_model.py`, …/pairtab_atomic_model.py` | Corrected `reduciable` to `reducible` in the `OutputVariableDef` within fitting output definitions. | | `deepmd/pt/model/model/transform_output.py` | Changed `reduciable` to `reducible` in functions handling model output transformations. | | `deepmd/pt/model/task/denoise.py`, …/dos.py`, …/ener.py`, …/invar_fitting.py`, …/polarizability.py` | Changed `reduciable` to `reducible` in multiple `output_def` functions affecting various tasks. | | `source/tests/common/dpmodel/test_dp_atomic_model.py`, …/test_output_def.py` | Corrected the `reduciable` attribute to `reducible` within test cases. | | `source/tests/pt/model/test_atomic_model_atomic_stat.py`, …/test_atomic_model_global_stat.py` | Corrected `reduciable` to `reducible` in `OutputVariableDef` declarations within test files. | | `source/tests/pt/model/test_dp_atomic_model.py`, …/test_linear_atomic_model_stat.py` | Corrected `reduciable` to `reducible` in specific test functions. |

Recent review details **Configuration used: CodeRabbit UI** **Review profile: CHILL**
Commits Files that changed from the base of the PR and between 0c472d1596ae24b5b548ae6ae38688dbab911de5 and 9a9b941379f5d0786d19412ed3c9abe8ab7687f9.
Files selected for processing (29) * deepmd/dpmodel/atomic_model/base_atomic_model.py (1 hunks) * deepmd/dpmodel/atomic_model/linear_atomic_model.py (1 hunks) * deepmd/dpmodel/atomic_model/pairtab_atomic_model.py (1 hunks) * deepmd/dpmodel/fitting/dipole_fitting.py (2 hunks) * deepmd/dpmodel/fitting/invar_fitting.py (1 hunks) * deepmd/dpmodel/fitting/polarizability_fitting.py (1 hunks) * deepmd/dpmodel/model/transform_output.py (2 hunks) * deepmd/dpmodel/output_def.py (11 hunks) * deepmd/infer/deep_dos.py (1 hunks) * deepmd/infer/deep_polar.py (1 hunks) * deepmd/infer/deep_pot.py (2 hunks) * deepmd/infer/deep_tensor.py (1 hunks) * deepmd/infer/deep_wfc.py (1 hunks) * deepmd/pt/model/atomic_model/base_atomic_model.py (1 hunks) * deepmd/pt/model/atomic_model/linear_atomic_model.py (1 hunks) * deepmd/pt/model/atomic_model/pairtab_atomic_model.py (1 hunks) * deepmd/pt/model/model/transform_output.py (2 hunks) * deepmd/pt/model/task/denoise.py (1 hunks) * deepmd/pt/model/task/dipole.py (2 hunks) * deepmd/pt/model/task/dos.py (1 hunks) * deepmd/pt/model/task/ener.py (1 hunks) * deepmd/pt/model/task/invar_fitting.py (1 hunks) * deepmd/pt/model/task/polarizability.py (1 hunks) * source/tests/common/dpmodel/test_dp_atomic_model.py (1 hunks) * source/tests/common/dpmodel/test_output_def.py (15 hunks) * source/tests/pt/model/test_atomic_model_atomic_stat.py (1 hunks) * source/tests/pt/model/test_atomic_model_global_stat.py (1 hunks) * source/tests/pt/model/test_dp_atomic_model.py (1 hunks) * source/tests/pt/model/test_linear_atomic_model_stat.py (2 hunks)
Files skipped from review due to trivial changes (9) * deepmd/dpmodel/atomic_model/linear_atomic_model.py * deepmd/dpmodel/model/transform_output.py * deepmd/infer/deep_polar.py * deepmd/infer/deep_pot.py * deepmd/infer/deep_tensor.py * deepmd/infer/deep_wfc.py * deepmd/pt/model/atomic_model/pairtab_atomic_model.py * deepmd/pt/model/model/transform_output.py * source/tests/common/dpmodel/test_dp_atomic_model.py
Additional context used
Ruff
deepmd/pt/model/task/dos.py
48-48: Do not use mutable data structures for argument defaults (B006) Replace with `None`; initialize within function --- 58-58: Do not use mutable data structures for argument defaults (B006) Replace with `None`; initialize within function
deepmd/pt/model/task/denoise.py
32-32: Do not use mutable data structures for argument defaults (B006) Replace with `None`; initialize within function
deepmd/pt/model/task/invar_fitting.py
89-89: Do not use mutable data structures for argument defaults (B006) Replace with `None`; initialize within function --- 99-99: Do not use mutable data structures for argument defaults (B006) Replace with `None`; initialize within function
deepmd/pt/model/task/dipole.py
82-82: Do not use mutable data structures for argument defaults (B006) Replace with `None`; initialize within function --- 91-91: Do not use mutable data structures for argument defaults (B006) Replace with `None`; initialize within function
source/tests/pt/model/test_linear_atomic_model_stat.py
179-179: Local variable `f` is assigned to but never used (F841) Remove assignment to unused variable `f`
deepmd/dpmodel/fitting/dipole_fitting.py
92-92: Do not use mutable data structures for argument defaults (B006) Replace with `None`; initialize within function --- 105-105: Do not use mutable data structures for argument defaults (B006) Replace with `None`; initialize within function
deepmd/pt/model/task/ener.py
50-50: Do not use mutable data structures for argument defaults (B006) Replace with `None`; initialize within function
deepmd/dpmodel/fitting/invar_fitting.py
120-120: Do not use mutable data structures for argument defaults (B006) Replace with `None`; initialize within function --- 135-135: Do not use mutable data structures for argument defaults (B006) Replace with `None`; initialize within function
deepmd/pt/model/task/polarizability.py
86-86: Do not use mutable data structures for argument defaults (B006) Replace with `None`; initialize within function --- 95-95: Do not use mutable data structures for argument defaults (B006) Replace with `None`; initialize within function
deepmd/dpmodel/atomic_model/base_atomic_model.py
40-40: Do not use mutable data structures for argument defaults (B006) Replace with `None`; initialize within function --- 41-41: Do not use mutable data structures for argument defaults (B006) Replace with `None`; initialize within function --- 87-87: Do not use mutable data structures for argument defaults (B006) Replace with `None`; initialize within function --- 97-97: Do not use mutable data structures for argument defaults (B006) Replace with `None`; initialize within function --- 201-201: Use `key in dict` instead of `key in dict.keys()` (SIM118) Remove `.keys()` --- 247-247: Use `key in dict` instead of `key in dict.keys()` (SIM118) Remove `.keys()`
deepmd/dpmodel/fitting/polarizability_fitting.py
97-97: Do not use mutable data structures for argument defaults (B006) Replace with `None`; initialize within function --- 110-110: Do not use mutable data structures for argument defaults (B006) Replace with `None`; initialize within function
source/tests/pt/model/test_atomic_model_atomic_stat.py
171-171: Local variable `f` is assigned to but never used (F841) Remove assignment to unused variable `f` --- 341-341: Local variable `f` is assigned to but never used (F841) Remove assignment to unused variable `f`
deepmd/dpmodel/output_def.py
107-107: Use `key in dict` instead of `key in dict.keys()` (SIM118) Remove `.keys()` --- 436-436: Loop control variable `kk` not used within loop body (B007) Rename unused `kk` to `_kk`
source/tests/pt/model/test_atomic_model_global_stat.py
173-173: Local variable `f` is assigned to but never used (F841) Remove assignment to unused variable `f` --- 490-490: Local variable `at` is assigned to but never used (F841) Remove assignment to unused variable `at`
deepmd/pt/model/atomic_model/base_atomic_model.py
80-80: Do not use mutable data structures for argument defaults (B006) Replace with `None`; initialize within function --- 81-81: Do not use mutable data structures for argument defaults (B006) Replace with `None`; initialize within function --- 95-95: Local variable `ntypes` is assigned to but never used (F841) Remove assignment to unused variable `ntypes` --- 129-129: Do not use mutable data structures for argument defaults (B006) Replace with `None`; initialize within function --- 139-139: Do not use mutable data structures for argument defaults (B006) Replace with `None`; initialize within function --- 254-254: Use `key in dict` instead of `key in dict.keys()` (SIM118) Remove `.keys()` --- 542-542: Use `key in dict` instead of `key in dict.keys()` (SIM118) Remove `.keys()` --- 543-543: Use `key in dict` instead of `key in dict.keys()` (SIM118) Remove `.keys()`
source/tests/common/dpmodel/test_output_def.py
482-482: Local variable `context` is assigned to but never used (F841) Remove assignment to unused variable `context` --- 492-492: Local variable `context` is assigned to but never used (F841) Remove assignment to unused variable `context` --- 496-496: Local variable `context` is assigned to but never used (F841) Remove assignment to unused variable `context` --- 509-509: Local variable `context` is assigned to but never used (F841) Remove assignment to unused variable `context` --- 522-522: Local variable `context` is assigned to but never used (F841) Remove assignment to unused variable `context` --- 608-608: Do not use mutable data structures for argument defaults (B006) Replace with `None`; initialize within function --- 609-609: Do not use mutable data structures for argument defaults (B006) Replace with `None`; initialize within function --- 661-661: Local variable `nall` is assigned to but never used (F841) Remove assignment to unused variable `nall` --- 693-693: Do not use mutable data structures for argument defaults (B006) Replace with `None`; initialize within function
Additional comments not posted (32)
deepmd/pt/model/task/dos.py (1)
`94-94`: Correct spelling change from `reduciable` to `reducible` enhances consistency and correctness.
deepmd/infer/deep_dos.py (1)
`51-51`: Correct spelling change from `reduciable` to `reducible` enhances consistency and correctness.
deepmd/pt/model/task/denoise.py (1)
`80-80`: Correct spelling change from `reduciable` to `reducible` enhances consistency and correctness. Also applies to: 87-87
deepmd/pt/model/task/invar_fitting.py (1)
`151-151`: Correct spelling change from `reduciable` to `reducible` enhances consistency and correctness.
deepmd/pt/model/task/dipole.py (2)
`69-69`: Corrected the spelling of "reducible" in the comments describing the properties of `r_differentiable` and `c_differentiable`. Also applies to: 72-72 --- `145-145`: Corrected the spelling of "reducible" in the `output_def` method. This change aligns with the stated PR objectives and ensures consistency across the codebase.
source/tests/pt/model/test_linear_atomic_model_stat.py (1)
`55-55`: Corrected the spelling of "reducible" in the `output_def` method for both `FooFittingA` and `FooFittingB` classes. This change aligns with the stated PR objectives and ensures consistency across the codebase. Also applies to: 107-107
source/tests/pt/model/test_dp_atomic_model.py (1)
`174-174`: Corrected the spelling of "reducible" in the `test_excl_consistency` method. This change aligns with the stated PR objectives and ensures consistency across the codebase.
deepmd/dpmodel/fitting/dipole_fitting.py (2)
`79-79`: Corrected the spelling of "reducible" in the comments describing the properties of `r_differentiable` and `c_differentiable`. Also applies to: 82-82 --- `175-175`: Corrected the spelling of "reducible" in the `output_def` method. This change aligns with the stated PR objectives and ensures consistency across the codebase.
deepmd/pt/model/task/ener.py (2)
`166-166`: Corrected typo in the `OutputVariableDef` for "energy". --- `173-173`: Corrected typo in the `OutputVariableDef` for "dforce".
deepmd/dpmodel/fitting/invar_fitting.py (1)
`204-204`: Corrected typo in the `OutputVariableDef`.
deepmd/pt/model/task/polarizability.py (1)
`219-219`: Corrected typo in the `OutputVariableDef` for "polarizability".
deepmd/dpmodel/atomic_model/base_atomic_model.py (1)
`114-114`: Corrected typo in the `OutputVariableDef` for "mask".
deepmd/dpmodel/fitting/polarizability_fitting.py (3)
Line range hint `75-117`: Constructor logic for unsupported configurations is correctly implemented. --- `218-218`: Spelling correction from `reduciable` to `reducible` is correctly applied. --- Line range hint `218-333`: The `call` method is well-structured and correctly implements the model computation logic.
deepmd/dpmodel/atomic_model/pairtab_atomic_model.py (1)
`102-102`: Spelling correction from `reduciable` to `reducible` is correctly applied.
source/tests/pt/model/test_atomic_model_atomic_stat.py (1)
Line range hint `1-400`: The test cases are comprehensive and correctly test the functionality of atomic models.
deepmd/dpmodel/output_def.py (6)
`68-68`: Corrected spelling from `reduciable` to `reducible`. --- `169-169`: Corrected spelling from `reduciable` to `reducible` in the class `OutputVariableDef`. Also applies to: 195-195, 211-211 --- `410-410`: Corrected spelling from `reduciable` to `reducible` and made logical adjustments in the `do_reduce` function. Also applies to: 415-415 --- `432-432`: Corrected spelling from `reduciable` to `reducible` in the `do_mask` function. Also applies to: 442-442 --- `461-461`: Corrected spelling from `reduciable` to `reducible` and made logical adjustments in the `do_derivative` function. Also applies to: 473-473, 488-488, 498-498 --- `173-173`: Ensure consistency in the logical conditions related to `reducible` and `atomic`. Also applies to: 216-216
source/tests/pt/model/test_atomic_model_global_stat.py (3)
`60-60`: Corrected typo in the attribute name enhances code readability and consistency. --- `67-67`: Typo correction aligns with the project's standards for attribute names. --- `74-74`: Spelling correction ensures consistency in attribute naming across the module.
deepmd/pt/model/atomic_model/linear_atomic_model.py (1)
`296-296`: Corrected attribute name spelling improves consistency and readability.
deepmd/pt/model/atomic_model/base_atomic_model.py (1)
`179-179`: Corrected the typo from 'reduciable' to 'reducible' in the `atomic_output_def` method.
source/tests/common/dpmodel/test_output_def.py (1)
`43-43`: Corrected the typo from 'reduciable' to 'reducible' in various test definitions. Also applies to: 52-52, 61-61, 70-70, 78-78, 104-108, 163-167
--- Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
Share - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)
Tips ### Chat There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai): - Review comments: Directly reply to a review comment made by CodeRabbit. Example: - `I pushed a fix in commit .` - `Generate unit testing code for this file.` - `Open a follow-up GitHub issue for this discussion.` - Files and specific lines of code (under the "Files changed" tab): Tag `@coderabbitai` in a new review comment at the desired location with your query. Examples: - `@coderabbitai generate unit testing code for this file.` - `@coderabbitai modularize this function.` - PR comments: Tag `@coderabbitai` in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples: - `@coderabbitai generate interesting stats about this repository and render them as a table.` - `@coderabbitai show all the console.log statements in this repository.` - `@coderabbitai read src/utils.ts and generate unit testing code.` - `@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.` - `@coderabbitai help me debug CodeRabbit configuration file.` Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. ### CodeRabbit Commands (invoked as PR comments) - `@coderabbitai pause` to pause the reviews on a PR. - `@coderabbitai resume` to resume the paused reviews. - `@coderabbitai review` to trigger an incremental review. This is useful when automatic reviews are disabled for the repository. - `@coderabbitai full review` to do a full review from scratch and review all the files again. - `@coderabbitai summary` to regenerate the summary of the PR. - `@coderabbitai resolve` resolve all the CodeRabbit review comments. - `@coderabbitai configuration` to show the current CodeRabbit configuration for the repository. - `@coderabbitai help` to get help. Additionally, you can add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed. ### CodeRabbit Configration File (`.coderabbit.yaml`) - You can programmatically configure CodeRabbit by adding a `.coderabbit.yaml` file to the root of your repository. - Please see the [configuration documentation](https://docs.coderabbit.ai/guides/configure-coderabbit) for more information. - If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: `# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json` ### Documentation and Community - Visit our [Documentation](https://coderabbit.ai/docs) for detailed information on how to use CodeRabbit. - Join our [Discord Community](https://discord.com/invite/GsXnASn26c) to get help, request features, and share feedback. - Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.
codecov[bot] commented 2 weeks ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 82.74%. Comparing base (e2b659a) to head (9a9b941). Report is 1 commits behind head on devel.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## devel #3888 +/- ## ========================================== + Coverage 82.71% 82.74% +0.02% ========================================== Files 517 518 +1 Lines 50139 50215 +76 Branches 2984 2984 ========================================== + Hits 41472 41548 +76 Misses 7757 7757 Partials 910 910 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.