]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
DataArrayChar, DataArrayByte, DataArrayAsciiChar + throw in the API for swig protection
authorageay <ageay>
Mon, 18 Mar 2013 15:16:43 +0000 (15:16 +0000)
committerageay <ageay>
Mon, 18 Mar 2013 15:16:43 +0000 (15:16 +0000)
src/MEDCoupling_Swig/MEDCouplingBasicsTest.py

index 9d2b09aa653b35d3d7dcf6fc17589056fc925e33..e29fa484d320ad3164a0a703eac63256d40c7945 100644 (file)
@@ -11491,6 +11491,99 @@ class MEDCouplingBasicsTest(unittest.TestCase):
             self.assertTrue(idsExpected3.isEqual(ids3))
             pass
 
+    def testSwig2DataArrayAsciiChar1(self):
+        alpha=DataArrayInt(26) ; alpha.iota(ord("A"))
+        d=DataArrayAsciiChar(alpha.getValues(),2,13)
+        d.setInfoOnComponents(["c%i"%(v) for v in xrange(13)])
+        self.assertEqual('ABCDEFGHIJKLM',d.getTuple(0))
+        self.assertEqual('NOPQRSTUVWXYZ',d.getTuple(1))
+        self.assertEqual(2,d.getNumberOfTuples())
+        self.assertEqual(26,d.getNbOfElems())
+        self.assertEqual(13,d.getNumberOfComponents())
+        dd=d.deepCpy()
+        self.assertTrue(d.isEqual(dd))
+        dd.setIJ(0,3,'d')
+        self.assertTrue(not d.isEqual(dd))
+        d.setIJ(0,3,ord('d'))
+        self.assertTrue(d.isEqual(dd))
+        d.rearrange(1)
+        d.reserve(20)
+        self.assertEqual(20,d.getNumberOfTuples())
+        self.assertEqual(20,d.getNbOfElems())
+        self.assertEqual(1,d.getNumberOfComponents())
+        #
+        d0=DataArrayAsciiChar([ord('a')],1,1)
+        self.assertEqual('a',d0.asciiCharValue())
+        self.assertTrue(not d0.empty())
+        d0=DataArrayAsciiChar(0,3)
+        self.assertTrue(d0.empty())
+        d.pushBackSilent("U") ; d.pushBackSilent("V") ; d.pushBackSilent("W")
+        self.assertEqual("W",d.popBackSilent())
+        d.rearrange(2)
+        self.assertEqual(['AB','Cd','EF','GH','IJ','KL','MN','OP','QR','ST','UV'],d.toStrList())
+        d.fillWithZero()
+        self.assertEqual(11*[''],d.toStrList())
+        d.fillWithValue('T')
+        self.assertEqual(11*["TT"],d.toStrList())
+        d.rearrange(1)
+        self.assertTrue(d.isUniform("T"))
+        d.rearrange(2)
+        #
+        dd.rearrange(2)
+        dd2=dd.deepCpy()
+        dd.renumberInPlace([3,1,2,4,0,11,10,9,8,7,5,12,6])
+        self.assertEqual(dd.toStrList(),['IJ','Cd','EF','AB','GH','UV','YZ','ST','QR','OP','MN','KL','WX'])
+        dd.renumberInPlaceR([3,1,2,4,0,11,10,9,8,7,5,12,6])
+        self.assertEqual(['AB','Cd','EF','GH','IJ','KL','MN','OP','QR','ST','UV','WX','YZ'],dd.toStrList())
+        e=dd.renumber([3,1,2,4,0,11,10,9,8,7,5,12,6])
+        self.assertEqual(e.toStrList(),['IJ','Cd','EF','AB','GH','UV','YZ','ST','QR','OP','MN','KL','WX'])
+        e=dd.renumberR([3,1,2,4,0,11,10,9,8,7,5,12,6])
+        self.assertEqual(e.toStrList(),['GH','Cd','EF','IJ','AB','WX','UV','ST','QR','OP','KL','YZ','MN'])
+        e=dd.renumberAndReduce([1,1,1,1,1,1,1,2,0,0,0,0,0],3)
+        self.assertEqual(['YZ','MN','OP'],e.toStrList())
+        self.assertEqual(['GH','IJ'],dd.selectByTupleIdSafe([3,4]).toStrList())
+        self.assertEqual(['AB','GH','MN','ST','YZ'],dd.selectByTupleId2(0,13,3).toStrList())
+        dd3=dd.changeNbOfComponents(3,"G")
+        self.assertEqual(['ABG','CdG','EFG','GHG','IJG','KLG','MNG','OPG','QRG','STG','UVG','WXG','YZG'],dd3.toStrList())
+        dd3.rearrange(1) ; self.assertEqual("G",dd3.back()) ; dd3.rearrange(3)
+        self.assertTrue(dd3.changeNbOfComponents(2,"\0").isEqual(dd))
+        self.assertEqual(len(dd),13)
+        d=DataArrayAsciiChar(13,2) ; d.fillWithValue('Y')
+        dd3.meldWith(d)
+        self.assertEqual(['ABGYY','CdGYY','EFGYY','GHGYY','IJGYY','KLGYY','MNGYY','OPGYY','QRGYY','STGYY','UVGYY','WXGYY','YZGYY'],dd3.toStrList())
+        self.assertEqual("d",dd3.getIJ(0,6))
+        self.assertRaises(InterpKernelException,dd3.getIJSafe,0,6)
+        self.assertEqual("d",dd3.getIJSafe(1,1))
+        dd3.rearrange(1)
+        e=dd3.getIdsEqual("Y")
+        self.assertTrue(e.isEqual(DataArrayInt([3,4,8,9,13,14,18,19,23,24,28,29,33,34,38,39,43,44,48,49,53,54,58,59,60,63,64])))
+        e=dd3.getIdsNotEqual("Y")
+        self.assertTrue(e.isEqual(DataArrayInt([0,1,2,5,6,7,10,11,12,15,16,17,20,21,22,25,26,27,30,31,32,35,36,37,40,41,42,45,46,47,50,51,52,55,56,57,61,62])))
+        self.assertEqual(("d",6),dd3.getMaxValue())
+        self.assertEqual(("A",0),dd3.getMinValue())
+        self.assertEqual(26,dd3.search("LGYYM"))
+        self.assertEqual(-1,dd3.search("LGYYN"))
+        dd3.rearrange(5)
+        self.assertEqual(7,dd3.locateTuple("OPGYY"))
+        self.assertTrue("OPGYY" in dd3)
+        self.assertEqual(7,dd3.index("OPGYY"))
+        self.assertEqual(-1,dd3.locateTuple("OPGYP"))
+        dd3.rearrange(1)
+        self.assertEqual(2,dd3.locateValue("OPGYY"))
+        self.assertTrue(dd3.presenceOfValue("OPGYY"))
+        self.assertTrue("O" in dd3)
+        self.assertTrue(not dd3.presenceOfValue("z"))
+        self.assertTrue("z" not in dd3)
+        dd3.rearrange(5)
+        l=list(dd3)
+        self.assertEqual([e.buildDAAsciiChar().toStrList()[0] for e in list(dd3)],dd3.toStrList())
+        dd3.reAlloc(5)
+        dd4=DataArrayChar.Aggregate(dd3,dd3)
+        self.assertEqual(['ABGYY','CdGYY','EFGYY','GHGYY','IJGYY','ABGYY','CdGYY','EFGYY','GHGYY','IJGYY'],dd4.toStrList())
+        dd5=DataArrayChar.Aggregate([dd4,dd3,dd4])
+        self.assertEqual(['ABGYY','CdGYY','EFGYY','GHGYY','IJGYY','ABGYY','CdGYY','EFGYY','GHGYY','IJGYY','ABGYY','CdGYY','EFGYY','GHGYY','IJGYY','ABGYY','CdGYY','EFGYY','GHGYY','IJGYY','ABGYY','CdGYY','EFGYY','GHGYY','IJGYY'],dd5.toStrList())
+        pass
+
     def setUp(self):
         pass
     pass