Skip to content

Commit ff4bc78

Browse files
committed
use custom_eval_int_strict_pos
1 parent 0b106e6 commit ff4bc78

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

‎paths_cli/compiling/engines.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from .topology import build_topology
22
from .core import Builder
33
from paths_cli.compiling.core import Parameter
4-
from .tools import custom_eval_int
4+
from .tools import custom_eval_int_strict_pos
55
from paths_cli.compiling.plugins import EngineCompilerPlugin, CategoryPlugin
66

77
def load_openmm_xml(filename):
@@ -32,9 +32,9 @@ def _openmm_options(dct):
3232
description="XML file with the OpenMM system"),
3333
Parameter('integrator', load_openmm_xml, json_type='string',
3434
description="XML file with the OpenMM integrator"),
35-
Parameter('n_steps_per_frame', custom_eval_int,
35+
Parameter('n_steps_per_frame', custom_eval_int_strict_pos,
3636
description="number of MD steps per saved frame"),
37-
Parameter("n_frames_max", custom_eval_int,
37+
Parameter("n_frames_max", custom_eval_int_strict_pos,
3838
description=("maximum number of frames before aborting "
3939
"trajectory")),
4040
]

‎paths_cli/compiling/tools.py‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ def custom_eval_int(obj, named_objs=None):
2222
val = custom_eval(obj, named_objs)
2323
return int(val)
2424

25+
def custom_eval_int_strict_pos(obj, named_objs=None):
26+
val = custom_eval_int(obj, named_objs)
27+
if val <= 0:
28+
raise InputError(f"Positive integer required; found {val}")
29+
return val
30+
2531

2632
class UnknownAtomsError(RuntimeError):
2733
pass

0 commit comments

Comments
 (0)