From 9f122d3270c428e957786e8f6469173d07dd9fb7 Mon Sep 17 00:00:00 2001 From: ageay Date: Tue, 3 Apr 2012 12:35:08 +0000 Subject: [PATCH] Addition of abs method in DataArrays. --- .../Test/MEDCouplingBasicsTest5.cxx | 6 +++--- src/MEDCoupling_Swig/MEDCouplingBasicsTest.py | 20 +++++++++++++++++++ 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/MEDCoupling/Test/MEDCouplingBasicsTest5.cxx b/src/MEDCoupling/Test/MEDCouplingBasicsTest5.cxx index 861554d79..617ae1de4 100644 --- a/src/MEDCoupling/Test/MEDCouplingBasicsTest5.cxx +++ b/src/MEDCoupling/Test/MEDCouplingBasicsTest5.cxx @@ -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)); diff --git a/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py b/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py index d889e3c4a..46c7dc3b0 100644 --- a/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py +++ b/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py @@ -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 -- 2.39.2