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

Updating check script to be python3 compatible.

parent 42edc4ca
Loading
Loading
Loading
Loading
+106 −106
Original line number Diff line number Diff line
@@ -20,7 +20,7 @@ def check_solution(path_to_results):
    ref_k = ref_k_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
    flux_filename = os.path.join(path_to_results,'c5g7_3d_flux.h5')
@@ -38,7 +38,7 @@ def check_solution(path_to_results):
    k = k_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

@@ -48,7 +48,7 @@ def check_solution(path_to_results):
    # Check k values
    kdiff = np.abs(k - ref_k)
    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

    if passes:
@@ -83,15 +83,15 @@ def check_solution(path_to_results):

    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
    if num_failed > 1:
        passes = False

    if num_failed > 0:
	    print '\nThe following flux values were outside of expected tolerance:'
	    print ' Index   Reference   Value       Difference Tolerance'
        print('\nThe following flux values were outside of expected tolerance:')
        print(' Index   Reference   Value       Difference Tolerance')
        for ind in failed_indices:
            ref_val = ref_flux[ind]
            ref_std = ref_flux_std[ind]
@@ -99,15 +99,15 @@ def check_solution(path_to_results):
            std     = flux_std[ind]
            tol = safety_factor*np.sqrt(ref_std*ref_std + std*std)
            flux_diff = np.abs(val - ref_val)
		print '{0:5}    {1:.4e}  {2:.4e}  {3:.3e}  {4:.3e}'.format(
		    ind,ref_val,val,flux_diff,tol)
            print('{0:5}    {1:.4e}  {2:.4e}  {3:.3e}  {4:.3e}'.format(
                ind,ref_val,val,flux_diff,tol))

    # Print pass/fail status
	print '\n',
    print('\n'),
    if passes:
	    print 'Solution PASSED'
        print('Solution PASSED')
        return 0
    else:
	    print 'Solution FAILED'
        print('Solution FAILED')
        return 1