Bug/fix read model behavior for missing version line

This MR hardens read_model's handling of malformed nep.txt files, found via fuzz testing in the GPUMD repo.

  • read_model now validates version/types/model_type up front, so a nep.txt missing its leading nep* line fails with a clear error instead of a KeyError.
  • read_model now rejects non-finite (inf/nan) cutoff values with a clear error instead of an OverflowError or an opaque ValueError from int().
  • Converted the checks that validate untrusted nep.txt/nep.restart content in read_model, _get_nep_contents, _get_restart_contents, and _sort_descriptor_parameters from assert to raise ValueError/raise IOError, since assert is stripped under python -O and would silently skip validation of external input. Checks guarding calorine's own internal invariants are left as assert.
  • Added tests covering the missing-version-line and non-finite-cutoff cases.

Merge request reports

Loading