Integrate reading/writing restart files with reading/writing nep.txt files
Summary
read_model and Model.write now accept an optional restart_file keyword argument, allowing the NEP model file and its restart file to be read or written in a single call.
The standalone read_restart and write_restart methods remain available for cases where only the restart file needs to be handled.
Changes
calorine/nep/model.py
read_model(filename, restart_file=None): ifrestart_fileis provided, callsmodel.read_restart(restart_file)before returning the model and populatesmodel.restart_parameters.Model.write(filename, restart_file=None): ifrestart_fileis provided, callsself.write_restart(restart_file)after writing the model file.- Both functions have updated NumPy-style docstrings documenting the new parameter.
tests/test_nep_model.py
Updated the following tests to exercise the new keyword arguments instead of calling read_restart/write_restart separately:
test_read_nep_restarttest_write_nep_restarttest_modify_sigma_nep_restarttest_modify_species
Usage
# Before
model = read_model('nep.txt')
model.read_restart('nep.restart')
model.write('nep_modified.txt')
model.write_restart('nep_modified.restart')
# After
model = read_model('nep.txt', restart_file='nep.restart')
model.write('nep_modified.txt', restart_file='nep_modified.restart')