Conversation
updates: - [github.com/astral-sh/ruff-pre-commit: v0.12.10 → v0.12.11](astral-sh/ruff-pre-commit@v0.12.10...v0.12.11) - [github.com/pre-commit/mirrors-clang-format: v20.1.8 → v21.1.0](pre-commit/mirrors-clang-format@v20.1.8...v21.1.0)
for more information, see https://pre-commit.ci
| int *type = atom->type; | ||
| int *mask = atom->mask; | ||
| double** x = atom->x; | ||
| double** f = atom->f; |
Check notice
Code scanning / CodeQL
Unused local variable Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 8 months ago
To fix the problem, simply remove the unused local variable f from the function ComputeDeeptensorAtom::compute_peratom(). This is the best and only necessary change, as it has no effect on any functionality, and no other parts of the code shown depend on f. The change is isolated to the lines where f is declared and does not require any further code modification, method changes, or imports.
| @@ -102,7 +102,6 @@ | ||
| } | ||
|
|
||
| double** x = atom->x; | ||
| double** f = atom->f; | ||
| int* type = atom->type; | ||
| int* mask = atom->mask; | ||
| int nlocal = atom->nlocal; |
| int *type = atom->type; | ||
| double** x = atom->x; | ||
| double** v = atom->v; | ||
| int* type = atom->type; |
Check notice
Code scanning / CodeQL
Unused local variable Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 8 months ago
To fix this issue, remove the unused local variable type from the pre_exchange function in source/lmp/fix_dplr.cpp. This involves deleting the line int* type = atom->type; (line 442), as it is never referenced within the function. No changes to logic or functionality are necessary, and no additional imports or definitions are needed.
| @@ -439,7 +439,6 @@ | ||
| void FixDPLR::pre_exchange() { | ||
| double** x = atom->x; | ||
| double** v = atom->v; | ||
| int* type = atom->type; | ||
| int nlocal = atom->nlocal; | ||
| int nghost = atom->nghost; | ||
| int nall = nlocal + nghost; |
| return tmp; | ||
| }; | ||
| double ***const get_T_electron() const { return T_electron; }; | ||
| double*** const get_T_electron() const { return T_electron; }; |
Check warning
Code scanning / CodeQL
Constant return type on member Warning
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 8 months ago
To fix the problem, remove the unnecessary const qualifier in the return type of the get_T_electron member function. Instead of double*** const get_T_electron() const, it should be just double*** get_T_electron() const. Leave the trailing const after the argument list unchanged because it denotes the function as a const member function, which is correct. Ensure no other changes are made to type qualifiers or function signatures in this process. Only change the declaration/definition of get_T_electron on line 16 of the file source/lmp/fix_ttm_dp.h.
| @@ -13,6 +13,6 @@ | ||
| tmp[2] = nzgrid; | ||
| return tmp; | ||
| }; | ||
| double*** const get_T_electron() const { return T_electron; }; | ||
| double*** get_T_electron() const { return T_electron; }; | ||
| }; | ||
| } // namespace LAMMPS_NS |
| } | ||
|
|
||
| void PairDeepSpin::settings(int narg, char **arg) { | ||
| void PairDeepSpin::settings(int narg, char** arg) { |
Check warning
Code scanning / CodeQL
Poorly documented large function Warning
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 8 months ago
To fix this problem, we should add clear, descriptive comments throughout the PairDeepSpin::settings function, particularly before major sections or logical operations to explain what the code is doing, why, and any relevant edge cases or decision points. The top of the function should have a summary comment explaining its purpose, usage, and any major side effects. For code blocks that process input arguments, configure models, or handle errors, inline comments or block comments should provide rationale and clarify non-obvious code.
The changes should be made directly within the code of the settings function in source/lmp/pair_deepspin.cpp. No imports or outside definitions are required—just added comments within the function. No changes to code logic or functionality should be made.
| @@ -581,29 +581,47 @@ | ||
| return false; | ||
| } | ||
|
|
||
| /** | ||
| * Set up the DeepSpin pair style based on input arguments. | ||
| * Parses model and key parameters, initializes DeepSpin module(s), | ||
| * and configures associated member variables. | ||
| * Throws errors if input is invalid or initialization fails. | ||
| * | ||
| * @param narg Number of input arguments. | ||
| * @param arg Array of input argument strings. | ||
| */ | ||
| void PairDeepSpin::settings(int narg, char** arg) { | ||
| // Ensure that there is at least one argument | ||
| if (narg <= 0) { | ||
| error->all(FLERR, "Illegal pair_style command"); | ||
| } | ||
|
|
||
| // Gather model file names from the input arguments until a keyword is encountered | ||
| vector<string> models; | ||
| int iarg = 0; | ||
| while (iarg < narg) { | ||
| if (is_key(arg[iarg])) { | ||
| // Stop at the first keyword argument, remaining args will be processed separately | ||
| break; | ||
| } | ||
| iarg++; | ||
| } | ||
| // Store the collected model filenames | ||
| for (int ii = 0; ii < iarg; ++ii) { | ||
| models.push_back(arg[ii]); | ||
| } | ||
| numb_models = models.size(); | ||
|
|
||
| // Initialize DeepSpin using the provided model(s) | ||
| if (numb_models == 1) { | ||
| try { | ||
| // Initialize single DeepSpin model using provided parameters | ||
| deep_spin.init(arg[0], get_node_rank(), get_file_content(arg[0])); | ||
| } catch (deepmd_compat::deepmd_exception& e) { | ||
| // Propagate initialization error | ||
| error->one(FLERR, e.what()); | ||
| } | ||
| // Cache common model-dependent parameters | ||
| cutoff = deep_spin.cutoff() * dist_unit_cvt_factor; | ||
| numb_types = deep_spin.numb_types(); | ||
| numb_types_spin = deep_spin.numb_types_spin(); |
| const Tensor& coord_tensor = context->input(context_input_index++); | ||
| const Tensor& type_tensor = context->input(context_input_index++); | ||
| const Tensor& mask_matrix_tensor = context->input(context_input_index++); | ||
| const Tensor& box_tensor = context->input(context_input_index++); |
Check notice
Code scanning / CodeQL
Unused local variable Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 8 months ago
To resolve the issue, remove the declaration of the unused local variable box_tensor on line 60 within the _Compute method of DescrptSeAMaskOp. No other code needs modification; the rest of the indexing scheme (context_input_index) can remain, because subsequent inputs rely on the increment regardless of this unused variable. This improves code readability and eliminates potential confusion regarding the role of box_tensor.
| @@ -57,7 +57,7 @@ | ||
| const Tensor& coord_tensor = context->input(context_input_index++); | ||
| const Tensor& type_tensor = context->input(context_input_index++); | ||
| const Tensor& mask_matrix_tensor = context->input(context_input_index++); | ||
| const Tensor& box_tensor = context->input(context_input_index++); | ||
| context_input_index++; | ||
| const Tensor& natoms_tensor = context->input(context_input_index++); | ||
| const Tensor& mesh_tensor = context->input(context_input_index++); | ||
|
|
| const Tensor& mask_matrix_tensor = context->input(context_input_index++); | ||
| const Tensor& box_tensor = context->input(context_input_index++); | ||
| const Tensor& natoms_tensor = context->input(context_input_index++); | ||
| const Tensor& mesh_tensor = context->input(context_input_index++); |
Check notice
Code scanning / CodeQL
Unused local variable Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 8 months ago
The best way to fix the problem is to remove the unused local variable declaration for mesh_tensor from line 62. Since the variable is never used, this improves readability and avoids confusion. However, care must be taken to ensure that the indexing of context_input_index remains correct. Because the computation uses context_input_index++ on each input to fetch tensors, and the subsequent code does not refer to mesh_tensor or the value at that index, we can safely drop the assignment line for mesh_tensor without affecting the logic of the function.
Specifically, in source/op/tf/descrpt_se_a_mask.cc, remove line 62:
const Tensor& mesh_tensor = context->input(context_input_index++);No other changes, imports, or additional methods are required.
| @@ -59,7 +59,6 @@ | ||
| const Tensor& mask_matrix_tensor = context->input(context_input_index++); | ||
| const Tensor& box_tensor = context->input(context_input_index++); | ||
| const Tensor& natoms_tensor = context->input(context_input_index++); | ||
| const Tensor& mesh_tensor = context->input(context_input_index++); | ||
|
|
||
| // set size of the sample | ||
| OP_REQUIRES(context, (coord_tensor.shape().dims() == 2), |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## devel #4948 +/- ##
=======================================
Coverage 84.29% 84.29%
=======================================
Files 704 704
Lines 68907 68905 -2
Branches 3572 3572
=======================================
+ Hits 58085 58086 +1
+ Misses 9681 9679 -2
+ Partials 1141 1140 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
<!--pre-commit.ci start--> updates: - [github.com/astral-sh/ruff-pre-commit: v0.12.10 → v0.12.11](astral-sh/ruff-pre-commit@v0.12.10...v0.12.11) - [github.com/pre-commit/mirrors-clang-format: v20.1.8 → v21.1.0](pre-commit/mirrors-clang-format@v20.1.8...v21.1.0) <!--pre-commit.ci end--> --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
updates: