mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-06-08 15:05:15 +02:00
format on save
This commit is contained in:
parent
247b84e90b
commit
1d7504fdfb
1 changed files with 20 additions and 16 deletions
|
|
@ -9,8 +9,7 @@ try:
|
|||
from mpi4py import MPI
|
||||
import subprocess
|
||||
|
||||
class MPITests(unittest.TestCase):
|
||||
|
||||
class MPITests:
|
||||
def test_BayesianGPLVM_MPI(self):
|
||||
code = """
|
||||
import numpy as np
|
||||
|
|
@ -33,17 +32,20 @@ if comm.rank==0:
|
|||
m._trigger_params_changed()
|
||||
print float(m.objective_function())
|
||||
"""
|
||||
with open('mpi_test__.py','w') as f:
|
||||
with open("mpi_test__.py", "w") as f:
|
||||
f.write(code)
|
||||
f.close()
|
||||
p = subprocess.Popen('mpirun -n 4 python mpi_test__.py',stdout=subprocess.PIPE,shell=True)
|
||||
p = subprocess.Popen(
|
||||
"mpirun -n 4 python mpi_test__.py", stdout=subprocess.PIPE, shell=True
|
||||
)
|
||||
(stdout, stderr) = p.communicate()
|
||||
L1 = float(stdout.splitlines()[-2])
|
||||
L2 = float(stdout.splitlines()[-1])
|
||||
self.assertTrue(np.allclose(L1,L2))
|
||||
L1 = float(stdout.splitlines()[-2])
|
||||
L2 = float(stdout.splitlines()[-1])
|
||||
self.assertTrue(np.allclose(L1, L2))
|
||||
import os
|
||||
os.remove('mpi_test__.py')
|
||||
|
||||
|
||||
os.remove("mpi_test__.py")
|
||||
|
||||
def test_SparseGPRegression_MPI(self):
|
||||
code = """
|
||||
import numpy as np
|
||||
|
|
@ -66,27 +68,29 @@ if comm.rank==0:
|
|||
m._trigger_params_changed()
|
||||
print float(m.objective_function())
|
||||
"""
|
||||
with open('mpi_test__.py','w') as f:
|
||||
with open("mpi_test__.py", "w") as f:
|
||||
f.write(code)
|
||||
f.close()
|
||||
p = subprocess.Popen('mpirun -n 4 python mpi_test__.py',stdout=subprocess.PIPE,shell=True)
|
||||
p = subprocess.Popen(
|
||||
"mpirun -n 4 python mpi_test__.py", stdout=subprocess.PIPE, shell=True
|
||||
)
|
||||
(stdout, stderr) = p.communicate()
|
||||
L1 = float(stdout.splitlines()[-2])
|
||||
L2 = float(stdout.splitlines()[-1])
|
||||
self.assertTrue(np.allclose(L1,L2))
|
||||
L1 = float(stdout.splitlines()[-2])
|
||||
L2 = float(stdout.splitlines()[-1])
|
||||
self.assertTrue(np.allclose(L1, L2))
|
||||
import os
|
||||
os.remove('mpi_test__.py')
|
||||
|
||||
os.remove("mpi_test__.py")
|
||||
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
print("Running unit tests, please be (very) patient...")
|
||||
try:
|
||||
import mpi4py
|
||||
|
||||
unittest.main()
|
||||
except:
|
||||
pass
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue