File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -268,11 +268,22 @@ def setUp(self) -> None:
268268 self .config ["training" ]["numb_steps" ] = 1
269269 self .config ["training" ]["save_freq" ] = 1
270270 self .set_path = Path (__file__ ).parent / "water/data/data_0" / "set.000"
271- shutil .copyfile (self .set_path / "energy.npy" , self .set_path / "fparam.npy" )
271+ # Backup the committed fparam.npy (numb_fparam=2) before overwriting
272+ # with a 1-column version for this test.
273+ self ._fparam_backup = self .set_path / "fparam.npy.bak"
274+ fparam_path = self .set_path / "fparam.npy"
275+ if fparam_path .exists ():
276+ shutil .copyfile (fparam_path , self ._fparam_backup )
277+ shutil .copyfile (self .set_path / "energy.npy" , fparam_path )
272278 self .config ["model" ]["data_stat_nbatch" ] = 100
273279
274280 def tearDown (self ) -> None :
275- (self .set_path / "fparam.npy" ).unlink (missing_ok = True )
281+ # Restore the original fparam.npy so other tests can use it.
282+ fparam_path = self .set_path / "fparam.npy"
283+ if self ._fparam_backup .exists ():
284+ shutil .move (str (self ._fparam_backup ), str (fparam_path ))
285+ else :
286+ fparam_path .unlink (missing_ok = True )
276287 DPTrainTest .tearDown (self )
277288
278289
Original file line number Diff line number Diff line change @@ -117,18 +117,13 @@ def _get_weighted_fitting_stat(
117117 return weighted_avg , weighted_std
118118
119119
120- # Paths to the water data used by PT tests.
121- # resolve() follows the ``pt/water -> model/water`` symlink so numpy can
122- # always open the real file, even on CI runners where symlink handling
123- # can be fragile.
124- _PT_DATA = str (
125- (Path (__file__ ).parent .parent .parent / "pt" / "water" / "data" / "data_0" ).resolve ()
126- )
120+ # Paths to the water data used by PT tests
121+ _PT_DATA = str (Path (__file__ ).parent .parent .parent / "pt" / "water" / "data" / "data_0" )
127122_PT_DATA_NO_FPARAM = str (
128- ( Path (__file__ ).parent .parent .parent / "pt" / "water" / "data" / "data_1" ). resolve ()
123+ Path (__file__ ).parent .parent .parent / "pt" / "water" / "data" / "data_1"
129124)
130125_PT_DATA_SINGLE = str (
131- ( Path (__file__ ).parent .parent .parent / "pt" / "water" / "data" / "single" ). resolve ()
126+ Path (__file__ ).parent .parent .parent / "pt" / "water" / "data" / "single"
132127)
133128
134129_descriptor_se_e2_a = {
You can’t perform that action at this time.
0 commit comments