Skip to content

Commit f61e50e

Browse files
committed
Format cylayer selection test for Black
1 parent d05ed3d commit f61e50e

1 file changed

Lines changed: 23 additions & 62 deletions

File tree

testsuite/MDAnalysisTests/core/test_atomselections.py

Lines changed: 23 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,7 @@ def test_resid_single(self, universe):
128128
def test_resid_range(self, universe):
129129
sel = universe.select_atoms("resid 100:105")
130130
assert_equal(sel.n_atoms, 89)
131-
assert_equal(
132-
sel.residues.resnames, ["GLY", "ILE", "ASN", "VAL", "ASP", "TYR"]
133-
)
131+
assert_equal(sel.residues.resnames, ["GLY", "ILE", "ASN", "VAL", "ASP", "TYR"])
134132

135133
def test_selgroup(self, universe):
136134
sel = universe.select_atoms("not resid 100")
@@ -157,23 +155,15 @@ def test_resnum_range(self, universe):
157155
sel = universe.select_atoms("resnum 100:105")
158156
assert_equal(sel.n_atoms, 89)
159157
assert_equal(sel.residues.resids, range(100, 106))
160-
assert_equal(
161-
sel.residues.resnames, ["GLY", "ILE", "ASN", "VAL", "ASP", "TYR"]
162-
)
158+
assert_equal(sel.residues.resnames, ["GLY", "ILE", "ASN", "VAL", "ASP", "TYR"])
163159

164160
def test_resname(self, universe):
165161
sel = universe.select_atoms("resname LEU")
166-
assert_equal(
167-
sel.n_atoms, 304, "Failed to find all 'resname LEU' atoms."
168-
)
169-
assert_equal(
170-
sel.n_residues, 16, "Failed to find all 'resname LEU' residues."
171-
)
162+
assert_equal(sel.n_atoms, 304, "Failed to find all 'resname LEU' atoms.")
163+
assert_equal(sel.n_residues, 16, "Failed to find all 'resname LEU' residues.")
172164
assert_equal(
173165
sorted(sel.indices),
174-
sorted(
175-
universe.select_atoms("segid 4AKE and resname LEU").indices
176-
),
166+
sorted(universe.select_atoms("segid 4AKE and resname LEU").indices),
177167
"selected 'resname LEU' atoms are not the same as auto-generated s4AKE.LEU",
178168
)
179169

@@ -187,9 +177,7 @@ def test_atom(self, universe):
187177
assert_equal(sel.resnames, ["GLY"])
188178
assert_equal(
189179
sel.positions,
190-
np.array(
191-
[[20.38685226, -3.44224262, -5.92158318]], dtype=np.float32
192-
),
180+
np.array([[20.38685226, -3.44224262, -5.92158318]], dtype=np.float32),
193181
)
194182

