Fixed parsing of the charge_mode keyword in nep.in

The syntax of the charge_mode keyword in nep.in has been updated to charge_mode <mode> [<flip_charge>]. As a result read_nepfile() crashed with ValueError: invalid literal for int() with base 10: '1 1' on the extended nep.in syntax.

This MR fixes this behavior. It also cleans up the handling of lists of floats and ints, respectively.

Changes

  • Fold charge_mode into the existing list-value handling, alongside cutoff/n_max/l_max/basis_size/type_weight, instead of treating it as a scalar. charge_mode is now returned as a list ([mode] or [mode, flip_charge]).
  • Split that list-value branch by type: n_max/l_max/basis_size/ charge_mode as ints, cutoff/type_weight as floats. Previously everything was cast to float, so round-tripping through write_nepfile() turned n_max 8 6 into n_max 8.0 6.0.
  • Update read_structures()'s charge_mode lookup for the new list shape.
  • Add tests for the extended charge_mode syntax and for int-vs-float formatting on a read/write roundtrip.

Merge request reports

Loading