From: Anthony Geay Date: Mon, 18 Jan 2016 10:53:50 +0000 (+0100) Subject: Remove DataArrayInt::isIdentity-> DataArrayInt::isIdentity2 for everybody. Remove... X-Git-Tag: V8_0_0b1~23 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=0d89ead3756a73241e61fc46b60e59104b4be02c;p=tools%2Fmedcoupling.git Remove DataArrayInt::isIdentity-> DataArrayInt::isIdentity2 for everybody. Remove DataArrayInt::replaceOneValByInThis replaced by DataArrayInt::changeValue. --- diff --git a/doc/user/doxygen/fakesources/MEDCouplingMemArray.C b/doc/user/doxygen/fakesources/MEDCouplingMemArray.C index 26f45eab2..2d0d63ddd 100644 --- a/doc/user/doxygen/fakesources/MEDCouplingMemArray.C +++ b/doc/user/doxygen/fakesources/MEDCouplingMemArray.C @@ -478,7 +478,7 @@ DataArrayInt::selectByTupleRanges(const std::vector >& ranges DataArrayInt::checkAndPreparePermutation() const; DataArrayInt::changeSurjectiveFormat(int targetNb, DataArrayInt *&arr, DataArrayInt *&arrI) const; DataArrayInt::buildPermArrPerLevel() const; -DataArrayInt::isIdentity() const; +DataArrayInt::isIdentity2(int sizeExpected) const; DataArrayInt::isUniform(int val) const; DataArrayInt::substr(int tupleIdBg, int tupleIdEnd=-1) const; DataArrayInt::rearrange(int newNbOfCompo); diff --git a/src/MEDCoupling/MEDCoupling1GTUMesh.cxx b/src/MEDCoupling/MEDCoupling1GTUMesh.cxx index 17dfb5d66..c59a09a1f 100644 --- a/src/MEDCoupling/MEDCoupling1GTUMesh.cxx +++ b/src/MEDCoupling/MEDCoupling1GTUMesh.cxx @@ -183,12 +183,11 @@ void MEDCoupling1GTUMesh::splitProfilePerType(const DataArrayInt *profile, std:: throw INTERP_KERNEL::Exception("MEDCoupling1GTUMesh::splitProfilePerType : input profile is NULL !"); if(profile->getNumberOfComponents()!=1) throw INTERP_KERNEL::Exception("MEDCoupling1GTUMesh::splitProfilePerType : input profile should have exactly one component !"); - int nbTuples=profile->getNumberOfTuples(); - int nbOfCells=getNumberOfCells(); + int nbTuples(profile->getNumberOfTuples()),nbOfCells(getNumberOfCells()); code.resize(3); idsInPflPerType.resize(1); code[0]=(int)getCellModelEnum(); code[1]=nbTuples; idsInPflPerType.resize(1); - if(profile->isIdentity() && nbTuples==nbOfCells) + if(profile->isIdentity2(nbOfCells)) { code[2]=-1; idsInPflPerType[0]=const_cast(profile); idsInPflPerType[0]->incrRef(); diff --git a/src/MEDCoupling/MEDCouplingMemArray.cxx b/src/MEDCoupling/MEDCouplingMemArray.cxx index 8f1d1513d..337c822e0 100644 --- a/src/MEDCoupling/MEDCouplingMemArray.cxx +++ b/src/MEDCoupling/MEDCouplingMemArray.cxx @@ -6479,7 +6479,7 @@ void DataArrayInt::reprQuickOverviewData(std::ostream& stream, std::size_t maxNb * \throw If any value of \a this can't be used as a valid index for * [\a indArrBg, \a indArrEnd). * - * \sa replaceOneValByInThis + * \sa changeValue */ void DataArrayInt::transformWithIndArr(const int *indArrBg, const int *indArrEnd) { @@ -6500,29 +6500,6 @@ void DataArrayInt::transformWithIndArr(const int *indArrBg, const int *indArrEnd declareAsNew(); } -/*! - * Modifies in place \a this one-dimensional array like this : each id in \a this so that this[id] equal to \a valToBeReplaced will be replaced at the same place by \a replacedBy. - * - * \param [in] valToBeReplaced - the value in \a this to be replaced. - * \param [in] replacedBy - the value taken by each tuple previously equal to \a valToBeReplaced. - * - * \sa DataArrayInt::transformWithIndArr - */ -void DataArrayInt::replaceOneValByInThis(int valToBeReplaced, int replacedBy) -{ - checkAllocated(); - if(getNumberOfComponents()!=1) - throw INTERP_KERNEL::Exception("Call replaceOneValByInThis method on DataArrayInt with only one component, you can call 'rearrange' method before !"); - if(valToBeReplaced==replacedBy) - return ; - int nbOfTuples(getNumberOfTuples()),*pt(getPointer()); - for(int i=0;igetNumberOfTuples()) * \throw If \a this is not allocated. * \throw If \a this->getNumberOfComponents() != 1. - * \sa isIdentity2 */ -bool DataArrayInt::isIdentity() const +bool DataArrayInt::isIdentity2(int sizeExpected) const { checkAllocated(); if(getNumberOfComponents()!=1) return false; int nbOfTuples(getNumberOfTuples()); + if(nbOfTuples!=sizeExpected) + return false; const int *pt=getConstPointer(); for(int i=0;igetNumberOfTuples()) and if \a this has \a sizeExpected tuples in it. - * - * \throw If \a this is not allocated. - * \throw If \a this->getNumberOfComponents() != 1. - * \sa isIdentity - */ -bool DataArrayInt::isIdentity2(int sizeExpected) const -{ - bool ret0(isIdentity()); - if(!ret0) - return false; - return getNumberOfTuples()==sizeExpected; -} - /*! * Checks if all values in \a this array are equal to \a val. * \param [in] val - value to check equality of array values to. @@ -8929,9 +8889,10 @@ int DataArrayInt::changeValue(int oldValue, int newValue) checkAllocated(); if(getNumberOfComponents()!=1) throw INTERP_KERNEL::Exception("DataArrayInt::changeValue : the array must have only one component, you can call 'rearrange' method before !"); - int *start=getPointer(); - int *end2=start+getNbOfElems(); - int ret=0; + if(oldValue==newValue) + return 0; + int *start(getPointer()),*end2(start+getNbOfElems()); + int ret(0); for(int *val=start;val!=end2;val++) { if(*val==oldValue) @@ -8940,6 +8901,8 @@ int DataArrayInt::changeValue(int oldValue, int newValue) ret++; } } + if(ret>0) + declareAsNew(); return ret; } @@ -8958,9 +8921,9 @@ DataArrayInt *DataArrayInt::getIdsEqualList(const int *valsBg, const int *valsEn if(getNumberOfComponents()!=1) throw INTERP_KERNEL::Exception("DataArrayInt::getIdsEqualList : the array must have only one component, you can call 'rearrange' method before !"); std::set vals2(valsBg,valsEnd); - const int *cptr=getConstPointer(); + const int *cptr(getConstPointer()); std::vector res; - int nbOfTuples=getNumberOfTuples(); + int nbOfTuples(getNumberOfTuples()); MEDCouplingAutoRefCountObjectPtr ret(DataArrayInt::New()); ret->alloc(0,1); for(int i=0;i cellCor2=da->selectByTupleId2(nbCells,da->getNbOfElems(),1); - nodeCor=nodeCor2->isIdentity()?0:nodeCor2.retn(); - cellCor=cellCor2->isIdentity()?0:cellCor2.retn(); + nodeCor=nodeCor2->isIdentity2(nodeCor2->getNumberOfTuples())?0:nodeCor2.retn(); + cellCor=cellCor2->isIdentity2(cellCor2->getNumberOfTuples())?0:cellCor2.retn(); } /*! @@ -1542,7 +1542,7 @@ void MEDCouplingPointSet::checkDeepEquivalOnSameNodesWith(const MEDCouplingMesh throw INTERP_KERNEL::Exception("checkDeepEquivalOnSameNodesWith : some cells in other are not in this !"); } MEDCouplingAutoRefCountObjectPtr cellCor2=da->selectByTupleId2(getNumberOfCells(),da->getNbOfElems(),1); - cellCor=cellCor2->isIdentity()?0:cellCor2.retn(); + cellCor=cellCor2->isIdentity2(cellCor2->getNumberOfTuples())?0:cellCor2.retn(); } void MEDCouplingPointSet::checkFastEquivalWith(const MEDCouplingMesh *other, double prec) const diff --git a/src/MEDCoupling/MEDCouplingUMesh.cxx b/src/MEDCoupling/MEDCouplingUMesh.cxx index a9c55c697..b852a63b3 100644 --- a/src/MEDCoupling/MEDCouplingUMesh.cxx +++ b/src/MEDCoupling/MEDCouplingUMesh.cxx @@ -7012,7 +7012,7 @@ void MEDCouplingUMesh::splitProfilePerType(const DataArrayInt *profile, std::vec code[3*i]=(int)types[castId]; code[3*i+1]=tmp3->getNumberOfTuples(); MEDCouplingAutoRefCountObjectPtr tmp4=rankInsideCast->selectByTupleId(tmp3->getConstPointer(),tmp3->getConstPointer()+tmp3->getNumberOfTuples()); - if(tmp4->getNumberOfTuples()!=typeRangeVals[castId+1]-typeRangeVals[castId] || !tmp4->isIdentity()) + if(!tmp4->isIdentity2(typeRangeVals[castId+1]-typeRangeVals[castId])) { tmp4->copyStringInfoFrom(*profile); idsPerType2.push_back(tmp4); @@ -9942,7 +9942,7 @@ void MEDCouplingUMesh::Intersect2DMeshWith1DLine(const MEDCouplingUMesh *mesh2D, MEDCouplingAutoRefCountObjectPtr candidates(ret2->getIdsEqual(old2DCellId)); ret3->setIJ(*it,0,FindRightCandidateAmong(ret2D,candidates->begin(),candidates->end(),ret1,*it%2==0?-((*it)/2+1):(*it)/2+1,eps));// div by 2 because 2 components natively in ret3 } - ret3->replaceOneValByInThis(std::numeric_limits::max(),-1); + ret3->changeValue(std::numeric_limits::max(),-1); ret3->rearrange(2); // splitMesh1D=ret1.retn(); diff --git a/src/MEDCoupling/Test/MEDCouplingBasicsTest4.cxx b/src/MEDCoupling/Test/MEDCouplingBasicsTest4.cxx index 8b547fe08..b9c49c424 100644 --- a/src/MEDCoupling/Test/MEDCouplingBasicsTest4.cxx +++ b/src/MEDCoupling/Test/MEDCouplingBasicsTest4.cxx @@ -178,9 +178,8 @@ void MEDCouplingBasicsTest4::testDAICheckAndPreparePermutation1() da->alloc(8,1); da->iota(0); da2=da->checkAndPreparePermutation(); - CPPUNIT_ASSERT_EQUAL(8,da2->getNumberOfTuples()); CPPUNIT_ASSERT_EQUAL(1,da2->getNumberOfComponents()); - CPPUNIT_ASSERT(da2->isIdentity()); + CPPUNIT_ASSERT(da2->isIdentity2(8)); da2->decrRef(); da->decrRef(); // @@ -238,8 +237,7 @@ void MEDCouplingBasicsTest4::testUMeshFindCellIdsOnBoundary1() { MEDCouplingUMesh *m=build3DSurfTargetMesh_1(); DataArrayInt *da5=m->findCellIdsOnBoundary(); - CPPUNIT_ASSERT_EQUAL(5,da5->getNumberOfTuples()); - CPPUNIT_ASSERT(da5->isIdentity()); + CPPUNIT_ASSERT(da5->isIdentity2(5)); // da5->decrRef(); m->decrRef(); diff --git a/src/MEDCoupling/Test/MEDCouplingBasicsTest5.cxx b/src/MEDCoupling/Test/MEDCouplingBasicsTest5.cxx index 0dc0e8c01..2c855155e 100644 --- a/src/MEDCoupling/Test/MEDCouplingBasicsTest5.cxx +++ b/src/MEDCoupling/Test/MEDCouplingBasicsTest5.cxx @@ -1139,8 +1139,7 @@ void MEDCouplingBasicsTest5::testConvexEnvelop2D1() ref2->decrRef(); vals->abs(); DataArrayInt *theTest=vals->getIdsInRange(-1.,1e-7); - CPPUNIT_ASSERT(theTest->isIdentity()); - CPPUNIT_ASSERT_EQUAL(331,theTest->getNumberOfTuples()); + CPPUNIT_ASSERT(theTest->isIdentity2(331)); theTest->decrRef(); valsF->decrRef(); // diff --git a/src/MEDCoupling_Swig/MEDCouplingBasicsTest3.py b/src/MEDCoupling_Swig/MEDCouplingBasicsTest3.py index 23260abbe..30cbabe01 100644 --- a/src/MEDCoupling_Swig/MEDCouplingBasicsTest3.py +++ b/src/MEDCoupling_Swig/MEDCouplingBasicsTest3.py @@ -813,9 +813,8 @@ class MEDCouplingBasicsTest3(unittest.TestCase): da.alloc(8,1); da.iota(0); da2=da.checkAndPreparePermutation(); - self.assertEqual(8,da2.getNumberOfTuples()); self.assertEqual(1,da2.getNumberOfComponents()); - self.assertTrue(da2.isIdentity()); + self.assertTrue(da2.isIdentity2(8)); # da=DataArrayInt.New(); da.alloc(8,1); @@ -860,8 +859,7 @@ class MEDCouplingBasicsTest3(unittest.TestCase): def testUMeshFindCellIdsOnBoundary1(self): m=MEDCouplingDataForTest.build3DSurfTargetMesh_1(); da5=m.findCellIdsOnBoundary(); - self.assertEqual(5,da5.getNumberOfTuples()); - self.assertTrue(da5.isIdentity()); + self.assertTrue(da5.isIdentity2(5)); pass def testMeshSetTime1(self): diff --git a/src/MEDCoupling_Swig/MEDCouplingBasicsTest4.py b/src/MEDCoupling_Swig/MEDCouplingBasicsTest4.py index 939145114..ee374ac67 100644 --- a/src/MEDCoupling_Swig/MEDCouplingBasicsTest4.py +++ b/src/MEDCoupling_Swig/MEDCouplingBasicsTest4.py @@ -947,8 +947,7 @@ class MEDCouplingBasicsTest4(unittest.TestCase): vals-=DataArrayDouble.New(ref) vals.abs() theTest=vals.getIdsInRange(-1.,1e-7) - self.assertTrue(theTest.isIdentity()) - self.assertEqual(331,len(theTest)) + self.assertTrue(theTest.isIdentity2(331)) pass def testSwigDAIOp8(self): @@ -2150,13 +2149,13 @@ class MEDCouplingBasicsTest4(unittest.TestCase): # n,ni=m.computeNeighborsOfCells() a,b=MEDCouplingUMesh.ComputeSpreadZoneGraduallyFromSeed(0,n,ni) - self.assertEqual(13,b) ; self.assertEqual(125,len(a)) ; self.assertTrue(a.isIdentity()) + self.assertEqual(13,b) ; self.assertTrue(a.isIdentity2(125)) a,b=MEDCouplingUMesh.ComputeSpreadZoneGraduallyFromSeed([1],n,ni) - self.assertEqual(12,b) ; self.assertEqual(125,len(a)) ; self.assertTrue(a.isIdentity()) + self.assertEqual(12,b) ; self.assertTrue(a.isIdentity2(125)) a,b=MEDCouplingUMesh.ComputeSpreadZoneGraduallyFromSeed((2,),n,ni) - self.assertEqual(11,b) ; self.assertEqual(125,len(a)) ; self.assertTrue(a.isIdentity()) + self.assertEqual(11,b) ; self.assertTrue(a.isIdentity2(125)) a,b=MEDCouplingUMesh.ComputeSpreadZoneGraduallyFromSeed(DataArrayInt([3]),n,ni) - self.assertEqual(12,b) ; self.assertEqual(125,len(a)) ; self.assertTrue(a.isIdentity()) + self.assertEqual(12,b) ; self.assertTrue(a.isIdentity2(125)) pass def testSwigUMeshInsertNextCell1(self): @@ -2552,8 +2551,7 @@ class MEDCouplingBasicsTest4(unittest.TestCase): def testSwig2ConvertLinearCellsToQuadratic2(self): m2D=MEDCouplingDataForTest.build2DTargetMesh_1() ret=m2D.convertLinearCellsToQuadratic(1) - self.assertTrue(ret.isIdentity()) - self.assertEqual(5,len(ret)) + self.assertTrue(ret.isIdentity2(5)) m2D.checkCoherency1() coordsExp=DataArrayDouble([-0.3,-0.3,0.2,-0.3,0.7,-0.3,-0.3,0.2,0.2,0.2,0.7,0.2,-0.3,0.7,0.2,0.7,0.7,0.7,-0.3,-0.05,-0.05,0.2,0.2,-0.05,-0.05,-0.3,0.45,-0.05,0.45,-0.3,0.45,0.2,0.7,-0.05,-0.05,0.7,0.2,0.45,-0.3,0.45,0.45,0.7,0.7,0.45,-0.05,-0.05,0.3666666666666667,-0.1333333333333333,0.5333333333333332,0.03333333333333334,-0.05,0.45,0.45,0.45],27,2) self.assertTrue(m2D.getCoords().isEqual(coordsExp,1e-14)) @@ -2568,8 +2566,7 @@ class MEDCouplingBasicsTest4(unittest.TestCase): cooTmp=m2D.getCoords()[:] m3D=m2D.buildExtrudedMesh(m1D,0) ret=m3D.convertLinearCellsToQuadratic(1) - self.assertTrue(ret.isIdentity()) - self.assertEqual(4,len(ret)) + self.assertTrue(ret.isIdentity2(4)) m3D.checkCoherency1() coordsExp2=DataArrayDouble([-0.3,-0.3,0.0,0.2,-0.3,0.0,-0.3,0.2,0.0,0.2,0.2,0.0,-0.3,0.7,0.0,0.2,0.7,0.0,-0.3,-0.3,1.0,0.2,-0.3,1.0,-0.3,0.2,1.0,0.2,0.2,1.0,-0.3,0.7,1.0,0.2,0.7,1.0,-0.3,-0.3,2.0,0.2,-0.3,2.0,-0.3,0.2,2.0,0.2,0.2,2.0,-0.3,0.7,2.0,0.2,0.7,2.0,-0.3,-0.05,0.0,-0.05,0.2,0.0,0.2,-0.05,0.0,-0.05,-0.3,0.0,-0.3,-0.05,1.0,-0.05,0.2,1.0,0.2,-0.05,1.0,-0.05,-0.3,1.0,-0.3,-0.3,0.5,-0.3,0.2,0.5,0.2,0.2,0.5,0.2,-0.3,0.5,-0.05,0.7,0.0,0.2,0.45,0.0,-0.3,0.45,0.0,-0.05,0.7,1.0,0.2,0.45,1.0,-0.3,0.45,1.0,-0.3,0.7,0.5,0.2,0.7,0.5,-0.3,-0.05,2.0,-0.05,0.2,2.0,0.2,-0.05,2.0,-0.05,-0.3,2.0,-0.3,-0.3,1.5,-0.3,0.2,1.5,0.2,0.2,1.5,0.2,-0.3,1.5,-0.05,0.7,2.0,0.2,0.45,2.0,-0.3,0.45,2.0,-0.3,0.7,1.5,0.2,0.7,1.5,-0.05,-0.05,0.0,-0.3,-0.05,0.5,-0.05,0.2,0.5,0.2,-0.05,0.5,-0.05,-0.3,0.5,-0.05,-0.05,1.0,-0.05,0.45,0.0,-0.05,0.7,0.5,0.2,0.45,0.5,-0.3,0.45,0.5,-0.05,0.45,1.0,-0.3,-0.05,1.5,-0.05,0.2,1.5,0.2,-0.05,1.5,-0.05,-0.3,1.5,-0.05,-0.05,2.0,-0.05,0.7,1.5,0.2,0.45,1.5,-0.3,0.45,1.5,-0.05,0.45,2.0,-0.05,-0.05,0.5,-0.05,0.45,0.5,-0.05,-0.05,1.5,-0.05,0.45,1.5],75,3) self.assertTrue(m3D.getCoords().isEqual(coordsExp2,1e-14)) @@ -3596,4 +3593,4 @@ class MEDCouplingBasicsTest4(unittest.TestCase): if __name__ == '__main__': unittest.main() - \ No newline at end of file + diff --git a/src/MEDCoupling_Swig/MEDCouplingBasicsTest5.py b/src/MEDCoupling_Swig/MEDCouplingBasicsTest5.py index cd110a899..10f6d5a53 100644 --- a/src/MEDCoupling_Swig/MEDCouplingBasicsTest5.py +++ b/src/MEDCoupling_Swig/MEDCouplingBasicsTest5.py @@ -3798,7 +3798,7 @@ class MEDCouplingBasicsTest5(unittest.TestCase): def testSwig2DAIReplaceOneValByInThis1(self): d=DataArrayInt([4,-5,-1,0,-5,99,-7,5]) - d.replaceOneValByInThis(-5,900) + d.changeValue(-5,900) self.assertTrue(d.isEqual(DataArrayInt([4,900,-1,0,900,99,-7,5]))) pass diff --git a/src/MEDCoupling_Swig/MEDCouplingMemArray.i b/src/MEDCoupling_Swig/MEDCouplingMemArray.i index 77e88536e..e13e8eec1 100644 --- a/src/MEDCoupling_Swig/MEDCouplingMemArray.i +++ b/src/MEDCoupling_Swig/MEDCouplingMemArray.i @@ -2608,7 +2608,6 @@ namespace ParaMEDMEM void fillWithZero() throw(INTERP_KERNEL::Exception); void fillWithValue(int val) throw(INTERP_KERNEL::Exception); void iota(int init=0) throw(INTERP_KERNEL::Exception); - void replaceOneValByInThis(int valToBeReplaced, int replacedBy) throw(INTERP_KERNEL::Exception); std::string repr() const throw(INTERP_KERNEL::Exception); std::string reprZip() const throw(INTERP_KERNEL::Exception); std::string reprNotTooLong() const throw(INTERP_KERNEL::Exception); @@ -2621,7 +2620,6 @@ namespace ParaMEDMEM DataArrayInt *selectByTupleId2(int bg, int end, int step) const throw(INTERP_KERNEL::Exception); DataArrayInt *checkAndPreparePermutation() const throw(INTERP_KERNEL::Exception); DataArrayInt *buildPermArrPerLevel() const throw(INTERP_KERNEL::Exception); - bool isIdentity() const throw(INTERP_KERNEL::Exception); bool isIdentity2(int sizeExpected) const throw(INTERP_KERNEL::Exception); bool isUniform(int val) const throw(INTERP_KERNEL::Exception); DataArrayInt *substr(int tupleIdBg, int tupleIdEnd=-1) const throw(INTERP_KERNEL::Exception); diff --git a/src/MEDCoupling_Swig/MEDCouplingNumPyTest.py b/src/MEDCoupling_Swig/MEDCouplingNumPyTest.py index e5d7943bf..308e33e27 100644 --- a/src/MEDCoupling_Swig/MEDCouplingNumPyTest.py +++ b/src/MEDCoupling_Swig/MEDCouplingNumPyTest.py @@ -102,8 +102,7 @@ class MEDCouplingNumPyTest(unittest.TestCase): d=DataArrayInt(a) self.assertEqual(weakref.getweakrefcount(a),1) self.assertTrue(not a.flags["OWNDATA"]) - self.assertTrue(d.isIdentity()) - self.assertEqual(len(d),20) + self.assertTrue(d.isIdentity2(20)) a[:]=2 # modifying a and d because a and d share the same chunk of data self.assertTrue(d.isUniform(2)) del d # d is destroyed, a retrieves its ownership of its initial chunk of data @@ -120,8 +119,8 @@ class MEDCouplingNumPyTest(unittest.TestCase): a=arange(20,dtype=int32) d=DataArrayInt(a) # d owns data of a e=DataArrayInt(a) # a not owned -> e only an access to chunk of a - self.assertTrue(d.isIdentity()) - self.assertTrue(e.isIdentity()) + self.assertTrue(d.isIdentity2(d.getNumberOfTuples())) + self.assertTrue(e.isIdentity2(e.getNumberOfTuples())) a[:]=6 self.assertTrue(d.isUniform(6)) self.assertTrue(e.isUniform(6)) @@ -155,13 +154,13 @@ class MEDCouplingNumPyTest(unittest.TestCase): del b # no impact on e and f because a is the base of a. ##@@ Ensure a pass of the garbage collector so that the de-allocator of d is called gc.collect() - self.assertTrue(f.isIdentity()) - self.assertTrue(e.isIdentity()) + self.assertTrue(f.isIdentity2(f.getNumberOfTuples())) + self.assertTrue(e.isIdentity2(e.getNumberOfTuples())) del a # a destroyed, but as c has its base set to a, a exists -> e and f not allocated ##@@ Ensure a pass of the garbage collector so that the de-allocator of d is called gc.collect() - self.assertTrue(f.isIdentity()) - self.assertTrue(e.isIdentity()) + self.assertTrue(f.isIdentity2(f.getNumberOfTuples())) + self.assertTrue(e.isIdentity2(e.getNumberOfTuples())) del c # c killed -> a killed -> e and d are put into not allocated state ##@@ Ensure a pass of the garbage collector so that the de-allocator of d is called gc.collect() @@ -563,33 +562,33 @@ class MEDCouplingNumPyTest(unittest.TestCase): b=DataArrayInt(a) c=DataArrayInt(a) d=DataArrayInt(a) - self.assertTrue(b.isIdentity()) ; self.assertEqual(len(b),10) - self.assertTrue(c.isIdentity()) ; self.assertEqual(len(c),10) - self.assertTrue(d.isIdentity()) ; self.assertEqual(len(d),10) + self.assertTrue(b.isIdentity2(10)) + self.assertTrue(c.isIdentity2(10)) + self.assertTrue(d.isIdentity2(10)) c.pushBackSilent(10) # c and a,b are dissociated - self.assertTrue(b.isIdentity()) ; self.assertEqual(len(b),10) - self.assertTrue(c.isIdentity()) ; self.assertEqual(len(c),11) - self.assertTrue(d.isIdentity()) ; self.assertEqual(len(d),10) + self.assertTrue(b.isIdentity2(10)) + self.assertTrue(c.isIdentity2(11)) + self.assertTrue(d.isIdentity2(10)) del a gc.collect() - self.assertTrue(b.isIdentity()) ; self.assertEqual(len(b),10) - self.assertTrue(c.isIdentity()) ; self.assertEqual(len(c),11) + self.assertTrue(b.isIdentity2(10)) + self.assertTrue(c.isIdentity2(11)) self.assertTrue(not d.isAllocated()) del b gc.collect() - self.assertTrue(c.isIdentity()) ; self.assertEqual(len(c),11) + self.assertTrue(c.isIdentity2(11)) # a=arange(10,dtype=int32) b=DataArrayInt(a) c=DataArrayInt(a) - self.assertTrue(b.isIdentity()) ; self.assertEqual(len(b),10) - self.assertTrue(c.isIdentity()) ; self.assertEqual(len(c),10) + self.assertTrue(b.isIdentity2(10)) + self.assertTrue(c.isIdentity2(10)) b.pushBackSilent(10) # c and a,b are dissociated - self.assertTrue(b.isIdentity()) ; self.assertEqual(len(b),11) - self.assertTrue(c.isIdentity()) ; self.assertEqual(len(c),10) + self.assertTrue(b.isIdentity2(11)) + self.assertTrue(c.isIdentity2(10)) del a gc.collect() - self.assertTrue(b.isIdentity()) ; self.assertEqual(len(b),11) + self.assertTrue(b.isIdentity2(11)) self.assertTrue(not c.isAllocated()) del b gc.collect() diff --git a/src/MEDLoader/MEDFileField.cxx b/src/MEDLoader/MEDFileField.cxx index 0918d29d4..e757a6f82 100644 --- a/src/MEDLoader/MEDFileField.cxx +++ b/src/MEDLoader/MEDFileField.cxx @@ -372,7 +372,7 @@ void MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile(bool isPflAlone, int& } else { - if(da3->getNumberOfTuples()!=nbOfEltsInWholeMesh || !da3->isIdentity()) + if(!da3->isIdentity2(nbOfEltsInWholeMesh)) { da3->setName(oss.str().c_str()); glob.appendProfile(da3); @@ -959,7 +959,7 @@ bool MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(int offset, const std::ve int nbEntityElts=subIds->getNumberOfTuples(); bool ret2; MEDCouplingAutoRefCountObjectPtr eltToAdd=MEDFileFieldPerMeshPerTypePerDisc:: - NewObjectOnSameDiscThanPool(type,(INTERP_KERNEL::NormalizedCellType)newCode[3*(*idIt)],subIds,!subIds->isIdentity() || nbEntityElts!=newCode[3*(*idIt)+1],nbi, + NewObjectOnSameDiscThanPool(type,(INTERP_KERNEL::NormalizedCellType)newCode[3*(*idIt)],subIds,!subIds->isIdentity2(newCode[3*(*idIt)+1]),nbi, offset+offset2, li,glob,ret2); ret=ret || ret2; @@ -2385,12 +2385,8 @@ MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField2(TypeOfField type, cons const std::vector& geoTypes, const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MEDCouplingAutoRefCountObjectPtr& arrOut, const MEDFileFieldNameScope& nasc) const { - if(da->isIdentity()) - { - int nbOfTuples=da->getNumberOfTuples(); - if(nbOfTuples==mesh->getNumberOfCells()) - return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc); - } + if(da->isIdentity2(mesh->getNumberOfCells())) + return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc); MEDCouplingAutoRefCountObjectPtr m2=mesh->buildPart(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems()); m2->setName(mesh->getName().c_str()); MEDCouplingAutoRefCountObjectPtr ret=finishField(type,glob,dads,locs,m2,isPfl,arrOut,nasc); @@ -2405,12 +2401,8 @@ MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishFieldNode2(const MEDFileField const std::vector >& dads, const std::vector& locs, const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MEDCouplingAutoRefCountObjectPtr& arrOut, const MEDFileFieldNameScope& nasc) const { - if(da->isIdentity()) - { - int nbOfTuples=da->getNumberOfTuples(); - if(nbOfTuples==mesh->getNumberOfNodes())//No problem for NORM_ERROR because it is in context of node - return finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc); - } + if(da->isIdentity2(mesh->getNumberOfNodes())) + return finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc); // Treatment of particular case where nodal field on pfl is requested with a meshDimRelToMax=1. const MEDCouplingUMesh *meshu=dynamic_cast(mesh); if(meshu) diff --git a/src/MEDLoader/MEDFileFieldOverView.cxx b/src/MEDLoader/MEDFileFieldOverView.cxx index 4f0367cb2..036503cab 100644 --- a/src/MEDLoader/MEDFileFieldOverView.cxx +++ b/src/MEDLoader/MEDFileFieldOverView.cxx @@ -482,7 +482,7 @@ DataArray *MEDMeshMultiLev::constructDataArray(const MEDFileField1TSStructItem& { MEDCouplingAutoRefCountObjectPtr p1(globs->getProfile(pflName.c_str())->deepCpy()); p1->sort(true); - if(!p1->isIdentity() || p1->getNumberOfTuples()!=getNumberOfNodes()) + if(!p1->isIdentity2(getNumberOfNodes())) throw INTERP_KERNEL::Exception("MEDMeshMultiLev::constructDataArray : unexpected situation for nodes 4 !"); MEDCouplingAutoRefCountObjectPtr ret(vals->deepCpy()); ret->renumberInPlace(globs->getProfile(pflName.c_str())->begin()); @@ -1747,7 +1747,7 @@ MEDFileField1TSStructItem2 MEDFileField1TSStructItem2::BuildAggregationOf(const arr=arr->buildUnique(); if(oldNbTuples!=arr->getNumberOfTuples()) throw INTERP_KERNEL::Exception("MEDFileField1TSStructItem2::BuildAggregationOf : some entities are present several times !"); - if(arr->isIdentity() && oldNbTuples==nbEntityRef) + if(arr->isIdentity2(nbEntityRef)) { std::pair p(0,nbEntityRef); std::string a,b; @@ -1938,7 +1938,7 @@ bool MEDFileField1TSStructItem::isCompatibleWithNodesDiscr(const MEDFileField1TS const DataArrayInt *pfl=globs->getProfile(otherNodeIt.getPflName().c_str()); MEDCouplingAutoRefCountObjectPtr cpyPfl(pfl->deepCpy()); cpyPfl->sort(); - if(cpyPfl->isIdentity() && cpyPfl->getNumberOfTuples()==nbOfNodes) + if(cpyPfl->isIdentity2(nbOfNodes)) {//on all nodes also ! if(!ret0) return false; diff --git a/src/MEDLoader/MEDFileMesh.cxx b/src/MEDLoader/MEDFileMesh.cxx index 6c388c796..66cad4ba0 100644 --- a/src/MEDLoader/MEDFileMesh.cxx +++ b/src/MEDLoader/MEDFileMesh.cxx @@ -3840,7 +3840,7 @@ bool MEDFileUMesh::unPolyze(std::vector& oldCode, std::vector& newCode end=PutInThirdComponentOfCodeOffset(code2,start); newCode.insert(newCode.end(),code2.begin(),code2.end()); // - if(o2nCellsPart2->isIdentity()) + if(o2nCellsPart2->isIdentity2(o2nCellsPart2->getNumberOfTuples())) continue; if(famField) { diff --git a/src/MEDLoader/MEDFileMeshLL.cxx b/src/MEDLoader/MEDFileMeshLL.cxx index 92dd11f20..25ad1fd53 100644 --- a/src/MEDLoader/MEDFileMeshLL.cxx +++ b/src/MEDLoader/MEDFileMeshLL.cxx @@ -1025,7 +1025,7 @@ void MEDFileUMeshSplitL1::assignMesh(MEDCouplingUMesh *m, bool newOrOld) _m=m; _m_by_types.assignUMesh(dynamic_cast(m->deepCpy())); MEDCouplingAutoRefCountObjectPtr da=_m_by_types.getUmesh()->getRenumArrForConsecutiveCellTypesSpec(typmai2,typmai2+MED_N_CELL_FIXED_GEO); - if(!da->isIdentity()) + if(!da->isIdentity2(m->getNumberOfCells())) { _num=da->invertArrayO2N2N2O(m->getNumberOfCells()); _m.updateTime(); diff --git a/src/MEDLoader/MEDLoader.cxx b/src/MEDLoader/MEDLoader.cxx index af614c4f3..dc1355a19 100644 --- a/src/MEDLoader/MEDLoader.cxx +++ b/src/MEDLoader/MEDLoader.cxx @@ -1518,7 +1518,7 @@ void MEDLoader::WriteField(const std::string& fileName, const ParaMEDMEM::MEDCou } MEDCouplingAutoRefCountObjectPtr f1ts(MEDFileField1TS::New()); AssignStaticWritePropertiesTo(*f1ts); - if(part->isIdentity() && part->getNumberOfTuples()==mread->getNumberOfCells()) + if(part->isIdentity2(mread->getNumberOfCells())) f1ts->setFieldNoProfileSBT(f2); else { @@ -1540,7 +1540,7 @@ void MEDLoader::WriteField(const std::string& fileName, const ParaMEDMEM::MEDCou } MEDCouplingAutoRefCountObjectPtr f1ts(MEDFileField1TS::New()); AssignStaticWritePropertiesTo(*f1ts); - if(part->isIdentity() && part->getNumberOfTuples()==mread->getNumberOfNodes()) + if(part->isIdentity2(mread->getNumberOfNodes())) f1ts->setFieldNoProfileSBT(f2); else { diff --git a/src/MEDLoader/Swig/MEDLoaderTest3.py b/src/MEDLoader/Swig/MEDLoaderTest3.py index 13b3e4318..d702be45c 100644 --- a/src/MEDLoader/Swig/MEDLoaderTest3.py +++ b/src/MEDLoader/Swig/MEDLoaderTest3.py @@ -891,8 +891,7 @@ class MEDLoaderTest(unittest.TestCase): ff1.write(fname,0) f1=ff1.getFieldOnMeshAtLevel(ON_GAUSS_NE,m1,0) f2,p1=ff1.getFieldWithProfile(ON_GAUSS_NE,0,mm1) ; f2.setName("") - self.assertTrue(p1.isIdentity()) - self.assertEqual(5,p1.getNumberOfTuples()) + self.assertTrue(p1.isIdentity2(5)) self.assertTrue(f1.getArray().isEqual(f2,1e-12)) pass # Test for getFieldAtTopLevel method diff --git a/v8_work/TODO.txt b/v8_work/TODO.txt index 807525298..507a69f9d 100644 --- a/v8_work/TODO.txt +++ b/v8_work/TODO.txt @@ -25,6 +25,7 @@ Various simplifications + remove isIdentity2 + remove replaceOneValByInThis (changeValue fait le meme boulot) - Attention repercuter if(oldValue==newValue) return 0 + tessellate2D et tessellate2DCurve: à merger en un seul tessellate2D + + remove checkCoherency2 Inheritance fix (OK but at the end of process) ===============