当前位置: 首页>>代码示例>>Python>>正文


Python SpreadsheetData.SpreadsheetData类代码示例

本文整理汇总了Python中PyFoam.Basics.SpreadsheetData.SpreadsheetData的典型用法代码示例。如果您正苦于以下问题:Python SpreadsheetData类的具体用法?Python SpreadsheetData怎么用?Python SpreadsheetData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了SpreadsheetData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testSpreadsheetReadFileTest

 def testSpreadsheetReadFileTest(self):
     fName="/tmp/testdata"
     open(fName,"w").write(filecontent)
     sp=SpreadsheetData(txtName=fName)
     self.assertEqual(len(sp.names()),4)
     self.assertEqual(sp.size(),5)
     self.assertEqual(sp.tRange(),(0.005,0.025))
     self.assertEqual(sp.names()[1],"Initial")
开发者ID:floli,项目名称:tools,代码行数:8,代码来源:SpreadsheetData.py

示例2: testSpreadsheetDataCompare4c

 def testSpreadsheetDataCompare4c(self):
     sp=SpreadsheetData(data=[[i*0.5,math.sin(i)] for i in range(10)],names=['t','val'])
     sp2=SpreadsheetData(data=[[i*0.5,math.sin(i)+0.5] for i in range(10)],names=['t','val'])
     diff1=sp.compare(sp2,"val")
     diff2=sp2.compare(sp,"val")
     self.assertAlmostEqual(diff1["max"],diff2["max"])
     self.assertAlmostEqual(diff1["average"],diff2["average"])
     self.assertAlmostEqual(diff1["wAverage"],diff2["wAverage"])
     self.assertAlmostEqual(diff1["average"],diff1["wAverage"])
开发者ID:floli,项目名称:tools,代码行数:9,代码来源:SpreadsheetData.py

示例3: testSpreadsheetDataCompare4f

 def testSpreadsheetDataCompare4f(self):
     sp=SpreadsheetData(data=[[i*0.5,i*0.5] for i in range(10)],names=['t','val'])
     sp2=SpreadsheetData(data=[[i*0.5-0.25,i*0.5-0.25] for i in range(10)],names=['t','val'])
     diff3=sp.compare(sp2,"val",common=True)
     diff4=sp2.compare(sp,"val",common=True)
     self.assertAlmostEqual(diff3["max"],diff4["max"])
     self.assertAlmostEqual(diff3["average"],diff4["average"])
     self.assertAlmostEqual(diff3["wAverage"],diff4["wAverage"])
     self.assertAlmostEqual(diff3["average"],diff3["wAverage"])
     self.assertAlmostEqual(diff4["average"],diff4["wAverage"])
开发者ID:floli,项目名称:tools,代码行数:10,代码来源:SpreadsheetData.py

示例4: run

    def run(self):
        dest=self.parser.getArgs()[-1]
        if path.exists(dest) and not self.opts.force:
            self.error("CSV-file",dest,"exists already. Use --force to overwrite")
        sources=self.parser.getArgs()[0:-1]

        data=SpreadsheetData(txtName=sources[0],
                             timeName=self.opts.time,
                             validData=self.opts.columns,
                             title=path.splitext(path.basename(sources[0]))[0])

        if self.opts.time==None:
            self.opts.time=data.names()[0]

        for s in sources[1:]:
            addition=path.splitext(path.basename(s))[0]
            sData=SpreadsheetData(txtName=s)
            for n in sData.names():
                if n!=self.opts.time and (self.opts.columns==[] or n in self.opts.columns):
                    d=data.resample(sData,
                                    n,
                                    time=self.opts.time,
                                    extendData=self.opts.extendData)
                    data.append(addition+" "+n,d)

        data.writeCSV(dest,
                      delimiter=self.opts.delimiter)
开发者ID:blueCFD,项目名称:PyFoam,代码行数:27,代码来源:ConvertToCSV.py

示例5: testSpreadsheetDataCompare3

 def testSpreadsheetDataCompare3(self):
     sp=SpreadsheetData(data=data6,names=names3)
     sp2=SpreadsheetData(data=data7,names=names4)
     diff1=sp.compare(sp2,"val")
     self.assertAlmostEqual(diff1["max"],0)
     self.assertAlmostEqual(diff1["average"],0)
     self.assertAlmostEqual(diff1["wAverage"],0)        
     diff2=sp2.compare(sp,"val")
     self.assertAlmostEqual(diff2["max"],0.5)
     self.assertAlmostEqual(diff2["average"],0.09090909)
     self.assertAlmostEqual(diff2["wAverage"],0.05)
开发者ID:floli,项目名称:tools,代码行数:11,代码来源:SpreadsheetData.py

示例6: testSpreadsheetDataCompare2

 def testSpreadsheetDataCompare2(self):
     sp=SpreadsheetData(data=data3,names=names3)
     sp2=SpreadsheetData(data=data5,names=names4)
     diff1=sp.compare(sp2,"val")
     self.assertAlmostEqual(diff1["max"],0.25)
     self.assertAlmostEqual(diff1["average"],0.25)
     self.assertAlmostEqual(diff1["wAverage"],0.25)        
     diff2=sp2.compare(sp,"val")
     self.assertAlmostEqual(diff2["max"],9.25)
     self.assertAlmostEqual(diff2["average"],1.0681818181)
     self.assertAlmostEqual(diff2["wAverage"],0.7)        
