Skip to content

Commit

Permalink
back in black
Browse files Browse the repository at this point in the history
  • Loading branch information
ilhamv committed Nov 22, 2023
1 parent 8951505 commit 299a2ac
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 36 deletions.
6 changes: 3 additions & 3 deletions mcdc/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down
2 changes: 2 additions & 0 deletions test/regression/dsm_lattice/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

lib = h5py.File("c5g7.h5", "r")


def set_mat(mat):
return mcdc.material(
capture=mat["capture"][:],
Expand All @@ -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
Expand Down
51 changes: 18 additions & 33 deletions test/regression/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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

Expand All @@ -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()
Expand All @@ -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)
Expand Down

0 comments on commit 299a2ac

Please sign in to comment.