Skip to content
Closed
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions source/tests/pt/test_training.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import json
import os
import shutil
import tempfile
import unittest
from copy import (
deepcopy,
Expand Down Expand Up @@ -195,18 +196,25 @@ def setUp(self):
input_json = str(Path(__file__).parent / "water/se_atten.json")
with open(input_json) as f:
self.config = json.load(f)
data_file = [str(Path(__file__).parent / "water/data/data_0")]
self.original_data_path = Path(__file__).parent / "water/data/data_0"
# Create a temporary directory for this test
self.temp_dir = Path(tempfile.mkdtemp())
self.temp_data_path = self.temp_dir / "data_0"
shutil.copytree(self.original_data_path, self.temp_data_path)

data_file = [str(self.temp_data_path)]
self.config["training"]["training_data"]["systems"] = data_file
self.config["training"]["validation_data"]["systems"] = data_file
self.config["model"] = deepcopy(model_se_e2_a)
self.config["model"]["fitting_net"]["numb_fparam"] = 1
self.config["training"]["numb_steps"] = 1
self.config["training"]["save_freq"] = 1
self.set_path = Path(__file__).parent / "water/data/data_0" / "set.000"
self.set_path = self.temp_data_path / "set.000"
shutil.copyfile(self.set_path / "energy.npy", self.set_path / "fparam.npy")

def tearDown(self) -> None:
(self.set_path / "fparam.npy").unlink(missing_ok=True)
# Remove the temporary directory and all its contents
shutil.rmtree(self.temp_dir)
DPTrainTest.tearDown(self)


Expand Down
Loading