Skip to content
Merged
1 change: 1 addition & 0 deletions package/AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ Chronological list of authors
- Ra煤l Lois-Cuns
- Pranay Pelapkar
- Shreejan Dolai
- Tanisha Dubey

External code
-------------
Expand Down
6 changes: 3 additions & 3 deletions package/MDAnalysis/analysis/msd.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,10 +382,10 @@ def _parse_msd_type(self):
"xyz": [0, 1, 2],
}

self.msd_type = self.msd_type.lower()

try:
self._dim = keys[self.msd_type]
self._dim = keys[self.msd_type.lower()]
except AttributeError:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't double except here, just do the one exception message and add the word "string" in the message.

raise TypeError("msd_type must be a string")
except KeyError:
raise ValueError(
"invalid msd_type: {} specified, please specify one of xyz, "
Expand Down
9 changes: 9 additions & 0 deletions testsuite/MDAnalysisTests/analysis/test_msd.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,15 @@ def test_msdtype_error(self, u, SELECTION, msdtype):
with pytest.raises(ValueError, match=errmsg):
m = MSD(u, SELECTION, msd_type=msdtype)

def test_msd_type_uppercase(self, u, SELECTION):
m = MSD(u, SELECTION, msd_type="Xz", fft=False)
assert m.dim_fac == 2
assert m._dim == [0, 2]

def test_msd_type_nonstring(self, u, SELECTION):
with pytest.raises(TypeError):
MSD(u, SELECTION, msd_type=123, fft=False)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just make these extra parameters of the test_msdtype_error method above.


@pytest.mark.parametrize(
"dim, dim_factor",
[
Expand Down
Loading