From 65bc85b76c06ce4cd0793df6ecc223a197ba3a18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20V=C3=A9ril?= Date: Sat, 4 Jul 2020 15:41:24 +0200 Subject: [PATCH] Fix undefined variables --- tools/lib/formats/default/TBEHandler.py | 2 +- tools/lib/formats/default/columnHandler.py | 5 +++-- .../lib/formats/default/exoticColumnHandler.py | 17 +++++++++-------- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/tools/lib/formats/default/TBEHandler.py b/tools/lib/formats/default/TBEHandler.py index 611f60c1..db37ce6f 100644 --- a/tools/lib/formats/default/TBEHandler.py +++ b/tools/lib/formats/default/TBEHandler.py @@ -12,7 +12,7 @@ class TBEHandler(formatHandlerBase): mymolecule=str(table[first,0]) initialState=self.TexOps.initialStates[mymolecule] mymethod=(method("TBE(FC)"),method("TBE")) - finsts=dataFileBase.convertState(table[first:last+1,1],initialState,default=TexOps.defaultType,commands=commands) + finsts=dataFileBase.convertState(table[first:last+1,1],initialState,default=self.TexOps.defaultType,commands=self.commands) for index,row in enumerate(table[first:last+1,]): oscilatorForces=checkFloat(str(row[2])) T1 = checkFloat(str(row[3])) diff --git a/tools/lib/formats/default/columnHandler.py b/tools/lib/formats/default/columnHandler.py index 5bbc87ed..bc53593a 100644 --- a/tools/lib/formats/default/columnHandler.py +++ b/tools/lib/formats/default/columnHandler.py @@ -2,6 +2,7 @@ from ..formatHandlerBase import formatHandlerBase from ..formatName import formatName from ...data import dataFileBase,DataType,method,excitationValue,datafileSelector,getSubtableIndex from ...utils import getValFromCell +import numpy as np @formatName("column") class columnHandler(formatHandlerBase): def readFromTable(self,table): @@ -12,9 +13,9 @@ class columnHandler(formatHandlerBase): datacls=dict() col=table[:,col] mymolecule=str(table[first,0]) - initialState=TexOps.initialStates[mymolecule] + initialState=self.TexOps.initialStates[mymolecule] mymethod=method(str(col[1]),str(col[0])) - finsts=dataFileBase.convertState(table[first:last+1,1],initialState,default=TexOps.defaultType,commands=commands) + finsts=dataFileBase.convertState(table[first:last+1,1],initialState,default=self.TexOps.defaultType,commands=self.commands) for index,cell in enumerate(col[first:last+1]): if str(cell)!="": val,unsafe=getValFromCell(cell) diff --git a/tools/lib/formats/default/exoticColumnHandler.py b/tools/lib/formats/default/exoticColumnHandler.py index 2a14e442..548d8fd4 100644 --- a/tools/lib/formats/default/exoticColumnHandler.py +++ b/tools/lib/formats/default/exoticColumnHandler.py @@ -1,9 +1,10 @@ from ..formatHandlerBase import formatHandlerBase from ..formatName import formatName -from ...data import dataFileBase,DataType,method,excitationValue,datafileSelector,getSubtableIndex +from ...data import dataFileBase,DataType,method,excitationValue,datafileSelector,getSubtableIndex,state from ...utils import getValFromCell -from TexSoup import TexSoup +from TexSoup import TexSoup,TexNode from ...LaTeX import newCommand +import numpy as np import json @formatName("exoticColumn") class exoticColumnHandler(formatHandlerBase): @@ -13,26 +14,26 @@ class exoticColumnHandler(formatHandlerBase): for first, last in subtablesindex: valDic=dict() mymolecule=str(table[first,0]) - initialState=TexOps.initialStates[mymolecule] + initialState=self.TexOps.initialStates[mymolecule] for col in range(2,np.size(table,1)): col=table[:,col] basis=str(col[0]) mymethcell=list(col[1]) if isinstance(mymethcell[0],TexNode) and mymethcell[0].name=="$": kindSoup=TexSoup("".join(list(mymethcell[0].expr.all))) - newCommand.runAll(kindSoup,commands) + newCommand.runAll(kindSoup,self.commands) kind=str(kindSoup) methodnameSoup=TexSoup(mymethcell[1].value) - newCommand.runAll(methodnameSoup,commands) + newCommand.runAll(methodnameSoup,self.commands) methodname=str(methodnameSoup) else: kind="" methtex=col[1] - newCommand.runAll(methtex,commands) + newCommand.runAll(methtex,self.commands) methodname=str(methtex) mymethod=method(methodname,basis) methkey=json.dumps(mymethod.__dict__) - finsts=dataFileBase.convertState(table[first:last+1,1],initialState,default=TexOps.default,commands=commands) + finsts=dataFileBase.convertState(table[first:last+1,1],initialState,default=self.TexOps.default,commands=self.commands) for index,cell in enumerate(col[first:last+1]): if str(cell)!="": val,unsafe=getValFromCell(cell) @@ -56,7 +57,7 @@ class exoticColumnHandler(formatHandlerBase): #data.excitations.append(excitationValue(initialState,finst[0],val,type=finst[2])) for dt,methdic in valDic.items(): for methstring,exdic in methdic.items(): - data=switcher[dt]() + data=datafileSelector[dt]() data.molecule=mymolecule methdic=json.loads(methstring) data.method=method(methdic["name"],methdic["basis"])