mdanalysis icon indicating copy to clipboard operation
mdanalysis copied to clipboard

Improve msd_type parsing: add whitespace handling, type validation, and missing tests

Open tanii1125 opened this issue 2 weeks ago • 4 comments

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

  1. Add .strip() before .lower() to handle inputs like " xy ".
  2. Add type validation (raise TypeError when msd_type is not a string).
  3. 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.

tanii1125 avatar Dec 08 '25 11:12 tanii1125

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 !!

Sparshagarwal29 avatar Dec 09 '25 13:12 Sparshagarwal29

I want to work on this issue can you assign it to me?

mariam-29 avatar Dec 09 '25 18:12 mariam-29

I would like to work on this issue. Could you please assign it to me.

anujaiitj123 avatar Dec 10 '25 18:12 anujaiitj123

Is this open to work on? I'd like to work on it.

dibyajyoti-mandal avatar Dec 13 '25 15:12 dibyajyoti-mandal