mdanalysis
mdanalysis copied to clipboard
Improve msd_type parsing: add whitespace handling, type validation, and missing tests
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.
I am interested in working on this issue as well. Is this issue assigned to anyone ? If not, I’d be happy to take it !!
I want to work on this issue can you assign it to me?
I would like to work on this issue. Could you please assign it to me.
Is this open to work on? I'd like to work on it.