Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pathlib object handling for Universe, SingleFrameReaderBase and Toplogy parsers (Issue #3937) #4535

Open
wants to merge 17 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package/AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ Chronological list of authors
2024
- Aditya Keshari
- Philipp Stärk
- Valerij Talagayev

External code
-------------
Expand Down
3 changes: 2 additions & 1 deletion package/CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ The rules for this file:
-------------------------------------------------------------------------------
??/??/?? IAlibay, HeetVekariya, marinegor, lilyminium, RMeli,
ljwoods2, aditya292002, pstaerk, PicoCentauri, BFedder,
tyler.je.reddy
tyler.je.reddy, talagayev

* 2.8.0

Expand All @@ -34,6 +34,7 @@ Fixes
* Fix deploy action to use the correct version of the pypi upload action.

Enhancements
* Implementation of tests for str and pathlib handling of SingleFrameReaderBase (Issue #3937)
* Improved performance of PDBWriter (Issue #2785, PR #4472)
* Added parsing of arbitrary columns of the LAMMPS dump parser. (Issue #3504)
* Documented the r0 attribute in the `Contacts` class and added the
Expand Down
15 changes: 14 additions & 1 deletion testsuite/MDAnalysisTests/coordinates/test_gro.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
# 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
Expand All @@ -46,7 +47,6 @@
assert_equal,
)
import pytest
from io import StringIO


class TestGROReaderOld(RefAdK):
Expand Down Expand Up @@ -529,3 +529,16 @@ 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
14 changes: 14 additions & 0 deletions testsuite/MDAnalysisTests/coordinates/test_lammps.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
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 (
Expand Down Expand Up @@ -819,3 +820,16 @@ 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
Loading