From 1d7504fdfb2c63ad75b63f3e8e63a2b151f84aed Mon Sep 17 00:00:00 2001 From: Martin Bubel Date: Tue, 10 Oct 2023 18:48:06 +0200 Subject: [PATCH] format on save --- GPy/testing/mpi_tests.py | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/GPy/testing/mpi_tests.py b/GPy/testing/mpi_tests.py index 28a23288..8bde8755 100644 --- a/GPy/testing/mpi_tests.py +++ b/GPy/testing/mpi_tests.py @@ -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