From be99f5e519aa8072ff293f5d480b251c21ebc9c2 Mon Sep 17 00:00:00 2001 From: ageay Date: Mon, 13 Dec 2010 14:16:33 +0000 Subject: [PATCH] *** empty log message *** --- src/MEDCoupling/MEDCouplingMemArray.cxx | 6 ++--- src/MEDCoupling/MEDCouplingMemArray.hxx | 2 +- .../Test/MEDCouplingBasicsTest.hxx | 2 ++ .../Test/MEDCouplingBasicsTest2.cxx | 22 +++++++++++++++++++ src/MEDCoupling_Swig/MEDCoupling.i | 2 +- src/MEDCoupling_Swig/MEDCouplingBasicsTest.py | 10 +++++++++ 6 files changed, 39 insertions(+), 5 deletions(-) diff --git a/src/MEDCoupling/MEDCouplingMemArray.cxx b/src/MEDCoupling/MEDCouplingMemArray.cxx index 2b044363f..6ba17ac7f 100644 --- a/src/MEDCoupling/MEDCouplingMemArray.cxx +++ b/src/MEDCoupling/MEDCouplingMemArray.cxx @@ -2089,14 +2089,14 @@ DataArrayInt *DataArrayInt::buildComplement(int nbOfElement) const throw(INTERP_ return ret; } -DataArrayInt *DataArrayInt::substract(const DataArrayInt *other) const throw(INTERP_KERNEL::Exception) +DataArrayInt *DataArrayInt::buildSubstraction(const DataArrayInt *other) const throw(INTERP_KERNEL::Exception) { checkAllocated(); other->checkAllocated(); if(getNumberOfComponents()!=1) - throw INTERP_KERNEL::Exception("DataArrayInt::substract : only single component allowed !"); + throw INTERP_KERNEL::Exception("DataArrayInt::buildSubstraction : only single component allowed !"); if(other->getNumberOfComponents()!=1) - throw INTERP_KERNEL::Exception("DataArrayInt::substract : only single component allowed for other type !"); + throw INTERP_KERNEL::Exception("DataArrayInt::buildSubstraction : only single component allowed for other type !"); const int *pt=getConstPointer(); int nbOfTuples=getNumberOfTuples(); std::set s1(pt,pt+nbOfTuples); diff --git a/src/MEDCoupling/MEDCouplingMemArray.hxx b/src/MEDCoupling/MEDCouplingMemArray.hxx index c0eed999c..0cbefafb9 100644 --- a/src/MEDCoupling/MEDCouplingMemArray.hxx +++ b/src/MEDCoupling/MEDCouplingMemArray.hxx @@ -267,7 +267,7 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT static DataArrayInt *meld(const std::vector& a) throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT static DataArrayInt *makePartition(const std::vector& groups, int newNb, std::vector< std::vector >& fidsOfGroups); MEDCOUPLING_EXPORT DataArrayInt *buildComplement(int nbOfElement) const throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT DataArrayInt *substract(const DataArrayInt *other) const throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT DataArrayInt *buildSubstraction(const DataArrayInt *other) const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT DataArrayInt *buildUnion(const DataArrayInt *other) const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT DataArrayInt *buildIntersection(const DataArrayInt *other) const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT DataArrayInt *deltaShiftIndex() const throw(INTERP_KERNEL::Exception); diff --git a/src/MEDCoupling/Test/MEDCouplingBasicsTest.hxx b/src/MEDCoupling/Test/MEDCouplingBasicsTest.hxx index 2f69327b4..88de848a4 100644 --- a/src/MEDCoupling/Test/MEDCouplingBasicsTest.hxx +++ b/src/MEDCoupling/Test/MEDCouplingBasicsTest.hxx @@ -170,6 +170,7 @@ namespace ParaMEDMEM CPPUNIT_TEST( testDAIDeltaShiftIndex1 ); CPPUNIT_TEST( testDaDoubleSelectByTupleIdSafe1 ); CPPUNIT_TEST( testAreCellsIncludedIn1 ); + CPPUNIT_TEST( testDAIBuildSubstraction1 ); //MEDCouplingBasicsTestInterp.cxx CPPUNIT_TEST( test2DInterpP0P0_1 ); CPPUNIT_TEST( test2DInterpP0P0PL_1 ); @@ -368,6 +369,7 @@ namespace ParaMEDMEM void testDAIDeltaShiftIndex1(); void testDaDoubleSelectByTupleIdSafe1(); void testAreCellsIncludedIn1(); + void testDAIBuildSubstraction1(); //MEDCouplingBasicsTestInterp.cxx void test2DInterpP0P0_1(); void test2DInterpP0P0PL_1(); diff --git a/src/MEDCoupling/Test/MEDCouplingBasicsTest2.cxx b/src/MEDCoupling/Test/MEDCouplingBasicsTest2.cxx index 63e8bde7c..6029b80be 100644 --- a/src/MEDCoupling/Test/MEDCouplingBasicsTest2.cxx +++ b/src/MEDCoupling/Test/MEDCouplingBasicsTest2.cxx @@ -3959,3 +3959,25 @@ void MEDCouplingBasicsTest::testAreCellsIncludedIn1() m2->decrRef(); m->decrRef(); } + +void MEDCouplingBasicsTest::testDAIBuildSubstraction1() +{ + DataArrayInt *a=DataArrayInt::New(); + const int aa[]={2,3,6,8,9}; + a->alloc(5,1); + std::copy(aa,aa+5,a->getPointer()); + DataArrayInt *b=DataArrayInt::New(); + const int bb[]={1,3,5,9,11}; + b->alloc(5,1); + std::copy(bb,bb+5,b->getPointer()); + // + DataArrayInt *c=a->buildSubstraction(b); + CPPUNIT_ASSERT_EQUAL(3,c->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(1,c->getNumberOfComponents()); + const int expected1[3]={2,6,8}; + CPPUNIT_ASSERT(std::equal(expected1,expected1+3,c->getConstPointer())); + // + c->decrRef(); + b->decrRef(); + a->decrRef(); +} diff --git a/src/MEDCoupling_Swig/MEDCoupling.i b/src/MEDCoupling_Swig/MEDCoupling.i index cb00f5c13..fba3e5363 100644 --- a/src/MEDCoupling_Swig/MEDCoupling.i +++ b/src/MEDCoupling_Swig/MEDCoupling.i @@ -115,7 +115,7 @@ using namespace INTERP_KERNEL; %newobject ParaMEDMEM::DataArrayInt::toNoInterlace; %newobject ParaMEDMEM::DataArrayInt::buildComplement; %newobject ParaMEDMEM::DataArrayInt::buildUnion; -%newobject ParaMEDMEM::DataArrayInt::substract; +%newobject ParaMEDMEM::DataArrayInt::buildSubstraction; %newobject ParaMEDMEM::DataArrayInt::buildIntersection; %newobject ParaMEDMEM::DataArrayInt::deltaShiftIndex; %newobject ParaMEDMEM::DataArrayDouble::New; diff --git a/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py b/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py index 6d97b8f31..602adfd2b 100644 --- a/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py +++ b/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py @@ -5473,6 +5473,16 @@ class MEDCouplingBasicsTest(unittest.TestCase): self.assertTrue(da1.isEqual(da2,1e-12)) self.assertRaises(Exception,m.getCoords().keepSelectedComponents,["1"]) pass + + def testDAIBuildSubstraction1(self): + a=DataArrayInt.New() + aa=[2,3,6,8,9] + a.setValues(aa,5,1) + b=DataArrayInt.New() + bb=[1,3,5,9,11] + b.setValues(bb,5,1) + self.assertEqual([2,6,8],a.buildSubstraction(b).getValues()) + pass def setUp(self): pass -- 2.39.2