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

Limit threads usage in numpy during test to reduce test time #4584

Open
wants to merge 12 commits into
base: develop
Choose a base branch
from
16 changes: 8 additions & 8 deletions testsuite/MDAnalysisTests/analysis/test_encore.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def test_parallel_calculation(self):
arguments = [tuple([i]) for i in np.arange(0, 100)]

parallel_calculation = encore.utils.ParallelCalculation(
function=function, n_jobs=4, args=arguments
function=function, n_jobs=2, args=arguments
)
results = parallel_calculation.run()

Expand All @@ -173,14 +173,14 @@ def test_rmsd_matrix_with_superimposition(self, ens1):
encore.confdistmatrix.conformational_distance_matrix(
ens1,
encore.confdistmatrix.set_rmsd_matrix_elements,
select="name CA",
select="name CA and resnum 1:3",
pairwise_align=True,
weights="mass",
n_jobs=1,
)
)

reference = rms.RMSD(ens1, select="name CA")
reference = rms.RMSD(ens1, select="name CA and resnum 1:3")
reference.run()
err_msg = (
"Calculated RMSD values differ from "
Expand All @@ -200,7 +200,7 @@ def test_rmsd_matrix_with_superimposition_custom_weights(self, ens1):
encore.confdistmatrix.conformational_distance_matrix(
ens1,
encore.confdistmatrix.set_rmsd_matrix_elements,
select="name CA",
select="name CA and resnum 1:3",
pairwise_align=True,
weights="mass",
n_jobs=1,
Expand All @@ -211,11 +211,11 @@ def test_rmsd_matrix_with_superimposition_custom_weights(self, ens1):
encore.confdistmatrix.conformational_distance_matrix(
ens1,
encore.confdistmatrix.set_rmsd_matrix_elements,
select="name CA",
select="name CA and resnum 1:3",
pairwise_align=True,
weights=(
ens1.select_atoms("name CA").masses,
ens1.select_atoms("name CA").masses,
ens1.select_atoms("name CA and resnum 1:3").masses,
ens1.select_atoms("name CA and resnum 1:3").masses,
),
n_jobs=1,
)
Expand All @@ -230,7 +230,7 @@ def test_rmsd_matrix_with_superimposition_custom_weights(self, ens1):
)

def test_rmsd_matrix_without_superimposition(self, ens1):
selection_string = "name CA"
selection_string = "name CA and resnum 1:3"
selection = ens1.select_atoms(selection_string)
reference_rmsd = []
coordinates = ens1.trajectory.timeseries(selection, order="fac")
Expand Down
18 changes: 9 additions & 9 deletions testsuite/MDAnalysisTests/parallelism/test_multiprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@
),
(NCDF,),
(np.arange(150).reshape(5, 10, 3).astype(np.float64),),
(GRO, [GRO, GRO, GRO, GRO, GRO]),
(PDB, [PDB, PDB, PDB, PDB, PDB]),
(GRO, [GRO, GRO]),
(PDB, [PDB, PDB]),
(GRO, [XTC, XTC]),
(TRC_PDB_VAC, TRC_TRAJ1_VAC),
(TRC_PDB_VAC, [TRC_TRAJ1_VAC, TRC_TRAJ2_VAC]),
Expand Down Expand Up @@ -130,10 +130,10 @@ def cog(u, ag, frame_id):
def test_multiprocess_COG(u):
ag = u.atoms[2:5]

ref = np.array([cog(u, ag, i) for i in range(3)])
ref = np.array([cog(u, ag, i) for i in range(2)])

p = multiprocessing.Pool(2)
res = np.array([p.apply(cog, args=(u, ag, i)) for i in range(3)])
res = np.array([p.apply(cog, args=(u, ag, i)) for i in range(2)])
p.close()
assert_equal(ref, res)

Expand All @@ -145,10 +145,10 @@ def getnames(u, ix):

def test_universe_unpickle_in_new_process():
u = mda.Universe(GRO, XTC)
ref = [getnames(u, i) for i in range(3)]
ref = [getnames(u, i) for i in range(2)]

p = multiprocessing.Pool(2)
res = [p.apply(getnames, args=(u, i)) for i in range(3)]
res = [p.apply(getnames, args=(u, i)) for i in range(2)]
p.close()

assert_equal(ref, res)
Expand Down Expand Up @@ -206,9 +206,9 @@ def test_creating_multiple_universe_without_offset(temp_xtc, ncopies=3):
("memory", np.arange(60).reshape(2, 10, 3).astype(np.float64), dict()),
("TRC", TRC_TRAJ1_VAC, dict()),
("CHAIN", [TRC_TRAJ1_VAC, TRC_TRAJ2_VAC], dict()),
("CHAIN", [GRO, GRO, GRO], dict()),
("CHAIN", [PDB, PDB, PDB], dict()),
("CHAIN", [XTC, XTC, XTC], dict()),
("CHAIN", [GRO, GRO], dict()),
("CHAIN", [PDB, PDB], dict()),
("CHAIN", [XTC, XTC], dict()),
]
)
def ref_reader(request):
Expand Down
Loading