开发者ID:floli,项目名称:tools,代码行数:11,代码来源:SpreadsheetData.py

示例7: testGetSpreadsheet

 def testGetSpreadsheet(self):
     csvName="/tmp/nix.csv"
     sd=TimelineDirectory(theDir)
     st=sd["p"]
     spread=st()
     spread.writeCSV(csvName)
     self.assertEqual(len(st.positions)+1,len(spread.names()))
     rereadSpread=SpreadsheetData(csvName=csvName)
     self.assertEqual(len(spread.names()),len(rereadSpread.names()))
     self.assertEqual(len(spread.data),len(rereadSpread.data))        
     sd=TimelineDirectory(theDir,"timeline")
     st=sd["p"]
     spread=st()
     spread.writeCSV("/tmp/nix2.csv")
开发者ID:floli,项目名称:tools,代码行数:14,代码来源:TimelineDirectory.py

示例8: testSpreadsheetDataCompare1

 def testSpreadsheetDataCompare1(self):
     sp=SpreadsheetData(data=data3,names=names3)
     sp2=SpreadsheetData(data=data4,names=names4)
     diff1=sp.compare(sp2,"val")
     self.assertAlmostEqual(diff1["max"],1)
     self.assertAlmostEqual(diff1["average"],1)
     self.assertAlmostEqual(diff1["wAverage"],1)        
     diff2=sp2.compare(sp,"val")
     self.assertEqual(diff1["max"],diff2["max"])
     self.assertEqual(diff1["average"],diff2["average"])
     self.assertEqual(diff1["wAverage"],diff2["wAverage"])
     diff3=sp.compare(sp,"val")
     self.assertAlmostEqual(diff3["max"],0)
     self.assertAlmostEqual(diff3["average"],0)
     self.assertAlmostEqual(diff3["wAverage"],0)        
开发者ID:floli,项目名称:tools,代码行数:15,代码来源:SpreadsheetData.py

示例9: testGetSpreadsheet

 def testGetSpreadsheet(self):
     csvName=path.join(self.theDir,"nix.csv")
     sd=TimelineDirectory(self.theDir)
     st=sd["p"]
     spread=st()
     assert len(spread.names())==5
     assert spread.size()==3
     spread.writeCSV(csvName)
     assert len(st.positions)+1==len(spread.names())
     rereadSpread=SpreadsheetData(csvName=csvName)
     assert len(spread.names())==len(rereadSpread.names())
     assert len(spread.data)==len(rereadSpread.data)
     sd=TimelineDirectory(self.theDir,"timeline")
     st=sd["p"]
     spread=st()
     spread.writeCSV(path.join(self.theDir,"nix2.csv"))
开发者ID:Unofficial-Extend-Project-Mirror,项目名称:openfoam-extend-Breeder-other-scripting-PyFoam,代码行数:16,代码来源:test_TimelineDirectory.py

示例10: testSpreadsheetScaleData

 def testSpreadsheetScaleData(self):
     sp1=SpreadsheetData(data=data1,names=names1)
     self.assertAlmostEqual(min(sp1.data["t"]),0)
     self.assertAlmostEqual(max(sp1.data["t"]),5.0)
     self.assertAlmostEqual(min(sp1.data["p1"]),0)
     self.assertAlmostEqual(max(sp1.data["p1"]),10.0)
     self.assertAlmostEqual(min(sp1.data["p2"]),0)
     self.assertAlmostEqual(max(sp1.data["p2"]),15.0)
     sp1.recalcData("t","t/60")
     self.assertAlmostEqual(min(sp1.data["t"]),0)
     self.assertAlmostEqual(max(sp1.data["t"]),5.0/60.)
     sp1.recalcData("p 3","p1+p2",create=True)
     self.assertAlmostEqual(min(sp1.data["p 3"]),0)
     self.assertAlmostEqual(max(sp1.data["p 3"]),25.0)
     sp1.recalcData("p4","data['p1']+data['p2']",create=True)
     self.assertAlmostEqual(min(sp1.data["p4"]),0)
     self.assertAlmostEqual(max(sp1.data["p4"]),25.0)
     sp1.recalcData("p1","this/10+1")
     self.assertAlmostEqual(min(sp1.data["p1"]),1)
     self.assertAlmostEqual(max(sp1.data["p1"]),2)
开发者ID:LeeRuns,项目名称:PyFoam,代码行数:20,代码来源:SpreadsheetData.py

