]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
*** empty log message ***
authorageay <ageay>
Mon, 13 Dec 2010 14:16:33 +0000 (14:16 +0000)
committerageay <ageay>
Mon, 13 Dec 2010 14:16:33 +0000 (14:16 +0000)
src/MEDCoupling/MEDCouplingMemArray.cxx
src/MEDCoupling/MEDCouplingMemArray.hxx
src/MEDCoupling/Test/MEDCouplingBasicsTest.hxx
src/MEDCoupling/Test/MEDCouplingBasicsTest2.cxx
src/MEDCoupling_Swig/MEDCoupling.i
src/MEDCoupling_Swig/MEDCouplingBasicsTest.py

index 2b044363fa22baea666f890e485431752db3efd3..6ba17ac7f6b3ff852883eb502c73514d2c9d1a3b 100644 (file)
@@ -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<int> s1(pt,pt+nbOfTuples);
index c0eed999c96e3bcd89aa1a6edfa44d4d73c8b5ed..0cbefafb9fdf196bb3951fd05b2198dd8637dfcd 100644 (file)
@@ -267,7 +267,7 @@ namespace ParaMEDMEM
     MEDCOUPLING_EXPORT static DataArrayInt *meld(const std::vector<const DataArrayInt *>& a) throw(INTERP_KERNEL::Exception);
     MEDCOUPLING_EXPORT static DataArrayInt *makePartition(const std::vector<DataArrayInt *>& groups, int newNb, std::vector< std::vector<int> >& 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);
index 2f69327b4b37d2e26e3de57fd4f9701f7ca4f31f..88de848a4dbcc246264fb59a465c841f55979fa0 100644 (file)
@@ -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();
index 63e8bde7c67520bf9f5bd86f52439699a0a526f8..6029b80be6803788f0310faaaad2a8714c7f8359 100644 (file)
@@ -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();
+}
index cb00f5c13b205c3a4486c3e7478d64a2515c4a72..fba3e53633e040b1cfba4a3264be0744ed37f89c 100644 (file)
@@ -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;
index 6d97b8f31f2cd52989bf9dfb0f04e747723bd3e9..602adfd2b54a014e90055b9b4078a75872aa4aac 100644 (file)
@@ -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