diff options
Diffstat (limited to 'utils')
| -rw-r--r-- | utils/fr.py | 4 | ||||
| -rw-r--r-- | utils/gf.py | 2 | ||||
| -rw-r--r-- | utils/llh.py | 2 | ||||
| -rw-r--r-- | utils/mcmc.py | 2 | ||||
| -rw-r--r-- | utils/misc.py | 4 | ||||
| -rw-r--r-- | utils/mn.py | 2 | ||||
| -rw-r--r-- | utils/param.py | 2 | ||||
| -rw-r--r-- | utils/plot.py | 70 |
8 files changed, 44 insertions, 44 deletions
diff --git a/utils/fr.py b/utils/fr.py index bf0fb56..bd92d39 100644 --- a/utils/fr.py +++ b/utils/fr.py @@ -7,7 +7,7 @@ Useful functions for the BSM flavour ratio analysis """ -from __future__ import absolute_import, division +from __future__ import absolute_import, division, print_function from functools import partial @@ -483,7 +483,7 @@ def test_unitarity(x, prnt=False, rse=False, epsilon=None): """ f = np.abs(np.dot(x, x.conj().T), dtype=DTYPE) if prnt: - print 'Unitarity test:\n{0}'.format(f) + print('Unitarity test:\n{0}'.format(f)) if rse: if not np.abs(np.trace(f) - 3.) < epsilon or \ not np.abs(np.sum(f) - 3.) < epsilon: diff --git a/utils/gf.py b/utils/gf.py index de21cc5..fe0a2a4 100644 --- a/utils/gf.py +++ b/utils/gf.py @@ -7,7 +7,7 @@ Useful GolemFit wrappers for the BSM flavour ratio analysis """ -from __future__ import absolute_import, division +from __future__ import absolute_import, division, print_function from functools import partial diff --git a/utils/llh.py b/utils/llh.py index 5a0eea7..940f344 100644 --- a/utils/llh.py +++ b/utils/llh.py @@ -7,7 +7,7 @@ Likelihood functions for the BSM flavour ratio analysis """ -from __future__ import absolute_import, division +from __future__ import absolute_import, division, print_function from copy import deepcopy from functools import partial diff --git a/utils/mcmc.py b/utils/mcmc.py index 49e5022..4ccbcc3 100644 --- a/utils/mcmc.py +++ b/utils/mcmc.py @@ -7,7 +7,7 @@ Useful functions to use an MCMC for the BSM flavour ratio analysis """ -from __future__ import absolute_import, division +from __future__ import absolute_import, division, print_function from functools import partial diff --git a/utils/misc.py b/utils/misc.py index 630aaf6..21cb11e 100644 --- a/utils/misc.py +++ b/utils/misc.py @@ -7,7 +7,7 @@ Misc functions for the BSM flavour ratio analysis """ -from __future__ import absolute_import, division +from __future__ import absolute_import, division, print_function import os import errno @@ -104,7 +104,7 @@ def print_args(args): """ arg_vars = vars(args) for key in sorted(arg_vars): - print '== {0:<25} = {1}'.format(key, arg_vars[key]) + print('== {0:<25} = {1}'.format(key, arg_vars[key])) def enum_parse(s, c): diff --git a/utils/mn.py b/utils/mn.py index e3a4a09..5ac125c 100644 --- a/utils/mn.py +++ b/utils/mn.py @@ -7,7 +7,7 @@ Useful functions to use MultiNest for the BSM flavour ratio analysis """ -from __future__ import absolute_import, division +from __future__ import absolute_import, division, print_function from functools import partial diff --git a/utils/param.py b/utils/param.py index 2378758..8d95462 100644 --- a/utils/param.py +++ b/utils/param.py @@ -7,7 +7,7 @@ Param class and functions for the BSM flavour ratio analysis """ -from __future__ import absolute_import, division +from __future__ import absolute_import, division, print_function import sys diff --git a/utils/plot.py b/utils/plot.py index aa3b57d..f5eb439 100644 --- a/utils/plot.py +++ b/utils/plot.py @@ -7,7 +7,7 @@ Plotting functions for the BSM flavour ratio analysis """ -from __future__ import absolute_import, division +from __future__ import absolute_import, division, print_function import os import socket @@ -119,14 +119,14 @@ def cmap_discretize(cmap, N): indices = np.linspace(0, 1., N+1) cdict = {} for ki,key in enumerate(('red','green','blue')): - cdict[key] = [ (indices[i], colors_rgba[i-1,ki], colors_rgba[i,ki]) for i in xrange(N+1) ] + cdict[key] = [ (indices[i], colors_rgba[i-1,ki], colors_rgba[i,ki]) for i in range(N+1) ] # Return colormap object. return mpl.colors.LinearSegmentedColormap(cmap.name + "_%d"%N, cdict, 1024) def get_limit(scales, statistic, args, mask_initial=False): max_st = np.max(statistic) - print 'scales, stat', zip(scales, statistic) + print('scales, stat', zip(scales, statistic)) if args.stat_method is StatCateg.BAYESIAN: if (statistic[0] - max_st) > np.log(10**(BAYES_K)): raise AssertionError('Discovered LV!') @@ -134,7 +134,7 @@ def get_limit(scales, statistic, args, mask_initial=False): try: tck, u = splprep([scales, statistic], s=0) except: - print 'Failed to spline' + print('Failed to spline') # return None raise sc, st = splev(np.linspace(0, 1, 1000), tck) @@ -150,23 +150,23 @@ def get_limit(scales, statistic, args, mask_initial=False): null = statistic[min_idx] if args.stat_method is StatCateg.BAYESIAN: reduced_ev = -(statistic_rm - null) - print '[reduced_ev > np.log(10**(BAYES_K))]', np.sum([reduced_ev > np.log(10**(BAYES_K))]) + print('[reduced_ev > np.log(10**(BAYES_K))]', np.sum([reduced_ev > np.log(10**(BAYES_K))])) al = scales_rm[reduced_ev > np.log(10**(BAYES_K))] else: assert 0 if len(al) == 0: - print 'No points for DIM {0} [{1}, {2}, {3}]!'.format( + print('No points for DIM {0} [{1}, {2}, {3}]!'.format( args.dimension, *args.source_ratio - ) + )) return None if reduced_ev[-1] < np.log(10**(BAYES_K)) - 0.1: - 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 lim = al[0] - print 'limit = {0}'.format(lim) + print('limit = {0}'.format(lim)) return lim @@ -335,9 +335,9 @@ def flavour_contour(frs, nbins, coverage, ax=None, smoothing=0.4, # Get vertices inside covered region binx = np.linspace(0, 1, os_nbins+1) interp_dict = {} - for i in xrange(len(binx)): - for j in xrange(len(binx)): - for k in xrange(len(binx)): + for i in range(len(binx)): + for j in range(len(binx)): + for k in range(len(binx)): if mask[i][j][k] == 1: interp_dict[(i, j, k)] = H_s[i, j, k] vertices = np.array(heatmap(interp_dict, os_nbins)) @@ -431,8 +431,8 @@ def chainer_plot(infile, outfile, outformat, args, llh_paramset, fig_text=None, raw = np.load(infile) else: raw = infile - print 'raw.shape', raw.shape - print 'raw', raw + print('raw.shape', raw.shape) + print('raw', raw) make_dir(outfile), make_dir if fig_text is None: @@ -443,7 +443,7 @@ def chainer_plot(infile, outfile, outformat, args, llh_paramset, fig_text=None, if ranges is None: ranges = llh_paramset.ranges if args.plot_angles: - print "Making triangle plots" + print("Making triangle plots") Tchain = raw g = plot_Tchain(Tchain, axes_labels, ranges) @@ -468,14 +468,14 @@ def chainer_plot(infile, outfile, outformat, args, llh_paramset, fig_text=None, # ) for of in outformat: - print 'Saving', outfile+'_angles.'+of + print('Saving', outfile+'_angles.'+of) g.export(outfile+'_angles.'+of) if not hasattr(args, 'plot_elements'): return if args.plot_elements: - print "Making triangle plots" + print("Making triangle plots") if args.fix_mixing_almost: raise NotImplementedError nu_index = llh_paramset.from_tag(ParamTag.NUISANCE, index=True) @@ -524,18 +524,18 @@ def chainer_plot(infile, outfile, outformat, args, llh_paramset, fig_text=None, mpl.pyplot.figtext(0.5, 0.7, fig_text, fontsize=15) for of in outformat: - print 'Saving', outfile+'_elements'+of + print('Saving', outfile+'_elements'+of) g.export(outfile+'_elements.'+of) def plot_statistic(data, outfile, outformat, args, scale_param, label=None): """Make MultiNest factor or LLH value plot.""" - print 'Making Statistic plot' + print('Making Statistic plot') fig_text = gen_figtext(args) if label is not None: fig_text += '\n' + label - print 'data', data - print 'data.shape', data.shape + print('data', data) + print('data.shape', data.shape) scales, statistic = ma.compress_rows(data).T try: tck, u = splprep([scales, statistic], s=0) @@ -593,12 +593,12 @@ def plot_statistic(data, outfile, outformat, args, scale_param, label=None): ax.add_artist(at) make_dir(outfile) for of in outformat: - print 'Saving as {0}'.format(outfile+'.'+of) + print('Saving as {0}'.format(outfile+'.'+of)) fig.savefig(outfile+'.'+of, bbox_inches='tight', dpi=150) def plot_table_sens(data, outfile, outformat, args): - print 'Making TABLE sensitivity plot' + print('Making TABLE sensitivity plot') argsc = deepcopy(args) dims = args.dimensions @@ -626,7 +626,7 @@ def plot_table_sens(data, outfile, outformat, args): legend_elements = [] for idim, dim in enumerate(dimensions): - 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 @@ -663,7 +663,7 @@ def plot_table_sens(data, outfile, outformat, args): ax.spines['bottom'].set_alpha(0.6) for isrc, src in enumerate(srcs): - print '== src', src + print('== src', src) argsc.source_ratio = src if dim in PLANCK_SCALE.iterkeys(): @@ -743,14 +743,14 @@ def plot_table_sens(data, outfile, outformat, args): make_dir(outfile) for of in outformat: - print 'Saving plot as {0}'.format(outfile+'.'+of) + print('Saving plot as {0}'.format(outfile+'.'+of)) fig.savefig(outfile+'.'+of, bbox_inches='tight', dpi=150) def plot_x(data, outfile, outformat, args, normalise=False): """Limit plot as a function of the source flavour ratio for each operator texture.""" - print 'Making X sensitivity plot' + print('Making X sensitivity plot') dim = args.dimension srcs = args.source_ratios x_arr = np.array([i[0] for i in srcs]) @@ -764,11 +764,11 @@ def plot_x(data, outfile, outformat, args, normalise=False): data.shape[1], data.shape[0], data.shape[2], data.shape[3] ), np.nan) - for isrc in xrange(data.shape[0]): - for itex in xrange(data.shape[1]): + for isrc in range(data.shape[0]): + for itex in range(data.shape[1]): r_data[itex][isrc] = data[isrc][itex] r_data = ma.masked_invalid(r_data) - print r_data.shape, 'r_data.shape' + print(r_data.shape, 'r_data.shape') if normalise: fig = plt.figure(figsize=(7, 6)) @@ -828,12 +828,12 @@ def plot_x(data, outfile, outformat, args, normalise=False): ) for itex, tex in enumerate(textures): - print '|||| TEX = {0}'.format(tex) + print('|||| TEX = {0}'.format(tex)) lims = np.full(len(srcs), np.nan) for isrc, src in enumerate(srcs): x = src[0] - print '|||| X = {0}'.format(x) + print('|||| X = {0}'.format(x)) args.source_ratio = src d = r_data[itex][isrc] if np.sum(d.mask) > 0: @@ -849,7 +849,7 @@ def plot_x(data, outfile, outformat, args, normalise=False): size = np.sum(~lims.mask) if size == 0: continue - print 'x_arr, lims', zip(x_arr, lims) + print('x_arr, lims', zip(x_arr, lims)) if normalise: zeropoint = 100 else: @@ -951,5 +951,5 @@ def plot_x(data, outfile, outformat, args, normalise=False): make_dir(outfile) for of in outformat: - print 'Saving plot as {0}'.format(outfile + '.' + of) + print('Saving plot as {0}'.format(outfile + '.' + of)) fig.savefig(outfile + '.' + of, bbox_inches='tight', dpi=150) |
