MDAnalysis / mdacli

Command line interface for MDAnalysis
https://mdacli.readthedocs.io/
GNU General Public License v3.0
19 stars 7 forks source link

mdacli doesn't loop over single frames #98

Closed hejamu closed 2 years ago

hejamu commented 2 years ago

If one is using an AnalysisClass on a trajectory with only one frame, the AnalysisBaseClass from MDA will happily do exactly that. This is because at initialization ( https://github.com/MDAnalysis/mdanalysis/blob/3769ee29e5907221527ff0ec88a8c5acf9f86dee/package/MDAnalysis/analysis/base.py#L247 ), if start, stop and step are None, and the trajectory is ONE frame long, it sets them to 0, 1 and 1 respectively.

mdacli however sets the default values to start = 0, stop = -1 and step = 1. This does not result in the same behaviour, since for array of length 1:

a[0:-1:1] != a[0:1:1]

This difference in behaviour finally matters at this point: https://github.com/MDAnalysis/mdanalysis/blob/3769ee29e5907221527ff0ec88a8c5acf9f86dee/package/MDAnalysis/analysis/base.py#L296

Maybe setting the defaults to None would be an option?

PicoCentauri commented 2 years ago

Good idea of changing these. Would you be able to do it? The lines are here:

https://github.com/MDAnalysis/mdacli/blob/cd902069ea937d35baa17b316ebc7801d258c66b/src/mdacli/libcli.py#L182-L204

We ran through a test to check the units and maybe the function

https://github.com/MDAnalysis/mdacli/blob/cd902069ea937d35baa17b316ebc7801d258c66b/src/mdacli/utils.py#L25

will breaks. An additional test for None would be sufficient I guess.

PicoCentauri commented 2 years ago

Closed by #99