Beispiel #1
0
 def testAddMerge(self):
      dMaster=PyFoamDataFrame(data=self.data1,index=self.index1)
      self.assertEqual(len(dMaster.keys()),2)
      dSlave=PyFoamDataFrame(data=self.data2,index=self.index2)
      try:
           dMaster=dMaster.addData(dSlave)
           self.fail()
      except PandasWrapperPyFoamException:
           pass
      dMaster=dMaster.addData(dSlave,mergeIndex=True)
      self.assertEqual(len(dMaster.keys()),4)
      self.assert_(len(dMaster.index)>len(self.index1))
      self.assertEqual(min(dMaster.index),min(min(self.index1),min(self.index2)))
      self.assertEqual(max(dMaster.index),max(max(self.index1),max(self.index2)))
      for i,v in enumerate(self.index1):
           self.assertEqual(self.data1["a"][i],dMaster["a"][v])
           self.assertEqual(self.data1["b"][i],dMaster["b"][v])
           self.assertEqual(self.index1[i],dMaster.index[i])
      self.assert_(dMaster["a"].map(isnan).any())
      dMaster=PyFoamDataFrame(data=self.data1,index=self.index1)
      dMaster=dMaster.addData(dSlave,mergeIndex=True,allowExtrapolate=True)
      self.assert_(not dMaster["a"].map(isnan).any())
      dMaster=PyFoamDataFrame(data=self.data1,index=self.index1)
      dSlave=PyFoamDataFrame(data=self.data2,index=self.index2a)
      dMaster=dMaster.addData(dSlave,mergeIndex=True)
      self.assert_(dMaster["c"].map(isnan).any())
Beispiel #2
0
    def testAddWrong(self):
         dMaster=PyFoamDataFrame(data=self.data1,index=self.index1)
         self.assertEqual(len(dMaster.keys()),2)
         try:
              dMaster=dMaster.addData(self.data2)
              self.fail()
         except PandasWrapperPyFoamException:
              pass

         try:
              dMaster=dMaster.addData(PyFoamDataFrame(self.data3,self.index3))
              self.fail()
         except PandasWrapperPyFoamException:
              pass
Beispiel #3
0
 def testAddDifferent(self):
      dMaster=PyFoamDataFrame(data=self.data1,index=self.index1)
      self.assertEqual(len(dMaster.keys()),2)
      dSlave=PyFoamDataFrame(data=self.data2,index=self.index2)
      try:
           dMaster=dMaster.addData(dSlave)
           self.fail()
      except PandasWrapperPyFoamException:
           pass
      dMaster=dMaster.addData(dSlave,sameIndex=False)
      self.assertEqual(len(dMaster.keys()),4)
      self.assertEqual(len(dMaster.index),len(self.index1))
      self.assertEqual(min(dMaster.index),min(self.index1))
      self.assertEqual(max(dMaster.index),max(self.index1))
      for i,v in enumerate(self.index1):
           self.assertEqual(self.data1["a"][i],dMaster["a"][v])
           self.assertEqual(self.data1["b"][i],dMaster["b"][v])
           self.assertEqual(self.index1[i],dMaster.index[i])
Beispiel #4
0
 def testAddSame(self):
      dMaster=PyFoamDataFrame(data=self.data1,index=self.index1)
      self.assertEqual(len(dMaster.keys()),2)
      dSlave=PyFoamDataFrame(data=self.data2,index=self.index1)
      dMaster=dMaster.addData(dSlave)
      self.assertEqual(len(dMaster.keys()),4)
      for i,v in enumerate(self.index1):
          self.assertEqual(self.data2["c"][i],dMaster["c"][v])
          self.assertEqual(self.data2["d"][i],dMaster["d"][v])
      try:
          dMaster=dMaster.addData(dSlave)
          self.fail()
      except PandasWrapperPyFoamException:
           pass
      dMaster=dMaster.addData(dSlave,prefix="pre_")
      self.assertEqual(len(dMaster.keys()),6)
      dMaster=dMaster.addData(dSlave,suffix="_post")
      self.assertEqual(len(dMaster.keys()),8)