]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
Addition of abs method in DataArrays.
authorageay <ageay>
Tue, 3 Apr 2012 12:35:08 +0000 (12:35 +0000)
committerageay <ageay>
Tue, 3 Apr 2012 12:35:08 +0000 (12:35 +0000)
src/MEDCoupling/Test/MEDCouplingBasicsTest5.cxx
src/MEDCoupling_Swig/MEDCouplingBasicsTest.py

index 861554d791b0cd17c85671646f94fe8f26a87ac6..617ae1de42e4f41f287b939cd13a14b3941f682d 100644 (file)
@@ -572,8 +572,8 @@ void MEDCouplingBasicsTest5::testAre2DCellsNotCorrectlyOriented1()
 void MEDCouplingBasicsTest5::testDataArrayAbs1()
 {
   DataArrayDouble *d1=DataArrayDouble::New();
-  const double val1[12]={2.,-3.,-5.,6.,-7.,-8.,9.,10.,-11.,-12.};
-  const double expected1[12]={2.,3.,5.,6.,7.,8.,9.,10.,11.,12.};
+  const double val1[12]={2.,-3.,-5.,6.,-7.,-8.,9.,10.,-11.,-12.,-13.,-15.};
+  const double expected1[12]={2.,3.,5.,6.,7.,8.,9.,10.,11.,12.,13.,15.};
   d1->alloc(6,2);
   std::copy(val1,val1+12,d1->getPointer());
   DataArrayInt *d2=d1->convertToIntArr();
@@ -582,7 +582,7 @@ void MEDCouplingBasicsTest5::testDataArrayAbs1()
   for(int i=0;i<12;i++)
     CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],d1->getIJ(0,i),1e-14);
   //
-  const int expected2[12]={2,3,5,6,7,8,9,10,11,12};
+  const int expected2[12]={2,3,5,6,7,8,9,10,11,12,13,15};
   d2->abs();
   for(int i=0;i<12;i++)
     CPPUNIT_ASSERT_EQUAL(expected2[i],d2->getIJ(0,i));
index d889e3c4a1f1dd115fa8f22576c947a1aba57787..46c7dc3b05acee1fa6ac640431d808ef59508836 100644 (file)
@@ -9190,6 +9190,26 @@ class MEDCouplingBasicsTest(unittest.TestCase):
             self.assertEqual([0],res.getValues());
             pass
         pass
+
+    def testDataArrayAbs1(self):
+        d1=DataArrayDouble.New();
+        val1=[2.,-3.,-5.,6.,-7.,-8.,9.,10.,-11.,-12.,-13.,-15.]
+        expected1=[2.,3.,5.,6.,7.,8.,9.,10.,11.,12.,13.,15.]
+        d1.setValues(val1,6,2);
+        d2=d1.convertToIntArr();
+        #
+        d1.abs();
+        for i in xrange(12):
+            self.assertAlmostEqual(expected1[i],d1.getIJ(0,i),14);
+            pass
+        #
+        expected2=[2,3,5,6,7,8,9,10,11,12,13,15]
+        d2.abs();
+        for i in xrange(12):
+            self.assertEqual(expected2[i],d2.getIJ(0,i));
+            pass
+        #
+        pass
     
     def setUp(self):
         pass