diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0fd2d1b40f..85486e3901 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -30,7 +30,7 @@ repos: exclude: ^source/3rdparty - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. - rev: v0.1.14 + rev: v0.2.0 hooks: - id: ruff args: ["--fix"] diff --git a/deepmd/tf/descriptor/loc_frame.py b/deepmd/tf/descriptor/loc_frame.py index b43678c381..185c5062aa 100644 --- a/deepmd/tf/descriptor/loc_frame.py +++ b/deepmd/tf/descriptor/loc_frame.py @@ -343,7 +343,10 @@ def prod_force_virial( tf.summary.histogram("net_derivative", net_deriv) net_deriv_reshape = tf.reshape( net_deriv, - [np.cast["int64"](-1), natoms[0] * np.cast["int64"](self.ndescrpt)], + [ + np.asarray(-1, dtype=np.int64), + natoms[0] * np.asarray(self.ndescrpt, dtype=np.int64), + ], ) force = op_module.prod_force( net_deriv_reshape, diff --git a/deepmd/tf/descriptor/se_a.py b/deepmd/tf/descriptor/se_a.py index f1f90451fc..01c4ee8844 100644 --- a/deepmd/tf/descriptor/se_a.py +++ b/deepmd/tf/descriptor/se_a.py @@ -708,7 +708,10 @@ def prod_force_virial( tf.summary.histogram("net_derivative", net_deriv) net_deriv_reshape = tf.reshape( net_deriv, - [np.cast["int64"](-1), natoms[0] * np.cast["int64"](self.ndescrpt)], + [ + np.asarray(-1, dtype=np.int64), + natoms[0] * np.asarray(self.ndescrpt, dtype=np.int64), + ], ) force = op_module.prod_force_se_a( net_deriv_reshape, diff --git a/deepmd/tf/descriptor/se_r.py b/deepmd/tf/descriptor/se_r.py index ac94ec0614..f790d0a8fb 100644 --- a/deepmd/tf/descriptor/se_r.py +++ b/deepmd/tf/descriptor/se_r.py @@ -500,7 +500,10 @@ def prod_force_virial( tf.summary.histogram("net_derivative", net_deriv) net_deriv_reshape = tf.reshape( net_deriv, - [np.cast["int64"](-1), natoms[0] * np.cast["int64"](self.ndescrpt)], + [ + np.asarray(-1, dtype=np.int64), + natoms[0] * np.asarray(self.ndescrpt, dtype=np.int64), + ], ) force = op_module.prod_force_se_r( net_deriv_reshape, self.descrpt_deriv, self.nlist, natoms diff --git a/deepmd/tf/descriptor/se_t.py b/deepmd/tf/descriptor/se_t.py index 98f4cf8212..c72296daa7 100644 --- a/deepmd/tf/descriptor/se_t.py +++ b/deepmd/tf/descriptor/se_t.py @@ -513,7 +513,10 @@ def prod_force_virial( [net_deriv] = tf.gradients(atom_ener, self.descrpt_reshape) net_deriv_reshape = tf.reshape( net_deriv, - [np.cast["int64"](-1), natoms[0] * np.cast["int64"](self.ndescrpt)], + [ + np.asarray(-1, dtype=np.int64), + natoms[0] * np.asarray(self.ndescrpt, dtype=np.int64), + ], ) force = op_module.prod_force_se_a( net_deriv_reshape, diff --git a/pyproject.toml b/pyproject.toml index aa0da4725d..e4096b37b4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -224,7 +224,7 @@ ignore = "D413, D416, D203, D107, D213" profile = "black" force_grid_wrap = 1 -[tool.ruff] +[tool.ruff.lint] select = [ "E", # errors "F", # pyflakes @@ -252,7 +252,7 @@ ignore = [ ] ignore-init-module-imports = true -[tool.ruff.pydocstyle] +[tool.ruff.lint.pydocstyle] convention = "numpy" [tool.pytest.ini_options]