Skip to content

Commit

Permalink
Fix doesn't loop over single frames (#99)
Browse files Browse the repository at this point in the history
  • Loading branch information
hejamu committed Apr 22, 2022
1 parent cd90206 commit 8a844fa
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions docs/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Changelog
=========

* Allow None as start/stop values (need for 1 frame trajectories)

v0.1.20 (2022-04-13)
------------------------------------------
Expand Down
7 changes: 4 additions & 3 deletions src/mdacli/libcli.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,15 +183,15 @@ def add_run_group(analysis_class_parser):
"-b",
dest="start",
type=str,
default="0",
default=None,
help="start frame or time for evaluation (default: %(default)s)"
)

run_group.add_argument(
"-e",
dest="stop",
type=str,
default="-1",
default=None,
help="end frame or time for evaluation (default: %(default)s)"
)

Expand Down Expand Up @@ -602,7 +602,8 @@ def run_analsis(analysis_callable,

# Run the analysis
for key, value in run_parameters.items():
run_parameters[key] = convert_str_time(value, universe.trajectory.dt)
run_parameters[key] = \
convert_str_time(value, universe.trajectory.dt) if value else value

ac.run(verbose=verbose, **run_parameters)

Expand Down
2 changes: 1 addition & 1 deletion tests/test_libcli.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def test_split_argparse_into_groups():

@pytest.mark.parametrize(
'dest, default',
[("start", "0"), ("stop", "-1"), ("step", "1"), ("verbose", False)])
[("start", None), ("stop", None), ("step", "1"), ("verbose", False)])
def test_add_run_group_args(dest, default):
"""Test for added run arguments."""
parser = argparse.ArgumentParser()
Expand Down

0 comments on commit 8a844fa

Please sign in to comment.