195183
def test_atom_empty(self, universe):
@@ -331,10 +319,7 @@ def test_same_resname(self, universe):
331319
assert_equal(
332320
len(sel),
333321
331,
334-
(
335-
"Found a wrong number of atoms with same resname as "
336-
"resids 10 or 11"
337-
),
322+
("Found a wrong number of atoms with same resname as " "resids 10 or 11"),
338323
)
339324
# fmt: off
340325
target_resids = np.array(
@@ -429,9 +414,7 @@ def test_no_space_around_parentheses(self, universe):
429414
def test_concatenated_selection(self, universe):
430415
E151 = universe.select_atoms("segid 4AKE").select_atoms("resid 151")
431416
# note that this is not quite phi... HN should be C of prec. residue
432-
phi151 = E151.atoms.select_atoms(
433-
"name HN", "name N", "name CA", "name CB"
434-
)
417+
phi151 = E151.atoms.select_atoms("name HN", "name N", "name CA", "name CB")
435418
assert_equal(len(phi151), 4)
436419
assert_equal(
437420
phi151[0].name,
@@ -443,9 +426,7 @@ def test_global(self, universe):
443426
"""Test the `global` modifier keyword (Issue 268)"""
444427
ag = universe.select_atoms("resname LYS and name NZ")
445428
# Lys amines within 4 angstrom of the backbone.
446-
ag1 = universe.select_atoms(
447-
"resname LYS and name NZ and around 4 backbone"
448-
)
429+
ag1 = universe.select_atoms("resname LYS and name NZ and around 4 backbone")
449430
ag2 = ag.select_atoms("around 4 global backbone")
450431
assert_equal(ag2.indices, ag1.indices)
451432

@@ -496,12 +477,8 @@ def universe(self):
496477
def test_protein(self, universe):
497478
# must include non-standard residues
498479
sel = universe.select_atoms("protein or resname HAO or resname ORT")
499-
assert_equal(
500-
sel.n_atoms, universe.atoms.n_atoms, "failed to select peptide"
501-
)
502-
assert_equal(
503-
sel.n_residues, 6, "failed to select all peptide residues"
504-
)
480+
assert_equal(sel.n_atoms, universe.atoms.n_atoms, "failed to select peptide")
481+
assert_equal(sel.n_residues, 6, "failed to select all peptide residues")
505482

506483
def test_resid_single(self, universe):
507484
sel = universe.select_atoms("resid 12")
@@ -591,9 +568,7 @@ def test_same_fragment(self, universe, selstr):
591568
# This test comes here because it's a system with solvent,
592569
# and thus multiple fragments.
593570
sel = universe.select_atoms(selstr)
594-
errmsg = (
595-
"Found a wrong number of atoms " "on the same fragment as id 1"
596-
)
571+
errmsg = "Found a wrong number of atoms " "on the same fragment as id 1"
597572
assert_equal(len(sel), 3341, errmsg)
598573
errmsg = (
599574
"Found a differ set of atoms when using the 'same "
@@ -696,9 +671,7 @@ def test_passing_rdkit_kwargs_to_converter(self):
696671
def test_passing_max_matches_to_converter(self, u2):
697672
with pytest.warns(UserWarning, match="Your smarts-based") as wsmg:
698673
sel = u2.select_atoms("smarts C", smarts_kwargs=dict(maxMatches=2))
699-
sel2 = u2.select_atoms(
700-
"smarts C", smarts_kwargs=dict(maxMatches=1000)
701-
)
674+
sel2 = u2.select_atoms("smarts C", smarts_kwargs=dict(maxMatches=1000))
702675
assert sel.n_atoms == 2
703676
assert sel2.n_atoms == 3
704677

@@ -909,9 +882,7 @@ class TestOrthogonalDistanceSelections(BaseDistanceSelection):
909882
def u(self):
910883
return mda.Universe(TRZ_psf, TRZ)
911884

912-
@pytest.mark.parametrize(
913-
"meth, periodic", [("distmat", True), ("distmat", False)]
914-
)
885+
@pytest.mark.parametrize("meth, periodic", [("distmat", True), ("distmat", False)])
915886
def test_cyzone(self, u, meth, periodic):
916887
sel = Parser.parse("cyzone 5 4 -4 resid 2", u.atoms)
917888
sel.periodic = periodic
@@ -1179,9 +1150,7 @@ def test_flip(self, prop, ag, op):
11791150
# reference group, doing things forwards
11801151
ref = ag[func(getattr(ag, self.plurals[prop]), 1.5)]
11811152

1182-
selstr = "prop 1.5 {op} {prop}".format(
1183-
op=self.opposites[op], prop=prop
1184-
)
1153+
selstr = "prop 1.5 {op} {prop}".format(op=self.opposites[op], prop=prop)
11851154
sel = ag.select_atoms(selstr)
11861155

11871156
assert_equal(set(ref.indices), set(sel.indices))
@@ -1212,9 +1181,7 @@ class TestSelectionErrors(object):
12121181
@staticmethod
12131182
@pytest.fixture()
12141183
def universe():
1215-
return make_Universe(
1216-
("names", "masses", "resids", "resnames", "resnums")
1217-
)
1184+
return make_Universe(("names", "masses", "resids", "resnames", "resnums"))
12181185

12191186
@pytest.mark.parametrize(
12201187
"selstr",
@@ -1317,9 +1284,7 @@ def test_string_selections(self, ref, sel, universe):
13171284
],
13181285
)
13191286
def test_range_selections(self, seltype, ref, sel, universe):
1320-
self._check_sels(
1321-
ref.format(typ=seltype), sel.format(typ=seltype), universe
1322-
)
1287+
self._check_sels(ref.format(typ=seltype), sel.format(typ=seltype), universe)
13231288

13241289

13251290
class TestICodeSelection(object):
@@ -1663,9 +1628,7 @@ def test_bool_sel_error():
16631628

16641629
def test_error_selection_for_strange_dtype():
16651630
with pytest.raises(ValueError, match="No base class defined for dtype"):
1666-
MDAnalysis.core.selection.gen_selection_class(
1667-
"star", "stars", dict, "atom"
1668-
)
1631+
MDAnalysis.core.selection.gen_selection_class("star", "stars", dict, "atom")
16691632

16701633

16711634
@pytest.mark.parametrize(
@@ -1732,9 +1695,7 @@ def test_chirality(smi, chirality):
17321695
assert u.atoms[0].chirality == ""
17331696
assert u.atoms[1].chirality == chirality
17341697

1735-
assert_equal(
1736-
u.atoms[:3].chiralities, np.array(["", chirality, ""], dtype="U1")
1737-
)
1698+
assert_equal(u.atoms[:3].chiralities, np.array(["", chirality, ""], dtype="U1"))
17381699

17391700

17401701
@pytest.mark.parametrize(
@@ -1776,19 +1737,19 @@ def test_formal_charge_selection(sel, size, name):
17761737
assert len(ag) == size
17771738
assert ag.atoms[0].name == name
17781739

1740+
17791741
@pytest.fixture(scope="module")
17801742
def universe():
17811743
u = mda.Universe(PSF, DCD)
17821744
u.dimensions = np.array([100.0, 100.0, 100.0, 90.0, 90.0, 90.0])
17831745
return u
17841746

1747+
17851748
def test_cylayer_selection_parses_correctly(universe):
17861749
universe.dimensions = np.array([100, 100, 100, 90, 90, 90])
17871750

1788-
sel = universe.select_atoms(
1789-
"cylayer 5 10 15 -15 name CA"
1790-
)
1751+
sel = universe.select_atoms("cylayer 5 10 15 -15 name CA")
17911752

17921753
# Basic sanity checks
17931754
assert len(sel) > 0
1794-
assert sel.n_atoms <= universe.atoms.n_atoms
1755+
assert sel.n_atoms <= universe.atoms.n_atoms

0 commit comments

Comments
 (0)