Salome HOME
Remove DataArrayInt::isIdentity-> DataArrayInt::isIdentity2 for everybody. Remove...
authorAnthony Geay <anthony.geay@edf.fr>
Mon, 18 Jan 2016 10:53:50 +0000 (11:53 +0100)
committerAnthony Geay <anthony.geay@edf.fr>
Mon, 18 Jan 2016 10:53:50 +0000 (11:53 +0100)
20 files changed:
doc/user/doxygen/fakesources/MEDCouplingMemArray.C
src/MEDCoupling/MEDCoupling1GTUMesh.cxx
src/MEDCoupling/MEDCouplingMemArray.cxx
src/MEDCoupling/MEDCouplingMemArray.hxx
src/MEDCoupling/MEDCouplingPointSet.cxx
src/MEDCoupling/MEDCouplingUMesh.cxx
src/MEDCoupling/Test/MEDCouplingBasicsTest4.cxx
src/MEDCoupling/Test/MEDCouplingBasicsTest5.cxx
src/MEDCoupling_Swig/MEDCouplingBasicsTest3.py
src/MEDCoupling_Swig/MEDCouplingBasicsTest4.py
src/MEDCoupling_Swig/MEDCouplingBasicsTest5.py
src/MEDCoupling_Swig/MEDCouplingMemArray.i
src/MEDCoupling_Swig/MEDCouplingNumPyTest.py
src/MEDLoader/MEDFileField.cxx
src/MEDLoader/MEDFileFieldOverView.cxx
src/MEDLoader/MEDFileMesh.cxx
src/MEDLoader/MEDFileMeshLL.cxx
src/MEDLoader/MEDLoader.cxx
src/MEDLoader/Swig/MEDLoaderTest3.py
v8_work/TODO.txt

