10
0
mirror of https://github.com/LCPQ/QUESTDB_website.git synced 2024-12-24 13:23:40 +01:00

disable float convertion on python side from and check only if it's possible

This commit is contained in:
Mickaël Véril 2020-02-01 16:40:11 +01:00
parent b0f1082ada
commit 89356b1b51
2 changed files with 7 additions and 6 deletions

View File

@ -1,7 +1,7 @@
from collections import OrderedDict
from TexSoup import TexSoup
from .LaTeX import newCommand
from .utils import getValFromCell,toFloat
from .utils import getValFromCell,checkFloat
from TexSoup import TexNode
from enum import IntEnum,auto,unique,IntFlag
from .Format import Format
@ -139,8 +139,8 @@ class dataFileBase(object):
mymethod=(method("TBE(FC)"),method("TBE"))
finsts=dataFileBase.convertState(table[first:last+1,1],default=default,firstState=firstState,commands=commands)
for index,row in enumerate(table[first:last+1,]):
oscilatorForces=toFloat(str(row[2]))
T1 = toFloat(str(row[3]))
oscilatorForces=checkFloat(str(row[2]))
T1 = checkFloat(str(row[3]))
val,unsafe = getValFromCell(row[4])
corr,unsafecorr = getValFromCell(row[7])
finst=finsts[index]

View File

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