style: require explicit device and dtype#4001
Conversation
Signed-off-by: Jinzhe Zeng <jinzhe.zeng@rutgers.edu>
Signed-off-by: Jinzhe Zeng <jinzhe.zeng@rutgers.edu>
WalkthroughWalkthroughThis update introduces enhancements to the linting configuration and improves code quality across various files in the Changes
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? TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Additionally, you can add CodeRabbit Configuration File (
|
| # YWolfeee: support polar normalization, initialize to a more appropriate point | ||
| if self.shift_diag: | ||
| mean_polar = np.zeros([len(self.sel_type), 9]) | ||
| mean_polar = np.zeros([len(self.sel_type), 9]) # pylint: disable=no-explicit-dtype |
Check notice
Code scanning / CodeQL
Unused local variable
| self.nei_type = tf.constant(nei_type, dtype=tf.int32) | ||
|
|
||
| avg_zero = np.zeros([self.ntypes, self.ndescrpt]).astype( | ||
| avg_zero = np.zeros([self.ntypes, self.ndescrpt]).astype( # pylint: disable=no-explicit-dtype |
Check notice
Code scanning / CodeQL
Unused local variable
| GLOBAL_NP_FLOAT_PRECISION | ||
| ) | ||
| std_ones = np.ones([self.ntypes, self.ndescrpt]).astype( | ||
| std_ones = np.ones([self.ntypes, self.ndescrpt]).astype( # pylint: disable=no-explicit-dtype |
Check notice
Code scanning / CodeQL
Unused local variable
| with tf.variable_scope("descrpt_attr" + suffix, reuse=reuse): | ||
| if davg is None: | ||
| davg = np.zeros([self.ntypes, self.ndescrpt]) | ||
| davg = np.zeros([self.ntypes, self.ndescrpt]) # pylint: disable=no-explicit-dtype |
Check notice
Code scanning / CodeQL
Unused local variable
| davg = np.zeros([self.ntypes, self.ndescrpt]) # pylint: disable=no-explicit-dtype | ||
| if dstd is None: | ||
| dstd = np.ones([self.ntypes, self.ndescrpt]) | ||
| dstd = np.ones([self.ntypes, self.ndescrpt]) # pylint: disable=no-explicit-dtype |
Check notice
Code scanning / CodeQL
Unused local variable
| -1, self.ndescrpt | ||
| ) # shape is [nframes*nall, self.ndescrpt] | ||
| xyz_scatter = torch.empty( | ||
| xyz_scatter = torch.empty( # pylint: disable=no-explicit-dtype |
Check warning
Code scanning / CodeQL
Variable defined multiple times
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## devel #4001 +/- ##
=======================================
Coverage 82.83% 82.83%
=======================================
Files 522 522
Lines 50889 50901 +12
Branches 3015 3011 -4
=======================================
+ Hits 42154 42165 +11
- Misses 7798 7799 +1
Partials 937 937 ☔ View full report in Codecov by Sentry. |
|
CodeQL alerts are not related to this PR (but it's expected to fix them in a separated PR) |
Add a linter to require explicit `device` and `dtype` for
`{np,tf,pt}.{tensor,zeros,ones,arange,range,empty,full,rand,eye,linspace}`.
- EDP01: Require explicit device when initializing a PyTorch tensor.
- EDP02: Require explicit dtype when initializing a NumPy array, a
TensorFlow tensor, or a PyTorch tensor.
Missing `device` or `dtype` often causes a problem.
Note: I am not going to fix the existing codes in this PR, as too many
(200+) lines violate the rules. Fixing them takes a long time which I
don't have. I disable rules on those lines.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
- **New Features**
- Added enhanced linting capabilities through a new `deepmd_checker`
plugin in the `pyproject.toml` configuration.
- **Bug Fixes**
- Improved code clarity and compliance by suppressing pylint warnings
related to explicit data types across multiple files.
- **Documentation**
- Numerous comments added to clarify the suppression of linting
messages, enhancing code maintainability and readability.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Signed-off-by: Jinzhe Zeng <jinzhe.zeng@rutgers.edu>
Add a linter to require explicit
deviceanddtypefor{np,tf,pt}.{tensor,zeros,ones,arange,range,empty,full,rand,eye,linspace}.Missing
deviceordtypeoften causes a problem.Note: I am not going to fix the existing codes in this PR, as too many (200+) lines violate the rules. Fixing them takes a long time which I don't have. I disable rules on those lines.
Summary by CodeRabbit
New Features
deepmd_checkerplugin in thepyproject.tomlconfiguration.Bug Fixes
Documentation