index 26f45eab2c41f6d4b59c52332ba574c7fd4fdad0..2d0d63dddfcdd83ccc213d7aff25a585616a95f3 100644 (file)
@@ -478,7 +478,7 @@ DataArrayInt::selectByTupleRanges(const std::vector<std::pair<int,int> >& 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);
index 17dfb5d66adfb9352a159c41baba2a6cfd356020..c59a09a1fe94730c48fcfaf232fedcd375b06ba3 100644 (file)
@@ -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<DataArrayInt *>(profile); idsInPflPerType[0]->incrRef();
index 8f1d1513d40cf0cd9c5cd118a91253a46d625bd6..337c822e0877f0c3e77f643fe694a2c307b70a3b 100644 (file)
@@ -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;i<nbOfTuples;i++,pt++)
-    {
-      if(*pt==valToBeReplaced)
-        *pt=replacedBy;
-    }
-}
-
 /*!
  * Computes distribution of values of \a this one-dimensional array between given value
  * ranges (casts). This method is typically useful for entity number spliting by types,
@@ -7799,20 +7776,22 @@ DataArrayInt *DataArrayInt::buildPermArrPerLevel() const
 /*!
  * Checks if contents of \a this array are equal to that of an array filled with
  * iota(). This method is particularly useful for DataArrayInt instances that represent
- * a renumbering array to check the real need in renumbering. In this case it is better to use isIdentity2
- * method of isIdentity method.
+ * a renumbering array to check the real need in renumbering. This method checks than \a this can be considered as an identity function
+ * of a set having \a sizeExpected elements into itself.
  *
+ *  \param [in] sizeExpected - The number of elements expected.
  *  \return bool - \a true if \a this array contents == \a range( \a this->getNumberOfTuples())
  *  \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;i<nbOfTuples;i++,pt++)
     if(*pt!=i)
@@ -7820,25 +7799,6 @@ bool DataArrayInt::isIdentity() const
   return true;
 }
 
-/*!
- * This method is stronger than isIdentity method. This method checks than \a this can be considered as an identity function
- * of a set having \a sizeExpected elements into itself.
- *
- * \param [in] sizeExpected - The number of elements
- * \return bool - \a true if \a this array contents == \a range( \a this->getNumberOfTuples()) 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<int> vals2(valsBg,valsEnd);
-  const int *cptr=getConstPointer();
+  const int *cptr(getConstPointer());
   std::vector<int> res;
-  int nbOfTuples=getNumberOfTuples();
+  int nbOfTuples(getNumberOfTuples());
   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret(DataArrayInt::New()); ret->alloc(0,1);
   for(int i=0;i<nbOfTuples;i++,cptr++)
     if(vals2.find(*cptr)!=vals2.end())
index cf1ee4e7086802f65a5e8f0ecadbc39c346e0b0e..93de8ade0e83017d322ad8e28bba2263ea1a9e76 100644 (file)
@@ -495,7 +495,6 @@ namespace ParaMEDMEM
     MEDCOUPLING_EXPORT void reprQuickOverview(std::ostream& stream) const;
     MEDCOUPLING_EXPORT void reprQuickOverviewData(std::ostream& stream, std::size_t maxNbOfByteInRepr) const;
     MEDCOUPLING_EXPORT void transformWithIndArr(const int *indArrBg, const int *indArrEnd);
-    MEDCOUPLING_EXPORT void replaceOneValByInThis(int valToBeReplaced, int replacedBy);
     MEDCOUPLING_EXPORT DataArrayInt *transformWithIndArrR(const int *indArrBg, const int *indArrEnd) const;
     MEDCOUPLING_EXPORT void splitByValueRange(const int *arrBg, const int *arrEnd,
                                               DataArrayInt *& castArr, DataArrayInt *& rankInsideCast, DataArrayInt *& castsPresent) const;
@@ -521,7 +520,6 @@ namespace ParaMEDMEM
     MEDCOUPLING_EXPORT void changeSurjectiveFormat(int targetNb, DataArrayInt *&arr, DataArrayInt *&arrI) const;
     MEDCOUPLING_EXPORT static DataArrayInt *BuildOld2NewArrayFromSurjectiveFormat2(int nbOfOldTuples, const int *arr, const int *arrIBg, const int *arrIEnd, int &newNbOfTuples);
     MEDCOUPLING_EXPORT DataArrayInt *buildPermArrPerLevel() const;
-    MEDCOUPLING_EXPORT bool isIdentity() const;
     MEDCOUPLING_EXPORT bool isIdentity2(int sizeExpected) const;
     MEDCOUPLING_EXPORT bool isUniform(int val) const;
     MEDCOUPLING_EXPORT DataArrayInt *substr(int tupleIdBg, int tupleIdEnd=-1) const;
index 4793b7993ff5adfc236eee4c9f2298347a76d2d2..bfa15ca0683d076f40845c444de4a7a274155065 100644 (file)
@@ -1500,8 +1500,8 @@ void MEDCouplingPointSet::checkDeepEquivalWith(const MEDCouplingMesh *other, int
         throw INTERP_KERNEL::Exception("checkDeepEquivalWith : some cells in other are not in this !");
     }
   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> 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<DataArrayInt> 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
index a9c55c69725c1bc0f1cb7c6140a7d1d0c20144c7..b852a63b3fc0b6a60b3b9bc570decdea694ef039 100644 (file)
@@ -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<DataArrayInt> 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<DataArrayInt> 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<int>::max(),-1);
+  ret3->changeValue(std::numeric_limits<int>::max(),-1);
   ret3->rearrange(2);
   //
   splitMesh1D=ret1.retn();
index 8b547fe08bef8d7253f33d9d1a6039f1b807cb58..b9c49c424a5c3d7f73cf46db5c3d96d785e97c68 100644 (file)
@@ -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();
index 0dc0e8c017f43709f43abaae07261c60247457d9..2c855155e918754f39fe3744835ce0506f09ab74 100644 (file)
@@ -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();
   //
index 23260abbe7209d1411a7d927efbb4f59bb1cf51d..30cbabe015f0798dd75c6dd4e58c2d52e8281229 100644 (file)
@@ -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):
index 939145114c12797fee8b93acab4cd282e47ff1fb..ee374ac6777b5194916d7e19bf10f9fe76baedb2 100644 (file)
@@ -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
+  
index cd110a8995d789462713fb414d89c2214c037546..10f6d5a53f3b4d73dd04f00910566536b621f412 100644 (file)
@@ -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
 
index 77e88536ee817939f4af0e561b141651407f00cb..e13e8eec1f9fdc9f3a7e911ba8dfbf228ce9801a 100644 (file)
@@ -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);
index e5d7943bf1531970fb5d94b28e9c0a2626e29642..308e33e27786fa9d30e45fd117cd1f9be5348956 100644 (file)
@@ -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()
index 0918d29d480d30d4fc2f4fca4130fb9a1c691cb3..e757a6f82dd5211abbc52b75195fdff0f4be8923 100644 (file)
@@ -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<MEDFileFieldPerMeshPerTypePerDisc> 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<INTERP_KERNEL::NormalizedCellType>& geoTypes,
                                                           const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& 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<MEDCouplingMesh> m2=mesh->buildPart(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
   m2->setName(mesh->getName().c_str());
   MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(type,glob,dads,locs,m2,isPfl,arrOut,nasc);
@@ -2405,12 +2401,8 @@ MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishFieldNode2(const MEDFileField
                                                               const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
                                                               const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& 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<const MEDCouplingUMesh *>(mesh);
   if(meshu)
index 4f0367cb2ff9df1242bfc76e1b2be05b23207ffe..036503caba704c2cdb01075aac7ff74c3733abbb 100644 (file)
@@ -482,7 +482,7 @@ DataArray *MEDMeshMultiLev::constructDataArray(const MEDFileField1TSStructItem&
         {
           MEDCouplingAutoRefCountObjectPtr<DataArrayInt> 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<DataArray> 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<int,int> 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<DataArrayInt> cpyPfl(pfl->deepCpy());
       cpyPfl->sort();
-      if(cpyPfl->isIdentity() && cpyPfl->getNumberOfTuples()==nbOfNodes)
+      if(cpyPfl->isIdentity2(nbOfNodes))
         {//on all nodes also !
           if(!ret0)
             return false;
index 6c388c796d18be25399646cea40b84627f674f5b..66cad4ba07a8deb411dcbbdcfd6c1760d4295ae0 100644 (file)
@@ -3840,7 +3840,7 @@ bool MEDFileUMesh::unPolyze(std::vector<int>& oldCode, std::vector<int>& newCode
           end=PutInThirdComponentOfCodeOffset(code2,start);
           newCode.insert(newCode.end(),code2.begin(),code2.end());
           //
-          if(o2nCellsPart2->isIdentity())
+          if(o2nCellsPart2->isIdentity2(o2nCellsPart2->getNumberOfTuples()))
             continue;
           if(famField)
             {
index 92dd11f205e79a1dede3dcc662647b23eb2a4b67..25ad1fd5355749e2e999f1654eaa05cce048bb72 100644 (file)
@@ -1025,7 +1025,7 @@ void MEDFileUMeshSplitL1::assignMesh(MEDCouplingUMesh *m, bool newOrOld)
       _m=m;
       _m_by_types.assignUMesh(dynamic_cast<MEDCouplingUMesh *>(m->deepCpy()));
       MEDCouplingAutoRefCountObjectPtr<DataArrayInt> 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();
index af614c4f3575bc5b7a0f1a52e45e2af990afadaa..dc1355a19091ee0fddd615810c152c7a5de812f7 100644 (file)
@@ -1518,7 +1518,7 @@ void MEDLoader::WriteField(const std::string& fileName, const ParaMEDMEM::MEDCou
                 }
               MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> 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<MEDFileField1TS> f1ts(MEDFileField1TS::New());
               AssignStaticWritePropertiesTo(*f1ts);
-              if(part->isIdentity() && part->getNumberOfTuples()==mread->getNumberOfNodes())
+              if(part->isIdentity2(mread->getNumberOfNodes()))
                 f1ts->setFieldNoProfileSBT(f2);
               else
                 {
index 13b3e4318f940a3f4cf9fd75ad69f3a5e89a3e35..d702be45cbcd7f792306f02878e42b65149a9e57 100644 (file)
@@ -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
index 807525298906c8158c77223beca4cc10330fece9..507a69f9d76614b08ee6f5cdc8481c2bc699e68f 100644 (file)
@@ -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)
 ===============