Skip to content

[pre-commit.ci] pre-commit autoupdate#4948

Merged
njzjz merged 2 commits intodevelfrom
pre-commit-ci-update-config
Sep 2, 2025
Merged

[pre-commit.ci] pre-commit autoupdate#4948
njzjz merged 2 commits intodevelfrom
pre-commit-ci-update-config

Conversation

@pre-commit-ci
Copy link
Copy Markdown
Contributor

@pre-commit-ci pre-commit-ci Bot commented Sep 1, 2025

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)
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

Variable f is not used.

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.

Suggested changeset 1
source/lmp/compute_deeptensor_atom.cpp

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/source/lmp/compute_deeptensor_atom.cpp b/source/lmp/compute_deeptensor_atom.cpp
--- a/source/lmp/compute_deeptensor_atom.cpp
+++ b/source/lmp/compute_deeptensor_atom.cpp
@@ -102,7 +102,6 @@
   }
 
   double** x = atom->x;
-  double** f = atom->f;
   int* type = atom->type;
   int* mask = atom->mask;
   int nlocal = atom->nlocal;
EOF
@@ -102,7 +102,6 @@
}

double** x = atom->x;
double** f = atom->f;
int* type = atom->type;
int* mask = atom->mask;
int nlocal = atom->nlocal;
Copilot is powered by AI and may make mistakes. Always verify output.
Comment thread source/lmp/fix_dplr.cpp
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

Variable type is not used.

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.

Suggested changeset 1
source/lmp/fix_dplr.cpp

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/source/lmp/fix_dplr.cpp b/source/lmp/fix_dplr.cpp
--- a/source/lmp/fix_dplr.cpp
+++ b/source/lmp/fix_dplr.cpp
@@ -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;
EOF
@@ -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;
Copilot is powered by AI and may make mistakes. Always verify output.
Comment thread source/lmp/fix_ttm_dp.h
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

The 'const' modifier has no effect on return types. The 'const' modifying the return type can be removed.

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.


Suggested changeset 1
source/lmp/fix_ttm_dp.h

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/source/lmp/fix_ttm_dp.h b/source/lmp/fix_ttm_dp.h
--- a/source/lmp/fix_ttm_dp.h
+++ b/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
EOF
@@ -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
Copilot is powered by AI and may make mistakes. Always verify output.
}

void PairDeepSpin::settings(int narg, char **arg) {
void PairDeepSpin::settings(int narg, char** arg) {

Check warning

Code scanning / CodeQL

Poorly documented large function Warning

Poorly documented function: fewer than 2% comments for a function of 242 lines.

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.

Suggested changeset 1
source/lmp/pair_deepspin.cpp

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/source/lmp/pair_deepspin.cpp b/source/lmp/pair_deepspin.cpp
--- a/source/lmp/pair_deepspin.cpp
+++ b/source/lmp/pair_deepspin.cpp
@@ -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();
EOF
@@ -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();
Copilot is powered by AI and may make mistakes. Always verify output.
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

Variable box_tensor is not used.

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.

Suggested changeset 1
source/op/tf/descrpt_se_a_mask.cc

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/source/op/tf/descrpt_se_a_mask.cc b/source/op/tf/descrpt_se_a_mask.cc
--- a/source/op/tf/descrpt_se_a_mask.cc
+++ b/source/op/tf/descrpt_se_a_mask.cc
@@ -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++);
 
EOF
@@ -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++);

Copilot is powered by AI and may make mistakes. Always verify output.
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

Variable mesh_tensor is not used.

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.


Suggested changeset 1
source/op/tf/descrpt_se_a_mask.cc

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/source/op/tf/descrpt_se_a_mask.cc b/source/op/tf/descrpt_se_a_mask.cc
--- a/source/op/tf/descrpt_se_a_mask.cc
+++ b/source/op/tf/descrpt_se_a_mask.cc
@@ -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),
EOF
@@ -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),
Copilot is powered by AI and may make mistakes. Always verify output.
@codecov
Copy link
Copy Markdown

codecov Bot commented Sep 2, 2025

Codecov Report

❌ Patch coverage is 76.26113% with 80 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.29%. Comparing base (db22802) to head (8439b64).
⚠️ Report is 67 commits behind head on devel.

Files with missing lines Patch % Lines
source/lmp/pair_base.cpp 34.37% 21 Missing ⚠️
source/op/tf/optimizer/parallel.cc 0.00% 13 Missing ⚠️
source/op/tf/prod_force_se_a_mask_grad.cc 0.00% 10 Missing ⚠️
source/lmp/pair_deepmd.cpp 61.11% 7 Missing ⚠️
source/lmp/pair_deepspin.cpp 65.00% 7 Missing ⚠️
source/lib/include/SimulationRegion.h 33.33% 4 Missing ⚠️
source/lib/include/ComputeDescriptor.h 91.66% 3 Missing ⚠️
source/lmp/fix_dplr.cpp 88.46% 3 Missing ⚠️
source/lmp/pppm_dplr.cpp 50.00% 3 Missing ⚠️
source/lib/include/SimulationRegion_Impl.h 84.61% 2 Missing ⚠️
... and 6 more
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@njzjz njzjz added this pull request to the merge queue Sep 2, 2025
Merged via the queue into devel with commit d1428e0 Sep 2, 2025
59 of 60 checks passed
@njzjz njzjz deleted the pre-commit-ci-update-config branch September 2, 2025 20:15
ChiahsinChu pushed a commit to ChiahsinChu/deepmd-kit that referenced this pull request Dec 17, 2025
<!--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>
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