From 299a2ac4e8feb24d030c1ebb50d504d91b17a8f6 Mon Sep 17 00:00:00 2001 From: ilhamv Date: Wed, 22 Nov 2023 13:24:46 -0800 Subject: [PATCH] back in black --- mcdc/main.py | 6 ++-- test/regression/dsm_lattice/input.py | 2 ++ test/regression/run.py | 51 ++++++++++------------------ 3 files changed, 23 insertions(+), 36 deletions(-) diff --git a/mcdc/main.py b/mcdc/main.py index 9c69eda4..53e67045 100644 --- a/mcdc/main.py +++ b/mcdc/main.py @@ -9,8 +9,8 @@ ) parser.add_argument("--N_particle", type=int, help="Number of particles") parser.add_argument("--output", type=str, help="Output file name") -parser.add_argument('--progress_bar', default=False, action='store_true') -parser.add_argument('--no-progress_bar', dest='progress_bar', action='store_false') +parser.add_argument("--progress_bar", default=False, action="store_true") +parser.add_argument("--no-progress_bar", dest="progress_bar", action="store_false") args, unargs = parser.parse_known_args() # Set mode @@ -47,7 +47,7 @@ def run(): if args.output is not None: input_deck.setting["output_name"] = args.output if args.progress_bar is not None: - input_deck.setting['progress_bar'] = args.progress_bar + input_deck.setting["progress_bar"] = args.progress_bar # Start timer total_start = MPI.Wtime() diff --git a/test/regression/dsm_lattice/input.py b/test/regression/dsm_lattice/input.py index 6f5bde97..9d6478f2 100644 --- a/test/regression/dsm_lattice/input.py +++ b/test/regression/dsm_lattice/input.py @@ -10,6 +10,7 @@ lib = h5py.File("c5g7.h5", "r") + def set_mat(mat): return mcdc.material( capture=mat["capture"][:], @@ -24,6 +25,7 @@ def set_mat(mat): sensitivity=True, ) + mat_uo2 = set_mat(lib["uo2"]) # Fuel: UO2 mat_mod = set_mat(lib["mod"]) # Moderator mat_cr = set_mat(lib["cr"]) # Control rod diff --git a/test/regression/run.py b/test/regression/run.py index 3a5ef202..59f429fe 100644 --- a/test/regression/run.py +++ b/test/regression/run.py @@ -40,7 +40,7 @@ if name == "__pycache__": continue - print("\n[%i/%i] "%(i+1,len(names)) + name) + print("\n[%i/%i] " % (i + 1, len(names)) + name) error_msgs.append([]) crashes.append(False) runtimes.append(-1) @@ -123,7 +123,7 @@ ) # Other quantities - for result_name in ['k_mean', 'k_sdev', 'k_cycle', 'k_eff']: + for result_name in ["k_mean", "k_sdev", "k_cycle", "k_eff"]: if result_name not in output.keys(): continue @@ -132,45 +132,25 @@ # Passed? if np.isclose(a, b).all(): - print( - Fore.GREEN - + " {}: Passed".format(result_name) - + Style.RESET_ALL - ) + print(Fore.GREEN + " {}: Passed".format(result_name) + Style.RESET_ALL) else: all_pass = False - error_msgs[-1].append( - "Differences in {}\n{}".format(result_name, a - b) - ) - print( - Fore.RED - + " {}: Failed".format(result_name) - + Style.RESET_ALL - ) + error_msgs[-1].append("Differences in {}\n{}".format(result_name, a - b)) + print(Fore.RED + " {}: Failed".format(result_name) + Style.RESET_ALL) # iQMC flux - if 'iqmc' in output.keys(): - result_name = 'iqmc/flux' + if "iqmc" in output.keys(): + result_name = "iqmc/flux" a = output[result_name][:] b = answer[result_name][:] # Passed? if np.isclose(a, b).all(): - print( - Fore.GREEN - + " {}: Passed".format(result_name) - + Style.RESET_ALL - ) + print(Fore.GREEN + " {}: Passed".format(result_name) + Style.RESET_ALL) else: all_pass = False - error_msgs[-1].append( - "Differences in {}\n{}".format(result_name, a - b) - ) - print( - Fore.RED - + " {}: Failed".format(result_name) - + Style.RESET_ALL - ) + error_msgs[-1].append("Differences in {}\n{}".format(result_name, a - b)) + print(Fore.RED + " {}: Failed".format(result_name) + Style.RESET_ALL) # Close files output.close() @@ -185,9 +165,14 @@ if crashes[i] or len(error_msgs[i]) > 0: N_fails += 1 -print("\nTests passed: "+Fore.GREEN+"%i/%i"%(len(names)-N_fails, len(names))+Style.RESET_ALL) -print("Tests failed: "+Fore.RED+"%i/%i"%(N_fails, len(names))+Style.RESET_ALL) -print(" (%.2f seconds)\n"%np.sum(np.array(runtimes))) +print( + "\nTests passed: " + + Fore.GREEN + + "%i/%i" % (len(names) - N_fails, len(names)) + + Style.RESET_ALL +) +print("Tests failed: " + Fore.RED + "%i/%i" % (N_fails, len(names)) + Style.RESET_ALL) +print(" (%.2f seconds)\n" % np.sum(np.array(runtimes))) for i in range(len(names)): if crashes[i]: print("\n" + "=" * 80)