示例11: testSpreadsheetDataCompare6

 def testSpreadsheetDataCompare6(self):
     sp=SpreadsheetData(data=[[i*0.5,1] for i in range(10)],names=['t','val'])
     sp2=SpreadsheetData(data=[[i*0.5+10,2] for i in range(10)],names=['t','val'])
     diff1=sp.compare(sp2,"val")
     diff2=sp2.compare(sp,"val")
     self.assertAlmostEqual(diff1["max"],1)
     self.assertAlmostEqual(diff1["average"],1)
     self.assertAlmostEqual(diff1["wAverage"],1)        
     self.assertAlmostEqual(diff2["max"],1)
     self.assertAlmostEqual(diff2["average"],1)
     self.assertAlmostEqual(diff2["wAverage"],1)        
     diff1=sp.compare(sp2,"val",common=True)
     diff2=sp2.compare(sp,"val",common=True)
     self.assertEqual(diff1["max"],None)
     self.assertEqual(diff1["average"],None)
     self.assertEqual(diff1["wAverage"],None)        
     self.assertEqual(diff2["max"],None)
     self.assertEqual(diff2["average"],None)
     self.assertEqual(diff2["wAverage"],None)        
开发者ID:floli,项目名称:tools,代码行数:19,代码来源:SpreadsheetData.py

示例12: testSpreadsheetDataAddTimes

 def testSpreadsheetDataAddTimes(self):
     sp1=SpreadsheetData(data=data1,names=names1)
     self.assertEqual(len(sp1.data),6)
     sp1.addTimes([1.5],interpolate=True)
     self.assertEqual(len(sp1.data),7)
     self.assertAlmostEqual(sp1.data["p1"][2],3)
     sp1.addTimes([2.5],interpolate=False)
     self.assertEqual(len(sp1.data),8)
     self.assert_(math.isnan(sp1.data["p1"][4]))
     sp1.addTimes([-1],interpolate=True,invalidExtend=True)
     self.assertEqual(len(sp1.data),9)
     self.assertAlmostEqual(sp1.data["p1"][0],0)
     sp1.addTimes([10],interpolate=True,invalidExtend=False)
     self.assertEqual(len(sp1.data),10)
     self.assert_(math.isnan(sp1.data["p1"][-1]))
     sp1.addTimes([0,1,2],interpolate=True)
     self.assertEqual(len(sp1.data),10)
     sp1.addTimes([-2,2.37,20],interpolate=True)
     self.assertEqual(len(sp1.data),13)
     sp1.addTimes([-3,4,19],interpolate=True)
     self.assertEqual(len(sp1.data),15)
开发者ID:floli,项目名称:tools,代码行数:21,代码来源:SpreadsheetData.py

示例13: testSpreadsheetDataExtend

 def testSpreadsheetDataExtend(self):
     sp1=SpreadsheetData(data=data1,names=names1)
     sp1.append("test",[i*i for i in range(len(data1))])
     self.assertEqual(len(sp1.names()),len(names1)+1)
     self.assert_("test" in sp1.names())
开发者ID:floli,项目名称:tools,代码行数:5,代码来源:SpreadsheetData.py

示例14: testSpreadsheetReadFileHandleTest

 def testSpreadsheetReadFileHandleTest(self):
     sp=SpreadsheetData(txtName=StringIO(filecontent))
     self.assertEqual(len(sp.names()),4)
开发者ID:floli,项目名称:tools,代码行数:3,代码来源:SpreadsheetData.py

示例15: run

    def run(self):
        dest=self.parser.getArgs()[-1]
        if path.exists(dest) and not self.opts.force:
            self.error("CSV-file",dest,"exists already. Use --force to overwrite")
        sources=self.parser.getArgs()[0:-1]

        data=SpreadsheetData(title=path.splitext(path.basename(sources[0]))[0],
                             validData=self.opts.columns,
                             validMatchRegexp=self.opts.columnsRegexp,
                             **self.dataFormatOptions(sources[0]))
        self.printColumns(sources[0],data)
        self.recalcColumns(data)
        self.rawAddColumns(data)

        if self.opts.time==None:
            self.opts.time=data.names()[0]

        for s in sources[1:]:
            addition=path.splitext(path.basename(s))[0]

            sData=SpreadsheetData(validData=self.opts.columns,
                                  validMatchRegexp=self.opts.columnsRegexp,
                                  **self.dataFormatOptions(s))
            self.printColumns(s,sData)
            self.recalcColumns(sData)
            self.rawAddColumns(sData)

            if self.opts.addTimes:
                data.addTimes(time=self.opts.time,
                               times=sData.data[self.opts.time],
                               interpolate=self.opts.interpolateNewTime)
            for n in sData.names():
                if n!=self.opts.time:
                    d=data.resample(sData,
                                    n,
                                    time=self.opts.time,
                                    extendData=self.opts.extendData,
                                    noInterpolation=not self.opts.newDataInterpolate)
                    data.append(addition+" "+n,
                                d,
                                allowDuplicates=True)

        self.joinedAddColumns(data)

        if len(sources)>1:
            self.printColumns("written data",data)

        if self.opts.writeExcel:
            data.getData().to_excel(dest)
        else:
            data.writeCSV(dest,
                          delimiter=self.opts.delimiter)
开发者ID:LeeRuns,项目名称:PyFoam,代码行数:52,代码来源:JoinCSV.py


注:本文中的PyFoam.Basics.SpreadsheetData.SpreadsheetData类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。