From b9f0bc7921734f0cfecf1448a64220822068527b Mon Sep 17 00:00:00 2001 From: Yannick Ulrich <yannick.ulrich@psi.ch> Date: Sun, 16 Feb 2020 12:23:14 +0100 Subject: [PATCH] 5: minor changes and the remainder of the file towards #12 --- pymule/vegas.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/pymule/vegas.py b/pymule/vegas.py index 4c09574..0336eba 100644 --- a/pymule/vegas.py +++ b/pymule/vegas.py @@ -151,12 +151,16 @@ def exportvegas(dic, filename="", fp=None): dic['xi'] = -np.ones(17*50) if 'randy' not in dic: dic['randy'] = -1 + if 'runtime' not in dic: + dic['runtime'] = -1 + if 'msg' not in dic: + dic['msg'] = "Warning: Generated with Python" while type(dic['chi2a']) == list: dic['chi2a'] = dic['chi2a'][0] plots = sorted(list(set(dic.keys()) - { - 'SHA','chi2a','iteration','msg','value','time','ndo','randy','xi' + 'SHA','chi2a','iteration','msg','value','time','ndo','randy','xi','runtime' })) y,e = dic['value'] @@ -172,16 +176,17 @@ def exportvegas(dic, filename="", fp=None): dic['chi2a']*(dic['iteration']-1) + y**2/e**2 ) - write_record(fp, 'd', dic['xi']) + write_record(fp, 'd', list(dic['xi'])) write_record(fp, 'i', dic['randy']) nrbins = len(dic[plots[0]]) nrq = len(plots) + namelen = max(max([len(i) for i in plots]),6) write_record(fp, 'i', [ nrq, nrbins, - max(max([len(i) for i in plots]),6) + namelen ]) quant = np.zeros(2*(nrbins + 2)*nrq) @@ -213,3 +218,10 @@ def exportvegas(dic, filename="", fp=None): quant[nrq*(nrbins + 2) + i::nrq] = delta**2*dic['iteration']*( pp[:,2]**2*(dic['iteration']-1) + pp[:,1]**2 ) + + write_record(fp, 'd', minv+maxv) + write_record(fp, 'c', "".join([i.ljust(namelen) for i in plots])) + write_record(fp, 'd', list(quant)) + + write_record(fp, 'd', dic['runtime']) + write_record(fp, 'c', dic['msg']) -- GitLab