]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
Some little tests to test DataArrayIntTuple management in __getitem__ and __setitem__.
authorageay <ageay>
Fri, 27 Apr 2012 12:03:28 +0000 (12:03 +0000)
committerageay <ageay>
Fri, 27 Apr 2012 12:03:28 +0000 (12:03 +0000)
src/MEDCoupling_Swig/MEDCouplingBasicsTest.py

index 054a87c5b7fe1191bf0d98b98fe6470c2212344e..77f4b45dc7760038a5843bb7bab39638a9a6cef9 100644 (file)
@@ -9897,6 +9897,35 @@ class MEDCouplingBasicsTest(unittest.TestCase):
             self.assertAlmostEqual(expected4[pos][0],bary2.accumulate()[0],12);
             self.assertAlmostEqual(expected4[pos][1],bary2.accumulate()[1],12);
             pass
+        #
+        d=DataArrayInt.New([1,2,0,1,0,2],3,2)
+        e=DataArrayInt.New([1,11,101,2,12,102,3,13,103,4,14,104],4,3)
+        expected5=[[1,11,101,77,77,77,77,77,77,4,14,104],[77,77,77,77,77,77,3,13,103,4,14,104],[77,77,77,2,12,102,77,77,77,4,14,104]]
+        expected6=[[1,77,77,2,77,77,3,77,77,4,77,77],[77,77,101,77,77,102,77,77,103,77,77,104],[77,11,77,77,12,77,77,13,77,77,14,77]]
+        for pos,tup in enumerate(d):
+            f=e[:]
+            self.assertTrue(isinstance(f,DataArrayInt))
+            f[tup]=77
+            self.assertEqual(expected5[pos],f.getValues())
+            self.assertEqual(6*[77],f[tup].getValues())
+            f=e[:]
+            f[:,tup]=77
+            self.assertEqual(expected6[pos],f.getValues())
+            self.assertEqual(8*[77],f[:,tup].getValues())
+            pass
+        #
+        e=e.convertToDblArr()
+        for pos,tup in enumerate(d):
+            f=e[:]
+            self.assertTrue(isinstance(f,DataArrayDouble))
+            f[tup]=77.
+            self.assertEqual(expected5[pos],f.convertToIntArr().getValues())
+            self.assertEqual(6*[77],f[tup].convertToIntArr().getValues())
+            f=e[:]
+            f[:,tup]=77.
+            self.assertEqual(expected6[pos],f.convertToIntArr().getValues())
+            self.assertEqual(8*[77],f[:,tup].convertToIntArr().getValues())
+            pass
         pass
         
     def setUp(self):