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

Fix some error in generator

This commit is contained in:
Mickaël Véril 2019-12-18 15:18:46 +01:00
parent 83b4bb3c7f
commit efd791f395
2 changed files with 13 additions and 12 deletions

View File

@ -1,7 +1,7 @@
from collections import OrderedDict from collections import OrderedDict
from TexSoup import TexSoup from TexSoup import TexSoup
from .LaTeX import newCommand from .LaTeX import newCommand
from .utils import getValFromCell from .utils import getValFromCell,toFloat
from TexSoup import TexNode from TexSoup import TexNode
from enum import IntEnum,auto,unique,IntFlag from enum import IntEnum,auto,unique,IntFlag
from .Format import Format from .Format import Format
@ -112,7 +112,6 @@ class dataFileBase(object):
for index,cell in enumerate(col[first:last+1]): for index,cell in enumerate(col[first:last+1]):
if str(cell)!="": if str(cell)!="":
val,unsafe=getValFromCell(cell) val,unsafe=getValFromCell(cell)
val=float(str(val))
finst=finsts[index] finst=finsts[index]
dt=finst[1] dt=finst[1]
if dt in datacls: if dt in datacls:
@ -140,15 +139,10 @@ class dataFileBase(object):
mymethod=(method("TBE(FC)"),method("TBE")) mymethod=(method("TBE(FC)"),method("TBE"))
finsts=dataFileBase.convertState(table[first:last+1,1],default=default,firstState=firstState,commands=commands) finsts=dataFileBase.convertState(table[first:last+1,1],default=default,firstState=firstState,commands=commands)
for index,row in enumerate(table[first:last+1,]): for index,row in enumerate(table[first:last+1,]):
def toFloat(x):
try:
return float(x)
except ValueError:
return None
oscilatorForces=toFloat(str(row[2])) oscilatorForces=toFloat(str(row[2]))
T1 = toFloat(str(row[3])) T1 = toFloat(str(row[3]))
val = toFloat(str(row[4])) val,unsafe = getValFromCell(row[4])
corr = toFloat(str(row[7])) corr,unsafecorr = getValFromCell(row[7])
finst=finsts[index] finst=finsts[index]
dt=finst[1] dt=finst[1]
if dt in datacls: if dt in datacls:
@ -163,8 +157,9 @@ class dataFileBase(object):
datamtbe.append(data) datamtbe.append(data)
datacls[dt]=datamtbe datacls[dt]=datamtbe
vs=[val,corr] vs=[val,corr]
uns=[unsafe,unsafecorr]
for i in range(2): for i in range(2):
datamtbe[i].excitations.append(excitationValue(firstState,finst[0],vs[i],type=finst[2],T1=T1,forces=oscilatorForces)) datamtbe[i].excitations.append(excitationValue(firstState,finst[0],vs[i],type=finst[2],T1=T1,forces=oscilatorForces,isUnsafe=uns[i]))
for value in datacls.values(): for value in datacls.values():
for dat in value: for dat in value:
datalist.append(dat) datalist.append(dat)

View File

@ -27,5 +27,11 @@ def getValFromCell(cell):
if type(val) is TexNode and val.name=='emph': if type(val) is TexNode and val.name=='emph':
unsafe=True unsafe=True
val=val.string val=val.string
val=float(str(val)) val=toFloat(str(val))
return (val,unsafe) return (val,unsafe)
def toFloat(x):
try:
return float(x)
except ValueError:
return None