From 92f05ec611342ce1249c88f65b6d38d6f983f2fb Mon Sep 17 00:00:00 2001 From: eap Date: Wed, 11 Dec 2019 15:14:01 +0300 Subject: [PATCH] LOT4: 1) fix tests in config=int64 2) fix warnings --- src/INTERP_KERNEL/CMakeLists.txt | 4 + src/INTERP_KERNEL/CellModel.cxx | 16 +- .../ExprEval/InterpKernelAsmX86.cxx | 4 +- .../ExprEval/InterpKernelUnit.cxx | 9 +- .../GaussPoints/InterpKernelGaussCoords.cxx | 8 +- .../InterpKernelGeo2DComposedEdge.cxx | 2 +- .../Geometric2D/InterpKernelGeo2DEdge.cxx | 12 +- .../InterpKernelGeo2DElementaryEdge.cxx | 2 +- .../InterpKernelGeo2DQuadraticPolygon.cxx | 34 +- .../InterpKernelCellSimplify.cxx | 14 +- src/INTERP_KERNEL/InterpolationOptions.cxx | 4 +- src/INTERP_KERNEL/InterpolationOptions.hxx | 4 +- src/INTERP_KERNEL/SplitterTetra.cxx | 16 +- src/INTERP_KERNEL/TransformedTriangleMath.cxx | 4 +- src/MEDCoupling/MEDCouplingField.cxx | 2 +- src/MEDCoupling/MEDCouplingField.hxx | 2 +- src/MEDCoupling/MEDCouplingFieldDouble.cxx | 4 +- src/MEDCoupling/MEDCouplingFieldDouble.hxx | 4 +- src/MEDCoupling/MEDCouplingMemArray.hxx | 4 +- src/MEDCoupling/MEDCouplingMemArray.txx | 4 +- src/MEDCoupling/MEDCouplingMemArrayChar.cxx | 6 +- src/MEDCoupling/MEDCouplingTraits.hxx | 4 + src/MEDCoupling/MEDCouplingUMesh.cxx | 9 +- .../Test/MEDCouplingBasicsTest1.cxx | 2 +- .../Test/MEDCouplingBasicsTest3.cxx | 17 +- .../Test/MEDCouplingBasicsTest4.cxx | 4 +- .../Test/MEDCouplingBasicsTest5.cxx | 5 +- .../Test/MEDCouplingExamplesTest.cxx | 2 +- src/MEDCoupling_Swig/CMakeLists.txt | 4 + src/MEDCoupling_Swig/DataArrayInt.i | 106 +++---- .../MEDCouplingBasicsTest2.py | 4 +- .../MEDCouplingBasicsTest3.py | 2 +- .../MEDCouplingBasicsTest4.py | 2 +- .../MEDCouplingBasicsTest5.py | 22 +- src/MEDCoupling_Swig/MEDCouplingCommon.i | 146 ++++----- .../MEDCouplingDataArrayTraits.hxx | 97 +++++- .../MEDCouplingDataArrayTypemaps.i | 298 +++++++++--------- .../MEDCouplingFieldDiscretization.i | 14 +- src/MEDCoupling_Swig/MEDCouplingMemArray.i | 116 +++---- src/MEDCoupling_Swig/MEDCouplingNumPyTest.py | 58 ++-- src/MEDCoupling_Swig/MEDCouplingPickleTest.py | 2 +- .../MEDCouplingRemapperCommon.i | 13 +- .../MEDCouplingRemapperTest.py | 6 +- src/MEDCoupling_Swig/MEDCouplingTypemaps.i | 10 +- .../UsersGuideExamplesTest_numpy.py | 4 +- 45 files changed, 612 insertions(+), 494 deletions(-) diff --git a/src/INTERP_KERNEL/CMakeLists.txt b/src/INTERP_KERNEL/CMakeLists.txt index 4b70eceba..6cf3b22ba 100644 --- a/src/INTERP_KERNEL/CMakeLists.txt +++ b/src/INTERP_KERNEL/CMakeLists.txt @@ -72,6 +72,10 @@ INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR}/GaussPoints ) +IF (NOT DEFINED MSVC) + ADD_DEFINITIONS(-Wsign-compare -Wconversion) +ENDIF() + SET(PLATFORM_MMAP) IF(NOT WIN32) SET(PLATFORM_MMAP "-D_POSIX_MAPPED_FILES") diff --git a/src/INTERP_KERNEL/CellModel.cxx b/src/INTERP_KERNEL/CellModel.cxx index e79822e62..cf71d3a61 100644 --- a/src/INTERP_KERNEL/CellModel.cxx +++ b/src/INTERP_KERNEL/CellModel.cxx @@ -456,14 +456,14 @@ namespace INTERP_KERNEL if(_dim==2) { if(_type==NORM_POLYGON) - return lgth; + return FromIdType(lgth); else - return lgth/2; + return FromIdType(lgth/2); } else if(_dim==1) - return lgth;//NORM_POLYL + return FromIdType(lgth);//NORM_POLYL else - return std::count(conn,conn+lgth,-1)+1; + return (unsigned)std::count(conn,conn+lgth,-1)+1; } unsigned CellModel::getNumberOfEdgesIn3D(const mcIdType *conn, mcIdType lgth) const @@ -471,7 +471,7 @@ namespace INTERP_KERNEL if(!isDynamic()) return _nb_of_little_sons; else//polyhedron - return (lgth-std::count(conn,conn+lgth,-1))/2; + return FromIdType(lgth-ToIdType(std::count(conn,conn+lgth,-1)/2)); } /*! @@ -591,7 +591,7 @@ namespace INTERP_KERNEL } const mcIdType *where2=std::find(where,nodalConn+lgth,-1); std::copy(where,where2,sonNodalConn); - return where2-where; + return (unsigned)(where2-where); } else throw INTERP_KERNEL::Exception("CellModel::fillSonCellNodalConnectivity2 : no sons on NORM_POLYL !"); @@ -753,7 +753,7 @@ namespace INTERP_KERNEL where++; } const mcIdType *where2=std::find(where,nodalConn+lgth,-1); - return where2-where; + return (unsigned)(where2-where); } else throw INTERP_KERNEL::Exception("CellModel::getNumberOfNodesConstituentTheSon2 : no sons on NORM_POLYL !"); @@ -805,7 +805,7 @@ namespace INTERP_KERNEL } else { - int p=(lgth+1)/2; + mcIdType p=(lgth+1)/2; std::vector tmp(2*p); std::vector::iterator it=std::copy(conn1,conn1+p,tmp.begin()); std::copy(conn1,conn1+p,it); diff --git a/src/INTERP_KERNEL/ExprEval/InterpKernelAsmX86.cxx b/src/INTERP_KERNEL/ExprEval/InterpKernelAsmX86.cxx index d040be703..794c664db 100644 --- a/src/INTERP_KERNEL/ExprEval/InterpKernelAsmX86.cxx +++ b/src/INTERP_KERNEL/ExprEval/InterpKernelAsmX86.cxx @@ -45,7 +45,7 @@ std::vector INTERP_KERNEL::AsmX86::convertIntoMachineLangage(const std::ve char *INTERP_KERNEL::AsmX86::copyToExecMemZone(const std::vector& ml, unsigned& offset) const { char *ret=0; - int lgth=ml.size(); + std::size_t lgth=ml.size(); #ifdef _POSIX_MAPPED_FILES # ifdef __APPLE__ ret=(char *)mmap(0,lgth,PROT_EXEC | PROT_WRITE,MAP_ANON | MAP_PRIVATE,-1,0); @@ -492,7 +492,7 @@ void INTERP_KERNEL::AsmX86::appendAddress(const std::string& addr, int nbOfByte, for(int k=0;k>=8; } diff --git a/src/INTERP_KERNEL/ExprEval/InterpKernelUnit.cxx b/src/INTERP_KERNEL/ExprEval/InterpKernelUnit.cxx index ab5e989d9..ab5a4a79b 100644 --- a/src/INTERP_KERNEL/ExprEval/InterpKernelUnit.cxx +++ b/src/INTERP_KERNEL/ExprEval/InterpKernelUnit.cxx @@ -233,7 +233,8 @@ void DecompositionInUnitBase::tryToConvertInUnit(double val) DecompositionInUnitBase &DecompositionInUnitBase::operator*(const DecompositionInUnitBase& other) { - _value[0]+=other._value[0]; _value[1]+=other._value[1]; _value[2]+=other._value[2]; _value[3]+=other._value[3]; _value[4]+=other._value[4]; + // += causes ' conversion to 'short int' from 'int' may alter its value [-Wconversion]' + _value[0]=(short)(_value[0]+other._value[0]); _value[1]=(short)(_value[1]+other._value[1]); _value[2]=(short)(_value[2]+other._value[2]); _value[3]=(short)(_value[3]+other._value[3]); _value[4]=(short)(_value[4]+other._value[4]); _mult_fact_to_base*=other._mult_fact_to_base; _add_to_base=0.; return *this; @@ -241,7 +242,8 @@ DecompositionInUnitBase &DecompositionInUnitBase::operator*(const DecompositionI DecompositionInUnitBase &DecompositionInUnitBase::operator/(const DecompositionInUnitBase& other) { - _value[0]-=other._value[0]; _value[1]-=other._value[1]; _value[2]-=other._value[2]; _value[3]-=other._value[3]; _value[4]-=other._value[4]; + // -= causes ' conversion to 'short int' from 'int' may alter its value [-Wconversion]' + _value[0]=(short)(_value[0]-other._value[0]); _value[1]=(short)(_value[1]-other._value[1]); _value[2]=(short)(_value[2]-other._value[2]); _value[3]=(short)(_value[3]-other._value[3]); _value[4]=(short)(_value[4]-other._value[4]); _mult_fact_to_base/=other._mult_fact_to_base; _add_to_base=0.; return *this; @@ -252,7 +254,8 @@ DecompositionInUnitBase &DecompositionInUnitBase::operator^(const DecompositionI if(!other.isAdimensional()) throw INTERP_KERNEL::Exception("Trying to execute operator ^ with a second member not adimensionnal"); int exp=couldItBeConsideredAsInt(other._mult_fact_to_base); - _value[0]*=exp; _value[1]*=exp; _value[2]*=exp; _value[3]*=exp; _value[4]*=exp; + // *= causes ' conversion to 'short int' from 'int' may alter its value [-Wconversion]' + _value[0]=(short)(_value[0]*exp); _value[1]=(short)(_value[1]*exp); _value[2]=(short)(_value[2]*exp); _value[3]=(short)(_value[3]*exp); _value[4]=(short)(_value[4]*exp); _mult_fact_to_base=powInt(_mult_fact_to_base,exp); _add_to_base=0.; return *this; diff --git a/src/INTERP_KERNEL/GaussPoints/InterpKernelGaussCoords.cxx b/src/INTERP_KERNEL/GaussPoints/InterpKernelGaussCoords.cxx index 6b699a584..42adbc54c 100644 --- a/src/INTERP_KERNEL/GaussPoints/InterpKernelGaussCoords.cxx +++ b/src/INTERP_KERNEL/GaussPoints/InterpKernelGaussCoords.cxx @@ -172,7 +172,7 @@ int GaussInfo::getGaussCoordDim() const { if( _my_nb_gauss ) { - return _my_gauss_coord.size()/_my_nb_gauss; + return (int)_my_gauss_coord.size()/_my_nb_gauss; } else { @@ -187,7 +187,7 @@ int GaussInfo::getReferenceCoordDim() const { if( _my_nb_ref ) { - return _my_reference_coord.size()/_my_nb_ref; + return (int)(_my_reference_coord.size()/_my_nb_ref); } else { @@ -2967,7 +2967,7 @@ void GaussCoords::addGaussInfo( NormalizedCellType theGeometry, aReferenceCoord.push_back(theReferenceCoord[i]); - GaussInfo* info = new GaussInfo( theGeometry, aGaussCoord, theNbGauss, aReferenceCoord, theNbRef); + GaussInfo* info = new GaussInfo( theGeometry, aGaussCoord, FromIdType(theNbGauss), aReferenceCoord, FromIdType(theNbRef)); info->initLocalInfo(); //If info with cell type doesn't exist add it @@ -2979,7 +2979,7 @@ void GaussCoords::addGaussInfo( NormalizedCellType theGeometry, } else { - int index = std::distance(_my_gauss_info.begin(),it); + std::size_t index = std::distance(_my_gauss_info.begin(),it); delete (*it); _my_gauss_info[index] = info; } diff --git a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DComposedEdge.cxx b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DComposedEdge.cxx index 735728239..a2f2fe97b 100644 --- a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DComposedEdge.cxx +++ b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DComposedEdge.cxx @@ -587,7 +587,7 @@ double ComposedEdge::isInOrOutAlg(Node *nodeToTest, const std::set& nodes std::vector radialDistrib3(radialDistrib.size()); std::transform(radialDistrib2.begin(),radialDistrib2.end(),radialDistrib.begin(),radialDistrib3.begin(),std::minus()); std::vector::iterator iter3=max_element(radialDistrib3.begin(),radialDistrib3.end()); - int i=iter3-radialDistrib3.begin(); + std::size_t i=iter3-radialDistrib3.begin(); // ok for e1 - Let's go. EdgeInfLin *e1=new EdgeInfLin(nodeToTest,radialDistrib[i]+radialDistrib3[i]/2.); double ref=e1->getCharactValue(*nodeToTest); diff --git a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdge.cxx b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdge.cxx index 7617feb11..a3220bf61 100644 --- a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdge.cxx +++ b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdge.cxx @@ -684,17 +684,17 @@ bool Edge::IntersectOverlapped(const Edge *f1, const Edge *f2, EdgeIntersector * */ void Edge::Interpolate1DLin(const std::vector& distrib1, const std::vector& distrib2, std::map >& result) { - int nbOfV1=distrib1.size()-1; - int nbOfV2=distrib2.size()-1; + std::size_t nbOfV1=distrib1.size()-1; + std::size_t nbOfV2=distrib2.size()-1; Node *n1=new Node(0.,0.); Node *n3=new Node(0.,0.); Node *n2=new Node(0.,0.); Node *n4=new Node(0.,0.); MergePoints commonNode; - for(int i=0;i::const_iterator iter=find_if(distrib2.begin()+1,distrib2.end(),bind2nd(std::greater_equal(),distrib1[i])); if(iter!=distrib2.end()) { - for(int j=(iter-1)-distrib2.begin();j& addNodes, const tmpp2[tmpp.size()+1]=endId; std::vector::iterator itt=std::unique(tmpp2.begin(),tmpp2.end()); tmpp2.resize(std::distance(tmpp2.begin(),itt)); - int nbOfEdges=tmpp2.size()-1; - for(int i=0;i& edgesOther, std::vector& addCoo, std::map& mapAddCoo) const { if (!_direction) - skipStartOrEnd *= -1; // invert value - see QuadraticPolygon::splitAbs() + skipStartOrEnd = (short)(-skipStartOrEnd); // invert value - see QuadraticPolygon::splitAbs() _ptr->fillGlobalInfoAbs2(mapThis,mapOther,offset1,offset2,fact,baryX,baryY,skipStartOrEnd,edgesOther,addCoo,mapAddCoo); } diff --git a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DQuadraticPolygon.cxx b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DQuadraticPolygon.cxx index 5ccc4c06b..7494e5328 100644 --- a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DQuadraticPolygon.cxx +++ b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DQuadraticPolygon.cxx @@ -324,7 +324,7 @@ void QuadraticPolygon::splitAbs(QuadraticPolygon& other, // std::map::const_iterator thisStart(mapThis.find(curThis->getStartNode())),thisEnd(mapThis.find(curThis->getEndNode())), otherStart(mapOther.find(curOtherTmp->getStartNode())),otherEnd(mapOther.find(curOtherTmp->getEndNode())); - int thisStart2(thisStart==mapThis.end()?-1:(*thisStart).second), thisEnd2(thisEnd==mapThis.end()?-1:(*thisEnd).second), + mcIdType thisStart2(thisStart==mapThis.end()?-1:(*thisStart).second), thisEnd2(thisEnd==mapThis.end()?-1:(*thisEnd).second), otherStart2(otherStart==mapOther.end()?-1:(*otherStart).second+offset1),otherEnd2(otherEnd==mapOther.end()?-1:(*otherEnd).second+offset1); // if(curThis->getPtr()->intersectWith(curOtherTmp->getPtr(),merge,*cThis,*cOther)) @@ -362,7 +362,7 @@ void QuadraticPolygon::splitAbs(QuadraticPolygon& other, // Converting back to integer connectivity: if(otherTmp._sub_edges.size()>1) // only if a new point has been added (i.e. an actual intersection was done) { - int jj = 0, sz(otherTmp._sub_edges.size()); + std::size_t jj = 0, sz(otherTmp._sub_edges.size()); for(std::list::const_iterator it=otherTmp._sub_edges.begin();it!=otherTmp._sub_edges.end();it++, jj++) { short skipStartOrEnd = jj == 0 ? -1 : (jj == sz-1 ? 1 : 0); // -1 means START, 1 means END, 0 other @@ -403,7 +403,7 @@ void QuadraticPolygon::appendEdgeFromCrudeDataArray(std::size_t edgePos, const s if(!isQuad) { bool direct=descBg[edgePos]>0; - mcIdType edgeId=abs(descBg[edgePos])-1; // back to C indexing mode + mcIdType edgeId=std::abs(descBg[edgePos])-1; // back to C indexing mode const std::vector& subEdge=intersectEdges[edgeId]; std::size_t nbOfSubEdges=subEdge.size()/2; for(std::size_t j=0;j0; - mcIdType edgeId=abs(descBg[edgePos])-1; + mcIdType edgeId=std::abs(descBg[edgePos])-1; const std::vector& subEdge=intersectEdges[edgeId]; std::size_t nbOfSubEdges=subEdge.size()/2; if(colinearity) @@ -478,7 +478,7 @@ void QuadraticPolygon::buildFromCrudeDataArray2(const std::map0; - mcIdType edgeId=abs(descBg[i])-1;//current edge id of pol2 + mcIdType edgeId=std::abs(descBg[i])-1;//current edge id of pol2 std::map >::const_iterator it1=alreadyExistingIn2.find(descBg[i]),it2=alreadyExistingIn2.find(-descBg[i]); if(it1!=alreadyExistingIn2.end() || it2!=alreadyExistingIn2.end()) { @@ -511,13 +511,13 @@ void QuadraticPolygon::buildFromCrudeDataArray2(const std::map >(edgeId1,std::pair(descBg1[j]>0,offset1)));// it exists an edge into pol1 given by tuple (idIn1,direct1) that is colinear at edge 'edgeId' in pol2 //std::pair0; } - offset1+=intersectEdges1[edgeId1].size()/2;//offset1 is used to find the INTERP_KERNEL::Edge * instance into pol1 that will be part of edge into pol2 + offset1+=ToIdType(intersectEdges1[edgeId1].size()/2);//offset1 is used to find the INTERP_KERNEL::Edge * instance into pol1 that will be part of edge into pol2 } directos=idIns1.empty(); } @@ -543,16 +543,16 @@ void QuadraticPolygon::buildFromCrudeDataArray2(const std::map > >::const_iterator it=idIns1.begin();it!=idIns1.end() && !found;it++) { mcIdType idIn1=(*it).first;//store if needed the cell id in 1 direct1=(*it).second.first; offset1=(*it).second.second; const std::vector& subEdge1PossiblyAlreadyIn1=intersectEdges1[idIn1]; - nbOfSubEdges1=subEdge1PossiblyAlreadyIn1.size()/2; + nbOfSubEdges1=ToIdType(subEdge1PossiblyAlreadyIn1.size()/2); offset2=0; - for(std::size_t k=0;k reuse Edge instance of pol1 - ElementaryEdge *e=pol1[offset1+(direct1?offset2:nbOfSubEdges1-offset2-1)]; + ElementaryEdge *e=pol1[FromIdType(offset1+(direct1?offset2:nbOfSubEdges1-offset2-1))]; Edge *ee=e->getPtr(); ee->incrRef(); ElementaryEdge *e2=new ElementaryEdge(ee,!(direct1^direction11)); @@ -597,7 +597,7 @@ void QuadraticPolygon::updateLocOfEdgeFromCrudeDataArray2(const mcIdType *descBg for(std::size_t i=0;i0; - mcIdType edgeId=abs(descBg[i])-1;//current edge id of pol2 + mcIdType edgeId=std::abs(descBg[i])-1;//current edge id of pol2 const std::vector& c=colinear1[edgeId]; if(c.empty()) continue; @@ -608,7 +608,7 @@ void QuadraticPolygon::updateLocOfEdgeFromCrudeDataArray2(const mcIdType *descBg mcIdType offset1=0; for(std::size_t j=0;j0; const std::vector& subEdge1PossiblyAlreadyIn1=intersectEdges1[idIn1]; - std::size_t nbOfSubEdges1=subEdge1PossiblyAlreadyIn1.size()/2; + mcIdType nbOfSubEdges1=ToIdType(subEdge1PossiblyAlreadyIn1.size()/2); mcIdType offset2=0; bool found=false; - for(std::size_t kk=0;kkgetPtr()->declareOn(); } } } - offset1+=intersectEdges1[edgeId1].size()/2;//offset1 is used to find the INTERP_KERNEL::Edge * instance into pol1 that will be part of edge into pol2 + offset1+=ToIdType(intersectEdges1[edgeId1].size()/2);//offset1 is used to find the INTERP_KERNEL::Edge * instance into pol1 that will be part of edge into pol2 } } } diff --git a/src/INTERP_KERNEL/InterpKernelCellSimplify.cxx b/src/INTERP_KERNEL/InterpKernelCellSimplify.cxx index 1fa6079c9..028f61b5a 100644 --- a/src/INTERP_KERNEL/InterpKernelCellSimplify.cxx +++ b/src/INTERP_KERNEL/InterpKernelCellSimplify.cxx @@ -66,7 +66,7 @@ INTERP_KERNEL::NormalizedCellType CellSimplify::simplifyDegeneratedCell(INTERP_K } else { - int quadOff = lgth/2; + mcIdType quadOff = lgth/2; mcIdType *tmpQuad = new mcIdType[quadOff]; for(int i = 0; i < quadOff; i++) if(conn[i] != conn[(i+1)%quadOff] || conn[i] != conn[i+quadOff]) // zip nul segments/arcs (quad point must match too) @@ -181,8 +181,8 @@ INTERP_KERNEL::NormalizedCellType CellSimplify::tryToUnPoly3D(const mcIdType *co { std::set nodes(conn,conn+lgth); nodes.erase(-1); - int nbOfNodes=(int)nodes.size(); - int magicNumber=100*nbOfNodes+nbOfFaces; + std::size_t nbOfNodes=nodes.size(); + std::size_t magicNumber=100*nbOfNodes+nbOfFaces; switch(magicNumber) { case 806: @@ -260,8 +260,8 @@ bool CellSimplify::orientOppositeFace(const mcIdType *baseFace, mcIdType *retCon std::vector< std::pair >::iterator it=std::find(oppEdges.begin(),oppEdges.end(),pInOpp); if(it==oppEdges.end())//the opposite edge of side face is not found opposite face ... maybe problem of orientation of polyhedron return false; - int pos2=(int)std::distance(oppEdges.begin(),it); - int offset=pos-pos2; + mcIdType pos2=ToIdType(std::distance(oppEdges.begin(),it)); + mcIdType offset=pos-pos2; if(offset<0) offset+=lgthBaseFace; //this is the end copy the result @@ -451,7 +451,7 @@ INTERP_KERNEL::NormalizedCellType CellSimplify::tryToUnPolyPyra5(const mcIdType std::set quad4S(quad4,quad4+4); w=conn; bool ok=true; - int point=-1; + mcIdType point=-1; for(std::size_t i=0;i<5 && ok;i++) { if(i!=quad4_pos) @@ -496,7 +496,7 @@ INTERP_KERNEL::NormalizedCellType CellSimplify::tryToUnPolyTetra4(const mcIdType if(std::find_if(conn+lgth,conn+lgth+nbOfFaces,std::bind2nd(std::not_equal_to(),ToIdType(INTERP_KERNEL::NORM_TRI3)))==conn+lgth+nbOfFaces) { std::set tribase(conn,conn+3); - int point=-1; + mcIdType point=-1; bool ok=true; for(int i=1;i<4 && ok;i++) { diff --git a/src/INTERP_KERNEL/InterpolationOptions.cxx b/src/INTERP_KERNEL/InterpolationOptions.cxx index 63998d933..0d70a7d0a 100644 --- a/src/INTERP_KERNEL/InterpolationOptions.cxx +++ b/src/INTERP_KERNEL/InterpolationOptions.cxx @@ -255,7 +255,7 @@ std::string INTERP_KERNEL::InterpolationOptions::filterInterpolationMethod(const return std::string(meth); } -bool INTERP_KERNEL::InterpolationOptions::setInterpolationOptions(long print_level, +bool INTERP_KERNEL::InterpolationOptions::setInterpolationOptions(int print_level, std::string intersection_type, double precision, double median_plane, @@ -263,7 +263,7 @@ bool INTERP_KERNEL::InterpolationOptions::setInterpolationOptions(long print_lev double bounding_box_adjustment, double bounding_box_adjustment_abs, double max_distance_for_3Dsurf_intersect, - long orientation, + int orientation, bool measure_abs, std::string splitting_policy) { diff --git a/src/INTERP_KERNEL/InterpolationOptions.hxx b/src/INTERP_KERNEL/InterpolationOptions.hxx index d06c50964..f4fd8984d 100644 --- a/src/INTERP_KERNEL/InterpolationOptions.hxx +++ b/src/INTERP_KERNEL/InterpolationOptions.hxx @@ -98,7 +98,7 @@ namespace INTERP_KERNEL void init(); - bool setInterpolationOptions(long print_level, + bool setInterpolationOptions(int print_level, std::string intersection_type, double precision, double median_plane, @@ -106,7 +106,7 @@ namespace INTERP_KERNEL double bounding_box_adjustment, double bounding_box_adjustment_abs, double max_distance_for_3Dsurf_intersect, - long orientation, + int orientation, bool measure_abs, std::string splitting_policy); void copyOptions(const InterpolationOptions & other) { *this = other; } diff --git a/src/INTERP_KERNEL/SplitterTetra.cxx b/src/INTERP_KERNEL/SplitterTetra.cxx index 0d109f48d..c906545d3 100644 --- a/src/INTERP_KERNEL/SplitterTetra.cxx +++ b/src/INTERP_KERNEL/SplitterTetra.cxx @@ -187,27 +187,29 @@ namespace INTERP_KERNEL case NORM_POLYHED: { mcIdType nbOfFaces(ToIdType(std::count(nodalConnBg,nodalConnEnd,-1)+1)); - std::size_t nbOfTetra(std::distance(nodalConnBg,nodalConnEnd)-nbOfFaces+1); + mcIdType nbOfTetra(ToIdType(std::distance(nodalConnBg,nodalConnEnd)-nbOfFaces+1)); addCoords.resize((nbOfFaces+1)*3); tetrasNodalConn.resize(nbOfTetra*4); mcIdType *conn(&tetrasNodalConn[0]); const mcIdType *work(nodalConnBg); double *tmp(&addCoords[0]),*tmp2(&addCoords[3*nbOfFaces]); tmp2[0]=0.; tmp2[1]=0.; tmp2[2]=0.; - for(mcIdType i=0;i= 5 @@ -485,7 +485,7 @@ namespace INTERP_KERNEL const long double delta = MULT_PREC_F * (std::fabs(p_term) + std::fabs(q_term) + std::fabs(r_term)); #endif - if( epsilonEqual( p_term + q_term + r_term, 0.0, THRESHOLD_F * delta) ) + if( epsilonEqual( p_term + q_term + r_term, 0.0, (double)(THRESHOLD_F * delta)) ) { LOG(4, "Reset imprecise triple product for corner " << corner << " to zero" ); return 0.0; diff --git a/src/MEDCoupling/MEDCouplingField.cxx b/src/MEDCoupling/MEDCouplingField.cxx index 07d5c3562..167b4284f 100644 --- a/src/MEDCoupling/MEDCouplingField.cxx +++ b/src/MEDCoupling/MEDCouplingField.cxx @@ -428,7 +428,7 @@ mcIdType MEDCouplingField::getNbOfGaussLocalization() const * \throw If the spatial discretization of \a this field is NULL. * \throw If no Gauss localization object found for the given cell. */ -mcIdType MEDCouplingField::getGaussLocalizationIdOfOneCell(int cellId) const +mcIdType MEDCouplingField::getGaussLocalizationIdOfOneCell(mcIdType cellId) const { if(!((const MEDCouplingFieldDiscretization *)_type)) throw INTERP_KERNEL::Exception("Spatial discretization not set ! Impossible to call getGaussLocalizationIdOfOneCell method !"); diff --git a/src/MEDCoupling/MEDCouplingField.hxx b/src/MEDCoupling/MEDCouplingField.hxx index 54d8252c0..c472db057 100644 --- a/src/MEDCoupling/MEDCouplingField.hxx +++ b/src/MEDCoupling/MEDCouplingField.hxx @@ -79,7 +79,7 @@ namespace MEDCoupling MEDCOUPLING_EXPORT mcIdType getGaussLocalizationIdOfOneType(INTERP_KERNEL::NormalizedCellType type) const; MEDCOUPLING_EXPORT std::set getGaussLocalizationIdsOfOneType(INTERP_KERNEL::NormalizedCellType type) const; MEDCOUPLING_EXPORT mcIdType getNbOfGaussLocalization() const; - MEDCOUPLING_EXPORT mcIdType getGaussLocalizationIdOfOneCell(int cellId) const; + MEDCOUPLING_EXPORT mcIdType getGaussLocalizationIdOfOneCell(mcIdType cellId) const; MEDCOUPLING_EXPORT void getCellIdsHavingGaussLocalization(int locId, std::vector& cellIds) const; MEDCOUPLING_EXPORT const MEDCouplingGaussLocalization& getGaussLocalization(int locId) const; MEDCOUPLING_EXPORT void updateTime() const; diff --git a/src/MEDCoupling/MEDCouplingFieldDouble.cxx b/src/MEDCoupling/MEDCouplingFieldDouble.cxx index e2113c3e3..b65b77a3b 100755 --- a/src/MEDCoupling/MEDCouplingFieldDouble.cxx +++ b/src/MEDCoupling/MEDCouplingFieldDouble.cxx @@ -945,7 +945,7 @@ void MEDCouplingFieldDouble::integral(bool isWAbs, double *res) const * \ref py_mcfielddouble_getValueOnPos "Here is a Python example". * \endif */ -void MEDCouplingFieldDouble::getValueOnPos(int i, int j, int k, double *res) const +void MEDCouplingFieldDouble::getValueOnPos(mcIdType i, mcIdType j, mcIdType k, double *res) const { const DataArrayDouble *arr=timeDiscr()->getArray(); if(!_mesh) @@ -997,7 +997,7 @@ void MEDCouplingFieldDouble::getValueOn(const double *spaceLoc, double *res) con * \ref py_mcfielddouble_getValueOnMulti "Here is a Python example". * \endif */ -DataArrayDouble *MEDCouplingFieldDouble::getValueOnMulti(const double *spaceLoc, int nbOfPoints) const +DataArrayDouble *MEDCouplingFieldDouble::getValueOnMulti(const double *spaceLoc, mcIdType nbOfPoints) const { const DataArrayDouble *arr=timeDiscr()->getArray(); if(!_mesh) diff --git a/src/MEDCoupling/MEDCouplingFieldDouble.hxx b/src/MEDCoupling/MEDCouplingFieldDouble.hxx index 91ced90cb..ee88df0b4 100644 --- a/src/MEDCoupling/MEDCouplingFieldDouble.hxx +++ b/src/MEDCoupling/MEDCouplingFieldDouble.hxx @@ -70,10 +70,10 @@ namespace MEDCoupling MEDCOUPLING_EXPORT void normMax(double *res) const; MEDCOUPLING_EXPORT double integral(int compId, bool isWAbs) const; MEDCOUPLING_EXPORT void integral(bool isWAbs, double *res) const; - MEDCOUPLING_EXPORT void getValueOnPos(int i, int j, int k, double *res) const; + MEDCOUPLING_EXPORT void getValueOnPos(mcIdType i, mcIdType j, mcIdType k, double *res) const; MEDCOUPLING_EXPORT void getValueOn(const double *spaceLoc, double *res) const; MEDCOUPLING_EXPORT void getValueOn(const double *spaceLoc, double time, double *res) const; - MEDCOUPLING_EXPORT DataArrayDouble *getValueOnMulti(const double *spaceLoc, int nbOfPoints) const; + MEDCOUPLING_EXPORT DataArrayDouble *getValueOnMulti(const double *spaceLoc, mcIdType nbOfPoints) const; MEDCOUPLING_EXPORT void applyLin(double a, double b, int compoId); MEDCOUPLING_EXPORT void applyLin(double a, double b); MEDCOUPLING_EXPORT MEDCouplingFieldDouble &operator=(double value); diff --git a/src/MEDCoupling/MEDCouplingMemArray.hxx b/src/MEDCoupling/MEDCouplingMemArray.hxx index 28d3ddec4..549f3ca9b 100755 --- a/src/MEDCoupling/MEDCouplingMemArray.hxx +++ b/src/MEDCoupling/MEDCouplingMemArray.hxx @@ -323,7 +323,7 @@ namespace MEDCoupling { public: MEDCOUPLING_EXPORT MCAuto convertToDblArr() const; - MEDCOUPLING_EXPORT MCAuto convertToIntArr() const; + MEDCOUPLING_EXPORT MCAuto convertToIntArr() const; MEDCOUPLING_EXPORT MCAuto convertToFloatArr() const; MEDCOUPLING_EXPORT void applyLin(T a, T b, std::size_t compoId); MEDCOUPLING_EXPORT void applyLin(T a, T b); @@ -761,7 +761,7 @@ namespace MEDCoupling MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const DataArrayChar& other) const; MEDCOUPLING_EXPORT std::string repr() const; MEDCOUPLING_EXPORT std::string reprZip() const; - MEDCOUPLING_EXPORT DataArrayIdType *convertToIntArr() const; + MEDCOUPLING_EXPORT DataArrayInt *convertToIntArr() const; MEDCOUPLING_EXPORT DataArrayChar *selectByTupleId(const mcIdType *new2OldBg, const mcIdType *new2OldEnd) const { return this->mySelectByTupleId(new2OldBg,new2OldEnd); } MEDCOUPLING_EXPORT DataArrayChar *selectByTupleId(const DataArrayIdType& di) const { return this->mySelectByTupleId(di); } MEDCOUPLING_EXPORT DataArrayChar *selectByTupleIdSafe(const mcIdType *new2OldBg, const mcIdType *new2OldEnd) const { return DataArrayTemplate::mySelectByTupleIdSafe(new2OldBg,new2OldEnd); } diff --git a/src/MEDCoupling/MEDCouplingMemArray.txx b/src/MEDCoupling/MEDCouplingMemArray.txx index 68980ddac..e054290ad 100755 --- a/src/MEDCoupling/MEDCouplingMemArray.txx +++ b/src/MEDCoupling/MEDCouplingMemArray.txx @@ -2575,9 +2575,9 @@ namespace MEDCoupling * \return DataArrayInt * - the new instance of DataArrayInt. */ template - MCAuto DataArrayTemplateClassic::convertToIntArr() const + MCAuto DataArrayTemplateClassic::convertToIntArr() const { - return convertToOtherTypeOfArr(); + return convertToOtherTypeOfArr(); } /*! diff --git a/src/MEDCoupling/MEDCouplingMemArrayChar.cxx b/src/MEDCoupling/MEDCouplingMemArrayChar.cxx index 1c083670d..965794bf8 100755 --- a/src/MEDCoupling/MEDCouplingMemArrayChar.cxx +++ b/src/MEDCoupling/MEDCouplingMemArrayChar.cxx @@ -117,14 +117,14 @@ std::string DataArrayChar::reprZip() const * array to the new one. * \return DataArrayIdType * - the new instance of DataArrayChar. */ -DataArrayIdType *DataArrayChar::convertToIntArr() const +DataArrayInt *DataArrayChar::convertToIntArr() const { checkAllocated(); - DataArrayIdType *ret=DataArrayIdType::New(); + DataArrayInt *ret=DataArrayInt::New(); ret->alloc(getNumberOfTuples(),getNumberOfComponents()); std::size_t nbOfVals=getNbOfElems(); const char *src=getConstPointer(); - mcIdType *dest=ret->getPointer(); + int *dest=ret->getPointer(); std::copy(src,src+nbOfVals,dest); ret->copyStringInfoFrom(*this); return ret; diff --git a/src/MEDCoupling/MEDCouplingTraits.hxx b/src/MEDCoupling/MEDCouplingTraits.hxx index d0d8f7446..9d10b48fa 100644 --- a/src/MEDCoupling/MEDCouplingTraits.hxx +++ b/src/MEDCoupling/MEDCouplingTraits.hxx @@ -46,8 +46,10 @@ namespace MEDCoupling class DataArrayInt64Tuple; class DataArrayFloatTuple; class DataArrayDoubleTuple; + class DataArrayByteTuple; class DataArrayInt32Iterator; class DataArrayInt64Iterator; + class DataArrayByteIterator; template<> struct MEDCOUPLING_EXPORT Traits @@ -111,6 +113,8 @@ namespace MEDCoupling static const char ArrayTypeName[]; typedef DataArrayByte ArrayTypeCh; typedef DataArrayChar ArrayType; + typedef DataArrayByteTuple ArrayTuple; + typedef DataArrayByteIterator IteratorType; }; } diff --git a/src/MEDCoupling/MEDCouplingUMesh.cxx b/src/MEDCoupling/MEDCouplingUMesh.cxx index 603f7c5f7..05eaf2661 100755 --- a/src/MEDCoupling/MEDCouplingUMesh.cxx +++ b/src/MEDCoupling/MEDCouplingUMesh.cxx @@ -7564,11 +7564,12 @@ void MEDCouplingUMesh::writeVTKLL(std::ostream& ofs, const std::string& cellData } types->transformWithIndArr(MEDCOUPLING2VTKTYPETRADUCER,MEDCOUPLING2VTKTYPETRADUCER+INTERP_KERNEL::NORM_MAXTYPE+1); types->writeVTK(ofs,8,"UInt8","types",byteData); - offsets->writeVTK(ofs,8,"Int32","offsets",byteData); + std::string vtkTypeName = Traits::VTKReprStr; + offsets->writeVTK(ofs,8,vtkTypeName,"offsets",byteData); if(szFaceOffsets!=0) {//presence of Polyhedra connectivity->reAlloc(szConn); - faceoffsets->writeVTK(ofs,8,"Int32","faceoffsets",byteData); + faceoffsets->writeVTK(ofs,8,vtkTypeName,"faceoffsets",byteData); MCAuto faces=DataArrayIdType::New(); faces->alloc(szFaceOffsets,1); w1=faces->getPointer(); for(mcIdType i=0;iwriteVTK(ofs,8,"Int32","faces",byteData); + faces->writeVTK(ofs,8,vtkTypeName,"faces",byteData); } - connectivity->writeVTK(ofs,8,"Int32","connectivity",byteData); + connectivity->writeVTK(ofs,8,vtkTypeName,"connectivity",byteData); ofs << " \n"; ofs << " \n"; ofs << " \n"; diff --git a/src/MEDCoupling/Test/MEDCouplingBasicsTest1.cxx b/src/MEDCoupling/Test/MEDCouplingBasicsTest1.cxx index 2473089de..417e6bbab 100644 --- a/src/MEDCoupling/Test/MEDCouplingBasicsTest1.cxx +++ b/src/MEDCoupling/Test/MEDCouplingBasicsTest1.cxx @@ -72,7 +72,7 @@ void MEDCouplingBasicsTest1::testArray2() arr->setInfoOnComponent(1,"hhhh"); arr->setInfoOnComponent(2,"jj"); arr->setInfoOnComponent(3,"kkkkkk"); - MCAuto arr2(arr->convertToIntArr()); + MCAuto arr2(arr->convertToIntArr()); MCAuto arr3(arr2->convertToDblArr()); CPPUNIT_ASSERT(arr->isEqual(*arr3,1e-14)); arr->decrRef(); diff --git a/src/MEDCoupling/Test/MEDCouplingBasicsTest3.cxx b/src/MEDCoupling/Test/MEDCouplingBasicsTest3.cxx index 3841f4fd7..52200697a 100644 --- a/src/MEDCoupling/Test/MEDCouplingBasicsTest3.cxx +++ b/src/MEDCoupling/Test/MEDCouplingBasicsTest3.cxx @@ -24,6 +24,7 @@ #include "MEDCouplingMappedExtrudedMesh.hxx" #include "MEDCouplingFieldDouble.hxx" #include "MEDCouplingMemArray.hxx" +#include "MEDCouplingMemArray.txx" #include "MEDCouplingGaussLocalization.hxx" #include @@ -681,8 +682,8 @@ void MEDCouplingBasicsTest3::testKeepSetSelectedComponent1() const double expected1[30]={2.,3.,2.,3.,1.,1., 12.,13.,12.,13.,11.,11., 22.,23.,22.,23.,21.,21., 32.,33.,32.,33.,31.,31., 42.,43.,42.,43.,41.,41.}; for(int i=0;i<30;i++) CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],a2->getIJ(0,i),1e-14); - MCAuto a3(a1->convertToIntArr()); - DataArrayIdType *a4=static_cast(a3->keepSelectedComponents(arr2V)); + MCAuto a3(a1->convertToIntArr()); + DataArrayInt *a4=static_cast(a3->keepSelectedComponents(arr2V)); CPPUNIT_ASSERT_EQUAL(6,(int)a4->getNumberOfComponents()); CPPUNIT_ASSERT_EQUAL(5,(int)a4->getNumberOfTuples()); CPPUNIT_ASSERT(std::string(a4->getInfoOnComponent(0))=="bbbb"); @@ -692,7 +693,7 @@ void MEDCouplingBasicsTest3::testKeepSetSelectedComponent1() CPPUNIT_ASSERT(std::string(a4->getInfoOnComponent(4))=="aaaa"); CPPUNIT_ASSERT(std::string(a4->getInfoOnComponent(5))=="aaaa"); for(int i=0;i<30;i++) - CPPUNIT_ASSERT_EQUAL(ToIdType(expected1[i]),a4->getIJ(0,i)); + CPPUNIT_ASSERT_EQUAL((int)expected1[i],a4->getIJ(0,i)); // setSelectedComponents const mcIdType arr3[2]={3,2}; std::vector arr3V(arr3,arr3+2); @@ -713,7 +714,7 @@ void MEDCouplingBasicsTest3::testKeepSetSelectedComponent1() const double expected2[30]={2.,4.,3.,3.,1.,1., 12.,14.,13.,13.,11.,11., 22.,24.,23.,23.,21.,21., 32.,34.,33.,33.,31.,31., 42.,44.,43.,43.,41.,41.}; for(int i=0;i<30;i++) CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2[i],a2->getIJ(0,i),1e-14); - MCAuto a6=a5->convertToIntArr(); + MCAuto a6=a5->convertToIntArr(); a6->setInfoOnComponent(0,"eeee"); a6->setInfoOnComponent(1,"ffff"); a4->setSelectedComponents(a6,arr4V); @@ -1665,8 +1666,8 @@ void MEDCouplingBasicsTest3::testDAMeld1() for(int i=0;i<35;i++) CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],da1->getIJ(0,i),1e-10); // - MCAuto dai1=da1C->convertToIntArr(); - MCAuto dai3=da3->convertToIntArr(); + MCAuto dai1=da1C->convertToIntArr(); + MCAuto dai3=da3->convertToIntArr(); dai1->meldWith(dai3); CPPUNIT_ASSERT_EQUAL(5,(int)dai1->getNumberOfComponents()); CPPUNIT_ASSERT_EQUAL(7,(int)dai1->getNumberOfTuples()); @@ -1676,7 +1677,7 @@ void MEDCouplingBasicsTest3::testDAMeld1() CPPUNIT_ASSERT(dai1->getInfoOnComponent(3)=="c1da3"); CPPUNIT_ASSERT(dai1->getInfoOnComponent(4)=="c2da3"); for(int i=0;i<35;i++) - CPPUNIT_ASSERT_EQUAL(ToIdType(expected1[i]),dai1->getIJ(0,i)); + CPPUNIT_ASSERT_EQUAL((int)expected1[i],dai1->getIJ(0,i)); // test of static method DataArrayDouble::meld DataArrayDouble *da4=DataArrayDouble::Meld(da1C,da3); CPPUNIT_ASSERT_EQUAL(5,(int)da4->getNumberOfComponents()); @@ -1690,7 +1691,7 @@ void MEDCouplingBasicsTest3::testDAMeld1() CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],da4->getIJ(0,i),1e-10); // test of static method DataArrayIdType::meld dai1=da1C->convertToIntArr(); - DataArrayIdType *dai4=DataArrayIdType::Meld(dai1,dai3); + DataArrayInt *dai4=DataArrayInt::Meld(dai1,dai3); CPPUNIT_ASSERT_EQUAL(5,(int)dai4->getNumberOfComponents()); CPPUNIT_ASSERT_EQUAL(7,(int)dai4->getNumberOfTuples()); CPPUNIT_ASSERT(dai4->getInfoOnComponent(0)=="c0da1"); diff --git a/src/MEDCoupling/Test/MEDCouplingBasicsTest4.cxx b/src/MEDCoupling/Test/MEDCouplingBasicsTest4.cxx index 126a949e8..7eb6e1364 100644 --- a/src/MEDCoupling/Test/MEDCouplingBasicsTest4.cxx +++ b/src/MEDCoupling/Test/MEDCouplingBasicsTest4.cxx @@ -998,8 +998,8 @@ void MEDCouplingBasicsTest4::testDACpyFrom1() d1->deepCopyFrom(*d); CPPUNIT_ASSERT(d->isEqual(*d1,1e-12)); // - MCAuto d2=d->convertToIntArr(); - DataArrayIdType *d4=DataArrayIdType::New(); + MCAuto d2=d->convertToIntArr(); + DataArrayInt *d4=DataArrayInt::New(); CPPUNIT_ASSERT(!d2->isEqual(*d4)); d4->deepCopyFrom(*d2); CPPUNIT_ASSERT(d2->isEqual(*d4)); diff --git a/src/MEDCoupling/Test/MEDCouplingBasicsTest5.cxx b/src/MEDCoupling/Test/MEDCouplingBasicsTest5.cxx index 935a25517..41a7cb634 100644 --- a/src/MEDCoupling/Test/MEDCouplingBasicsTest5.cxx +++ b/src/MEDCoupling/Test/MEDCouplingBasicsTest5.cxx @@ -24,6 +24,7 @@ #include "MEDCouplingMappedExtrudedMesh.hxx" #include "MEDCouplingFieldDouble.hxx" #include "MEDCouplingMemArray.hxx" +#include "MEDCouplingMemArray.txx" #include "MEDCouplingGaussLocalization.hxx" #include "MEDCouplingMultiFields.hxx" #include "MEDCouplingFieldOverTime.hxx" @@ -601,7 +602,7 @@ void MEDCouplingBasicsTest5::testDataArrayAbs1() const double expected1[12]={2.,3.,5.,6.,7.,8.,9.,10.,11.,12.,13.,15.}; d1->alloc(6,2); std::copy(val1,val1+12,d1->getPointer()); - MCAuto d2=d1->convertToIntArr(); + MCAuto d2=d1->convertToIntArr(); // d1->abs(); for(int i=0;i<12;i++) @@ -610,7 +611,7 @@ void MEDCouplingBasicsTest5::testDataArrayAbs1() const mcIdType expected2[12]={2,3,5,6,7,8,9,10,11,12,13,15}; d2->abs(); for(int i=0;i<12;i++) - CPPUNIT_ASSERT_EQUAL(expected2[i],d2->getIJ(0,i)); + CPPUNIT_ASSERT_EQUAL((int)expected2[i],d2->getIJ(0,i)); // d1->decrRef(); } diff --git a/src/MEDCoupling/Test/MEDCouplingExamplesTest.cxx b/src/MEDCoupling/Test/MEDCouplingExamplesTest.cxx index 2549484ce..7e305f219 100644 --- a/src/MEDCoupling/Test/MEDCouplingExamplesTest.cxx +++ b/src/MEDCoupling/Test/MEDCouplingExamplesTest.cxx @@ -1697,7 +1697,7 @@ void CppExample_MEDCouplingUMesh_checkDeepEquivalWith() } //! [CppSnippet_MEDCouplingUMesh_checkDeepEquivalWith_1] //! [CppSnippet_MEDCouplingUMesh_checkDeepEquivalWith_2] - mcIdType cellCompPol = 1; // "permuted same orientation" - policy of medium severity + int cellCompPol = 1; // "permuted same orientation" - policy of medium severity DataArrayIdType *nOld2New, *cOld2New; mesh1->checkDeepEquivalWith( mesh2, cellCompPol, 0.002, cOld2New, nOld2New ); const mcIdType nOld2NewExpected[4] = { 3, 0, 1, 2 }; diff --git a/src/MEDCoupling_Swig/CMakeLists.txt b/src/MEDCoupling_Swig/CMakeLists.txt index 81ca4a501..a79ae5bc0 100644 --- a/src/MEDCoupling_Swig/CMakeLists.txt +++ b/src/MEDCoupling_Swig/CMakeLists.txt @@ -23,6 +23,10 @@ INCLUDE(${SWIG_USE_FILE}) ADD_DEFINITIONS(${PYTHON_DEFINITIONS} ${NUMPY_DEFINITIONS} ${SCIPY_DEFINITIONS}) +IF (NOT DEFINED MSVC) + ADD_DEFINITIONS(-Wsign-compare -Wconversion) +ENDIF() + SET_SOURCE_FILES_PROPERTIES(MEDCoupling.i PROPERTIES CPLUSPLUS ON) IF ("${PYTHON_VERSION_MAJOR}" STREQUAL "3") SET_SOURCE_FILES_PROPERTIES(MEDCoupling.i PROPERTIES SWIG_FLAGS "-py3") diff --git a/src/MEDCoupling_Swig/DataArrayInt.i b/src/MEDCoupling_Swig/DataArrayInt.i index f24a21d11..6017f1559 100644 --- a/src/MEDCoupling_Swig/DataArrayInt.i +++ b/src/MEDCoupling_Swig/DataArrayInt.i @@ -58,33 +58,33 @@ std::string repr() const; std::string reprZip() const; std::string reprNotTooLong() const; - ARRAY *invertArrayO2N2N2O(INT newNbOfElem) const; - ARRAY *invertArrayN2O2O2N(INT oldNbOfElem) const; - ARRAY *invertArrayO2N2N2OBis(INT newNbOfElem) const; + ARRAY *invertArrayO2N2N2O(mcIdType newNbOfElem) const; + ARRAY *invertArrayN2O2O2N(mcIdType oldNbOfElem) const; + ARRAY *invertArrayO2N2N2OBis(mcIdType newNbOfElem) const; DataArrayIdType *indicesOfSubPart(const ARRAY& partOfThis) const; ARRAY *fromNoInterlace() const; ARRAY *toNoInterlace() const; - ARRAY *selectByTupleIdSafeSlice(INT bg, INT end, INT step) const; + ARRAY *selectByTupleIdSafeSlice(mcIdType bg, mcIdType end, mcIdType step) const; DataArrayIdType *checkAndPreparePermutation() const; DataArrayIdType *buildPermArrPerLevel() const; - bool isIota(INT sizeExpected) const; + bool isIota(mcIdType sizeExpected) const; bool isUniform(INT val) const; INT checkUniformAndGuess() const; bool hasUniqueValues() const; - ARRAY *subArray(INT tupleIdBg, INT tupleIdEnd=-1) const; + ARRAY *subArray(mcIdType tupleIdBg, mcIdType tupleIdEnd=-1) const; void transpose(); ARRAY *changeNbOfComponents(std::size_t newNbOfComp, INT dftValue) const; void meldWith(const ARRAY *other); - void setPartOfValues1(const ARRAY *a, INT bgTuples, INT endTuples, INT stepTuples, INT bgComp, INT endComp, INT stepComp, bool strictCompoCompare=true); - void setPartOfValuesSimple1(INT a, INT bgTuples, INT endTuples, INT stepTuples, INT bgComp, INT endComp, INT stepComp); + void setPartOfValues1(const ARRAY *a, mcIdType bgTuples, mcIdType endTuples, mcIdType stepTuples, mcIdType bgComp, mcIdType endComp, mcIdType stepComp, bool strictCompoCompare=true); + void setPartOfValuesSimple1(INT a, mcIdType bgTuples, mcIdType endTuples, mcIdType stepTuples, mcIdType bgComp, mcIdType endComp, mcIdType stepComp); void setPartOfValuesAdv(const ARRAY *a, const DataArrayIdType *tuplesSelec); - void getTuple(INT tupleId, INT *res) const; + void getTuple(mcIdType tupleId, INT *res) const; INT getIJ(std::size_t tupleId, std::size_t compoId) const; - INT getIJSafe(INT tupleId, INT compoId) const; + INT getIJSafe(std::size_t tupleId, std::size_t compoId) const; INT front() const; INT back() const; - void setIJ(INT tupleId, INT compoId, INT newVal); - void setIJSilent(INT tupleId, INT compoId, INT newVal); + void setIJ(mcIdType tupleId, mcIdType compoId, INT newVal); + void setIJSilent(mcIdType tupleId, mcIdType compoId, INT newVal); INT *getPointer(); const INT *getConstPointer() const; ARRAY ## Iterator *iterator(); @@ -140,7 +140,7 @@ DataArrayIdType *findRangeIdForEachTuple(const ARRAY *ranges) const; ARRAY *findIdInRangeForEachTuple(const ARRAY *ranges) const; void sortEachPairToMakeALinkedList(); - ARRAY *duplicateEachTupleNTimes(INT nbTimes) const; + ARRAY *duplicateEachTupleNTimes(mcIdType nbTimes) const; ARRAY *getDifferentValues() const; static ARRAY *Add(const ARRAY *a1, const ARRAY *a2); void addEqual(const ARRAY *other); @@ -185,14 +185,14 @@ { if(PyInt_Check(nbOfTuples)) { - mcIdType nbOfTuples1=PyInt_AS_LONG(nbOfTuples); + mcIdType nbOfTuples1=ToIdType(PyInt_AS_LONG(nbOfTuples)); if(nbOfTuples1<0) throw INTERP_KERNEL::Exception("ARRAY::New : should be a positive set of allocated memory !"); if(nbOfComp) { if(PyInt_Check(nbOfComp)) {//ARRAY.New([1,3,4,5],2,2) - mcIdType nbOfCompo=PyInt_AS_LONG(nbOfComp); + mcIdType nbOfCompo=ToIdType(PyInt_AS_LONG(nbOfComp)); if(nbOfCompo<0) throw INTERP_KERNEL::Exception("ARRAY::New : should be a positive number of components !"); MCAuto ret=ARRAY::New(); @@ -226,7 +226,7 @@ } else if(PyInt_Check(elt0)) { - INT nbOfTuples1=PyInt_AS_LONG(elt0); + INT nbOfTuples1=(INT)PyInt_AS_LONG(elt0); if(nbOfTuples1<0) throw INTERP_KERNEL::Exception("ARRAY::New : should be a positive set of allocated memory !"); if(nbOfTuples) @@ -235,7 +235,7 @@ { if(PyInt_Check(nbOfTuples)) {//ARRAY.New(5,2) - INT nbOfCompo=PyInt_AS_LONG(nbOfTuples); + INT nbOfCompo=(INT)PyInt_AS_LONG(nbOfTuples); if(nbOfCompo<0) throw INTERP_KERNEL::Exception("ARRAY::New : should be a positive number of components !"); MCAuto ret=ARRAY::New(); @@ -257,7 +257,7 @@ } else if(MEDCouplingHasNumPyBindings() && PyArray_Check(elt0) && nbOfTuples==NULL && nbOfComp==NULL) {//ARRAY.New(numpyArray) - return BuildNewInstance(elt0,NPY_INT32,&PyCallBackDataArrayInt_RefType,"INT32"); + return BuildNewInstance(elt0,NPYTraits::NPYObjectType,NPYTraits::NPYFunc,MEDCoupling::Traits::NPYStr); } else throw INTERP_KERNEL::Exception(msg.c_str()); @@ -274,7 +274,7 @@ return self->reprNotTooLong(); } - INT __len__() const + mcIdType __len__() const { if(self->isAllocated()) { @@ -298,7 +298,7 @@ PyObject *accumulate() const { - mcIdType sz=self->getNumberOfComponents(); + mcIdType sz=ToIdType(self->getNumberOfComponents()); INTERP_KERNEL::AutoPtr tmp=new INT[sz]; self->accumulate((INT *)tmp); return convertIntArrToPyList((const INT *)tmp,sz); @@ -348,7 +348,7 @@ GetIndicesOfSliceExplicitely(slic,&strt,&stp,&step,"ARRAY::buildExplicitArrOfSliceOnScaledArr (wrap) : the input slice is invalid !"); if(strt==std::numeric_limits::max() || stp==std::numeric_limits::max()) throw INTERP_KERNEL::Exception("ARRAY::buildExplicitArrOfSliceOnScaledArr (wrap) : the input slice contains some unknowns that can't be determined in static method ! Call DataArray::getSlice (non static) instead !"); - return self->buildExplicitArrOfSliceOnScaledArr(strt,stp,step); + return self->buildExplicitArrOfSliceOnScaledArr((INT)strt,(INT)stp,(INT)step); } PyObject *getMinMaxValues() const @@ -397,14 +397,14 @@ { if(PyInt_Check(nbOfTuples)) { - mcIdType nbOfTuples1=PyInt_AS_LONG(nbOfTuples); + mcIdType nbOfTuples1=ToIdType(PyInt_AS_LONG(nbOfTuples)); if(nbOfTuples1<0) throw INTERP_KERNEL::Exception("ARRAY::setValue : should be a positive set of allocated memory !"); if(nbOfComp && nbOfComp != Py_None) { if(PyInt_Check(nbOfComp)) {//ARRAY.setValues([1,3,4,5],2,2) - mcIdType nbOfCompo=PyInt_AS_LONG(nbOfComp); + mcIdType nbOfCompo=ToIdType(PyInt_AS_LONG(nbOfComp)); if(nbOfCompo<0) throw INTERP_KERNEL::Exception("ARRAY::setValue : should be a positive number of components !"); std::vector tmp=fillArrayWithPyListInt2(li,nbOfTuples1,nbOfCompo); @@ -455,7 +455,7 @@ PyObject *getValuesAsTuple() const { const INT *vals=self->getConstPointer(); - mcIdType nbOfComp=self->getNumberOfComponents(); + mcIdType nbOfComp=ToIdType(self->getNumberOfComponents()); mcIdType nbOfTuples=self->getNumberOfTuples(); return convertIntArrToPyListOfTuple(vals,nbOfComp,nbOfTuples); } @@ -468,9 +468,9 @@ DataArrayIdType *ret0=MEDCoupling::ARRAY::MakePartition(groups,newNb,fidsOfGroups); PyObject *ret = PyList_New(2); PyList_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTITraits::TI, SWIG_POINTER_OWN | 0 )); - mcIdType sz=fidsOfGroups.size(); + std::size_t sz=fidsOfGroups.size(); PyObject *ret1 = PyList_New(sz); - for(mcIdType i=0;igetNumberOfComponents(); + mcIdType sz=ToIdType(self->getNumberOfComponents()); INTERP_KERNEL::AutoPtr tmp=new INT[sz]; self->getTuple(tupleId,tmp); return convertIntArrToPyList((const INT*)tmp,sz); @@ -751,7 +751,7 @@ mcIdType index(PyObject *obj) const { - mcIdType nbOfCompo=self->getNumberOfComponents(); + std::size_t nbOfCompo=self->getNumberOfComponents(); switch(nbOfCompo) { case 1: @@ -775,7 +775,7 @@ bool __contains__(PyObject *obj) const { - mcIdType nbOfCompo=self->getNumberOfComponents(); + std::size_t nbOfCompo=self->getNumberOfComponents(); switch(nbOfCompo) { case 0: @@ -805,7 +805,7 @@ const char msg2[]="ARRAY::__getitem__ : Mismatch of slice values in 2nd parameter (components) !"; self->checkAllocated(); mcIdType nbOfTuples=self->getNumberOfTuples(); - mcIdType nbOfComponents=self->getNumberOfComponents(); + std::size_t nbOfComponents=self->getNumberOfComponents(); mcIdType it1; std::size_t ic1; std::vector vt1; @@ -813,7 +813,7 @@ std::pair > pt1,pc1; DataArrayIdType *dt1=0,*dc1=0; mcIdType sw; - convertObjToPossibleCpp3(obj,nbOfTuples,nbOfComponents,sw,it1,ic1,vt1,vc1,pt1,pc1,dt1,dc1); + convertObjToPossibleCpp3(obj,nbOfTuples,(int)nbOfComponents,sw,it1,ic1,vt1,vc1,pt1,pc1,dt1,dc1); MCAuto ret; switch(sw) { @@ -915,7 +915,7 @@ self->checkAllocated(); const char msg[]="Unexpected situation in __setitem__ !"; mcIdType nbOfTuples=self->getNumberOfTuples(); - mcIdType nbOfComponents=self->getNumberOfComponents(); + int nbOfComponents=(int)self->getNumberOfComponents(); mcIdType sw1,sw2; INT i1; std::vector v1; @@ -2304,18 +2304,18 @@ { const char msg2[]="ARRAY ## Tuple::__getitem__ : Mismatch of slice values in 2nd parameter (components) !"; mcIdType sw; - mcIdType singleVal; - std::vector multiVal; + INT singleVal; + std::vector multiVal; std::pair > slic; MEDCoupling::DataArrayIdType *daIntTyypp=0; const INT *pt=self->getConstPointer(); - INT nbc=self->getNumberOfCompo(); - convertIntStarOrSliceLikePyObjToCppWithNegIntInterp(obj,nbc,sw,singleVal,multiVal,slic,daIntTyypp); + INT nbc=(INT)self->getNumberOfCompo(); + convertIntStarOrSliceLikePyObjToCppWithNegIntInterp(obj,ToIdType(nbc),sw,singleVal,multiVal,slic,daIntTyypp); switch(sw) { case 1: { - if(singleVal>=nbc) + if(singleVal>=(INT)nbc) { std::ostringstream oss; oss << "Requesting for id " << singleVal << " having only " << nbc << " components !"; @@ -2339,10 +2339,10 @@ case 2: { PyObject *t=PyTuple_New(multiVal.size()); - for(INT j=0;j<(INT)multiVal.size();j++) + for(std::size_t j=0;j=nbc) + if(cid>=(INT)nbc) { std::ostringstream oss; oss << "Requesting for id #" << cid << " having only " << nbc << " components !"; @@ -2354,7 +2354,7 @@ } case 3: { - INT sz=DataArray::GetNumberOfItemGivenBES(slic.first,slic.second.first,slic.second.second,msg2); + mcIdType sz=DataArray::GetNumberOfItemGivenBES(slic.first,slic.second.first,slic.second.second,msg2); PyObject *t=PyTuple_New(sz); for(INT j=0;j multiValV; std::pair > slicV; MEDCoupling::ARRAY ## Tuple *daIntTyyppV=0; - INT nbc=self->getNumberOfCompo(); + mcIdType nbc=ToIdType(self->getNumberOfCompo()); convertObjToPossibleCpp22(value,nbc,sw1,singleValV,multiValV,slicV,daIntTyyppV); INT singleVal; std::vector multiVal; @@ -2396,7 +2396,7 @@ { case 1: { - pt[singleVal]=singleValV; + pt[singleVal]=(INT)singleValV; return self; } case 2: @@ -2407,7 +2407,7 @@ oss << "Requesting for setting id # " << singleVal << " with a list or tuple with size != 1 ! "; throw INTERP_KERNEL::Exception(oss.str().c_str()); } - pt[singleVal]=multiValV[0]; + pt[singleVal]=(INT)multiValV[0]; return self; } case 4: @@ -2433,7 +2433,7 @@ oss << "Requesting for setting id # " << *it << " having only " << nbc << " components !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); } - pt[*it]=singleValV; + pt[*it]=(INT)singleValV; } return self; } @@ -2454,7 +2454,7 @@ oss << "Requesting for setting id # " << pos << " having only " << nbc << " components !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); } - pt[multiVal[i]]=multiValV[i]; + pt[multiVal[i]]=(INT)multiValV[i]; } return self; } @@ -2476,37 +2476,37 @@ } case 3: { - INT sz=DataArray::GetNumberOfItemGivenBES(slic.first,slic.second.first,slic.second.second,msg2); + std::size_t sz=DataArray::GetNumberOfItemGivenBES(slic.first,slic.second.first,slic.second.second,msg2); switch(sw1) { case 1: { - for(INT j=0;jgetConstPointer(); - if(sz>(INT)daIntTyyppV->getNumberOfCompo()) + if(sz>daIntTyyppV->getNumberOfCompo()) { std::ostringstream oss; oss << "Mismatch length of during assignment : " << nbc << " != " << daIntTyyppV->getNumberOfCompo() << " !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); } - for(INT j=0;j; -%template(lvec) std::vector; %template(dvec) std::vector; %template(svec) std::vector; @@ -72,10 +70,14 @@ using namespace INTERP_KERNEL; //typedef std::int32_t mcIdType; typedef int mcIdType; typedef DataArrayInt32 DataArrayIdType; +%template(ivec) std::vector; +%template(i64vec) std::vector; #else //typedef std::int64_t mcIdType; typedef long int mcIdType; typedef DataArrayInt64 DataArrayIdType; +%template(ivec) std::vector; +%template(i32vec) std::vector; #endif @@ -541,7 +543,7 @@ typedef DataArrayInt64 DataArrayIdType; Py_ssize_t sz(sizeof(MEDCouplingUMesh::MEDCOUPLING2VTKTYPETRADUCER)/sizeof(decltype(MEDCouplingUMesh::MEDCOUPLING2VTKTYPETRADUCER[0]))); auto maxElt(*std::max_element(MEDCouplingUMesh::MEDCOUPLING2VTKTYPETRADUCER,MEDCouplingUMesh::MEDCOUPLING2VTKTYPETRADUCER+sz)); auto szOut(maxElt+1); - std::vector< int > retCpp(szOut,-1); + std::vector< mcIdType > retCpp(szOut,-1); mcIdType id(0); for(const mcIdType *it=MEDCouplingUMesh::MEDCOUPLING2VTKTYPETRADUCER;it!=MEDCouplingUMesh::MEDCOUPLING2VTKTYPETRADUCER+sz;it++,id++) { @@ -739,7 +741,7 @@ namespace MEDCoupling return ret2; } - int getCellContainingPoint(PyObject *p, double eps) const + mcIdType getCellContainingPoint(PyObject *p, double eps) const { double val; DataArrayDouble *a; @@ -998,9 +1000,9 @@ namespace MEDCoupling for(std::size_t j=0;jbuildNewNumberingFromCommonNodesFormat(comm,commIndex,newNbOfNodes); PyObject *res = PyList_New(2); PyList_SetItem(res,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTITraits::TI, SWIG_POINTER_OWN | 0 )); - PyList_SetItem(res,1,SWIG_From_int(newNbOfNodes)); + PyList_SetItem(res,1,PyInt_FromLong(newNbOfNodes)); return res; } @@ -1751,7 +1753,7 @@ namespace MEDCoupling PyObject *res = PyList_New(3); PyList_SetItem(res,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTITraits::TI, SWIG_POINTER_OWN | 0 )); PyList_SetItem(res,1,SWIG_From_bool(ret1)); - PyList_SetItem(res,2,SWIG_From_int(ret2)); + PyList_SetItem(res,2,PyInt_FromLong(ret2)); return res; } @@ -1763,7 +1765,7 @@ namespace MEDCoupling PyObject *res = PyList_New(3); PyList_SetItem(res,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTITraits::TI, SWIG_POINTER_OWN | 0 )); PyList_SetItem(res,1,SWIG_From_bool(ret1)); - PyList_SetItem(res,2,SWIG_From_int(ret2)); + PyList_SetItem(res,2,PyInt_FromLong(ret2)); return res; } @@ -2506,14 +2508,14 @@ namespace MEDCoupling static PyObject *FuseUMeshesOnSameCoords(PyObject *ms, int compType) { - mcIdType sz; + std::size_t sz; std::vector meshes; convertFromPyObjVectorOfObj(ms,SWIGTYPE_p_MEDCoupling__MEDCouplingUMesh,"MEDCouplingUMesh",meshes); std::vector corr; MEDCouplingUMesh *um=MEDCouplingUMesh::FuseUMeshesOnSameCoords(meshes,compType,corr); sz=corr.size(); PyObject *ret1=PyList_New(sz); - for(int i=0;i::TI, SWIG_POINTER_OWN | 0 )); PyObject *ret=PyList_New(2); PyList_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(um),SWIGTYPE_p_MEDCoupling__MEDCouplingUMesh, SWIG_POINTER_OWN | 0 )); @@ -3586,7 +3588,7 @@ namespace MEDCoupling { return MEDCouplingIMesh::New(); } - static MEDCouplingIMesh *New(const std::string& meshName, mcIdType spaceDim, PyObject *nodeStrct, PyObject *origin, PyObject *dxyz) + static MEDCouplingIMesh *New(const std::string& meshName, int spaceDim, PyObject *nodeStrct, PyObject *origin, PyObject *dxyz) { static const char msg0[]="MEDCouplingIMesh::New : error on 'origin' parameter !"; static const char msg1[]="MEDCouplingIMesh::New : error on 'dxyz' parameter !"; @@ -3605,7 +3607,7 @@ namespace MEDCoupling return MEDCouplingIMesh::New(meshName,spaceDim,nodeStrctPtr,nodeStrctPtr+sz,originPtr,originPtr+sz1,dxyzPtr,dxyzPtr+sz2); } - MEDCouplingIMesh(const std::string& meshName, mcIdType spaceDim, PyObject *nodeStrct, PyObject *origin, PyObject *dxyz) + MEDCouplingIMesh(const std::string& meshName, int spaceDim, PyObject *nodeStrct, PyObject *origin, PyObject *dxyz) { return MEDCoupling_MEDCouplingIMesh_New__SWIG_1(meshName,spaceDim,nodeStrct,origin,dxyz); } @@ -3713,10 +3715,10 @@ namespace MEDCoupling void setGaussLocalizationOnType(INTERP_KERNEL::NormalizedCellType type, const std::vector& refCoo, const std::vector& gsCoo, const std::vector& wg); void clearGaussLocalizations(); - MEDCouplingGaussLocalization& getGaussLocalization(mcIdType locId); + MEDCouplingGaussLocalization& getGaussLocalization(int locId); mcIdType getNbOfGaussLocalization() const; mcIdType getGaussLocalizationIdOfOneCell(mcIdType cellId) const; - const MEDCouplingGaussLocalization& getGaussLocalization(mcIdType locId) const; + const MEDCouplingGaussLocalization& getGaussLocalization(int locId) const; mcIdType getGaussLocalizationIdOfOneType(INTERP_KERNEL::NormalizedCellType type) const; void setDiscretization(MEDCouplingFieldDiscretization *newDisc); %extend { @@ -3814,7 +3816,7 @@ namespace MEDCoupling } } - PyObject *getCellIdsHavingGaussLocalization(mcIdType locId) const + PyObject *getCellIdsHavingGaussLocalization(int locId) const { std::vector tmp; self->getCellIdsHavingGaussLocalization(locId,tmp); @@ -4086,9 +4088,9 @@ namespace MEDCoupling for(std::vector::iterator it=arrs.begin();it!=arrs.end();it++) if(*it) (*it)->incrRef(); - int sz=arrs.size(); + std::size_t sz=arrs.size(); PyObject *ret=PyTuple_New(sz); - for(int i=0;igetNumberOfComponents(); + mcIdType sz=ToIdType(self->getNumberOfComponents()); INTERP_KERNEL::AutoPtr res=new double[sz]; self->getValueOn(spaceLoc,res); return convertDblArrToPyList(res,sz); @@ -4139,7 +4141,7 @@ namespace MEDCoupling PyObject *getValueOnPos(mcIdType i, mcIdType j, mcIdType k) const { - int sz=self->getNumberOfComponents(); + mcIdType sz=ToIdType(self->getNumberOfComponents()); INTERP_KERNEL::AutoPtr res=new double[sz]; self->getValueOnPos(i,j,k,res); return convertDblArrToPyList(res,sz); @@ -4155,7 +4157,7 @@ namespace MEDCoupling double v0; MEDCoupling::DataArrayDouble *v1(0); MEDCoupling::DataArrayDoubleTuple *v2(0); std::vector v3; const double *inp=convertObjToPossibleCpp5_Safe2(locs,sw,v0,v1,v2,v3,"wrap of MEDCouplingFieldDouble::getValueOnMulti", mesh->getSpaceDimension(),true,nbPts); - return self->getValueOnMulti(inp,nbPts); + return self->getValueOnMulti(inp,(int)nbPts); } PyObject *getValueOn(PyObject *sl, double time) const @@ -4173,7 +4175,7 @@ namespace MEDCoupling const double *spaceLoc=convertObjToPossibleCpp5_Safe(sl,sw,val,a,aa,bb,msg,1,spaceDim,true); // // - int sz=self->getNumberOfComponents(); + mcIdType sz=ToIdType(self->getNumberOfComponents()); INTERP_KERNEL::AutoPtr res=new double[sz]; self->getValueOn(spaceLoc,time,res); return convertDblArrToPyList(res,sz); @@ -4225,42 +4227,42 @@ namespace MEDCoupling } PyObject *accumulate() const { - int sz=self->getNumberOfComponents(); + mcIdType sz=ToIdType(self->getNumberOfComponents()); INTERP_KERNEL::AutoPtr tmp=new double[sz]; self->accumulate(tmp); return convertDblArrToPyList(tmp,sz); } PyObject *integral(bool isWAbs) const { - int sz=self->getNumberOfComponents(); + mcIdType sz=ToIdType(self->getNumberOfComponents()); INTERP_KERNEL::AutoPtr tmp=new double[sz]; self->integral(isWAbs,tmp); return convertDblArrToPyList(tmp,sz); } PyObject *getWeightedAverageValue(bool isWAbs=true) const { - int sz=self->getNumberOfComponents(); + mcIdType sz=ToIdType(self->getNumberOfComponents()); INTERP_KERNEL::AutoPtr tmp=new double[sz]; self->getWeightedAverageValue(tmp,isWAbs); return convertDblArrToPyList(tmp,sz); } PyObject *normL1() const { - int sz=self->getNumberOfComponents(); + mcIdType sz=ToIdType(self->getNumberOfComponents()); INTERP_KERNEL::AutoPtr tmp=new double[sz]; self->normL1(tmp); return convertDblArrToPyList(tmp,sz); } PyObject *normL2() const { - int sz=self->getNumberOfComponents(); + mcIdType sz=ToIdType(self->getNumberOfComponents()); INTERP_KERNEL::AutoPtr tmp=new double[sz]; self->normL2(tmp); return convertDblArrToPyList(tmp,sz); } PyObject *normMax() const { - int sz=self->getNumberOfComponents(); + mcIdType sz=ToIdType(self->getNumberOfComponents()); INTERP_KERNEL::AutoPtr tmp=new double[sz]; self->normMax(tmp); return convertDblArrToPyList(tmp,sz); @@ -4348,7 +4350,7 @@ namespace MEDCoupling DataArrayDoubleTuple *aa,*aa2; std::vector bb,bb2; mcIdType sw; - mcIdType spaceDim=3; + int spaceDim=3; const char msg[]="Python wrap of MEDCouplingFieldDouble::extractSlice3D : 1st parameter for origin."; const char msg2[]="Python wrap of MEDCouplingFieldDouble::extractSlice3D : 2nd parameter for vector."; const double *orig=convertObjToPossibleCpp5_Safe(origin,sw,val,a,aa,bb,msg,1,spaceDim,true); @@ -4983,9 +4985,9 @@ namespace MEDCoupling { std::vector tmp; convertFromPyObjVectorOfObj(li,SWIGTYPE_p_MEDCoupling__MEDCouplingFieldDouble,"MEDCouplingFieldDouble",tmp); - int sz=tmp.size(); + std::size_t sz=tmp.size(); std::vector fs(sz); - for(int i=0;i(tmp[i]); return MEDCouplingMultiFields::New(fs); } @@ -4993,18 +4995,18 @@ namespace MEDCoupling { std::vector tmp; convertFromPyObjVectorOfObj(li,SWIGTYPE_p_MEDCoupling__MEDCouplingFieldDouble,"MEDCouplingFieldDouble",tmp); - int sz=tmp.size(); + std::size_t sz=tmp.size(); std::vector fs(sz); - for(int i=0;i(tmp[i]); return MEDCouplingMultiFields::New(fs); } PyObject *getFields() const { std::vector fields=self->getFields(); - int sz=fields.size(); + std::size_t sz=fields.size(); PyObject *res = PyList_New(sz); - for(int i=0;i ms=self->getMeshes(); - int sz=ms.size(); + std::size_t sz=ms.size(); PyObject *res = PyList_New(sz); - for(int i=0;i refs; std::vector ms=self->getDifferentMeshes(refs); - int sz=ms.size(); + std::size_t sz=ms.size(); PyObject *res = PyList_New(sz); - for(int i=0;i ms=self->getArrays(); - int sz=ms.size(); + std::size_t sz=ms.size(); PyObject *res = PyList_New(sz); - for(int i=0;i > refs; std::vector ms=self->getDifferentArrays(refs); - int sz=ms.size(); + std::size_t sz=ms.size(); PyObject *res = PyList_New(sz); PyObject *res2 = PyList_New(sz); - for(int i=0;i tmp; convertFromPyObjVectorOfObj(li,SWIGTYPE_p_MEDCoupling__MEDCouplingFieldDouble,"MEDCouplingFieldDouble",tmp); - int sz=tmp.size(); + std::size_t sz=tmp.size(); std::vector fs(sz); - for(int i=0;i(tmp[i]); return MEDCouplingFieldOverTime::New(fs); } @@ -5390,15 +5392,15 @@ namespace MEDCoupling return self->simpleRepr(); } static MEDCouplingFieldOverTime *New(PyObject *li) - { - std::vector tmp; - convertFromPyObjVectorOfObj(li,SWIGTYPE_p_MEDCoupling__MEDCouplingFieldDouble,"MEDCouplingFieldDouble",tmp); - int sz=tmp.size(); - std::vector fs(sz); - for(int i=0;i(tmp[i]); - return MEDCouplingFieldOverTime::New(fs); - } + { + std::vector tmp; + convertFromPyObjVectorOfObj(li,SWIGTYPE_p_MEDCoupling__MEDCouplingFieldDouble,"MEDCouplingFieldDouble",tmp); + std::size_t sz=tmp.size(); + std::vector fs(sz); + for(std::size_t i=0;i(tmp[i]); + return MEDCouplingFieldOverTime::New(fs); + } } }; @@ -5538,9 +5540,9 @@ namespace MEDCoupling PyObject *getPatches() const { std::vector< const MEDCouplingCartesianAMRPatch *> ps(self->getPatches()); - mcIdType sz(ps.size()); + std::size_t sz(ps.size()); PyObject *ret = PyList_New(sz); - for(mcIdType i=0;i(ps[i])); if(elt) @@ -5587,9 +5589,9 @@ namespace MEDCoupling virtual PyObject *retrieveGridsAt(mcIdType absoluteLev) const { std::vector ps(self->retrieveGridsAt(absoluteLev)); - mcIdType sz(ps.size()); + std::size_t sz(ps.size()); PyObject *ret = PyList_New(sz); - for(mcIdType i=0;i PyCallBackDataArrayChar; -typedef struct PyCallBackDataArraySt PyCallBackDataArrayInt; +typedef struct PyCallBackDataArraySt PyCallBackDataArrayInt32; +typedef struct PyCallBackDataArraySt PyCallBackDataArrayInt64; typedef struct PyCallBackDataArraySt PyCallBackDataArrayFloat; typedef struct PyCallBackDataArraySt PyCallBackDataArrayDouble; @@ -85,9 +86,15 @@ extern "C" return (PyObject *)self; } - static PyObject *callbackmcdataarrayint___new__(PyTypeObject *type, PyObject *args, PyObject *kwargs) + static PyObject *callbackmcdataarrayint32___new__(PyTypeObject *type, PyObject *args, PyObject *kwargs) { - PyCallBackDataArrayInt *self = (PyCallBackDataArrayInt *) ( type->tp_alloc(type, 0) ); + PyCallBackDataArrayInt32 *self = (PyCallBackDataArrayInt32 *) ( type->tp_alloc(type, 0) ); + return (PyObject *)self; + } + + static PyObject *callbackmcdataarrayint64___new__(PyTypeObject *type, PyObject *args, PyObject *kwargs) + { + PyCallBackDataArrayInt64 *self = (PyCallBackDataArrayInt64 *) ( type->tp_alloc(type, 0) ); return (PyObject *)self; } @@ -124,7 +131,7 @@ extern "C" // real callback called when a numpy arr having more than one DataArray instance client on it is destroyed. // In this case, all the "weak" clients, except the first one, invoke this call back that desable the content of these "weak" clients. - static PyObject *callbackmcdataarrayint_call(PyCallBackDataArrayInt *self, PyObject *args, PyObject *kw) + static PyObject *callbackmcdataarrayint32_call(PyCallBackDataArrayInt32 *self, PyObject *args, PyObject *kw) { if(self->_pt_mc) { @@ -135,6 +142,19 @@ extern "C" return Py_None; } + // real callback called when a numpy arr having more than one DataArray instance client on it is destroyed. + // In this case, all the "weak" clients, except the first one, invoke this call back that desable the content of these "weak" clients. + static PyObject *callbackmcdataarrayint64_call(PyCallBackDataArrayInt64 *self, PyObject *args, PyObject *kw) + { + if(self->_pt_mc) + { + MEDCoupling::MemArray& mma=self->_pt_mc->accessToMemArray(); + mma.destroy(); + } + Py_XINCREF(Py_None); + return Py_None; + } + // real callback called when a numpy arr having more than one DataArray instance client on it is destroyed. // In this case, all the "weak" clients, except the first one, invoke this call back that desable the content of these "weak" clients. static PyObject *callbackmcdataarrayfloat_call(PyCallBackDataArrayFloat *self, PyObject *args, PyObject *kw) @@ -205,10 +225,10 @@ PyTypeObject PyCallBackDataArrayChar_RefType = { }; -PyTypeObject PyCallBackDataArrayInt_RefType = { +PyTypeObject PyCallBackDataArrayInt32_RefType = { PyVarObject_HEAD_INIT(&PyType_Type, 0) - "callbackmcdataarrayint", - sizeof(PyCallBackDataArrayInt), + "callbackmcdataarrayint32", + sizeof(PyCallBackDataArrayInt32), 0, callbackmcdataarray_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ @@ -220,7 +240,7 @@ PyTypeObject PyCallBackDataArrayInt_RefType = { 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash*/ - (ternaryfunc)callbackmcdataarrayint_call, /*tp_call*/ + (ternaryfunc)callbackmcdataarrayint32_call, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ @@ -243,7 +263,50 @@ PyTypeObject PyCallBackDataArrayInt_RefType = { 0, /*tp_dictoffset*/ callbackmcdataarray___init__, /*tp_init*/ PyType_GenericAlloc, /*tp_alloc*/ - callbackmcdataarrayint___new__, /*tp_new*/ + callbackmcdataarrayint32___new__, /*tp_new*/ + PyObject_GC_Del, /*tp_free*/ +}; + + +PyTypeObject PyCallBackDataArrayInt64_RefType = { + PyVarObject_HEAD_INIT(&PyType_Type, 0) + "callbackmcdataarrayint64", + sizeof(PyCallBackDataArrayInt64), + 0, + callbackmcdataarray_dealloc, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + 0, /*tp_compare*/ + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash*/ + (ternaryfunc)callbackmcdataarrayint64_call, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE, /*tp_flags*/ + 0, /*tp_doc*/ + 0, /*tp_traverse*/ + 0, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + 0, /*tp_methods*/ + 0, /*tp_members*/ + 0, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + callbackmcdataarray___init__, /*tp_init*/ + PyType_GenericAlloc, /*tp_alloc*/ + callbackmcdataarrayint64___new__, /*tp_new*/ PyObject_GC_Del, /*tp_free*/ }; @@ -352,6 +415,22 @@ struct NPYTraits static PyTypeObject *NPYFunc; static PyObject *Array_SWIGTYPE; }; + +template<> +struct NPYTraits +{ + static const int NPYObjectType=NPY_INT32; + static PyTypeObject *NPYFunc; + static PyObject *Array_SWIGTYPE; +}; + +template<> +struct NPYTraits +{ + static const int NPYObjectType=NPY_INT64; + static PyTypeObject *NPYFunc; + static PyObject *Array_SWIGTYPE; +}; #endif #endif diff --git a/src/MEDCoupling_Swig/MEDCouplingDataArrayTypemaps.i b/src/MEDCoupling_Swig/MEDCouplingDataArrayTypemaps.i index b23df939f..cc99dc9bb 100644 --- a/src/MEDCoupling_Swig/MEDCouplingDataArrayTypemaps.i +++ b/src/MEDCoupling_Swig/MEDCouplingDataArrayTypemaps.i @@ -126,11 +126,11 @@ void GetIndicesOfSliceExplicitely(PyObject *slice, Py_ssize_t *start, Py_ssize_t throw INTERP_KERNEL::Exception(msgInCaseOfFailure); } -int InterpreteNegativeInt(int val, int nbelem) +int InterpreteNegativeInt(long val, mcIdType nbelem) { if(val<0) { - int newVal(nbelem+val); + int newVal((int)(nbelem+val)); if(newVal<0) { std::ostringstream oss; oss << "interpreteNegativeInt : request for negative int=" << val << " but number of elems is equal to " << nbelem << " !"; @@ -139,7 +139,7 @@ int InterpreteNegativeInt(int val, int nbelem) return newVal; } else - return val; + return (int)val; } #ifdef WITH_NUMPY @@ -167,6 +167,9 @@ MCData *BuildNewInstance(PyObject *elt0, int npyObjectType, PyTypeObject *pytype if(PyArray_DESCR(elt0)->type_num != npyObjectType) { std::ostringstream oss; oss << "Input numpy array has not the type " << msg << "!"; +#ifdef _DEBUG_ + oss << " type_num == " << PyArray_DESCR(elt0)->type_num; +#endif throw INTERP_KERNEL::Exception(oss.str().c_str()); } npy_intp sz0=PyArray_DIM(elt0,0); @@ -323,7 +326,7 @@ int NumpyArrSetBaseObjectExt(PyArrayObject *arr, PyObject *obj) } template -PyObject *ToNumPyArrayUnderground(MCData *self, int npyObjectType, const char *MCDataStr, int nbTuples, int nbComp) +PyObject *ToNumPyArrayUnderground(MCData *self, int npyObjectType, const char *MCDataStr, mcIdType nbTuples, std::size_t nbComp) { if(!self->isAllocated()) { @@ -338,7 +341,7 @@ PyObject *ToNumPyArrayUnderground(MCData *self, int npyObjectType, const char *M } int nbDims=nbComp==1?1:2; npy_intp dim[2]; - dim[0]=(npy_intp)nbTuples; dim[1]=nbComp; + dim[0]=(npy_intp)nbTuples; dim[1]=(npy_intp)nbComp; const T *bg=self->getConstPointer(); PyObject *ret(PyArray_SimpleNewFromData(nbDims,dim,npyObjectType,const_cast(bg))); if(mem.isDeallocatorCalled()) @@ -489,9 +492,9 @@ static PyObject *convertIntArrToPyList(const T *ptr, mcIdType size) template static PyObject *convertIntArrToPyList2(const std::vector& v) { - T size=v.size(); + std::size_t size=v.size(); PyObject *ret=PyList_New(size); - for(T i=0;i& v) template static PyObject *convertIntArrToPyList3(const std::set& v) { - T size=v.size(); + std::size_t size=v.size(); PyObject *ret=PyList_New(size); typename std::set::const_iterator it=v.begin(); - for(T i=0;i fillArrayWithPyListInt2(PyObject *pyLi, mcIdType& nbOfTupl mcIdType size1=-1,size2=-1; if(PyList_Check(pyLi)) { - size1=PyList_Size(pyLi); + size1=ToIdType(PyList_Size(pyLi)); for(mcIdType i=0;i fillArrayWithPyListInt2(PyObject *pyLi, mcIdType& nbOfTupl } else if(PyTuple_Check(pyLi)) { - size1=PyTuple_Size(pyLi); + size1=ToIdType(PyTuple_Size(pyLi)); for(mcIdType i=0;i& vec) { PyObject *o=PyList_GetItem(pyLi,i); if(PyInt_Check(o)) - vec[i]=PyInt_AS_LONG(o); + vec[i]=ToIdType(PyInt_AS_LONG(o)); else return false; } @@ -1041,7 +1044,7 @@ static bool fillIntVector(PyObject *pyLi, std::vector& vec) { PyObject *o=PyTuple_GetItem(pyLi,i); if(PyInt_Check(o)) - vec[i]=PyInt_AS_LONG(o); + vec[i]=ToIdType(PyInt_AS_LONG(o)); else return false; } @@ -1092,7 +1095,7 @@ static void convertPyToVectorPairStringVecString(PyObject *pyLi, std::vector< st PyObject *o=PyList_GetItem(pyLi,i); if(PyTuple_Check(o)) { - mcIdType sz2=PyTuple_Size(o); + std::size_t sz2=PyTuple_Size(o); if(sz2!=2) throw INTERP_KERNEL::Exception(msg); std::pair > item; @@ -1111,12 +1114,12 @@ static void convertPyToVectorPairStringVecString(PyObject *pyLi, std::vector< st { Py_ssize_t sz=PyTuple_Size(pyLi); arr.resize(sz); - for(mcIdType i=0;i > item; @@ -1136,31 +1139,31 @@ static void convertPyToVectorPairStringVecString(PyObject *pyLi, std::vector< st } template -PyObject *convertDblArrToPyList(const T *ptr, mcIdType size) +PyObject *convertDblArrToPyList(const T *ptr, std::size_t size) { PyObject *ret(PyList_New(size)); - for(mcIdType i=0;i& v) { - mcIdType size(v.size()); + std::size_t size(v.size()); PyObject *ret(PyList_New(size)); - for(mcIdType i=0;i -PyObject *convertDblArrToPyListOfTuple(const T *vals, int nbOfComp, mcIdType nbOfTuples) +PyObject *convertDblArrToPyListOfTuple(const T *vals, std::size_t nbOfComp, mcIdType nbOfTuples) { PyObject *ret(PyList_New(nbOfTuples)); for(mcIdType i=0;i fillArrayWithPyListDbl2(PyObject *pyLi, mcIdType& nbOfTuples, mcIdType& nbOfComp) { std::vector ret; - mcIdType size1=-1,size2=-1; + std::size_t size1=-1; + mcIdType size2=-1; if(PyList_Check(pyLi)) { size1=PyList_Size(pyLi); - for(mcIdType i=0;i fillArrayWithPyListDbl2(PyObject *pyLi, mcIdType& nbO else if(PyTuple_Check(pyLi)) { size1=PyTuple_Size(pyLi); - for(mcIdType i=0;i fillArrayWithPyListDbl2(PyObject *pyLi, mcIdType& nbO else throw INTERP_KERNEL::Exception("fillArrayWithPyListDbl2 : Unrecognized type ! Should be a tuple or a list !"); // - checkFillArrayWithPyList(size1,size2,nbOfTuples,nbOfComp); + checkFillArrayWithPyList(ToIdType(size1),ToIdType(size2),nbOfTuples,nbOfComp); return ret; } @@ -1343,9 +1347,9 @@ static void convertFromPyObjVectorOfObj(PyObject *pyLi, swig_type_info *ty, cons void *argp=0; if(PyList_Check(pyLi)) { - mcIdType size=PyList_Size(pyLi); + std::size_t size=PyList_Size(pyLi); ret.resize(size); - for(mcIdType i=0;i::ArrayTuple ARRAYTUPLE; ARRAYTUPLE *daIntTuple=reinterpret_cast< ARRAYTUPLE * >(argp); - sw=4; sz=daIntTuple->getNumberOfCompo(); + sw=4; sz=ToIdType(daIntTuple->getNumberOfCompo()); return daIntTuple->getConstPointer(); } throw INTERP_KERNEL::Exception("5 types accepted : integer, tuple of integer, list of integer, DataArrayIdType, DataArrayIdTypeTuple"); @@ -1570,9 +1574,9 @@ void considerPyObjAsATStarLikeObject(PyObject *value, mcIdType& sw, T& iTyypp, s } if(PyTuple_Check(value)) { - mcIdType size=PyTuple_Size(value); + std::size_t size=PyTuple_Size(value); stdvecTyypp.resize(size); - for(mcIdType i=0;igetNumberOfCompo(); + nbTuples=ToIdType(e->getNumberOfCompo()); return e->getConstPointer(); } else @@ -2567,14 +2571,14 @@ static typename MEDCoupling::Traits::ArrayType *DataArrayT_New(PyObject *elt0 { if(PyInt_Check(nbOfTuples)) { - mcIdType nbOfTuples1=PyInt_AS_LONG(nbOfTuples); + mcIdType nbOfTuples1=ToIdType(PyInt_AS_LONG(nbOfTuples)); if(nbOfTuples1<0) throw INTERP_KERNEL::Exception("DataArrayDouble::New : should be a positive set of allocated memory !"); if(elt2) { if(PyInt_Check(elt2)) {//DataArrayDouble.New([1.,3.,4.,5.],2,2) - mcIdType nbOfCompo=PyInt_AS_LONG(elt2); + mcIdType nbOfCompo=ToIdType(PyInt_AS_LONG(elt2)); if(nbOfCompo<0) throw INTERP_KERNEL::Exception("DataArrayDouble::New : should be a positive number of components !"); MEDCoupling::MCAuto< typename MEDCoupling::Traits::ArrayType > ret(MEDCoupling::Traits::ArrayType::New()); @@ -2608,7 +2612,7 @@ static typename MEDCoupling::Traits::ArrayType *DataArrayT_New(PyObject *elt0 } else if(PyInt_Check(elt0)) { - mcIdType nbOfTuples1(PyInt_AS_LONG(elt0)); + mcIdType nbOfTuples1(ToIdType(PyInt_AS_LONG(elt0))); if(nbOfTuples1<0) throw INTERP_KERNEL::Exception("DataArrayDouble::New : should be a positive set of allocated memory !"); if(nbOfTuples) @@ -2617,7 +2621,7 @@ static typename MEDCoupling::Traits::ArrayType *DataArrayT_New(PyObject *elt0 { if(PyInt_Check(nbOfTuples)) {//DataArrayDouble.New(5,2) - mcIdType nbOfCompo=PyInt_AS_LONG(nbOfTuples); + mcIdType nbOfCompo=ToIdType(PyInt_AS_LONG(nbOfTuples)); if(nbOfCompo<0) throw INTERP_KERNEL::Exception("DataArrayDouble::New : should be a positive number of components !"); MEDCoupling::MCAuto< typename MEDCoupling::Traits::ArrayType > ret(MEDCoupling::Traits::ArrayType::New()); @@ -2653,7 +2657,8 @@ typename MEDCoupling::Traits::ArrayType *DataArrayT__setitem__internal(typena { self->checkAllocated(); const char msg[]="Unexpected situation in DataArrayDouble::__setitem__ !"; - mcIdType nbOfTuples(self->getNumberOfTuples()),nbOfComponents(self->getNumberOfComponents()); + mcIdType nbOfTuples(self->getNumberOfTuples()); + int nbOfComponents((int)(self->getNumberOfComponents())); mcIdType sw1,sw2; T i1; std::vector v1; @@ -3000,7 +3005,8 @@ PyObject *DataArrayT__getitem__internal(const typename MEDCoupling::Traits::A const char msg[]="Unexpected situation in DataArrayDouble::__getitem__ !"; const char msg2[]="DataArrayDouble::__getitem__ : Mismatch of slice values in 2nd parameter (components) !"; self->checkAllocated(); - mcIdType nbOfTuples(self->getNumberOfTuples()),nbOfComponents(self->getNumberOfComponents()); + mcIdType nbOfTuples(self->getNumberOfTuples()); + int nbOfComponents((int)(self->getNumberOfComponents())); mcIdType it1; std::size_t ic1; std::vector vt1; @@ -3065,7 +3071,7 @@ PyObject *DataArrayT__getitem__internal(const typename MEDCoupling::Traits::A case 13: { ret=self->selectByTupleIdSafe(&it1,&it1+1); - int nbOfComp(MEDCoupling::DataArray::GetNumberOfItemGivenBESRelative(pc1.first,pc1.second.first,pc1.second.second,msg2)); + mcIdType nbOfComp(MEDCoupling::DataArray::GetNumberOfItemGivenBESRelative(pc1.first,pc1.second.first,pc1.second.second,msg2)); std::vector v2(nbOfComp); for(mcIdType i=0;i::A case 14: { ret=self->selectByTupleIdSafe(&vt1[0],&vt1[0]+vt1.size()); - int nbOfComp(MEDCoupling::DataArray::GetNumberOfItemGivenBESRelative(pc1.first,pc1.second.first,pc1.second.second,msg2)); + mcIdType nbOfComp(MEDCoupling::DataArray::GetNumberOfItemGivenBESRelative(pc1.first,pc1.second.first,pc1.second.second,msg2)); std::vector v2(nbOfComp); for(int i=0;i::A case 15: { ret=self->selectByTupleIdSafeSlice(pt1.first,pt1.second.first,pt1.second.second); - int nbOfComp(MEDCoupling::DataArray::GetNumberOfItemGivenBESRelative(pc1.first,pc1.second.first,pc1.second.second,msg2)); + mcIdType nbOfComp(MEDCoupling::DataArray::GetNumberOfItemGivenBESRelative(pc1.first,pc1.second.first,pc1.second.second,msg2)); std::vector v2(nbOfComp); for(int i=0;i::A case 16: { ret=self->selectByTupleIdSafe(dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems()); - int nbOfComp(MEDCoupling::DataArray::GetNumberOfItemGivenBESRelative(pc1.first,pc1.second.first,pc1.second.second,msg2)); + mcIdType nbOfComp(MEDCoupling::DataArray::GetNumberOfItemGivenBESRelative(pc1.first,pc1.second.first,pc1.second.second,msg2)); std::vector v2(nbOfComp); for(int i=0;i >& mCpp) +void convertCSR_MCDataToVectMapIntDouble(const MEDCoupling::DataArrayInt32 *indptrPtr, const MEDCoupling::DataArrayInt32 *indicesPtr, const MEDCoupling::DataArrayDouble *dataPtr, std::vector >& mCpp) { auto nbOfRows(indptrPtr->getNumberOfTuples()-1); if(nbOfRows<0) @@ -3171,7 +3177,7 @@ void convertToVectMapIntDouble(PyObject *pyobj, std::vectorapplyLin(1./val,0.); + self->applyLin((T)(1./val),(T)0.); Py_XINCREF(trueSelf); return trueSelf; } @@ -3354,6 +3360,10 @@ PyObject *DataArrayT_isub__internal(PyObject *trueSelf, PyObject *obj, typename PyTypeObject *NPYTraits::NPYFunc=&PyCallBackDataArrayDouble_RefType; PyTypeObject *NPYTraits::NPYFunc=&PyCallBackDataArrayFloat_RefType; + +PyTypeObject *NPYTraits::NPYFunc=&PyCallBackDataArrayInt32_RefType; + +PyTypeObject *NPYTraits::NPYFunc=&PyCallBackDataArrayInt64_RefType; #endif template diff --git a/src/MEDCoupling_Swig/MEDCouplingFieldDiscretization.i b/src/MEDCoupling_Swig/MEDCouplingFieldDiscretization.i index 124206120..c70d046f7 100644 --- a/src/MEDCoupling_Swig/MEDCouplingFieldDiscretization.i +++ b/src/MEDCoupling_Swig/MEDCouplingFieldDiscretization.i @@ -118,7 +118,7 @@ namespace MEDCoupling { if(!arr) throw INTERP_KERNEL::Exception("wrap of MEDCouplingFieldDiscretization::normL1 : input array is null !"); - int sz(arr->getNumberOfComponents()); + std::size_t sz(arr->getNumberOfComponents()); INTERP_KERNEL::AutoPtr tmp=new double[sz]; self->normL1(mesh,arr,tmp); return convertDblArrToPyList(tmp,sz); @@ -128,7 +128,7 @@ namespace MEDCoupling { if(!arr) throw INTERP_KERNEL::Exception("wrap of MEDCouplingFieldDiscretization::normL2 : input array is null !"); - int sz(arr->getNumberOfComponents()); + std::size_t sz(arr->getNumberOfComponents()); INTERP_KERNEL::AutoPtr tmp=new double[sz]; self->normL2(mesh,arr,tmp); return convertDblArrToPyList(tmp,sz); @@ -138,7 +138,7 @@ namespace MEDCoupling { if(!arr) throw INTERP_KERNEL::Exception("wrap of MEDCouplingFieldDiscretization::integral : input array is null !"); - int sz(arr->getNumberOfComponents()); + std::size_t sz(arr->getNumberOfComponents()); INTERP_KERNEL::AutoPtr tmp=new double[sz]; self->integral(mesh,arr,isWAbs,tmp); return convertDblArrToPyList(tmp,sz); @@ -203,7 +203,7 @@ namespace MEDCoupling { if(!arr) throw INTERP_KERNEL::Exception("wrap of MEDCouplingFieldDiscretization::getValueOnPos : input array is null !"); - int sz(arr->getNumberOfComponents()); + std::size_t sz(arr->getNumberOfComponents()); INTERP_KERNEL::AutoPtr res=new double[sz]; self->getValueOnPos(arr,mesh,i,j,k,res); return convertDblArrToPyList(res,sz); @@ -353,21 +353,21 @@ namespace MEDCoupling { std::size_t sz(0); const double *ret(MEDCouplingFieldDiscretizationGaussNE::GetWeightArrayFromGeometricType(geoType,sz)); - return convertDblArrToPyList(ret,sz); + return convertDblArrToPyList(ret,ToIdType(sz)); } static PyObject *GetRefCoordsFromGeometricType(INTERP_KERNEL::NormalizedCellType geoType) { std::size_t sz(0); const double *ret(MEDCouplingFieldDiscretizationGaussNE::GetRefCoordsFromGeometricType(geoType,sz)); - return convertDblArrToPyList(ret,sz); + return convertDblArrToPyList(ret,ToIdType(sz)); } static PyObject *GetLocsFromGeometricType(INTERP_KERNEL::NormalizedCellType geoType) { std::size_t sz(0); const double *ret(MEDCouplingFieldDiscretizationGaussNE::GetLocsFromGeometricType(geoType,sz)); - return convertDblArrToPyList(ret,sz); + return convertDblArrToPyList(ret,ToIdType(sz)); } } }; diff --git a/src/MEDCoupling_Swig/MEDCouplingMemArray.i b/src/MEDCoupling_Swig/MEDCouplingMemArray.i index d999ded1a..4c988d334 100644 --- a/src/MEDCoupling_Swig/MEDCouplingMemArray.i +++ b/src/MEDCoupling_Swig/MEDCouplingMemArray.i @@ -497,7 +497,7 @@ typedef DataArrayInt64 DataArrayIdType; void checkNbOfComps(int nbOfCompo, const std::string& msg) const; void checkNbOfTuplesAndComp(const DataArray& other, const std::string& msg) const; void checkNbOfTuplesAndComp(int nbOfTuples, int nbOfCompo, const std::string& msg) const; - void checkNbOfElems(std::size_t nbOfElems, const std::string& msg) const; + void checkNbOfElems(mcIdType nbOfElems, const std::string& msg) const; static int GetNumberOfItemGivenBES(int begin, int end, int step, const std::string& msg); static int GetNumberOfItemGivenBESRelative(int begin, int end, int step, const std::string& msg); static int GetPosOfItemGivenBESRelativeNoThrow(int value, int begin, int end, int step); @@ -673,7 +673,7 @@ typedef DataArrayInt64 DataArrayIdType; Py_ssize_t strt=2,stp=2,step=2; GetIndicesOfSliceExplicitely(slic,&strt,&stp,&step,"DataArray::GetSlice (wrap) : the input slice is invalid !"); mcIdType a,b; - DataArray::GetSlice(strt,stp,step,sliceId,nbOfSlices,a,b); + DataArray::GetSlice(ToIdType(strt),ToIdType(stp),ToIdType(step),sliceId,nbOfSlices,a,b); return PySlice_New(PyInt_FromLong(a),PyInt_FromLong(b),PyInt_FromLong(step)); } @@ -684,7 +684,7 @@ typedef DataArrayInt64 DataArrayIdType; Py_ssize_t strt=2,stp=2,step=2; GetIndicesOfSlice(slic,self->getNumberOfTuples(),&strt,&stp,&step,"DataArray::getSlice (wrap) : the input slice is invalid !"); mcIdType a,b; - DataArray::GetSlice(strt,stp,step,sliceId,nbOfSlices,a,b); + DataArray::GetSlice(ToIdType(strt),ToIdType(stp),ToIdType(step),sliceId,nbOfSlices,a,b); return PySlice_New(PyInt_FromLong(a),PyInt_FromLong(b),PyInt_FromLong(step)); } @@ -694,7 +694,7 @@ typedef DataArrayInt64 DataArrayIdType; throw INTERP_KERNEL::Exception("DataArray::GetNumberOfItemGivenBES (wrap) : expecting a pyslice as second (first) parameter !"); Py_ssize_t strt=2,stp=2,step=2; GetIndicesOfSliceExplicitely(slic,&strt,&stp,&step,"DataArray::GetNumberOfItemGivenBES (wrap) : the input slice is invalid !"); - return DataArray::GetNumberOfItemGivenBES(strt,stp,step,""); + return DataArray::GetNumberOfItemGivenBES(ToIdType(strt),ToIdType(stp),ToIdType(step),""); } static mcIdType GetNumberOfItemGivenBESRelative(PyObject *slic) @@ -703,7 +703,7 @@ typedef DataArrayInt64 DataArrayIdType; throw INTERP_KERNEL::Exception("DataArray::GetNumberOfItemGivenBESRelative (wrap) : expecting a pyslice as second (first) parameter !"); Py_ssize_t strt=2,stp=2,step=2; GetIndicesOfSliceExplicitely(slic,&strt,&stp,&step,"DataArray::GetNumberOfItemGivenBESRelative (wrap) : the input slice is invalid !"); - return DataArray::GetNumberOfItemGivenBESRelative(strt,stp,step,""); + return DataArray::GetNumberOfItemGivenBESRelative(ToIdType(strt),ToIdType(stp),ToIdType(step),""); } static DataArray *Aggregate(PyObject *arrs) @@ -719,7 +719,7 @@ typedef DataArrayInt64 DataArrayIdType; throw INTERP_KERNEL::Exception("DataArray::getNumberOfItemGivenBES (wrap) : expecting a pyslice as second (first) parameter !"); Py_ssize_t strt=2,stp=2,step=2; GetIndicesOfSlice(slic,self->getNumberOfTuples(),&strt,&stp,&step,"DataArray::getNumberOfItemGivenBES (wrap) : the input slice is invalid !"); - return DataArray::GetNumberOfItemGivenBES(strt,stp,step,""); + return DataArray::GetNumberOfItemGivenBES(ToIdType(strt),ToIdType(stp),ToIdType(step),""); } mcIdType getNumberOfItemGivenBESRelative(PyObject *slic) @@ -728,7 +728,7 @@ typedef DataArrayInt64 DataArrayIdType; throw INTERP_KERNEL::Exception("DataArray::getNumberOfItemGivenBESRelative (wrap) : expecting a pyslice as second (first) parameter !"); Py_ssize_t strt=2,stp=2,step=2; GetIndicesOfSlice(slic,self->getNumberOfTuples(),&strt,&stp,&step,"DataArray::getNumberOfItemGivenBESRelative (wrap) : the input slice is invalid !"); - return DataArray::GetNumberOfItemGivenBESRelative(strt,stp,step,""); + return DataArray::GetNumberOfItemGivenBESRelative(ToIdType(strt),ToIdType(stp),ToIdType(step),""); } PyObject *__getstate__() const @@ -738,9 +738,9 @@ typedef DataArrayInt64 DataArrayIdType; const std::vector &a1(self->getInfoOnComponents()); PyTuple_SetItem(ret,0,PyString_FromString(a0.c_str())); // - mcIdType sz(a1.size()); + std::size_t sz(a1.size()); PyObject *ret1(PyList_New(sz)); - for(mcIdType i=0;ibegin()); - mcIdType nbOfComp(self->getNumberOfComponents()),nbOfTuples(self->getNumberOfTuples()); + std::size_t nbOfComp(self->getNumberOfComponents()); + mcIdType nbOfTuples(self->getNumberOfTuples()); return convertDblArrToPyListOfTuple(vals,nbOfComp,nbOfTuples); } @@ -996,7 +997,7 @@ typedef DataArrayInt64 DataArrayIdType; DataArrayIdType *findClosestTupleId(const DataArrayDouble *other) const; DataArrayIdType *computeNbOfInteractionsWith(const DataArrayDouble *otherBBoxFrmt, double eps) const; void setPartOfValues1(const DataArrayDouble *a, int bgTuples, int endTuples, int stepTuples, int bgComp, int endComp, int stepComp, bool strictCompoCompare=true); - void setPartOfValuesSimple1(double a, int bgTuples, int endTuples, int stepTuples, int bgComp, int endComp, int stepComp); + void setPartOfValuesSimple1(double a, mcIdType bgTuples, mcIdType endTuples, mcIdType stepTuples, mcIdType bgComp, mcIdType endComp, mcIdType stepComp); void setPartOfValuesAdv(const DataArrayDouble *a, const DataArrayIdType *tuplesSelec); double getIJ(int tupleId, int compoId) const; double front() const; @@ -1076,7 +1077,7 @@ typedef DataArrayInt64 DataArrayIdType; MCAuto findIdsGreaterThan(double val) const; MCAuto findIdsLowerOrEqualTo(double val) const; MCAuto findIdsLowerThan(double val) const; - MCAuto convertToIntArr() const; + MCAuto convertToIntArr() const; MCAuto selectPartDef(const PartDefinition* pd) const; MCAuto cumSum() const; MCAuto convertToFloatArr() const; @@ -1124,7 +1125,7 @@ typedef DataArrayInt64 DataArrayIdType; return self->doubleValue(); } - int __len__() const + mcIdType __len__() const { if(self->isAllocated()) { @@ -1166,14 +1167,14 @@ typedef DataArrayInt64 DataArrayIdType; { if(PyInt_Check(nbOfTuples)) { - mcIdType nbOfTuples1=PyInt_AS_LONG(nbOfTuples); + mcIdType nbOfTuples1=ToIdType(PyInt_AS_LONG(nbOfTuples)); if(nbOfTuples1<0) throw INTERP_KERNEL::Exception("DataArrayDouble::setValues : should be a positive set of allocated memory !"); if(nbOfComp && nbOfComp != Py_None) { if(PyInt_Check(nbOfComp)) {//DataArrayDouble.setValues([1.,3.,4.,5.],2,2) - mcIdType nbOfCompo=PyInt_AS_LONG(nbOfComp); + mcIdType nbOfCompo=ToIdType(PyInt_AS_LONG(nbOfComp)); if(nbOfCompo<0) throw INTERP_KERNEL::Exception("DataArrayDouble::setValues : should be a positive number of components !"); std::vector tmp=fillArrayWithPyListDbl2(li,nbOfTuples1,nbOfCompo); @@ -1231,7 +1232,8 @@ typedef DataArrayInt64 DataArrayIdType; PyObject *getValuesAsTuple() const { const double *vals(self->begin()); - mcIdType nbOfComp(self->getNumberOfComponents()),nbOfTuples(self->getNumberOfTuples()); + std::size_t nbOfComp(self->getNumberOfComponents()); + mcIdType nbOfTuples(self->getNumberOfTuples()); return convertDblArrToPyListOfTuple(vals,nbOfComp,nbOfTuples); } @@ -1451,7 +1453,7 @@ typedef DataArrayInt64 DataArrayIdType; std::size_t nbOfCompo(self->getNumberOfComponents()); INTERP_KERNEL::AutoPtr tmp(new double[2*nbOfCompo]); self->getMinMaxPerComponent(tmp); - PyObject *ret=convertDblArrToPyListOfTuple(tmp,2,nbOfCompo); + PyObject *ret=convertDblArrToPyListOfTuple(tmp,2,ToIdType(nbOfCompo)); return ret; } @@ -1460,7 +1462,7 @@ typedef DataArrayInt64 DataArrayIdType; std::size_t nbOfCompo(self->getNumberOfComponents()); INTERP_KERNEL::AutoPtr tmp(new double[nbOfCompo]); self->normMaxPerComponent(tmp); - return convertDblArrToPyList(tmp,nbOfCompo); + return convertDblArrToPyList(tmp,ToIdType(nbOfCompo)); } PyObject *accumulate() const @@ -1468,7 +1470,7 @@ typedef DataArrayInt64 DataArrayIdType; std::size_t sz=self->getNumberOfComponents(); INTERP_KERNEL::AutoPtr tmp=new double[sz]; self->accumulate(tmp); - return convertDblArrToPyList(tmp,sz); + return convertDblArrToPyList(tmp,ToIdType(sz)); } DataArrayDouble *accumulatePerChunck(PyObject *indexArr) const @@ -1496,8 +1498,9 @@ typedef DataArrayInt64 DataArrayIdType; DataArrayDoubleTuple *aa; std::vector bb; mcIdType sw; - mcIdType tupleId=-1,nbOfCompo=self->getNumberOfComponents(); - const double *pt=convertObjToPossibleCpp5_Safe(tuple,sw,val,a,aa,bb,"Python wrap of DataArrayDouble::distanceToTuple",1,nbOfCompo,true); + mcIdType tupleId=-1; + std::size_t nbOfCompo=self->getNumberOfComponents(); + const double *pt=convertObjToPossibleCpp5_Safe(tuple,sw,val,a,aa,bb,"Python wrap of DataArrayDouble::distanceToTuple",1,(int)nbOfCompo,true); // double ret0=self->distanceToTuple(pt,pt+nbOfCompo,tupleId); PyObject *ret=PyTuple_New(2); @@ -1528,7 +1531,7 @@ typedef DataArrayInt64 DataArrayIdType; std::size_t sz=self->getNumberOfComponents(); INTERP_KERNEL::AutoPtr tmp=new double[sz]; self->getTuple(tupleId,tmp); - return convertDblArrToPyList(tmp,sz); + return convertDblArrToPyList(tmp,ToIdType(sz)); } static DataArrayDouble *Aggregate(PyObject *li) @@ -1552,9 +1555,10 @@ typedef DataArrayInt64 DataArrayIdType; DataArrayDoubleTuple *aa; std::vector bb; mcIdType sw; - mcIdType nbComp=self->getNumberOfComponents(),nbTuples=-1; + std::size_t nbComp=self->getNumberOfComponents(); + mcIdType nbTuples=-1; const char msg[]="Python wrap of DataArrayDouble::computeTupleIdsNearTuples : "; - const double *pos=convertObjToPossibleCpp5_Safe2(pt,sw,val,a,aa,bb,msg,nbComp,true,nbTuples); + const double *pos=convertObjToPossibleCpp5_Safe2(pt,sw,val,a,aa,bb,msg,(int)nbComp,true,nbTuples); MCAuto inpu=DataArrayDouble::New(); inpu->useArray(pos,false,DeallocType::CPP_DEALLOC,nbTuples,nbComp); DataArrayIdType *c=0,*cI=0; self->computeTupleIdsNearTuples(inpu,eps,c,cI); @@ -2154,7 +2158,7 @@ typedef DataArrayInt64 DataArrayIdType; std::pair > slic; MEDCoupling::DataArrayIdType *daIntTyypp=0; const double *pt=self->getConstPointer(); - mcIdType nbc=self->getNumberOfCompo(); + mcIdType nbc=ToIdType(self->getNumberOfCompo()); convertIntStarOrSliceLikePyObjToCppWithNegIntInterp(obj,nbc,sw,singleVal,multiVal,slic,daIntTyypp); switch(sw) { @@ -2218,7 +2222,7 @@ typedef DataArrayInt64 DataArrayIdType; double singleValV; std::vector multiValV; MEDCoupling::DataArrayDoubleTuple *daIntTyyppV=0; - mcIdType nbc=self->getNumberOfCompo(); + mcIdType nbc=ToIdType(self->getNumberOfCompo()); convertDoubleStarLikePyObjToCpp(value,sw1,singleValV,multiValV,daIntTyyppV); mcIdType singleVal; std::vector multiVal; @@ -2384,7 +2388,7 @@ typedef DataArrayInt64 DataArrayIdType; void fillWithValue(char val); std::string repr() const; std::string reprZip() const; - DataArrayIdType *convertToIntArr() const; + DataArrayInt *convertToIntArr() const; DataArrayChar *renumber(const mcIdType *old2New) const; DataArrayChar *renumberR(const mcIdType *new2Old) const; DataArrayChar *renumberAndReduce(const mcIdType *old2NewBg, mcIdType newNbOfTuple) const; @@ -2564,14 +2568,14 @@ typedef DataArrayInt64 DataArrayIdType; { if(PyInt_Check(nbOfTuples)) { - mcIdType nbOfTuples1=PyInt_AS_LONG(nbOfTuples); + mcIdType nbOfTuples1=ToIdType(PyInt_AS_LONG(nbOfTuples)); if(nbOfTuples1<0) throw INTERP_KERNEL::Exception("DataArrayByte::New : should be a positive set of allocated memory !"); if(nbOfComp) { if(PyInt_Check(nbOfComp)) {//DataArrayByte.New([1,3,4,5],2,2) - mcIdType nbOfCompo=PyInt_AS_LONG(nbOfComp); + mcIdType nbOfCompo=ToIdType(PyInt_AS_LONG(nbOfComp)); if(nbOfCompo<0) throw INTERP_KERNEL::Exception("DataArrayByte::New : should be a positive number of components !"); MCAuto ret=DataArrayByte::New(); @@ -2605,7 +2609,7 @@ typedef DataArrayInt64 DataArrayIdType; } else if(PyInt_Check(elt0)) { - mcIdType nbOfTuples1=PyInt_AS_LONG(elt0); + mcIdType nbOfTuples1=ToIdType(PyInt_AS_LONG(elt0)); if(nbOfTuples1<0) throw INTERP_KERNEL::Exception("DataArrayByte::New : should be a positive set of allocated memory !"); if(nbOfTuples) @@ -2614,7 +2618,7 @@ typedef DataArrayInt64 DataArrayIdType; { if(PyInt_Check(nbOfTuples)) {//DataArrayByte.New(5,2) - mcIdType nbOfCompo=PyInt_AS_LONG(nbOfTuples); + mcIdType nbOfCompo=ToIdType(PyInt_AS_LONG(nbOfTuples)); if(nbOfCompo<0) throw INTERP_KERNEL::Exception("DataArrayByte::New : should be a positive number of components !"); MCAuto ret=DataArrayByte::New(); @@ -2684,9 +2688,9 @@ typedef DataArrayInt64 DataArrayIdType; PyObject *toStrList() const { const char *vals=self->getConstPointer(); - mcIdType nbOfComp=self->getNumberOfComponents(); + std::size_t nbOfComp=self->getNumberOfComponents(); mcIdType nbOfTuples=self->getNumberOfTuples(); - return convertCharArrToPyListOfTuple(vals,nbOfComp,nbOfTuples); + return convertCharArrToPyListOfTuple(vals,(int)nbOfComp,nbOfTuples); } bool presenceOfTuple(PyObject *tupl) const @@ -2741,11 +2745,11 @@ typedef DataArrayInt64 DataArrayIdType; PyObject *getTuple(mcIdType tupleId) { - mcIdType sz=self->getNumberOfComponents(); + std::size_t sz=self->getNumberOfComponents(); INTERP_KERNEL::AutoPtr tmp=new char[sz]; self->getTuple(tupleId,tmp); PyObject *ret=PyTuple_New(sz); - for(mcIdType i=0;igetNumberOfComponents(); + std::size_t nbOfCompo=self->getNumberOfComponents(); switch(nbOfCompo) { case 1: { if(PyInt_Check(obj)) { - mcIdType val=(mcIdType)PyInt_AS_LONG(obj); + char val=(char)PyInt_AS_LONG(obj); return self->findIdFirstEqual(val); } else @@ -2791,7 +2795,7 @@ typedef DataArrayInt64 DataArrayIdType; bool __contains__(PyObject *obj) const { - mcIdType nbOfCompo=self->getNumberOfComponents(); + std::size_t nbOfCompo=self->getNumberOfComponents(); switch(nbOfCompo) { case 0: @@ -2800,7 +2804,7 @@ typedef DataArrayInt64 DataArrayIdType; { if(PyInt_Check(obj)) { - mcIdType val=(mcIdType)PyInt_AS_LONG(obj); + char val=(char)PyInt_AS_LONG(obj); return self->presenceOfValue(val); } else @@ -2822,19 +2826,21 @@ typedef DataArrayInt64 DataArrayIdType; { self->checkAllocated(); const char msg[]="Unexpected situation in __setitem__ !"; - mcIdType nbOfTuples(self->getNumberOfTuples()),nbOfComponents(self->getNumberOfComponents()); + mcIdType nbOfTuples(self->getNumberOfTuples()); + int nbOfComponents((int)self->getNumberOfComponents()); mcIdType sw1,sw2; - mcIdType i1; - std::vector v1; + int int1; + std::vector v1; DataArrayIdType *d1=0; - DataArrayIdTypeTuple *dd1=0; - convertIntStarLikePyObjToCpp(value,sw1,i1,v1,d1,dd1); + DataArrayIntTuple *dd1=0; + convertIntStarLikePyObjToCpp(value,sw1,int1,v1,d1,dd1); mcIdType it1,ic1; std::vector vt1,vc1; std::pair > pt1,pc1; DataArrayIdType *dt1=0,*dc1=0; convertObjToPossibleCpp3(obj,nbOfTuples,nbOfComponents,sw2,it1,ic1,vt1,vc1,pt1,pc1,dt1,dc1); MCAuto tmp; + char i1 = (char)int1; switch(sw2) { case 1: @@ -3095,14 +3101,14 @@ typedef DataArrayInt64 DataArrayIdType; { if(PyInt_Check(nbOfTuples)) { - mcIdType nbOfTuples1=PyInt_AS_LONG(nbOfTuples); + mcIdType nbOfTuples1=ToIdType(PyInt_AS_LONG(nbOfTuples)); if(nbOfTuples1<0) throw INTERP_KERNEL::Exception("DataArrayAsciiChar::New : should be a positive set of allocated memory !"); if(nbOfComp) { if(PyInt_Check(nbOfComp)) {//DataArrayAsciiChar.New([1,3,4,5],2,2) - mcIdType nbOfCompo=PyInt_AS_LONG(nbOfComp); + mcIdType nbOfCompo=ToIdType(PyInt_AS_LONG(nbOfComp)); if(nbOfCompo<0) throw INTERP_KERNEL::Exception("DataArrayAsciiChar::New : should be a positive number of components !"); MCAuto ret=DataArrayAsciiChar::New(); @@ -3168,7 +3174,7 @@ typedef DataArrayInt64 DataArrayIdType; } else if(PyInt_Check(elt0)) { - mcIdType nbOfTuples1=PyInt_AS_LONG(elt0); + mcIdType nbOfTuples1=ToIdType(PyInt_AS_LONG(elt0)); if(nbOfTuples1<0) throw INTERP_KERNEL::Exception("DataArrayAsciiChar::New : should be a positive set of allocated memory !"); if(nbOfTuples) @@ -3177,7 +3183,7 @@ typedef DataArrayInt64 DataArrayIdType; { if(PyInt_Check(nbOfTuples)) {//DataArrayAsciiChar.New(5,2) - mcIdType nbOfCompo=PyInt_AS_LONG(nbOfTuples); + mcIdType nbOfCompo=ToIdType(PyInt_AS_LONG(nbOfTuples)); if(nbOfCompo<0) throw INTERP_KERNEL::Exception("DataArrayAsciiChar::New : should be a positive number of components !"); MCAuto ret=DataArrayAsciiChar::New(); @@ -3240,9 +3246,9 @@ typedef DataArrayInt64 DataArrayIdType; PyObject *toStrList() const { const char *vals=self->getConstPointer(); - mcIdType nbOfComp=self->getNumberOfComponents(); + std::size_t nbOfComp=self->getNumberOfComponents(); mcIdType nbOfTuples=self->getNumberOfTuples(); - return convertCharArrToPyListOfTuple(vals,nbOfComp,nbOfTuples); + return convertCharArrToPyListOfTuple(vals,(int)nbOfComp,nbOfTuples); } bool presenceOfTuple(PyObject *tupl) const @@ -3357,7 +3363,7 @@ typedef DataArrayInt64 DataArrayIdType; PyObject *getTuple(mcIdType tupleId) const { - mcIdType sz=self->getNumberOfComponents(); + std::size_t sz=self->getNumberOfComponents(); INTERP_KERNEL::AutoPtr tmp=new char[sz+1]; tmp[sz]='\0'; self->getTuple(tupleId,tmp); return PyString_FromString(tmp); @@ -3387,7 +3393,7 @@ typedef DataArrayInt64 DataArrayIdType; mcIdType index(PyObject *obj) const { - mcIdType nbOfCompo=self->getNumberOfComponents(); + std::size_t nbOfCompo=self->getNumberOfComponents(); switch(nbOfCompo) { case 1: @@ -3422,7 +3428,7 @@ typedef DataArrayInt64 DataArrayIdType; bool __contains__(PyObject *obj) const { - mcIdType nbOfCompo=self->getNumberOfComponents(); + std::size_t nbOfCompo=self->getNumberOfComponents(); switch(nbOfCompo) { case 0: @@ -3486,7 +3492,7 @@ typedef DataArrayInt64 DataArrayIdType; std::vector stdvecTyyppArr; std::pair > sTyyppArr; MEDCoupling::DataArrayIdType *daIntTyypp=0; - mcIdType nbOfCompo=self->getNumberOfComponents(); + mcIdType nbOfCompo=ToIdType(self->getNumberOfComponents()); mcIdType nbOfTuples=self->getNumberOfTuples(); convertIntStarOrSliceLikePyObjToCppWithNegIntInterp(obj,nbOfTuples,sw1,iTypppArr,stdvecTyyppArr,sTyyppArr,daIntTyypp); mcIdType sw2; diff --git a/src/MEDCoupling_Swig/MEDCouplingNumPyTest.py b/src/MEDCoupling_Swig/MEDCouplingNumPyTest.py index a76432a4a..b35f9ecdb 100644 --- a/src/MEDCoupling_Swig/MEDCouplingNumPyTest.py +++ b/src/MEDCoupling_Swig/MEDCouplingNumPyTest.py @@ -46,10 +46,10 @@ class MEDCouplingNumPyTest(unittest.TestCase): a=a.cumsum(dtype=int32) a=array(a,dtype=int64) ; a=array(a,dtype=int32) self.assertEqual(getrefcount(a),2) - d=DataArrayInt(a) + d=DataArrayInt32(a) d[:]=2 # - e=DataArrayInt(sz) ; e.fillWithValue(2) + e=DataArrayInt32(sz) ; e.fillWithValue(2) self.assertTrue(d.isEqual(e)) # a[:]=4 ; e.fillWithValue(4) @@ -66,9 +66,9 @@ class MEDCouplingNumPyTest(unittest.TestCase): self.assertEqual(getrefcount(a),3) self.assertEqual(getrefcount(b),2) b[:]=5 - d=DataArrayInt(b) + d=DataArrayInt32(b) # - e=DataArrayInt(sz*2) ; e.fillWithValue(5) + e=DataArrayInt32(sz*2) ; e.fillWithValue(5) self.assertTrue(d.isEqual(e)) pass @@ -81,16 +81,16 @@ class MEDCouplingNumPyTest(unittest.TestCase): c=a.reshape(2,sz) b[:]=6 b[7:17]=7 - d=DataArrayInt(b) - self.assertTrue(d.isEqual(DataArrayInt([6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,6,6,6]))) + d=DataArrayInt32(b) + self.assertTrue(d.isEqual(DataArrayInt32([6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,6,6,6]))) # a=zeros((10,2),dtype=int32) b=a.T c=b.view() a.shape=20 a[3:]=10. - d=DataArrayInt(a) - self.assertTrue(d.isEqual(DataArrayInt([0,0,0,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10]))) + d=DataArrayInt32(a) + self.assertTrue(d.isEqual(DataArrayInt32([0,0,0,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10]))) pass @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy") @@ -104,7 +104,7 @@ class MEDCouplingNumPyTest(unittest.TestCase): def test5(self): a=arange(20,dtype=int32) self.assertEqual(weakref.getweakrefcount(a),0) - d=DataArrayInt(a) + d=DataArrayInt32(a) self.assertEqual(weakref.getweakrefcount(a),1) self.assertTrue(not a.flags["OWNDATA"]) self.assertTrue(d.isIota(20)) @@ -116,14 +116,14 @@ class MEDCouplingNumPyTest(unittest.TestCase): gc.collect() self.assertTrue(a.flags["OWNDATA"]) a[:]=4 # a can be used has usual - self.assertTrue(DataArrayInt(a).isUniform(4)) + self.assertTrue(DataArrayInt32(a).isUniform(4)) pass @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy") def test6(self): 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 + d=DataArrayInt32(a) # d owns data of a + e=DataArrayInt32(a) # a not owned -> e only an access to chunk of a self.assertTrue(d.isIota(d.getNumberOfTuples())) self.assertTrue(e.isIota(e.getNumberOfTuples())) a[:]=6 @@ -142,9 +142,9 @@ class MEDCouplingNumPyTest(unittest.TestCase): a=array(0,dtype=int32) ; a.resize(10,2) b=a.reshape(20) c=a.reshape(2,10) - d=DataArrayInt(b) # d owns data of a - e=DataArrayInt(b) # a not owned -> e only an access to chunk of a - f=DataArrayInt(b) # a not owned -> e only an access to chunk of a + d=DataArrayInt32(b) # d owns data of a + e=DataArrayInt32(b) # a not owned -> e only an access to chunk of a + f=DataArrayInt32(b) # a not owned -> e only an access to chunk of a del d # d removed -> a ownes again data ##@@ Ensure a pass of the garbage collector so that the de-allocator of d is called import gc @@ -177,11 +177,11 @@ class MEDCouplingNumPyTest(unittest.TestCase): def test8(self): a=arange(20,dtype=int32) self.assertTrue(a.flags["OWNDATA"]) - d=DataArrayInt(a) # d owns data of a + d=DataArrayInt32(a) # d owns data of a self.assertTrue(not a.flags["OWNDATA"]) d.pushBackSilent(20)# d pushBack so release of chunk of data -> a becomes owner of its data again self.assertTrue(a.flags["OWNDATA"]) - self.assertTrue(d.isEqual(DataArrayInt([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]))) + self.assertTrue(d.isEqual(DataArrayInt32([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]))) self.assertEqual(a.tolist(),[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19]) pass @@ -394,13 +394,13 @@ class MEDCouplingNumPyTest(unittest.TestCase): a.resize(sz//2,2) a[:]=4 self.assertEqual(getrefcount(a),2) - d=DataArrayInt(a) + d=DataArrayInt32(a) self.assertEqual(10,d.getNumberOfTuples()) self.assertEqual(2,d.getNumberOfComponents()) self.assertEqual(sz,d.getNbOfElems()) - self.assertTrue(d.isEqual(DataArrayInt([(4,4),(4,4),(4,4),(4,4),(4,4),(4,4),(4,4),(4,4),(4,4),(4,4)]))) + self.assertTrue(d.isEqual(DataArrayInt32([(4,4),(4,4),(4,4),(4,4),(4,4),(4,4),(4,4),(4,4),(4,4),(4,4)]))) a[:]=7 - self.assertTrue(d.isEqual(DataArrayInt([(7,7),(7,7),(7,7),(7,7),(7,7),(7,7),(7,7),(7,7),(7,7),(7,7)]))) + self.assertTrue(d.isEqual(DataArrayInt32([(7,7),(7,7),(7,7),(7,7),(7,7),(7,7),(7,7),(7,7),(7,7),(7,7)]))) # b=a.reshape((2,5,2)) self.assertRaises(InterpKernelException,DataArrayInt.New,b) # b has not dimension in [0,1] ! @@ -430,7 +430,7 @@ class MEDCouplingNumPyTest(unittest.TestCase): #tests that only DataArray*(npArray) constructor is available a=array(0,dtype=int32) a.resize(20) - DataArrayInt(a) + DataArrayInt32(a) self.assertRaises(InterpKernelException,DataArrayInt.New,a,20) self.assertRaises(InterpKernelException,DataArrayInt.New,a,20,1) a=array(0,dtype=float64) @@ -564,9 +564,9 @@ class MEDCouplingNumPyTest(unittest.TestCase): @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy") def test25(self): a=arange(10,dtype=int32) - b=DataArrayInt(a) - c=DataArrayInt(a) - d=DataArrayInt(a) + b=DataArrayInt32(a) + c=DataArrayInt32(a) + d=DataArrayInt32(a) self.assertTrue(b.isIota(10)) self.assertTrue(c.isIota(10)) self.assertTrue(d.isIota(10)) @@ -584,8 +584,8 @@ class MEDCouplingNumPyTest(unittest.TestCase): self.assertTrue(c.isIota(11)) # a=arange(10,dtype=int32) - b=DataArrayInt(a) - c=DataArrayInt(a) + b=DataArrayInt32(a) + c=DataArrayInt32(a) self.assertTrue(b.isIota(10)) self.assertTrue(c.isIota(10)) b.pushBackSilent(10) # c and a,b are dissociated @@ -644,9 +644,9 @@ class MEDCouplingNumPyTest(unittest.TestCase): self.assertEqual(a.ndim,2) self.assertEqual(a.size,15) self.assertEqual(a.shape,(5,3)) - self.assertEqual(a.strides,(12,4)) - self.assertEqual(a.nbytes,60) - self.assertEqual(a.itemsize,4) + self.assertEqual(a.strides,(3*MEDCouplingSizeOfIDs()//8,MEDCouplingSizeOfIDs()//8)) + self.assertEqual(a.nbytes,15*MEDCouplingSizeOfIDs()//8) + self.assertEqual(a.itemsize,MEDCouplingSizeOfIDs()//8) self.assertEqual(a.tolist(),[[0,1,2],[3,4,5],[6,7,8],[9,10,11],[12,13,14]]) # d2=d.convertToDblArr() diff --git a/src/MEDCoupling_Swig/MEDCouplingPickleTest.py b/src/MEDCoupling_Swig/MEDCouplingPickleTest.py index e5f6bb732..c0c633e1a 100644 --- a/src/MEDCoupling_Swig/MEDCouplingPickleTest.py +++ b/src/MEDCoupling_Swig/MEDCouplingPickleTest.py @@ -347,7 +347,7 @@ class MEDCouplingPickleTest(unittest.TestCase): f.setName("aname") a=f.getArray() b=a[:] ; b.iota(7000) - f.setArray(DataArrayInt.Meld(a,b)) + f.setArray(DataArrayInt32.Meld(a,b)) f.getArray().setInfoOnComponents(["u1","vv2"]) f.checkConsistencyLight(); # diff --git a/src/MEDCoupling_Swig/MEDCouplingRemapperCommon.i b/src/MEDCoupling_Swig/MEDCouplingRemapperCommon.i index 6c4e27c31..4c0c0188b 100644 --- a/src/MEDCoupling_Swig/MEDCouplingRemapperCommon.i +++ b/src/MEDCoupling_Swig/MEDCouplingRemapperCommon.i @@ -97,14 +97,15 @@ namespace MEDCoupling PyObject *indptr(PyObject_GetAttrString(m,"indptr")); PyObject *indices(PyObject_GetAttrString(m,"indices")); PyObject *data(PyObject_GetAttrString(m,"data")); - MCAuto indptrPtr, indicesPtr; -#if defined(MEDCOUPLING_USE_64BIT_IDS) - indptrPtr = MEDCoupling_DataArrayInt64_New__SWIG_1(indptr,NULL,NULL); - indicesPtr = MEDCoupling_DataArrayInt64_New__SWIG_1(indices,NULL,NULL); -#else + MCAuto indptrPtr, indicesPtr; + // csr_matrix.indptr and csr_matrix.indices are always dtype==int32 +// #if defined(MEDCOUPLING_USE_64BIT_IDS) +// indptrPtr = MEDCoupling_DataArrayInt64_New__SWIG_1(indptr,NULL,NULL); +// indicesPtr = MEDCoupling_DataArrayInt64_New__SWIG_1(indices,NULL,NULL); +// #else indptrPtr = MEDCoupling_DataArrayInt32_New__SWIG_1(indptr,NULL,NULL); indicesPtr = MEDCoupling_DataArrayInt32_New__SWIG_1(indices,NULL,NULL); -#endif +//#endif MCAuto dataPtr(MEDCoupling_DataArrayDouble_New__SWIG_1(data,NULL,NULL)); convertCSR_MCDataToVectMapIntDouble(indptrPtr,indicesPtr,dataPtr,mCpp); Py_XDECREF(data); Py_XDECREF(indptr); Py_XDECREF(indices); diff --git a/src/MEDCoupling_Swig/MEDCouplingRemapperTest.py b/src/MEDCoupling_Swig/MEDCouplingRemapperTest.py index e6aedde61..58054d519 100644 --- a/src/MEDCoupling_Swig/MEDCouplingRemapperTest.py +++ b/src/MEDCoupling_Swig/MEDCouplingRemapperTest.py @@ -806,8 +806,8 @@ class MEDCouplingBasicsTest(unittest.TestCase): vals*=1e-5 eps0=DataArrayDouble(m0.data)-vals ; eps0.abs() self.assertTrue(eps0.findIdsInRange(1e-17,1e300).empty()) - self.assertTrue(DataArrayInt(m0.indices).isEqual(DataArrayInt([0,1,3,1,4,5,4,6,7,6,8,9,8,10,11,10,12,13,12,14,15,14,16,17,16,18,19,18,20,21,20,22,23,22,24,25,24,26,27,0,2,3,1,3,5,4,5,7,6,7,9,8,9,11,10,11,13,12,13,15,14,15,17,16,17,19,18,19,21,20,21,23,22,23,25,24,25,27,0,2,3,1,3,5,4,5,7,6,7,9,8,9,11,10,11,13,12,13,15,14,15,17,16,17,19,18,19,21,20,21,23,22,23,25,24,25,27,0,2,3,1,3,5,4,5,7,6,7,9,8,9,11,10,11,13,12,13,15,14,15,17,16,17,19,18,19,21,20,21,23,22,23,25,24,25,27,0,2,3,1,3,5,4,5,7,6,7,9,8,9,11,10,11,13,12,13,15,14,15,17,16,17,19,18,19,21,20,21,23,22,23,25,24,25,27,0,1,3,1,4,5,4,6,7,6,8,9,8,10,11,10,12,13,12,14,15,14,16,17,16,18,19,18,20,21,20,22,23,22,24,25,24,26,27,0,1,3,1,4,5,4,6,7,6,8,9,8,10,11,10,12,13,12,14,15,14,16,17,16,18,19,18,20,21,20,22,23,22,24,25,24,26,27,0,1,3,1,4,5,4,6,7,6,8,9,8,10,11,10,12,13,12,14,15,14,16,17,16,18,19,18,20,21,20,22,23,22,24,25,24,26,27]))) - self.assertTrue(DataArrayInt(m0.indptr).isEqual(DataArrayInt([0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57,60,63,66,69,72,75,78,81,84,87,90,93,96,99,102,105,108,111,114,117,120,123,126,129,132,135,138,141,144,147,150,153,156,159,162,165,168,171,174,177,180,183,186,189,192,195,198,201,204,207,210,213,216,219,222,225,228,231,234,237,240,243,246,249,252,255,258,261,264,267,270,273,276,279,282,285,288,291,294,297,300,303,306,309,312]))) + self.assertTrue(DataArrayInt32(m0.indices).isEqual(DataArrayInt32([0,1,3,1,4,5,4,6,7,6,8,9,8,10,11,10,12,13,12,14,15,14,16,17,16,18,19,18,20,21,20,22,23,22,24,25,24,26,27,0,2,3,1,3,5,4,5,7,6,7,9,8,9,11,10,11,13,12,13,15,14,15,17,16,17,19,18,19,21,20,21,23,22,23,25,24,25,27,0,2,3,1,3,5,4,5,7,6,7,9,8,9,11,10,11,13,12,13,15,14,15,17,16,17,19,18,19,21,20,21,23,22,23,25,24,25,27,0,2,3,1,3,5,4,5,7,6,7,9,8,9,11,10,11,13,12,13,15,14,15,17,16,17,19,18,19,21,20,21,23,22,23,25,24,25,27,0,2,3,1,3,5,4,5,7,6,7,9,8,9,11,10,11,13,12,13,15,14,15,17,16,17,19,18,19,21,20,21,23,22,23,25,24,25,27,0,1,3,1,4,5,4,6,7,6,8,9,8,10,11,10,12,13,12,14,15,14,16,17,16,18,19,18,20,21,20,22,23,22,24,25,24,26,27,0,1,3,1,4,5,4,6,7,6,8,9,8,10,11,10,12,13,12,14,15,14,16,17,16,18,19,18,20,21,20,22,23,22,24,25,24,26,27,0,1,3,1,4,5,4,6,7,6,8,9,8,10,11,10,12,13,12,14,15,14,16,17,16,18,19,18,20,21,20,22,23,22,24,25,24,26,27]))) + self.assertTrue(DataArrayInt32(m0.indptr).isEqual(DataArrayInt32([0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57,60,63,66,69,72,75,78,81,84,87,90,93,96,99,102,105,108,111,114,117,120,123,126,129,132,135,138,141,144,147,150,153,156,159,162,165,168,171,174,177,180,183,186,189,192,195,198,201,204,207,210,213,216,219,222,225,228,231,234,237,240,243,246,249,252,255,258,261,264,267,270,273,276,279,282,285,288,291,294,297,300,303,306,309,312]))) # rem2=MEDCouplingRemapper() ; rem2.setIntersectionType(Barycentric) rem2.prepare(b,a,"P0P1") @@ -839,7 +839,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): rem.setMinDotBtwPlane3DSurfIntersect(0.99)# this line is important it is to tell to remapper to select only cells with very close orientation rem.prepare(skinAndNonConformCells,skinAndNonConformCells,"P0P0") mat=rem.getCrudeCSRMatrix() - indptr=DataArrayInt(mat.indptr) + indptr=DataArrayInt32(mat.indptr) #not depend on MEDCouplingUse64BitIDs() indptr2=indptr.deltaShiftIndex() cellIdsOfNonConformCells=indptr2.findIdsNotEqual(1) cellIdsOfSkin=indptr2.findIdsEqual(1) diff --git a/src/MEDCoupling_Swig/MEDCouplingTypemaps.i b/src/MEDCoupling_Swig/MEDCouplingTypemaps.i index e38e5c7ff..080def392 100644 --- a/src/MEDCoupling_Swig/MEDCouplingTypemaps.i +++ b/src/MEDCoupling_Swig/MEDCouplingTypemaps.i @@ -523,7 +523,7 @@ typename MEDCoupling::Traits::FieldType *fieldT__getitem__(const MEDCoupling: if(!self->getArray()) throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::__getitem__ : no array set on field to deduce number of components !"); try - { convertIntStarOrSliceLikePyObjToCpp(elt1,self->getArray()->getNumberOfComponents(),sw,singleVal,multiVal,slic,daIntTyypp); } + { convertIntStarOrSliceLikePyObjToCpp(elt1,ToIdType(self->getArray()->getNumberOfComponents()),sw,singleVal,multiVal,slic,daIntTyypp); } catch(INTERP_KERNEL::Exception& e) { std::ostringstream oss; oss << "MEDCouplingFieldDouble::__getitem__ : invalid type in 2nd parameter (compo) !" << e.what(); throw INTERP_KERNEL::Exception(oss.str().c_str()); } typename MEDCoupling::MCAuto< typename MEDCoupling::Traits::FieldType > ret0(fieldT_buildSubPart(self,elt0)); @@ -576,10 +576,10 @@ PyObject *field_getTinySerializationInformation(const FIELDT *self) PyObject *ret(PyTuple_New(3)); PyTuple_SetItem(ret,0,convertDblArrToPyList2(a0)); PyTuple_SetItem(ret,1,convertIntArrToPyList2(a1)); - mcIdType sz(a2.size()); + std::size_t sz(a2.size()); PyObject *ret2(PyList_New(sz)); { - for(mcIdType i=0;i::FieldType *self, PyObjec static const char MSG[]="MEDCouplingFieldDouble.__setstate__ : expected input is a tuple of size 3 !"; if(!PyTuple_Check(inp)) throw INTERP_KERNEL::Exception(MSG); - mcIdType sz(PyTuple_Size(inp)); + std::size_t sz(PyTuple_Size(inp)); if(sz!=3) throw INTERP_KERNEL::Exception(MSG); // mesh @@ -713,7 +713,7 @@ PyObject *Mesh_getCellsContainingPointsLike(PyObject *p, double eps, const MEDCo throw INTERP_KERNEL::Exception("MEDCouplingMesh::getCellsContainingPoints : Not null DataArrayDouble instance expected !"); da2->checkAllocated(); mcIdType size=da2->getNumberOfTuples(); - mcIdType nbOfCompo=da2->getNumberOfComponents(); + mcIdType nbOfCompo=ToIdType(da2->getNumberOfComponents()); if(nbOfCompo!=spaceDim) { throw INTERP_KERNEL::Exception("MEDCouplingMesh::getCellsContainingPoints : Invalid DataArrayDouble nb of components ! Expected same as self.getSpaceDimension() !"); diff --git a/src/MEDCoupling_Swig/UsersGuideExamplesTest_numpy.py b/src/MEDCoupling_Swig/UsersGuideExamplesTest_numpy.py index 6ad489506..cdca7ec5f 100644 --- a/src/MEDCoupling_Swig/UsersGuideExamplesTest_numpy.py +++ b/src/MEDCoupling_Swig/UsersGuideExamplesTest_numpy.py @@ -35,7 +35,7 @@ else: # NumPy is an optional pre-requisite! assert(MEDCoupling.MEDCouplingHasNumPyBindings()) a=numpy.arange(20,dtype=numpy.int32) -d=DataArrayInt(a) # d owns data of a -e=DataArrayInt(a) # a not owned -> e only an access to chunk of a +d=DataArrayInt32(a) # d owns data of a +e=DataArrayInt32(a) # a not owned -> e only an access to chunk of a a1=d.toNumPyArray() #! [UG_DataArrayNumpy_0] -- 2.39.2