Summary
EinsteinMSD currently lowercases the msd_type string but does not handle
leading/trailing whitespace or non-string inputs. This leads to errors such as:
- msd_type=" xy " → ValueError instead of working as "xy"
- msd_type=123 → AttributeError ("int has no attribute 'lower'")
Proposed improvements
- Add
.strip() before .lower() to handle inputs like " xy ".
- Add type validation (raise TypeError when msd_type is not a string).
- Add new tests to cover:
- whitespace (" xy ")
- uppercase/mixed case (" Xz ")
- non-string inputs
Why this is beneficial
- Makes msd_type parsing more robust.
- In line with how MDAnalysis handles flexible string inputs.
- Increases test coverage for the analysis module.
I am willing to submit a PR.