diff --git a/package/MDAnalysis/analysis/polymer.py b/package/MDAnalysis/analysis/polymer.py index c9e0a43188..04d96f3ec5 100644 --- a/package/MDAnalysis/analysis/polymer.py +++ b/package/MDAnalysis/analysis/polymer.py @@ -123,9 +123,9 @@ class PersistenceLength(AnalysisBase): C(n) = \langle \cos\theta_{i, i+n} \rangle = \langle \mathbf{a_i} \cdot \mathbf{a_{i+n}} \rangle - + where :math:`a_i` and :math:`a_{i+n}` are unit vectors - along the bonds. (Because for two vectors :math:`\mathbf{a}` and :math:`\mathbf{b}`, + along the bonds. (Because for two vectors :math:`\mathbf{a}` and :math:`\mathbf{b}`, :math:`\mathbf{a} \cdot \mathbf{b} = |\mathbf{a}| |\mathbf{b}| \cos{\alpha}`, where :math:`\alpha` is the angle between the two vectors.) diff --git a/package/MDAnalysis/core/selection.py b/package/MDAnalysis/core/selection.py index 6c2ea3c817..d47f4d7ac1 100644 --- a/package/MDAnalysis/core/selection.py +++ b/package/MDAnalysis/core/selection.py @@ -1106,25 +1106,41 @@ class WaterSelection(Selection): .. versionadded:: 2.9.0 """ - token = 'water' + + token = "water" # Recognized water resnames water_res = { - 'H2O', 'HOH', 'OH2', 'HHO', 'OHH', - 'T3P', 'T4P', 'T5P', 'SOL', 'WAT', - 'TIP', 'TIP2', 'TIP3', 'TIP4' + "H2O", + "HOH", + "OH2", + "HHO", + "OHH", + "T3P", + "T4P", + "T5P", + "SOL", + "WAT", + "TIP", + "TIP2", + "TIP3", + "TIP4", } def _apply(self, group): resnames = group.universe._topology.resnames nmidx = resnames.nmidx[group.resindices] - matches = [ix for (nm, ix) in resnames.namedict.items() - if nm in self.water_res] + matches = [ + ix + for (nm, ix) in resnames.namedict.items() + if nm in self.water_res + ] mask = np.isin(nmidx, matches) return group[mask] + class BackboneSelection(ProteinSelection): """A BackboneSelection contains all atoms with name 'N', 'CA', 'C', 'O'. diff --git a/testsuite/MDAnalysisTests/coordinates/test_xdr.py b/testsuite/MDAnalysisTests/coordinates/test_xdr.py index 2ca76580fc..c2c7a0b217 100644 --- a/testsuite/MDAnalysisTests/coordinates/test_xdr.py +++ b/testsuite/MDAnalysisTests/coordinates/test_xdr.py @@ -984,10 +984,12 @@ def test_persistent_offsets_readonly(self, tmpdir, trajectory): shutil.copy(self.filename, str(tmpdir)) filename = str(tmpdir.join(os.path.basename(self.filename))) - print('filename', filename) + print("filename", filename) ref_offset = trajectory._xdr.offsets # Mock filelock acquire to raise an error - with patch.object(FileLock, "acquire", side_effect=PermissionError): # Simulate failure + with patch.object( + FileLock, "acquire", side_effect=PermissionError + ): # Simulate failure with pytest.warns(UserWarning, match="Cannot write lock"): reader = self._reader(filename) saved_offsets = reader._xdr.offsets @@ -1008,12 +1010,10 @@ def test_persistent_offsets_readonly(self, tmpdir, trajectory): @pytest.mark.skipif( sys.platform.startswith("win"), - reason="The lock file only exists when it's locked in windows" + reason="The lock file only exists when it's locked in windows", ) def test_offset_lock_created(self, traj): - assert os.path.exists( - XDR.offsets_filename(traj, ending="lock") - ) + assert os.path.exists(XDR.offsets_filename(traj, ending="lock")) class TestXTCReader_offsets(_GromacsReader_offsets):