10
0
mirror of https://github.com/LCPQ/QUESTDB_website.git synced 2024-11-04 05:03:53 +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] return switcher[dataType]
def getSubtableIndex(table,firstindex=2,column=0,count=1): def getSubtableRange(table,firstindex=2,column=0,count=1):
subtablesindex=list() subtablesRange=list()
i=firstindex+count i=firstindex+count
while i<np.size(table,0): while i<np.size(table,0):
if str(table[i,column])!="": if str(table[i,column])!="":
subtablesindex.append((firstindex,i-1)) subtablesRange.append(range(firstindex,i))
firstindex=i firstindex=i
i+=count i+=count
else: else:
i+=1 i+=1
subtablesindex.append((firstindex,np.size(table,0))) subtablesRange.append(range(firstindex,np.size(table,0)))
return subtablesindex return subtablesRange
class dataFileBase(object): class dataFileBase(object):
def __init__(self): def __init__(self):

View File

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

View File

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

View File

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

View File

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

View File

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