diff options
| -rw-r--r-- | golemflavor/fr.py | 18 | ||||
| -rw-r--r-- | golemflavor/gf.py | 14 | ||||
| -rw-r--r-- | golemflavor/llh.py | 2 | ||||
| -rw-r--r-- | golemflavor/mcmc.py | 20 | ||||
| -rw-r--r-- | golemflavor/misc.py | 2 | ||||
| -rw-r--r-- | golemflavor/mn.py | 2 | ||||
| -rw-r--r-- | golemflavor/param.py | 2 | ||||
| -rw-r--r-- | golemflavor/plot.py | 26 | ||||
| -rw-r--r-- | scripts/contour.py | 8 | ||||
| -rw-r--r-- | scripts/fr.py | 8 | ||||
| -rw-r--r-- | scripts/mc_texture.py | 8 | ||||
| -rw-r--r-- | scripts/mc_unitary.py | 8 | ||||
| -rw-r--r-- | scripts/mc_x.py | 8 | ||||
| -rw-r--r-- | scripts/plot_sens.py | 24 | ||||
| -rw-r--r-- | scripts/sens.py | 22 |
15 files changed, 86 insertions, 86 deletions
diff --git a/golemflavor/fr.py b/golemflavor/fr.py index ba9a8e9..6692609 100644 --- a/golemflavor/fr.py +++ b/golemflavor/fr.py @@ -66,11 +66,11 @@ def determinant(x): Examples ---------- - >>> print determinant( + >>> print(determinant( >>> [[-1.65238188-0.59549718j, 0.27486548-0.18437467j, -1.35524534-0.38542072j], >>> [-1.07480906+0.29630449j, -0.47808456-0.80316821j, -0.88609356-1.50737308j], >>> [-0.14924144-0.99230446j, 0.49504234+0.63639805j, 2.29258915-0.36537507j]] - >>> ) + >>> )) (2.7797571563274688+3.0841795325804848j) """ @@ -94,7 +94,7 @@ def angles_to_fr(src_angles): Examples ---------- - >>> print angles_to_fr((0.3, 0.4)) + >>> print(angles_to_fr((0.3, 0.4))) (0.38340579025361626, 0.16431676725154978, 0.45227744249483393) """ @@ -129,7 +129,7 @@ def angles_to_u(bsm_angles): Examples ---------- >>> from fr import angles_to_u - >>> print angles_to_u((0.2, 0.3, 0.5, 1.5)) + >>> print(angles_to_u((0.2, 0.3, 0.5, 1.5))) array([[ 0.66195018+0.j , 0.33097509+0.j , 0.04757188-0.6708311j ], [-0.34631487-0.42427084j, 0.61741198-0.21213542j, 0.52331757+0.j ], [ 0.28614067-0.42427084j, -0.64749908-0.21213542j, 0.52331757+0.j ]]) @@ -184,7 +184,7 @@ def cardano_eqn(ham): >>> [-0.34631487-0.42427084j, 0.61741198-0.21213542j, 0.52331757+0.j ], >>> [ 0.28614067-0.42427084j, -0.64749908-0.21213542j, 0.52331757+0.j ]] >>> ) - >>> print cardano_eqn(ham) + >>> print(cardano_eqn(ham)) array([[-0.11143379-0.58863683j, -0.09067747-0.48219068j, 0.34276625-0.08686465j], [ 0.14835519+0.47511473j, -0.18299305+0.40777481j, 0.31906300+0.82514223j], [-0.62298966+0.07231745j, -0.61407815-0.42709603j, 0.03660313+0.30160428j]]) @@ -247,7 +247,7 @@ def normalise_fr(fr): Examples ---------- >>> from fr import normalise_fr - >>> print normalise_fr((1, 2, 3)) + >>> print(normalise_fr((1, 2, 3))) array([ 0.16666667, 0.33333333, 0.5 ]) """ @@ -347,7 +347,7 @@ def params_to_BSMu(bsm_angles, dim, energy, mass_eigenvalues=MASS_EIGENVALUES, Examples ---------- >>> from fr import params_to_BSMu - >>> print params_to_BSMu((0.2, 0.3, 0.5, 1.5, -20), dim=3, energy=1000) + >>> print(params_to_BSMu((0.2, 0.3, 0.5, 1.5, -20), dim=3, energy=1000)) array([[ 0.18658169 -6.34190523e-01j, -0.26460391 +2.01884200e-01j, 0.67247096 -9.86808417e-07j], [-0.50419832 +2.14420570e-01j, -0.36013768 +5.44254868e-01j, 0.03700961 +5.22039894e-01j], [-0.32561308 -3.95946524e-01j, 0.64294909 -2.23453580e-01j, 0.03700830 +5.22032403e-01j]]) @@ -475,7 +475,7 @@ def test_unitarity(x, prnt=False, rse=False, epsilon=None): ---------- >>> from fr import test_unitarity >>> x = np.identity(3) - >>> print test_unitarity(x) + >>> print(test_unitarity(x)) array([[ 1., 0., 0.], [ 0., 1., 0.], [ 0., 0., 1.]]) @@ -512,7 +512,7 @@ def u_to_fr(source_fr, matrix): Examples ---------- >>> from fr import params_to_BSMu, u_to_fr - >>> print u_to_fr((1, 2, 0), params_to_BSMu((0.2, 0.3, 0.5, 1.5, -20), 3, 1000)) + >>> print(u_to_fr((1, 2, 0), params_to_BSMu((0.2, 0.3, 0.5, 1.5, -20), 3, 1000))) array([ 0.33740075, 0.33176584, 0.33083341]) """ diff --git a/golemflavor/gf.py b/golemflavor/gf.py index fbabd49..252e706 100644 --- a/golemflavor/gf.py +++ b/golemflavor/gf.py @@ -16,7 +16,7 @@ import numpy as np try: import GolemFitPy as gf except: - print 'Running without GolemFit' + print('Running without GolemFit') pass from golemflavor.enums import DataType, Likelihood, SteeringCateg @@ -53,8 +53,8 @@ def fit_flags(llh_paramset): gf_nuisance = [] for param in llh_paramset: if param.name in default_flags: - print 'Setting param {0:<15} to float in the ' \ - 'minimisation'.format(param.name) + print('Setting param {0:<15} to float in the ' \ + 'minimisation'.format(param.name)) flags.__setattr__(param.name, False) gf_nuisance.append(param) return flags, ParamSet(gf_nuisance) @@ -85,7 +85,7 @@ def steering_params(args): def setup_asimov(params): - print 'Injecting the model', params + print('Injecting the model', params) asimov_params = gf.FitParameters(gf.sampleTag.MagicTau) for parm in params: asimov_params.__setattr__(parm.name, float(parm.value)) @@ -93,7 +93,7 @@ def setup_asimov(params): def setup_realisation(params, seed): - print 'Injecting the model', params + print('Injecting the model', params) asimov_params = gf.FitParameters(gf.sampleTag.MagicTau) for parm in params: asimov_params.__setattr__(parm.name, float(parm.value)) @@ -112,7 +112,7 @@ def setup_fitter(args, asimov_paramset): seed = args.seed if args.seed is not None else 1 setup_realisation(FITTER, asimov_paramset, seed) elif args.data is DataType.REAL: - print 'Using MagicTau DATA' + print('Using MagicTau DATA') def get_llh(params): @@ -124,7 +124,7 @@ def get_llh(params): def get_llh_freq(params): - print 'setting to {0}'.format(params) + print('setting to {0}'.format(params)) fitparams = gf.FitParameters(gf.sampleTag.MagicTau) for parm in params: fitparams.__setattr__(parm.name, float(parm.value)) diff --git a/golemflavor/llh.py b/golemflavor/llh.py index 93ae3bd..aa5d32d 100644 --- a/golemflavor/llh.py +++ b/golemflavor/llh.py @@ -88,7 +88,7 @@ def triangle_llh(theta, args, asimov_paramset, llh_paramset): fr = fr_utils.flux_averaged_BSMu(theta, args, spectral_index, llh_paramset) flavour_angles = fr_utils.fr_to_angles(fr) - # print 'flavour_angles', map(float, flavour_angles) + # print('flavour_angles', map(float, flavour_angles)) for idx, param in enumerate(hypo_paramset.from_tag(ParamTag.BESTFIT)): param.value = flavour_angles[idx] diff --git a/golemflavor/mcmc.py b/golemflavor/mcmc.py index 606da2d..4cad6e7 100644 --- a/golemflavor/mcmc.py +++ b/golemflavor/mcmc.py @@ -26,26 +26,26 @@ def mcmc(p0, ln_prob, ndim, nwalkers, burnin, nsteps, args, threads=1): nwalkers, ndim, ln_prob, threads=threads ) - print "Running burn-in" + print("Running burn-in") for result in tqdm.tqdm(sampler.sample(p0, iterations=burnin), total=burnin): pos, prob, state = result sampler.reset() - print "Finished burn-in" + print("Finished burn-in") args.burnin = False - print "Running" + print("Running") for _ in tqdm.tqdm(sampler.sample(pos, iterations=nsteps), total=nsteps): pass - print "Finished" + print("Finished") samples = sampler.chain.reshape((-1, ndim)) - print 'acceptance fraction', sampler.acceptance_fraction - print 'sum of acceptance fraction', np.sum(sampler.acceptance_fraction) - print 'np.unique(samples[:,0]).shape', np.unique(samples[:,0]).shape + print('acceptance fraction', sampler.acceptance_fraction) + print('sum of acceptance fraction', np.sum(sampler.acceptance_fraction)) + print('np.unique(samples[:,0]).shape', np.unique(samples[:,0]).shape) try: - print 'autocorrelation', sampler.acor + print('autocorrelation', sampler.acor) except: - print 'WARNING : NEED TO RUN MORE SAMPLES' + print('WARNING : NEED TO RUN MORE SAMPLES') return samples @@ -115,6 +115,6 @@ def save_chains(chains, outfile): """ make_dir(outfile) - print 'Saving chains to location {0}'.format(outfile+'.npy') + print('Saving chains to location {0}'.format(outfile+'.npy')) np.save(outfile+'.npy', chains) diff --git a/golemflavor/misc.py b/golemflavor/misc.py index 4974775..d83bb99 100644 --- a/golemflavor/misc.py +++ b/golemflavor/misc.py @@ -77,7 +77,7 @@ def parse_bool(s): Examples ---------- >>> from misc import parse_bool - >>> print parse_bool('true') + >>> print(parse_bool('true')) True """ diff --git a/golemflavor/mn.py b/golemflavor/mn.py index e8ff3b4..1e6c9fc 100644 --- a/golemflavor/mn.py +++ b/golemflavor/mn.py @@ -85,7 +85,7 @@ def mn_evidence(mn_paramset, llh_paramset, asimov_paramset, args, prefix='mn'): if args.run_mn: make_dir(prefix) - print 'Running evidence calculation for {0}'.format(prefix) + print('Running evidence calculation for {0}'.format(prefix)) run( LogLikelihood = lnProbEval, Prior = CubePrior, diff --git a/golemflavor/param.py b/golemflavor/param.py index 076386f..941f265 100644 --- a/golemflavor/param.py +++ b/golemflavor/param.py @@ -7,7 +7,7 @@ Param class and functions for the BSM flavour ratio analysis """ -from __future__ import absolute_import, division, print_function +from __future__ import absolute_import, division import sys diff --git a/golemflavor/plot.py b/golemflavor/plot.py index 2fc3210..caaed47 100644 --- a/golemflavor/plot.py +++ b/golemflavor/plot.py @@ -157,10 +157,10 @@ def get_limit(scales, statistic, args, mask_initial=False, return_interp=False): min_idx = np.argmin(scales) null = statistic[min_idx] # if np.abs(statistic_rm[0] - null) > 0.8: - # print 'Warning, null incompatible with smallest scanned scale! For ' \ + # print('Warning, null incompatible with smallest scanned scale! For ' \ # 'DIM {0} [{1}, {2}, {3}]!'.format( # args.dimension, *args.source_ratio - # ) + # )) # null = statistic_rm[0] if args.stat_method is StatCateg.BAYESIAN: reduced_ev = -(statistic_rm - null) @@ -175,16 +175,16 @@ def get_limit(scales, statistic, args, mask_initial=False, return_interp=False): return None re = -(statistic-null)[scales > al[0]] if np.sum(re < np.log(10**(BAYES_K)) - 0.1) >= 2: - print 'Warning, peaked contour does not exclude large scales! For ' \ + print('Warning, peaked contour does not exclude large scales! For ' \ 'DIM {0} [{1}, {2}, {3}]!'.format( args.dimension, *args.source_ratio - ) + )) return None if np.sum(re >= np.log(10**(BAYES_K)) + 0.0) < 2: - print 'Warning, only single point above threshold! For ' \ + print('Warning, only single point above threshold! For ' \ 'DIM {0} [{1}, {2}, {3}]!'.format( args.dimension, *args.source_ratio - ) + )) return None if return_interp: @@ -193,7 +193,7 @@ def get_limit(scales, statistic, args, mask_initial=False, return_interp=False): # Divide by 2 to convert to standard SME coefficient lim = al[0] - np.log10(2.) # lim = al[0] - print 'limit = {0}'.format(lim) + print('limit = {0}'.format(lim)) return lim @@ -323,7 +323,7 @@ def alpha_shape(points, alpha): area = np.sqrt(s*(s-a)*(s-b)*(s-c)) circum_r = a*b*c/(4.0*area) # Here's the radius filter. - #print circum_r + #print(circum_r) if circum_r < 1.0/alpha: add_edge(edges, edge_points, coords, ia, ib) add_edge(edges, edge_points, coords, ib, ic) @@ -562,9 +562,9 @@ def plot_statistic(data, outfile, outformat, args, scale_param, label=None): fig_text = gen_figtext(args) if label is not None: fig_text += '\n' + label - print 'data', data - print 'data.shape', data.shape - print 'outfile', outfile + print('data', data) + print('data.shape', data.shape) + print('outfile', outfile) try: scales, statistic = ma.compress_rows(data).T lim = get_limit(deepcopy(scales), deepcopy(statistic), args, mask_initial=True) @@ -620,7 +620,7 @@ def plot_statistic(data, outfile, outformat, args, scale_param, label=None): def plot_table_sens(data, outfile, outformat, args, show_lvatmo=True): - print 'Making TABLE sensitivity plot' + print('Making TABLE sensitivity plot') argsc = deepcopy(args) dims = args.dimensions @@ -648,7 +648,7 @@ def plot_table_sens(data, outfile, outformat, args, show_lvatmo=True): legend_elements = [] for idim, dim in enumerate(dims): - print '|||| DIM = {0}'.format(dim) + print('|||| DIM = {0}'.format(dim)) argsc.dimension = dim gs0 = gridspec.GridSpecFromSubplotSpec( len(textures), 1, subplot_spec=gs[idim], hspace=0 diff --git a/scripts/contour.py b/scripts/contour.py index 6f08617..cbb6c87 100644 --- a/scripts/contour.py +++ b/scripts/contour.py @@ -194,10 +194,10 @@ def main(): prefix = '' outfile = args.datadir + '/contour' + prefix + gen_identifier(args) - print '== {0:<25} = {1}'.format('outfile', outfile) + print('== {0:<25} = {1}'.format('outfile', outfile)) - print 'asimov_paramset', asimov_paramset - print 'hypo_paramset', hypo_paramset + print('asimov_paramset', asimov_paramset) + print('hypo_paramset', hypo_paramset) if args.run_mcmc: gf_utils.setup_fitter(args, asimov_paramset) @@ -250,7 +250,7 @@ def main(): labels = labels ) - print "DONE!" + print("DONE!") main.__doc__ = __doc__ diff --git a/scripts/fr.py b/scripts/fr.py index e32d7d0..25cc1f8 100644 --- a/scripts/fr.py +++ b/scripts/fr.py @@ -171,13 +171,13 @@ def main(): outfile = args.datadir + '/{0}/{1}/chains_'.format( *map(misc_utils.parse_enum, [args.stat_method, args.data]) ) + misc_utils.gen_identifier(args) - print '== {0:<25} = {1}'.format('outfile', outfile) + print('== {0:<25} = {1}'.format('outfile', outfile)) if args.run_mcmc: gf_utils.setup_fitter(args, asimov_paramset) - print 'asimov_paramset', asimov_paramset - print 'llh_paramset', llh_paramset + print('asimov_paramset', asimov_paramset) + print('llh_paramset', llh_paramset) ln_prob = partial( llh_utils.ln_prob, @@ -240,7 +240,7 @@ def main(): labels = labels, ranges = ranges ) - print "DONE!" + print("DONE!") main.__doc__ = __doc__ diff --git a/scripts/mc_texture.py b/scripts/mc_texture.py index 2813dc0..9e3f0eb 100644 --- a/scripts/mc_texture.py +++ b/scripts/mc_texture.py @@ -182,10 +182,10 @@ def main(): prefix = '' outfile = args.datadir + '/mc_texture' + prefix + gen_identifier(args) - print '== {0:<25} = {1}'.format('outfile', outfile) + print('== {0:<25} = {1}'.format('outfile', outfile)) - print 'asimov_paramset', asimov_paramset - print 'llh_paramset', llh_paramset + print('asimov_paramset', asimov_paramset) + print('llh_paramset', llh_paramset) if args.run_mcmc: ln_prob_eval = partial( @@ -223,7 +223,7 @@ def main(): frs_scale = np.vstack((frs.T, samples[:-1].T)).T mcmc_utils.save_chains(frs_scale, outfile) - print "DONE!" + print("DONE!") main.__doc__ = __doc__ diff --git a/scripts/mc_unitary.py b/scripts/mc_unitary.py index bbd5a28..0f0e8f4 100644 --- a/scripts/mc_unitary.py +++ b/scripts/mc_unitary.py @@ -155,10 +155,10 @@ def main(): prefix = '' outfile = args.datadir + '/mc_unitary' + prefix + gen_identifier(args) - print '== {0:<25} = {1}'.format('outfile', outfile) + print('== {0:<25} = {1}'.format('outfile', outfile)) - print 'asimov_paramset', asimov_paramset - print 'hypo_paramset', hypo_paramset + print('asimov_paramset', asimov_paramset) + print('hypo_paramset', hypo_paramset) if args.run_mcmc: ln_prob_eval = partial( @@ -193,7 +193,7 @@ def main(): ) mcmc_utils.save_chains(frs, outfile) - print "DONE!" + print("DONE!") main.__doc__ = __doc__ diff --git a/scripts/mc_x.py b/scripts/mc_x.py index 04319c4..875c40b 100644 --- a/scripts/mc_x.py +++ b/scripts/mc_x.py @@ -151,10 +151,10 @@ def main(): prefix = '' outfile = args.datadir + '/mc_x' + prefix - print '== {0:<25} = {1}'.format('outfile', outfile) + print('== {0:<25} = {1}'.format('outfile', outfile)) - print 'asimov_paramset', asimov_paramset - print 'hypo_paramset', hypo_paramset + print('asimov_paramset', asimov_paramset) + print('hypo_paramset', hypo_paramset) if args.run_mcmc: ln_prob_eval = partial( @@ -192,7 +192,7 @@ def main(): ) mcmc_utils.save_chains(frs, outfile) - print "DONE!" + print("DONE!") main.__doc__ = __doc__ diff --git a/scripts/plot_sens.py b/scripts/plot_sens.py index 18e0c03..2c827ca 100644 --- a/scripts/plot_sens.py +++ b/scripts/plot_sens.py @@ -82,7 +82,7 @@ def process_args(args): skip = False for a in anon: if (a[1] > x) & (x > a[0]): - print 'Skipping src', x + print('Skipping src', x) skip = True break if skip: continue @@ -171,7 +171,7 @@ def main(): # Initialise data structure. statistic_arr = np.full((dims, srcs, texs, args.segments, 2), np.nan) - print 'Loading data' + print('Loading data') argsc = deepcopy(args) for idim, dim in enumerate(args.dimensions): argsc.dimension = dim @@ -194,7 +194,7 @@ def main(): *map(parse_enum, [args.stat_method, args.data]) ) + r'{0}/fr_stat'.format(prefix) + gen_identifier(argsc) - print '== {0:<25} = {1}'.format('base_infile', base_infile) + print('== {0:<25} = {1}'.format('base_infile', base_infile)) if args.split_jobs: for idx_sc, scale in enumerate(eval_scales): @@ -202,31 +202,31 @@ def main(): np.power(10, scale) ) try: - print 'Loading from {0}'.format(infile+'.npy') + print('Loading from {0}'.format(infile+'.npy')) statistic_arr[idim][isrc][itex][idx_sc] = \ np.load(infile+'.npy')[0] except: - print 'Unable to load file {0}'.format( + print('Unable to load file {0}'.format( infile+'.npy' - ) + )) # raise continue else: - print 'Loading from {0}'.format(base_infile+'.npy') + print('Loading from {0}'.format(base_infile+'.npy')) try: statistic_arr[idim][isrc][itex] = \ np.load(base_infile+'.npy') except: - print 'Unable to load file {0}'.format( + print('Unable to load file {0}'.format( base_infile+'.npy' - ) + )) continue data = ma.masked_invalid(statistic_arr) - print 'data', data + print('data', data) if args.plot_statistic: - print 'Plotting statistic' + print('Plotting statistic') for idim, dim in enumerate(args.dimensions): argsc.dimension = dim @@ -268,7 +268,7 @@ def main(): argsc = deepcopy(args) if args.plot_x: for idim, dim in enumerate(args.dimensions): - print '|||| DIM = {0}'.format(dim) + print('|||| DIM = {0}'.format(dim)) argsc.dimension = dim plot_utils.plot_x( data = data[idim], diff --git a/scripts/sens.py b/scripts/sens.py index 6368159..5198016 100644 --- a/scripts/sens.py +++ b/scripts/sens.py @@ -209,8 +209,8 @@ def main(): ) + misc_utils.gen_identifier(args) if not args.overwrite and os.path.isfile(outfile+'.npy'): - print 'FILE EXISTS {0}'.format(outfile+'.npy') - print 'Exiting...' + print('FILE EXISTS {0}'.format(outfile+'.npy')) + print('Exiting...') return # Setup Golemfit. @@ -225,16 +225,16 @@ def main(): if idx_sc == args.eval_segment: outfile += '_scale_{0:.0E}'.format(np.power(10, scale)) else: continue - print '|||| SCALE = {0:.0E}'.format(np.power(10, scale)) + print('|||| SCALE = {0:.0E}'.format(np.power(10, scale))) if not args.overwrite and os.path.isfile(outfile+'.npy'): - print 'FILE EXISTS {0}'.format(outfile+'.npy') + print('FILE EXISTS {0}'.format(outfile+'.npy')) t = np.load(outfile+'.npy') if np.any(~np.isfinite(t)): - print 'nan found, rerunning...' + print('nan found, rerunning...') pass else: - print 'Exiting...' + print('Exiting...') return # Lower scale boundary for first (NULL) point and set the scale param. @@ -262,9 +262,9 @@ def main(): prefix = prefix ) except: - print 'Failed run' + print('Failed run') raise - print '## Evidence = {0}'.format(stat) + print('## Evidence = {0}'.format(stat)) if args.eval_segment is not None: stat_arr[0] = np.array([scale, stat]) @@ -278,14 +278,14 @@ def main(): if args.run_mn and not args.debug: try: for f in glob.glob(prefix + '*'): - print 'cleaning file {0}'.format(f) + print('cleaning file {0}'.format(f)) os.remove(f) except: - print 'got error trying to cleanup, continuing' + print('got error trying to cleanup, continuing') pass misc_utils.make_dir(outfile) - print 'Saving to {0}'.format(outfile+'.npy') + print('Saving to {0}'.format(outfile+'.npy')) np.save(outfile+'.npy', stat_arr) |
