From 1d51f79f1b68ae79f291ab16c10ff2f74ac63b58 Mon Sep 17 00:00:00 2001 From: ogiorgis Date: Tue, 30 Jan 2024 14:46:09 +0100 Subject: [PATCH] ci: run black on plugins --- .../src_cpp/2d/plot_results.py | 31 ++++++----- .../src_cpp/2d/run_benchs.py | 51 ++++++++++++------- 2 files changed, 47 insertions(+), 35 deletions(-) diff --git a/plugins/fluidfft-build-deps/fluidfft_build_deps/src_cpp/2d/plot_results.py b/plugins/fluidfft-build-deps/fluidfft_build_deps/src_cpp/2d/plot_results.py index 3baa6da..c031be2 100644 --- a/plugins/fluidfft-build-deps/fluidfft_build_deps/src_cpp/2d/plot_results.py +++ b/plugins/fluidfft-build-deps/fluidfft_build_deps/src_cpp/2d/plot_results.py @@ -1,4 +1,3 @@ - from runpy import run_path import numpy as np @@ -7,24 +6,24 @@ array = np.array -d = run_path('Results_bench/bench.py') +d = run_path("Results_bench/bench.py") -nb_procs = d['nb_procs'] -times_fft = d['times_fft'] -times_ifft = d['times_ifft'] +nb_procs = d["nb_procs"] +times_fft = d["times_fft"] +times_ifft = d["times_ifft"] fig = plt.figure() ax = plt.gca() for cls, nb_proc in nb_procs.items(): - ax.plot(nb_proc, times_fft[cls], 'bo--') - ax.plot(nb_proc, times_ifft[cls], 'ro--') + ax.plot(nb_proc, times_fft[cls], "bo--") + ax.plot(nb_proc, times_ifft[cls], "ro--") -ax.set_xlabel('number of processes') -ax.set_ylabel('time (s)') +ax.set_xlabel("number of processes") +ax.set_ylabel("time (s)") ind_base = 0 -cls_base = 'FFT2DMPIWithFFTW1D' +cls_base = "FFT2DMPIWithFFTW1D" nb_proc_base = nb_procs[cls_base][ind_base] @@ -34,14 +33,14 @@ for cls, nb_proc in nb_procs.items(): - speedup_fft = times_fft[cls_base][ind_base]/times_fft[cls] - speedup_ifft = times_ifft[cls_base][ind_base]/times_ifft[cls] + speedup_fft = times_fft[cls_base][ind_base] / times_fft[cls] + speedup_ifft = times_ifft[cls_base][ind_base] / times_ifft[cls] - ax.plot(nb_proc, nb_proc_base*speedup_fft/nb_proc, 'bo--') - ax.plot(nb_proc, nb_proc_base*speedup_ifft/nb_proc, 'ro--') + ax.plot(nb_proc, nb_proc_base * speedup_fft / nb_proc, "bo--") + ax.plot(nb_proc, nb_proc_base * speedup_ifft / nb_proc, "ro--") -ax.set_xlabel('number of processes') -ax.set_ylabel('speedup divided by the number of processes') +ax.set_xlabel("number of processes") +ax.set_ylabel("speedup divided by the number of processes") plt.show() diff --git a/plugins/fluidfft-build-deps/fluidfft_build_deps/src_cpp/2d/run_benchs.py b/plugins/fluidfft-build-deps/fluidfft_build_deps/src_cpp/2d/run_benchs.py index d83acb7..f6cad39 100644 --- a/plugins/fluidfft-build-deps/fluidfft_build_deps/src_cpp/2d/run_benchs.py +++ b/plugins/fluidfft-build-deps/fluidfft_build_deps/src_cpp/2d/run_benchs.py @@ -1,11 +1,10 @@ - import os import subprocess32 as subprocess import numpy as np -output_dir = 'Results_bench' +output_dir = "Results_bench" def call_bash(commands): @@ -25,22 +24,22 @@ def call_bash(commands): for i, nb_proc in enumerate(nb_procs_all): - command = './test_bench.out --N0={} --N1={}'.format(N0, N1) + command = "./test_bench.out --N0={} --N1={}".format(N0, N1) if nb_proc != 1: - command = 'mpirun -np {} '.format(nb_proc) + command + command = "mpirun -np {} ".format(nb_proc) + command txt = call_bash(command) - blocks = txt.split('--------') + blocks = txt.split("--------") # print('\n'.join(lines)) for block in blocks: - if 'Initialization' in block: + if "Initialization" in block: lines = block.splitlines() for line in lines: - if line.startswith('Initialization ('): - cls = line.split('(')[1].split(')')[0] + if line.startswith("Initialization ("): + cls = line.split("(")[1].split(")")[0] if cls not in classes: classes.append(cls) nb_procs[cls] = [] @@ -48,16 +47,20 @@ def call_bash(commands): times_ifft[cls] = [] for line in lines: - if line.startswith('nb_proc:'): + if line.startswith("nb_proc:"): nb_procs[cls].append(int(line.split()[1])) - if line.startswith('time fft'): + if line.startswith("time fft"): times_fft[cls].append(float(line.split()[3])) - if line.startswith('time ifft'): + if line.startswith("time ifft"): times_ifft[cls].append(float(line.split()[3])) - print('class ' + cls + - ': times fft and ifft: {:5.3f} ; {:5.3f}'.format( - times_fft[cls][-1], times_ifft[cls][-1])) + print( + "class " + + cls + + ": times fft and ifft: {:5.3f} ; {:5.3f}".format( + times_fft[cls][-1], times_ifft[cls][-1] + ) + ) src = """ from numpy import array @@ -69,12 +72,22 @@ def call_bash(commands): for cls in classes: src += ( - "\nnb_procs['" + cls + "'] = " + repr(np.array(nb_procs[cls])) + - "\ntimes_fft['" + cls + "'] = " + repr(np.array(times_fft[cls])) + - "\ntimes_ifft['" + cls + "'] = " + repr(np.array(times_ifft[cls]))) + "\nnb_procs['" + + cls + + "'] = " + + repr(np.array(nb_procs[cls])) + + "\ntimes_fft['" + + cls + + "'] = " + + repr(np.array(times_fft[cls])) + + "\ntimes_ifft['" + + cls + + "'] = " + + repr(np.array(times_ifft[cls])) + ) if not os.path.exists(output_dir): os.mkdir(output_dir) -with open(output_dir + '/bench.py', 'w') as f: - f.write(src + '\n') +with open(output_dir + "/bench.py", "w") as f: + f.write(src + "\n")