From 50cdfe002034025a260344b2c3e7cc1fdf3c03db Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 26 Feb 2024 06:53:37 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- deepmd/pt/model/descriptor/__init__.py | 1 - deepmd/pt/model/descriptor/env_mat.py | 15 ++++++++++++--- deepmd/pt/model/descriptor/se_r.py | 4 ---- deepmd/pt/utils/env_mat_stat.py | 12 ++++++++---- 4 files changed, 20 insertions(+), 12 deletions(-) diff --git a/deepmd/pt/model/descriptor/__init__.py b/deepmd/pt/model/descriptor/__init__.py index 2c55346f94..784db59be0 100644 --- a/deepmd/pt/model/descriptor/__init__.py +++ b/deepmd/pt/model/descriptor/__init__.py @@ -13,7 +13,6 @@ ) from .env_mat import ( prod_env_mat, - ) from .gaussian_lcc import ( DescrptGaussianLcc, diff --git a/deepmd/pt/model/descriptor/env_mat.py b/deepmd/pt/model/descriptor/env_mat.py index c3a1d38726..4e6ffb7785 100644 --- a/deepmd/pt/model/descriptor/env_mat.py +++ b/deepmd/pt/model/descriptor/env_mat.py @@ -1,5 +1,5 @@ # SPDX-License-Identifier: LGPL-3.0-or-later -from typing import Optional + import torch from deepmd.pt.utils.preprocess import ( @@ -7,7 +7,9 @@ ) -def _make_env_mat(nlist, coord, rcut: float, ruct_smth: float, radial_only: bool=False): +def _make_env_mat( + nlist, coord, rcut: float, ruct_smth: float, radial_only: bool = False +): """Make smooth environment matrix.""" bsz, natoms, nnei = nlist.shape coord = coord.view(bsz, -1, 3) @@ -35,7 +37,14 @@ def _make_env_mat(nlist, coord, rcut: float, ruct_smth: float, radial_only: bool def prod_env_mat( - extended_coord, nlist, atype, mean, stddev, rcut: float, rcut_smth: float, radial_only: bool=False + extended_coord, + nlist, + atype, + mean, + stddev, + rcut: float, + rcut_smth: float, + radial_only: bool = False, ): """Generate smooth environment matrix from atom coordinates and other context. diff --git a/deepmd/pt/model/descriptor/se_r.py b/deepmd/pt/model/descriptor/se_r.py index 0ddbfd5c63..4ccb6f8842 100644 --- a/deepmd/pt/model/descriptor/se_r.py +++ b/deepmd/pt/model/descriptor/se_r.py @@ -18,9 +18,6 @@ EmbeddingNet, NetworkCollection, ) -from deepmd.pt.model.network.network import ( - TypeFilter, -) from deepmd.pt.utils import ( env, ) @@ -89,7 +86,6 @@ def __init__( self.filter_layers_old = None self.filter_layers = None - filter_layers = NetworkCollection( ndim=1, ntypes=len(sel), network_type="embedding_network" ) diff --git a/deepmd/pt/utils/env_mat_stat.py b/deepmd/pt/utils/env_mat_stat.py index 7f63f0a99e..3af03bda97 100644 --- a/deepmd/pt/utils/env_mat_stat.py +++ b/deepmd/pt/utils/env_mat_stat.py @@ -68,7 +68,9 @@ class EnvMatStatSe(EnvMatStat): def __init__(self, descriptor: "DescriptorBlock"): super().__init__() self.descriptor = descriptor - self.last_dim = self.descriptor.ndescrpt// self.descriptor.nnei # se_r=1, se_a=4 + self.last_dim = ( + self.descriptor.ndescrpt // self.descriptor.nnei + ) # se_r=1, se_a=4 def iter( self, data: List[Dict[str, torch.Tensor]] @@ -132,7 +134,9 @@ def iter( # reshape to nframes * nloc at the atom level, # so nframes/mixed_type do not matter env_mat = env_mat.view( - coord.shape[0] * coord.shape[1], self.descriptor.get_nsel(), self.last_dim + coord.shape[0] * coord.shape[1], + self.descriptor.get_nsel(), + self.last_dim, ) atype = atype.view(coord.shape[0] * coord.shape[1]) # (1, nloc) eq (ntypes, 1), so broadcast is possible @@ -179,7 +183,7 @@ def __call__(self): all_davg = [] all_dstd = [] - + for type_i in range(self.descriptor.get_ntypes()): if self.last_dim == 4: davgunit = [[avgs[f"r_{type_i}"], 0, 0, 0]] @@ -205,4 +209,4 @@ def __call__(self): mean = np.stack(all_davg) stddev = np.stack(all_dstd) - return mean, stddev \ No newline at end of file + return mean, stddev