10
0
mirror of https://github.com/LCPQ/QUESTDB_website.git synced 2024-12-25 05:43:46 +01:00

Change getSubtableIndex to getSubtableRange

This commit is contained in:
Mickaël Véril 2020-07-08 13:21:40 +02:00
parent dda226d8b6
commit 76559d21db
6 changed files with 36 additions and 36 deletions

View File

@ -33,18 +33,18 @@ def datafileSelector(dataType):
}
return switcher[dataType]
def getSubtableIndex(table,firstindex=2,column=0,count=1):
subtablesindex=list()
def getSubtableRange(table,firstindex=2,column=0,count=1):
subtablesRange=list()
i=firstindex+count
while i<np.size(table,0):
if str(table[i,column])!="":
subtablesindex.append((firstindex,i-1))
subtablesRange.append(range(firstindex,i))
firstindex=i
i+=count
else:
i+=1
subtablesindex.append((firstindex,np.size(table,0)))
return subtablesindex
subtablesRange.append(range(firstindex,np.size(table,0)))
return subtablesRange
class dataFileBase(object):
def __init__(self):

View File

@ -1,19 +1,19 @@
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,getSubtablesRange
from ...utils import getValFromCell, checkFloat
@formatName("TBE")
class TBEHandler(formatHandlerBase):
def readFromTable(self,table):
datalist=list()
subtablesindex=getSubtableIndex(table)
for first, last in subtablesindex:
subtablesRange=getSubtablesRange(table)
for myrange in subtablesRange:
datacls=dict()
mymolecule=str(table[first,0])
mymolecule=str(table[myrange[0],0])
initialState=self.TexOps.initialStates[mymolecule]
mymethod=(method("TBE(FC)"),method("TBE"))
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,]):
finsts=dataFileBase.convertState(table[myrange,1],initialState,default=self.TexOps.defaultType,commands=self.commands)
for index,row in enumerate(table[myrange,]):
oscilatorForces=checkFloat(str(row[2]))
T1 = checkFloat(str(row[3]))
val,unsafe = getValFromCell(row[4])

View File

@ -1,22 +1,22 @@
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,getSubtablesRange
from ...utils import getValFromCell
import numpy as np
@formatName("column")
class columnHandler(formatHandlerBase):
def readFromTable(self,table):
datalist=list()
subtablesindex=getSubtableIndex(table)
for first, last in subtablesindex:
subtablesRange=getSubtablesRange(table)
for myrange in subtablesRange:
for col in range(2,np.size(table,1)):
datacls=dict()
col=table[:,col]
mymolecule=str(table[first,0])
mymolecule=str(table[myrange[0],0])
initialState=self.TexOps.initialStates[mymolecule]
mymethod=method(str(col[1]),str(col[0]))
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]):
finsts=dataFileBase.convertState(table[myrange,1],initialState,default=self.TexOps.defaultType,commands=self.commands)
for index,cell in enumerate(col[myrange]):
if str(cell)!="":
val,unsafe=getValFromCell(cell)
finst=finsts[index]

View File

@ -1,6 +1,6 @@
from ..formatHandlerBase import formatHandlerBase
from ..formatName import formatName
from ...data import dataFileBase,DataType,method,excitationValue,datafileSelector,AbsDataFile,getSubtableIndex
from ...data import dataFileBase,DataType,method,excitationValue,datafileSelector,AbsDataFile,getSubtablesRange
from ...LaTeX import newCommand
import re
from ...utils import getValFromCell
@ -8,13 +8,13 @@ from ...utils import getValFromCell
class doubleColumnHandler(formatHandlerBase):
def readFromTable(self,table):
datacls=dict()
subtablesMol=getSubtableIndex(table)
for firstMol, lastMol in subtablesMol:
mymolecule=str(table[firstMol,0])
moltable=table[firstMol:lastMol+1,:]
subtablestrans=getSubtableIndex(moltable,firstindex=0,column=1,count=2)
for firstTrans,lastTrans in subtablestrans:
mytrans=moltable[firstTrans:lastTrans+1,:]
subtablesMol=getSubtablesRange(table)
for rangeMol in subtablesMol:
mymolecule=str(table[rangeMol[0],0])
moltable=table[rangeMol,:]
subtablestrans=getSubtablesRange(moltable,firstindex=0,column=1,count=2)
for rangeTrans in subtablestrans:
mytrans=moltable[rangeTrans,:]
mytransdesc=mytrans[0:2,1]
for i in range(2):
try:

View File

@ -1,6 +1,6 @@
from ..formatHandlerBase import formatHandlerBase
from ..formatName import formatName
from ...data import dataFileBase,DataType,method,excitationValue,datafileSelector,getSubtableIndex,AbsDataFile,state
from ...data import dataFileBase,DataType,method,excitationValue,datafileSelector,getSubtablesRange,AbsDataFile,state
from ...utils import getValFromCell, checkFloat
from ...LaTeX import newCommand
from TexSoup import TexSoup
@ -9,12 +9,12 @@ import re
class doubleTBEHandler(formatHandlerBase):
def readFromTable(self,table):
datalist=list()
subtablesMol=getSubtableIndex(table)
for firstMol, lastMol in subtablesMol:
subtablesMol=getSubtablesRange(table)
for rangeMol in subtablesMol:
data=AbsDataFile()
data.molecule=str(table[firstMol,0])
data.molecule=str(table[rangeMol,0])
data.method=method("TBE","CBS")
for mytrans in table[firstMol:lastMol+1]:
for mytrans in table[rangeMol]:
try:
mathsoup=TexSoup(mytrans[1])
except:

View File

@ -1,6 +1,6 @@
from ..formatHandlerBase import formatHandlerBase
from ..formatName import formatName
from ...data import dataFileBase,DataType,method,excitationValue,datafileSelector,getSubtableIndex,state
from ...data import dataFileBase,DataType,method,excitationValue,datafileSelector,getSubtablesRange,state
from ...utils import getValFromCell
from TexSoup import TexSoup,TexNode
from ...LaTeX import newCommand
@ -10,10 +10,10 @@ import json
class exoticColumnHandler(formatHandlerBase):
def readFromTable(self,table):
datalist=list()
subtablesindex=getSubtableIndex(table)
for first, last in subtablesindex:
subtablesRange=getSubtablesRange(table)
for myrange in subtablesRange:
valDic=dict()
mymolecule=str(table[first,0])
mymolecule=str(table[myrange[0],0])
initialState=self.TexOps.initialStates[mymolecule]
for col in range(2,np.size(table,1)):
col=table[:,col]
@ -33,8 +33,8 @@ class exoticColumnHandler(formatHandlerBase):
methodname=str(methtex)
mymethod=method(methodname,basis)
methkey=json.dumps(mymethod.__dict__)
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]):
finsts=dataFileBase.convertState(table[myrange,1],initialState,default=self.TexOps.default,commands=self.commands)
for index,cell in enumerate(col[myrange]):
if str(cell)!="":
val,unsafe=getValFromCell(cell)
finst=finsts[index]