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 17, 2024
1 parent 58a92be commit 2009107
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 21 deletions.
4 changes: 1 addition & 3 deletions deepmd/pt/model/task/fitting.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,9 +254,7 @@ def change_energy_bias(
)
# data
systems = config["training"]["training_data"]["systems"]
finetune_data = DpLoaderSet(
systems, ntest, config["model"]
)
finetune_data = DpLoaderSet(systems, ntest, config["model"])

Check warning on line 257 in deepmd/pt/model/task/fitting.py

View check run for this annotation

Codecov / codecov/patch

deepmd/pt/model/task/fitting.py#L257

Added line #L257 was not covered by tests
sampled = make_stat_input(finetune_data.systems, finetune_data.dataloaders, 1)
# map
sorter = np.argsort(old_type_map)
Expand Down
4 changes: 1 addition & 3 deletions deepmd/pt/utils/dataloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from typing import (
List,
)

import h5py
import torch
import torch.distributed as dist
Expand All @@ -28,9 +29,6 @@
DistributedSampler,
)

from deepmd.pt.model.descriptor import (
Descriptor,
)
from deepmd.pt.utils import (
env,
)
Expand Down
12 changes: 2 additions & 10 deletions deepmd/pt/utils/dataset.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,14 @@
# SPDX-License-Identifier: LGPL-3.0-or-later
import glob
import os
from typing import (
List,
Optional,
)

import h5py
import numpy as np
import torch
from torch.utils.data import (
Dataset,
)

from deepmd.utils.data import (

Check warning on line 7 in deepmd/pt/utils/dataset.py

View check run for this annotation

Codecov / codecov/patch

deepmd/pt/utils/dataset.py#L7

Added line #L7 was not covered by tests
DeepmdData,
)


class DeepmdDataSetForLoader(Dataset):
def __init__(
self,
Expand All @@ -42,7 +35,6 @@ def __init__(
self._natoms = self._data_system.natoms

Check warning on line 35 in deepmd/pt/utils/dataset.py

View check run for this annotation

Codecov / codecov/patch

deepmd/pt/utils/dataset.py#L35

Added line #L35 was not covered by tests
self._natoms_vec = self._data_system.get_natoms_vec(self._ntypes)


def __len__(self):
return self._data_system.nframes

Expand Down
4 changes: 2 additions & 2 deletions source/tests/pt/model/test_embedding_net.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ def get_single_batch(dataset, index=None):
index = dp_random.choice(np.arange(len(dataset)))
np_batch = dataset[index]
pt_batch = {}

for key in ["coord", "box", "force", "energy", "virial", "atype", "natoms"]:
if key in np_batch.keys():
np_batch[key] = np.expand_dims(np_batch[key], axis=0)
np_batch[key] = np.expand_dims(np_batch[key], axis=0)
pt_batch[key] = torch.as_tensor(np_batch[key])
np_batch["coord"] = np_batch["coord"].reshape(1, -1)
np_batch["natoms"] = np_batch["natoms"][0]
Expand Down
4 changes: 1 addition & 3 deletions source/tests/pt/test_loss.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,7 @@ def get_batch():
systems = config["training"]["validation_data"]["systems"]
if isinstance(systems, str):
systems = expand_sys_str(systems)
dataset = DeepmdDataSetForLoader(
systems[0], model_config["type_map"]
)
dataset = DeepmdDataSetForLoader(systems[0], model_config["type_map"])
np_batch, pt_batch = get_single_batch(dataset)
return np_batch, pt_batch

Expand Down

0 comments on commit 2009107

Please sign in to comment.