10
0
mirror of https://github.com/LCPQ/QUESTDB_website.git synced 2024-12-25 13:53:48 +01:00

Improvement in ADC25generator

This commit is contained in:
Mickaël Véril 2020-09-15 12:51:47 +02:00
parent b250227f47
commit c89e865597

View File

@ -2,7 +2,7 @@
import os import os
import re import re
import sys import sys
import copy from copy import deepcopy
from statistics import mean from statistics import mean
from math import nan,isnan from math import nan,isnan
from pathlib import Path from pathlib import Path
@ -35,31 +35,43 @@ if args.articles is not None or args.sets is not None:
articles.add(article) articles.add(article)
outputdir=datadir/"test" if args.debug else datadir outputdir=datadir/"test" if args.debug else datadir
ADC23re=re.compile(r"ADC\(([23])\)") ADC23re=re.compile(r"ADC\(([23])\)")
def getValue(ADC2,ADC3,parametername): def getValue(ADC2,ADC3,parametername,exADC2=None,exADC3=None):
vals = [getattr(x,parametername) for x in [ADC2,ADC3]] def isObject(x):
isObject=hasattr(vals[0], '__dict__') return hasattr(x, '__dict__')
if isObject: def extractVals(x):
if vars(vals[0]) == vars(vals[1]): if isObject(x):
return copy.deepcopy(vals[0]) return vars(x)
else: else:
if vals[0] == vals[1]: return x
return vals[0] def copy(x):
if isObject(x):
return deepcopy(x)
else:
return x
def isSame(a,b):
return extractVals(a)==extractVals(b)
objs=[ADC2,ADC3]
exs=[exADC2,exADC3]
if all([x!=None for x in exs]):
objs=exs
vals = [getattr(x,parametername) for x in objs]
if isSame(*vals):
return copy(vals[0])
d=OrderedDict() d=OrderedDict()
for i in range(2): for i in range(2):
key=f"ADC({i+2})" key=f"ADC({i+2})"
if isObject: d[key]=copy(vals[i])
d[key]=copy.deepcopy(vals[i])
else:
d[key]=vals[i]
index=-1 index=-1
while len(vals)<index or index<0: while len(vals)<index or index<0:
if index==0: if index==0:
raise ValueError() raise ValueError("Operation canceled with ADC {ADC2File.moleucle},{ADC2File.method.basis} with {parametername}")
print("The Two values are different") print("The Two values are different")
i=0 i=0
for k in d: for k in d:
i+=1 i+=1
print(f"{i}){k} value: {vars(d[k]) if isObject else d[k]}") print(f"{i}){k} value: {extractVals(d[k])}")
index=int(input("Select value from the menu:")) index=int(input("Select value from the menu:"))
return vals[index-1] return vals[index-1]
@ -97,9 +109,9 @@ for t in DataType:
f = "_" f = "_"
isUnsafe = exADC2.isUnsafe or exADC3.isUnsafe isUnsafe = exADC2.isUnsafe or exADC3.isUnsafe
Type=getValue(exADC2,exADC3,"type") Type=getValue(exADC2,exADC3,"type")
exADC25=excitationValue(copy.deepcopy(exADC2.initial),copy.deepcopy(exADC2.final),value,Type,T1,isUnsafe,f) exADC25=excitationValue(deepcopy(exADC2.initial),deepcopy(exADC2.final),value,Type,T1,isUnsafe,f)
ADC25File.excitations.append(exADC25) ADC25File.excitations.append(exADC25)
ADC25File.toFile(outputdir) ADC25File.toFile(outputdir)
except ValueError as ex: except ValueError as ex:
pass print(ex,file=sys.stderr)