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);
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);
CPPUNIT_TEST( testDAIDeltaShiftIndex1 );
CPPUNIT_TEST( testDaDoubleSelectByTupleIdSafe1 );
CPPUNIT_TEST( testAreCellsIncludedIn1 );
+ CPPUNIT_TEST( testDAIBuildSubstraction1 );
//MEDCouplingBasicsTestInterp.cxx
CPPUNIT_TEST( test2DInterpP0P0_1 );
CPPUNIT_TEST( test2DInterpP0P0PL_1 );
void testDAIDeltaShiftIndex1();
void testDaDoubleSelectByTupleIdSafe1();
void testAreCellsIncludedIn1();
+ void testDAIBuildSubstraction1();
//MEDCouplingBasicsTestInterp.cxx
void test2DInterpP0P0_1();
void test2DInterpP0P0PL_1();
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();
+}
%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;
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