From 01e32272029430a787cdcbb6e6bb99f459cdd231 Mon Sep 17 00:00:00 2001 From: cvw Date: Wed, 29 Feb 2012 09:02:20 +0000 Subject: [PATCH] *** empty log message *** --- src/MEDCoupling_Swig/MEDCouplingBasicsTest.py | 200 +++++++++++++++++- 1 file changed, 198 insertions(+), 2 deletions(-) diff --git a/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py b/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py index 53b0d568e..09de918dd 100644 --- a/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py +++ b/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py @@ -1695,7 +1695,6 @@ class MEDCouplingBasicsTest(unittest.TestCase): meshDeepCopy=mesh.deepCpy(); meshClone=mesh.clone(False); - #self.assertRaises(meshEmpty.copyTinyStringsFrom(None),Exception); meshEmpty.copyTinyStringsFrom(mesh); #no data in meshEmpty, expected False self.assertTrue(not meshEmpty.isEqual(mesh, 1e-12)); @@ -4940,6 +4939,203 @@ class MEDCouplingBasicsTest(unittest.TestCase): pass # pass + + def testElementaryDAThrowAndSpecialCases(self): + return + da=DataArrayInt.New(); + self.assertRaises(InterpKernelException, da.checkAllocated); + self.assertRaises(InterpKernelException, da.fillWithValue, 1); + self.assertRaises(InterpKernelException, da.iota, 1); + da.alloc(7,1); + da.fillWithValue(11); #11,11,11,11... + da.iota(10); #10,11,12,13... + + db=DataArrayInt.New(); + db.alloc(7,2); + + dbl2=DataArrayDouble.New(); + dbl2.alloc(7,2); + self.assertRaises(InterpKernelException, dbl2.isUniform, 10., 1e-15); + self.assertRaises(InterpKernelException, dbl2.sort); + self.assertRaises(InterpKernelException, dbl2.reverse); + self.assertRaises(InterpKernelException, dbl2.iota, 10.); + + dbl=DataArrayDouble.New(); + #DataArrayDouble not allocated yet + self.assertRaises(InterpKernelException, dbl.iota, 10.); + self.assertRaises(InterpKernelException, dbl.isUniform, 10., 1e-15); + self.assertRaises(InterpKernelException, dbl.sort); + self.assertRaises(InterpKernelException, dbl.reverse); + self.assertRaises(InterpKernelException, dbl.fromNoInterlace); + self.assertRaises(InterpKernelException, dbl.toNoInterlace); + + dbl.alloc(7,1); + dbl.iota(10.); + self.assertTrue(not dbl.isUniform(10.,1e-15)); + dbl.sort(); + self.assertTrue(dbl.isMonotonic(True, .99)); + self.assertTrue(dbl.isMonotonic(True, -.99)); + self.assertTrue(not dbl.isMonotonic(True, 1.1)); + self.assertTrue(not dbl.isMonotonic(True, -1.1)); + dbl.reverse(); + self.assertTrue(dbl.isMonotonic(False, .99)); + self.assertTrue(not dbl.isMonotonic(False, 1.1)); + self.assertTrue(not dbl.isMonotonic(False, -1.1)); + + dc=DataArrayInt.New(); + dc.alloc(14,1); + + dd=DataArrayDouble.New(); + self.assertRaises(InterpKernelException, dd.checkAllocated); + self.assertRaises(InterpKernelException, dd.fillWithValue, 1.); + self.assertRaises(InterpKernelException, dd.iota, 1.); + self.assertTrue(not ((dd.repr().find("No data"))==-1)); + + dd.alloc(0,1); #Allocated but nbOfElements==0! + self.assertTrue(not ((dd.repr().find("Number of tuples : 0"))==-1)); + self.assertTrue(not ((dd.repr().find("Empty Data"))==-1)); + dd.fillWithValue(11); #?!...ok + dd.iota(10); #?!...ok + self.assertTrue(dd.isMonotonic(True, 1.)); #nothing is monotonic + self.assertTrue(dd.isMonotonic(False, 1.)); + + self.assertRaises(InterpKernelException, db.copyStringInfoFrom, da); + self.assertRaises(InterpKernelException, db.copyStringInfoFrom, da); + cIds=[2,2] + self.assertRaises(InterpKernelException, da.copyPartOfStringInfoFrom, db, cIds); + cIds[0]=1; + cIds[0]=-1; + self.assertRaises(InterpKernelException, da.copyPartOfStringInfoFrom, db, cIds); + + info=["infoOfOneComponent"]*2; + self.assertRaises(InterpKernelException, da.setInfoOnComponents, info); + self.assertRaises(InterpKernelException, da.setInfoOnComponent, 1, info[0]); + db.setInfoOnComponents(info); + + self.assertRaises(InterpKernelException, da.getInfoOnComponent, -1); + self.assertRaises(InterpKernelException, da.getInfoOnComponent, 2); + self.assertTrue(db.getInfoOnComponent(1)==db.getInfoOnComponent(0)); + self.assertRaises(InterpKernelException, db.getVarOnComponent, -1); + self.assertRaises(InterpKernelException, db.getVarOnComponent, 2); + self.assertRaises(InterpKernelException, db.getUnitOnComponent, -1); + self.assertRaises(InterpKernelException, db.getUnitOnComponent, 2); + + self.assertTrue(da.GetVarNameFromInfo("varname unit ")=="varname unit "); + self.assertTrue(da.GetVarNameFromInfo("varname]unit[")=="varname]unit["); + self.assertTrue(da.GetVarNameFromInfo("[unit]")==""); + self.assertTrue(da.GetVarNameFromInfo("varname [unit]")=="varname"); + + self.assertTrue(da.GetUnitFromInfo("varname unit ")==""); + self.assertTrue(da.GetUnitFromInfo("varname]unit[")==""); + self.assertTrue(da.GetUnitFromInfo("[unit]")=="unit"); + self.assertTrue(da.GetUnitFromInfo("varname [unit]")=="unit"); + + self.assertRaises(InterpKernelException, da.checkNbOfTuplesAndComp, db, "theMessageInThrow"); + self.assertRaises(InterpKernelException, da.checkNbOfTuplesAndComp, dc, "theMessageInThrow"); + self.assertRaises(InterpKernelException, db.checkNbOfTuplesAndComp, dc, "theMessageInThrow"); + + self.assertRaises(InterpKernelException, da.checkNbOfTuplesAndComp, 7, 2, "theMessageInThrow"); + da.checkNbOfTuplesAndComp(7,1,"theMessageInThrow"); + + self.assertRaises(InterpKernelException, db.checkNbOfElems, 7*2+1, "theMessageInThrow"); + db.checkNbOfElems(7*2,"theMessageInThrow"); + + self.assertRaises(InterpKernelException, db.GetNumberOfItemGivenBES, 10, 9, 1, "theMessageInThrow"); + self.assertRaises(InterpKernelException, db.GetNumberOfItemGivenBES, 0, 1, -1, "theMessageInThrow"); + self.assertEqual(10,db.GetNumberOfItemGivenBES(0,10,1,"theMessageInThrow")); + self.assertEqual(5,db.GetNumberOfItemGivenBES(0,10,2,"theMessageInThrow")); + self.assertEqual(6,db.GetNumberOfItemGivenBES(0,11,2,"theMessageInThrow")); + + #std::cout<<"\n!!!!!!!!!\n"< a(0); #input list must be NON EMPTY + a=[] + self.assertRaises(InterpKernelException, DataArrayDouble_Aggregate, a); + self.assertRaises(InterpKernelException, DataArrayDouble_Meld, a); + + a.push_back(dbl2); + a.push_back(dbl); #Nb of components mismatch + self.assertRaises(InterpKernelException, DataArrayDouble_Aggregate, a); + + self.assertRaises(InterpKernelException, DataArrayDouble_Dot, dbl2, dbl); + + self.assertRaises(InterpKernelException, DataArrayDouble_CrossProduct, dbl2, dbl); #Nb of components mismatch + self.assertRaises(InterpKernelException, DataArrayDouble_CrossProduct, dbl2, dbl2); #Nb of components must be equal to 3 + dbl4=DataArrayDouble.New(); + dbl4.alloc(6,3); + dbl5=DataArrayDouble.New(); + dbl5.alloc(7,3); + self.assertRaises(InterpKernelException, DataArrayDouble_CrossProduct, dbl4, dbl5); #Nb of tuples mismatch + + a[0]=dbl4; #Nb of tuple mismatch + a[1]=dbl5; #Nb of tuple mismatch + self.assertRaises(InterpKernelException, DataArrayDouble_Meld, a); + self.assertRaises(InterpKernelException, DataArrayDouble_Dot, dbl4, dbl5); + pass def testDAIGetIdsEqual1(self): tab1=[5,-2,-4,-2,3,2,-2]; @@ -8221,7 +8417,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): self.assertEqual(1,cI.getNbOfElems()); self.assertEqual([0],cI.getValues()) - array12=[0]*(6*4) + array12=[0.]*(6*4) da.setValues(array12,6,4) #bad NumberOfComponents self.assertRaises(InterpKernelException, da.findCommonTuples, 1e-2); pass -- 2.39.2