Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Feb 26, 2024
1 parent 8a1a86c commit 50cdfe0
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 12 deletions.
1 change: 0 additions & 1 deletion deepmd/pt/model/descriptor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
)
from .env_mat import (
prod_env_mat,

)
from .gaussian_lcc import (
DescrptGaussianLcc,
Expand Down
15 changes: 12 additions & 3 deletions deepmd/pt/model/descriptor/env_mat.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
# SPDX-License-Identifier: LGPL-3.0-or-later
from typing import Optional

import torch

from deepmd.pt.utils.preprocess import (
compute_smooth_weight,
)


def _make_env_mat(nlist, coord, rcut: float, ruct_smth: float, radial_only: bool=False):
def _make_env_mat(

Check warning on line 10 in deepmd/pt/model/descriptor/env_mat.py

View check run for this annotation

Codecov / codecov/patch

deepmd/pt/model/descriptor/env_mat.py#L10

Added line #L10 was not covered by tests
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)
Expand Down Expand Up @@ -35,7 +37,14 @@ def _make_env_mat(nlist, coord, rcut: float, ruct_smth: float, radial_only: bool


def prod_env_mat(

Check warning on line 39 in deepmd/pt/model/descriptor/env_mat.py

View check run for this annotation

Codecov / codecov/patch

deepmd/pt/model/descriptor/env_mat.py#L39

Added line #L39 was not covered by tests
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.
Expand Down
4 changes: 0 additions & 4 deletions deepmd/pt/model/descriptor/se_r.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@
EmbeddingNet,
NetworkCollection,
)
from deepmd.pt.model.network.network import (
TypeFilter,
)
from deepmd.pt.utils import (

Check warning on line 21 in deepmd/pt/model/descriptor/se_r.py

View check run for this annotation

Codecov / codecov/patch

deepmd/pt/model/descriptor/se_r.py#L21

Added line #L21 was not covered by tests
env,
)
Expand Down Expand Up @@ -89,7 +86,6 @@ def __init__(
self.filter_layers_old = None
self.filter_layers = None

Check warning on line 87 in deepmd/pt/model/descriptor/se_r.py

View check run for this annotation

Codecov / codecov/patch

deepmd/pt/model/descriptor/se_r.py#L81-L87

Added lines #L81 - L87 were not covered by tests


filter_layers = NetworkCollection(

Check warning on line 89 in deepmd/pt/model/descriptor/se_r.py

View check run for this annotation

Codecov / codecov/patch

deepmd/pt/model/descriptor/se_r.py#L89

Added line #L89 was not covered by tests
ndim=1, ntypes=len(sel), network_type="embedding_network"
)
Expand Down
12 changes: 8 additions & 4 deletions deepmd/pt/utils/env_mat_stat.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (

Check warning on line 71 in deepmd/pt/utils/env_mat_stat.py

View check run for this annotation

Codecov / codecov/patch

deepmd/pt/utils/env_mat_stat.py#L71

Added line #L71 was not covered by tests
self.descriptor.ndescrpt // self.descriptor.nnei
) # se_r=1, se_a=4

def iter(
self, data: List[Dict[str, torch.Tensor]]
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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]]
Expand All @@ -205,4 +209,4 @@ def __call__(self):

mean = np.stack(all_davg)
stddev = np.stack(all_dstd)
return mean, stddev
return mean, stddev

0 comments on commit 50cdfe0

Please sign in to comment.