From 58ae18e60bb00a86cadad4b1d966b350b9bca79a Mon Sep 17 00:00:00 2001 From: Klaus Rabbertz <klaus.rabbertz@cern.ch> Date: Fri, 27 Oct 2023 14:53:34 +0200 Subject: [PATCH] Start updating fnlo-compare-ab.py for py3 --- tools/plotting/fnlo-compare-ab.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/tools/plotting/fnlo-compare-ab.py b/tools/plotting/fnlo-compare-ab.py index 66734f4c..dc48cbb4 100755 --- a/tools/plotting/fnlo-compare-ab.py +++ b/tools/plotting/fnlo-compare-ab.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python3 #-*- coding:utf-8 -*- # # Make comparison plots between two predictions @@ -15,7 +15,7 @@ import glob import os import re import sys -from StringIO import StringIO +from io import StringIO import matplotlib.lines as mpllines import matplotlib.gridspec as gridspec import matplotlib.patches as mplpatches @@ -30,9 +30,9 @@ import numpy as np #from fnlo_parsers import FNLOCppReadOutputParser #from fnlo_parsers import FNLOYodaOutputParser # fastNLO -#import fastnlo -#from fastnlo import fastNLOLHAPDF -#from fastnlo import SetGlobalVerbosity +import fastnlo +from fastnlo import fastNLOLHAPDF +from fastnlo import SetGlobalVerbosity # Redefine ScalarFormatter @@ -105,16 +105,16 @@ def main(): exit(0) # Extract no. of columns from files - print 'Reading no. of columns from 1st file ', afile + print ('Reading no. of columns from 1st file ', afile) cols = np.loadtxt(afile, comments=['#', ' #', 'C', 'L']) nacol = cols.shape[1] - print 'Found ', nacol, ' columns' - print 'Reading no. of columns from 2nd file ', bfile + print ('Found ', nacol, ' columns') + print ('Reading no. of columns from 2nd file ', bfile) cols = np.loadtxt(bfile, comments=['#', ' #', 'C', 'L']) nbcol = cols.shape[1] - print 'Found ', nbcol, ' columns' + print ('Found ', nbcol, ' columns') if nacol != nbcol: - print 'Different no. of columns found, aborted!' + print ('Different no. of columns found, aborted!') exit(1) ncol = nacol @@ -125,7 +125,7 @@ def main(): iobsb, bwb, id0b, xlb, xub, xaveb, xsb_lo, xsb_nlo, kb_nlo = np.loadtxt(bfile, comments=['#', ' #', 'C', 'L'], dtype=[( 'f0', int), ('f1', float), ('f2', int), ('f3', float), ('f4', float), ('f5', float), ('f6', float), ('f7', float), ('f8', float)], unpack=True) else: - print 'ncol different from 9 not yet implemented. Aborted!' + print ('ncol different from 9 not yet implemented. Aborted!') exit(2) exit(0) @@ -136,10 +136,10 @@ nvala = iobsa.size nvalb = iobsb.size nobsa = max(iobsa) nobsb = max(iobsb) -print 'Found ', nvala, ' result lines for ', nobsa, ' observable bins in file ', afile -print 'Found ', nvalb, ' result lines for ', nobsb, ' observable bins in file ', bfile +print ('Found ', nvala, ' result lines for ', nobsa, ' observable bins in file ', afile) +print ('Found ', nvalb, ' result lines for ', nobsb, ' observable bins in file ', bfile) if nvala != nvalb or nobsa != nobsb: - print 'nval or nobs different between the two files to compare, aborted!' + print ('nval or nobs different between the two files to compare, aborted!') exit(3) nobs = nobsa nval = nvala -- GitLab