From 87f7a95d9bf40cf117294116d7a6fdaf60af4dac Mon Sep 17 00:00:00 2001 From: Valerij Talagayev <82884038+talagayev@users.noreply.github.com> Date: Mon, 15 Apr 2024 10:25:43 +0200 Subject: [PATCH 1/4] removed singleframereader test in test_gro.py --- testsuite/MDAnalysisTests/coordinates/test_gro.py | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/testsuite/MDAnalysisTests/coordinates/test_gro.py b/testsuite/MDAnalysisTests/coordinates/test_gro.py index ee1539d1474..a4342f3801f 100644 --- a/testsuite/MDAnalysisTests/coordinates/test_gro.py +++ b/testsuite/MDAnalysisTests/coordinates/test_gro.py @@ -21,7 +21,6 @@ # J. Comput. Chem. 32 (2011), 2319--2327, doi:10.1002/jcc.21787 # from io import StringIO -from pathlib import Path import MDAnalysis as mda import numpy as np @@ -529,16 +528,3 @@ def test_gro_empty_box_write_read(tmpdir): with pytest.warns(UserWarning, match=wmsg): u2 = mda.Universe('test.gro') assert u2.dimensions is None - - -def test_gro_pathlib_singleframereaderbase(): - top = Path(GRO) - assert isinstance(top, Path) - u = mda.Universe(top) - assert u.atoms.n_atoms == 47681 - - -def test_gro_string_singleframereaderbase(): - assert isinstance(GRO, str) - u = mda.Universe(GRO) - assert u.atoms.n_atoms == 47681 From 27e9685200e2d582162e14769ea4eab0e6753e9d Mon Sep 17 00:00:00 2001 From: Valerij Talagayev <82884038+talagayev@users.noreply.github.com> Date: Mon, 15 Apr 2024 10:26:50 +0200 Subject: [PATCH 2/4] removed singleframe_reader test in test_lammps.py --- .../MDAnalysisTests/coordinates/test_lammps.py | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/testsuite/MDAnalysisTests/coordinates/test_lammps.py b/testsuite/MDAnalysisTests/coordinates/test_lammps.py index 3d105131dec..88b4b8c35ee 100644 --- a/testsuite/MDAnalysisTests/coordinates/test_lammps.py +++ b/testsuite/MDAnalysisTests/coordinates/test_lammps.py @@ -30,7 +30,6 @@ from MDAnalysis import NoDataError from numpy.testing import (assert_equal, assert_allclose) -from pathlib import Path from MDAnalysisTests import make_Universe from MDAnalysisTests.coordinates.reference import ( @@ -820,16 +819,3 @@ def test_box(self, u_dump, u_data, reference_box): rtol=1e-5, atol=0) assert_allclose(u_data.dimensions, reference_box, rtol=1e-5, atol=0) - - -def test_pathlib_lammps_singleframereaderbase(): - top = Path(LAMMPSdata) - assert isinstance(top, Path) - u = mda.Universe(top) - assert u.atoms.n_atoms == 18364 - - -def test_string_lammps_singleframereaderbase(): - assert isinstance(LAMMPSdata, str) - u = mda.Universe(LAMMPSdata) - assert u.atoms.n_atoms == 18364 From 567e6ef4e37adef9c087aa24b6cef9c2e1210be6 Mon Sep 17 00:00:00 2001 From: Valerij Talagayev <82884038+talagayev@users.noreply.github.com> Date: Mon, 15 Apr 2024 10:31:20 +0200 Subject: [PATCH 3/4] added test for str and path input for singleframereader in base.py --- testsuite/MDAnalysisTests/coordinates/base.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/testsuite/MDAnalysisTests/coordinates/base.py b/testsuite/MDAnalysisTests/coordinates/base.py index a2a131bbbde..f48e4d1de88 100644 --- a/testsuite/MDAnalysisTests/coordinates/base.py +++ b/testsuite/MDAnalysisTests/coordinates/base.py @@ -25,6 +25,7 @@ import numpy as np import pytest +from pathlib import Path from unittest import TestCase from numpy.testing import (assert_equal, assert_almost_equal, assert_array_almost_equal, assert_allclose) @@ -126,6 +127,12 @@ def test_pickle_singleframe_reader(self): assert_equal(reader.ts, reader_p.ts, "Single-frame timestep is changed after pickling") + def test_pathlib_input_single(self): + path = Path(self.filename) + u_str = mda.Universe(self.filename) + u_path = mda.Universe(path) + assert u_str.atoms.n_atoms == u_path.atoms.n_atoms + class BaseReference(object): def __init__(self): From 5558dda257663dbc25152965847fd9e70b08fc48 Mon Sep 17 00:00:00 2001 From: Valerij Talagayev <82884038+talagayev@users.noreply.github.com> Date: Mon, 15 Apr 2024 11:17:41 +0200 Subject: [PATCH 4/4] Added Baseframe test for singleframes str and path input in base.py --- testsuite/MDAnalysisTests/coordinates/base.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/testsuite/MDAnalysisTests/coordinates/base.py b/testsuite/MDAnalysisTests/coordinates/base.py index f48e4d1de88..11104dc4989 100644 --- a/testsuite/MDAnalysisTests/coordinates/base.py +++ b/testsuite/MDAnalysisTests/coordinates/base.py @@ -32,6 +32,7 @@ import MDAnalysis as mda from MDAnalysis.coordinates.timestep import Timestep +from MDAnalysis.coordinates.memory import MemoryReader from MDAnalysis.transformations import translate @@ -528,6 +529,19 @@ def test_timeseries_atomgroup_asel_mutex(self, reader): atoms = mda.Universe(reader.filename).select_atoms("index 1") with pytest.raises(ValueError, match="Cannot provide both"): timeseries = reader.timeseries(atomgroup=atoms, asel=atoms, order='fac') + + def test_pathlib_input_base(self, reader): + skip_formats = ["DCD", "TNG", "XTC", "TRR"] + if isinstance(reader, MemoryReader) or reader.format in skip_formats: + if isinstance(reader, MemoryReader): + skip_reason = "MemoryReader" + else: + skip_reason = f"{reader.format} file format" + pytest.skip(f"Skipping test for {skip_reason}") + path = Path(reader.filename) + u_str = mda.Universe(reader.filename) + u_path = mda.Universe(path) + assert u_str.atoms.n_atoms == u_path.atoms.n_atoms class MultiframeReaderTest(BaseReaderTest):