Commit f1c98e93 authored by Hamilton, Steven P's avatar Hamilton, Steven P
Browse files

Updating check script to be python3 compatible.

parent 42edc4ca
...@@ -20,7 +20,7 @@ def check_solution(path_to_results): ...@@ -20,7 +20,7 @@ def check_solution(path_to_results):
ref_k = ref_k_dset[0] ref_k = ref_k_dset[0]
ref_k_std = np.sqrt(ref_k_var_dset[0]) ref_k_std = np.sqrt(ref_k_var_dset[0])
print '\nReference k = {0:.6f} +/- {1:.3e}'.format(ref_k,ref_k_std) print('\nReference k = {0:.6f} +/- {1:.3e}'.format(ref_k,ref_k_std))
# Load flux file for comparison # Load flux file for comparison
flux_filename = os.path.join(path_to_results,'c5g7_3d_flux.h5') flux_filename = os.path.join(path_to_results,'c5g7_3d_flux.h5')
...@@ -38,7 +38,7 @@ def check_solution(path_to_results): ...@@ -38,7 +38,7 @@ def check_solution(path_to_results):
k = k_dset[0] k = k_dset[0]
k_std = np.sqrt(k_var_dset[0]) k_std = np.sqrt(k_var_dset[0])
print 'New k = {0:.6f} +/- {1:.3e}'.format(k,k_std) print('New k = {0:.6f} +/- {1:.3e}'.format(k,k_std))
passes = True passes = True
...@@ -48,7 +48,7 @@ def check_solution(path_to_results): ...@@ -48,7 +48,7 @@ def check_solution(path_to_results):
# Check k values # Check k values
kdiff = np.abs(k - ref_k) kdiff = np.abs(k - ref_k)
tol = safety_factor*np.sqrt(k_std*k_std + ref_k_std*ref_k_std) tol = safety_factor*np.sqrt(k_std*k_std + ref_k_std*ref_k_std)
print 'Difference in k = {0:.2e} with tolerance of {1:.2e}'.format(kdiff,tol) print('Difference in k = {0:.2e} with tolerance of {1:.2e}'.format(kdiff,tol))
passes = kdiff < tol passes = kdiff < tol
if passes: if passes:
...@@ -83,15 +83,15 @@ def check_solution(path_to_results): ...@@ -83,15 +83,15 @@ def check_solution(path_to_results):
num_failed = len(failed_indices) num_failed = len(failed_indices)
print '\nMaximum relative error is {0:.3f} times tolerance'.format(max_ratio) print('\nMaximum relative error is {0:.3f} times tolerance'.format(max_ratio))
# Allow one outlier # Allow one outlier
if num_failed > 1: if num_failed > 1:
passes = False passes = False
if num_failed > 0: if num_failed > 0:
print '\nThe following flux values were outside of expected tolerance:' print('\nThe following flux values were outside of expected tolerance:')
print ' Index Reference Value Difference Tolerance' print(' Index Reference Value Difference Tolerance')
for ind in failed_indices: for ind in failed_indices:
ref_val = ref_flux[ind] ref_val = ref_flux[ind]
ref_std = ref_flux_std[ind] ref_std = ref_flux_std[ind]
...@@ -99,15 +99,15 @@ def check_solution(path_to_results): ...@@ -99,15 +99,15 @@ def check_solution(path_to_results):
std = flux_std[ind] std = flux_std[ind]
tol = safety_factor*np.sqrt(ref_std*ref_std + std*std) tol = safety_factor*np.sqrt(ref_std*ref_std + std*std)
flux_diff = np.abs(val - ref_val) flux_diff = np.abs(val - ref_val)
print '{0:5} {1:.4e} {2:.4e} {3:.3e} {4:.3e}'.format( print('{0:5} {1:.4e} {2:.4e} {3:.3e} {4:.3e}'.format(
ind,ref_val,val,flux_diff,tol) ind,ref_val,val,flux_diff,tol))
# Print pass/fail status # Print pass/fail status
print '\n', print('\n'),
if passes: if passes:
print 'Solution PASSED' print('Solution PASSED')
return 0 return 0
else: else:
print 'Solution FAILED' print('Solution FAILED')
return 1 return 1
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment