Skip to content

Commit

Permalink
Update test_align.py
Browse files Browse the repository at this point in the history
fixing pep
  • Loading branch information
talagayev authored Oct 18, 2024
1 parent 2457c74 commit 0796f48
Showing 1 changed file with 24 additions and 11 deletions.
35 changes: 24 additions & 11 deletions testsuite/MDAnalysisTests/analysis/test_align.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,9 +472,9 @@ def test_average_structure_deprecated_attrs(
self, universe, reference, client_AverageStructure
):
# Issue #3278 - remove in MDAnalysis 3.0.0
avg = align.AverageStructure(universe, reference).run(stop=2,
**client_AverageStructure
)
avg = align.AverageStructure(universe, reference).run(
stop=2,**client_AverageStructure
)

wmsg = "The `universe` attribute was deprecated in MDAnalysis 2.0.0"
with pytest.warns(DeprecationWarning, match=wmsg):
Expand All @@ -489,23 +489,32 @@ def test_average_structure_deprecated_attrs(
with pytest.warns(DeprecationWarning, match=wmsg):
assert avg.rmsd == avg.results.rmsd

def test_average_structure(self, universe, reference, client_AverageStructure):
def test_average_structure(
self, universe, reference, client_AverageStructure
):
ref, rmsd = _get_aligned_average_positions(self.ref_files, reference)
avg = align.AverageStructure(universe, reference).run(**client_AverageStructure)
avg = align.AverageStructure(universe, reference).run(
**client_AverageStructure
)
assert_allclose(avg.results.universe.atoms.positions, ref, rtol=0, atol=1.5e-4)
assert_allclose(avg.results.rmsd, rmsd, rtol=0, atol=1.5e-7)

def test_average_structure_mass_weighted(self, universe, reference, client_AverageStructure):
def test_average_structure_mass_weighted(
self, universe, reference, client_AverageStructure
):
ref, rmsd = _get_aligned_average_positions(self.ref_files, reference, weights='mass')
avg = align.AverageStructure(universe, reference, weights='mass').run(**client_AverageStructure)
assert_allclose(avg.results.universe.atoms.positions, ref,
rtol=0, atol=1.5e-4)
assert_allclose(avg.results.rmsd, rmsd, rtol=0, atol=1.5e-7)

def test_average_structure_select(self, universe, reference, client_AverageStructure):
def test_average_structure_select(
self, universe, reference, client_AverageStructure
):
select = 'protein and name CA and resid 3-5'
ref, rmsd = _get_aligned_average_positions(self.ref_files, reference, select=select)
avg = align.AverageStructure(universe, reference, select=select).run(**client_AverageStructure)
avg = align.AverageStructure(universe, reference,
select=select).run(**client_AverageStructure)
assert_allclose(avg.results.universe.atoms.positions, ref,
rtol=0, atol=1.5e-4)
assert_allclose(avg.results.rmsd, rmsd, rtol=0, atol=1.5e-7)
Expand Down Expand Up @@ -537,13 +546,17 @@ def test_average_structure_ref_frame(self, universe, client_AverageStructure):
# back to start
universe.trajectory[0]
ref, rmsd = _get_aligned_average_positions(self.ref_files, u)
avg = align.AverageStructure(universe, ref_frame=ref_frame).run(**client_AverageStructure)
avg = align.AverageStructure(universe,
ref_frame=ref_frame).run(**client_AverageStructure)
assert_allclose(avg.results.universe.atoms.positions, ref,
rtol=0, atol=1.5e-4)
assert_allclose(avg.results.rmsd, rmsd, rtol=0, atol=1.5e-7)

def test_average_structure_in_memory(self, universe, client_AverageStructure):
avg = align.AverageStructure(universe, in_memory=True).run(**client_AverageStructure)
def test_average_structure_in_memory(
self, universe, client_AverageStructure
):
avg = align.AverageStructure(universe,
in_memory=True).run(**client_AverageStructure)
reference_coordinates = universe.trajectory.timeseries().mean(axis=1)
assert_allclose(avg.results.universe.atoms.positions,
reference_coordinates, rtol=0, atol=1.5e-4)
Expand Down

0 comments on commit 0796f48

Please sign in to comment.