X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FMEDCoupling_Swig%2FMEDCouplingMemArray.i;h=7bc107464dc3967dfcec647000d8449bfff904b1;hb=9727e779d56acece98be02cdccd0f99cc5ef0fa2;hp=fcad0d7c05813ee536a197367992526f80b5696c;hpb=c490fbf0b83dc78ae4e60db568d3f23d897aaafc;p=tools%2Fmedcoupling.git diff --git a/src/MEDCoupling_Swig/MEDCouplingMemArray.i b/src/MEDCoupling_Swig/MEDCouplingMemArray.i index fcad0d7c0..7bc107464 100644 --- a/src/MEDCoupling_Swig/MEDCouplingMemArray.i +++ b/src/MEDCoupling_Swig/MEDCouplingMemArray.i @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2016 CEA/DEN, EDF R&D +// Copyright (C) 2007-2019 CEA/DEN, EDF R&D // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -16,7 +16,7 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -// Author : Anthony Geay (CEA/DEN) +// Author : Anthony Geay (EDF R&D) //////////////////// %typemap(out) MEDCoupling::DataArray* @@ -55,6 +55,11 @@ { $result=SWIG_NewPointerObj(SWIG_as_voidptr($1.retn()),SWIGTYPE_p_MEDCoupling__DataArrayFloat,SWIG_POINTER_OWN|0); } + +%typemap(out) MCAuto +{ + $result=SWIG_NewPointerObj(SWIG_as_voidptr($1.retn()),SWIGTYPE_p_MEDCoupling__MapII,SWIG_POINTER_OWN|0); +} //$$$$$$$$$$$$$$$$$$ %newobject MEDCoupling::DataArray::deepCopy; @@ -67,6 +72,8 @@ %newobject MEDCoupling::DataArrayFloat::New; %newobject MEDCoupling::DataArrayFloat::iterator; %newobject MEDCoupling::DataArrayFloat::__iter__; +%newobject MEDCoupling::DataArrayFloat::Meld; +%newobject MEDCoupling::DataArrayFloat::__rmul__; %newobject MEDCoupling::DataArrayInt::New; %newobject MEDCoupling::DataArrayInt::__iter__; %newobject MEDCoupling::DataArrayInt::performCopyOrIncrRef; @@ -86,6 +93,7 @@ %newobject MEDCoupling::DataArrayInt::findIdsEqualList; %newobject MEDCoupling::DataArrayInt::findIdsNotEqualList; %newobject MEDCoupling::DataArrayInt::findIdsEqualTuple; +%newobject MEDCoupling::DataArrayInt::findIdForEach; %newobject MEDCoupling::DataArrayInt::sumPerTuple; %newobject MEDCoupling::DataArrayInt::negate; %newobject MEDCoupling::DataArrayInt::computeAbs; @@ -235,6 +243,7 @@ %feature("unref") DataArrayAsciiChar "$this->decrRef();" %feature("unref") DataArrayByte "$this->decrRef();" +%feature("unref") MapII "$this->decrRef();" %feature("unref") PartDefinition "$this->decrRef();" %feature("unref") DataArrayPartDefinition "$this->decrRef();" %feature("unref") SlicePartDefinition "$this->decrRef();" @@ -249,6 +258,12 @@ namespace MEDCoupling } MEDCouplingAxisType; class DataArrayInt; + + class MapII : public RefCountObject, public TimeLabel + { + public: + static MCAuto< MapII > New(); + }; class PartDefinition : public RefCountObject, public TimeLabel { @@ -564,8 +579,7 @@ namespace MEDCoupling if(!PySlice_Check(slic)) throw INTERP_KERNEL::Exception("DataArray::GetSlice (wrap) : expecting a pyslice as second (first) parameter !"); Py_ssize_t strt=2,stp=2,step=2; - PySliceObject *sly=reinterpret_cast(slic); - GetIndicesOfSliceExplicitely(sly,&strt,&stp,&step,"DataArray::GetSlice (wrap) : the input slice is invalid !"); + GetIndicesOfSliceExplicitely(slic,&strt,&stp,&step,"DataArray::GetSlice (wrap) : the input slice is invalid !"); int a,b; DataArray::GetSlice(strt,stp,step,sliceId,nbOfSlices,a,b); return PySlice_New(PyInt_FromLong(a),PyInt_FromLong(b),PyInt_FromLong(step)); @@ -576,8 +590,7 @@ namespace MEDCoupling if(!PySlice_Check(slic)) throw INTERP_KERNEL::Exception("DataArray::getSlice (wrap) : expecting a pyslice as second (first) parameter !"); Py_ssize_t strt=2,stp=2,step=2; - PySliceObject *sly=reinterpret_cast(slic); - GetIndicesOfSlice(sly,self->getNumberOfTuples(),&strt,&stp,&step,"DataArray::getSlice (wrap) : the input slice is invalid !"); + GetIndicesOfSlice(slic,self->getNumberOfTuples(),&strt,&stp,&step,"DataArray::getSlice (wrap) : the input slice is invalid !"); int a,b; DataArray::GetSlice(strt,stp,step,sliceId,nbOfSlices,a,b); return PySlice_New(PyInt_FromLong(a),PyInt_FromLong(b),PyInt_FromLong(step)); @@ -588,8 +601,7 @@ namespace MEDCoupling if(!PySlice_Check(slic)) throw INTERP_KERNEL::Exception("DataArray::GetNumberOfItemGivenBES (wrap) : expecting a pyslice as second (first) parameter !"); Py_ssize_t strt=2,stp=2,step=2; - PySliceObject *sly=reinterpret_cast(slic); - GetIndicesOfSliceExplicitely(sly,&strt,&stp,&step,"DataArray::GetNumberOfItemGivenBES (wrap) : the input slice is invalid !"); + GetIndicesOfSliceExplicitely(slic,&strt,&stp,&step,"DataArray::GetNumberOfItemGivenBES (wrap) : the input slice is invalid !"); return DataArray::GetNumberOfItemGivenBES(strt,stp,step,""); } @@ -598,8 +610,7 @@ namespace MEDCoupling if(!PySlice_Check(slic)) throw INTERP_KERNEL::Exception("DataArray::GetNumberOfItemGivenBESRelative (wrap) : expecting a pyslice as second (first) parameter !"); Py_ssize_t strt=2,stp=2,step=2; - PySliceObject *sly=reinterpret_cast(slic); - GetIndicesOfSliceExplicitely(sly,&strt,&stp,&step,"DataArray::GetNumberOfItemGivenBESRelative (wrap) : the input slice is invalid !"); + GetIndicesOfSliceExplicitely(slic,&strt,&stp,&step,"DataArray::GetNumberOfItemGivenBESRelative (wrap) : the input slice is invalid !"); return DataArray::GetNumberOfItemGivenBESRelative(strt,stp,step,""); } @@ -615,8 +626,7 @@ namespace MEDCoupling if(!PySlice_Check(slic)) throw INTERP_KERNEL::Exception("DataArray::getNumberOfItemGivenBES (wrap) : expecting a pyslice as second (first) parameter !"); Py_ssize_t strt=2,stp=2,step=2; - PySliceObject *sly=reinterpret_cast(slic); - GetIndicesOfSlice(sly,self->getNumberOfTuples(),&strt,&stp,&step,"DataArray::getNumberOfItemGivenBES (wrap) : the input slice is invalid !"); + GetIndicesOfSlice(slic,self->getNumberOfTuples(),&strt,&stp,&step,"DataArray::getNumberOfItemGivenBES (wrap) : the input slice is invalid !"); return DataArray::GetNumberOfItemGivenBES(strt,stp,step,""); } @@ -625,8 +635,7 @@ namespace MEDCoupling if(!PySlice_Check(slic)) throw INTERP_KERNEL::Exception("DataArray::getNumberOfItemGivenBESRelative (wrap) : expecting a pyslice as second (first) parameter !"); Py_ssize_t strt=2,stp=2,step=2; - PySliceObject *sly=reinterpret_cast(slic); - GetIndicesOfSlice(sly,self->getNumberOfTuples(),&strt,&stp,&step,"DataArray::getNumberOfItemGivenBESRelative (wrap) : the input slice is invalid !"); + GetIndicesOfSlice(slic,self->getNumberOfTuples(),&strt,&stp,&step,"DataArray::getNumberOfItemGivenBESRelative (wrap) : the input slice is invalid !"); return DataArray::GetNumberOfItemGivenBESRelative(strt,stp,step,""); } @@ -655,13 +664,11 @@ namespace MEDCoupling if(sz!=2) throw INTERP_KERNEL::Exception("DataArrayDouble.__setstate__ : invalid tuple in input ! Should be of size 2 ! Invalid overwrite of __getstate__ ?"); PyObject *a0(PyTuple_GetItem(inp,0)); - if(!PyString_Check(a0)) - throw INTERP_KERNEL::Exception(MSG); + self->setName(convertPyObjectToStr(a0,MSG)); PyObject *a1(PyTuple_GetItem(inp,1)); std::vector a1cpp; if(!fillStringVector(a1,a1cpp)) throw INTERP_KERNEL::Exception(MSG); - self->setName(PyString_AsString(a0)); self->setInfoOnComponents(a1cpp); } } @@ -681,6 +688,7 @@ namespace MEDCoupling void iota(float init=0.) throw(INTERP_KERNEL::Exception); DataArrayFloatIterator *iterator() throw(INTERP_KERNEL::Exception); MCAuto convertToDblArr() const throw(INTERP_KERNEL::Exception); + static DataArrayFloat *Meld(const DataArrayFloat *a1, const DataArrayFloat *a2) throw(INTERP_KERNEL::Exception); %extend { DataArrayFloat() throw(INTERP_KERNEL::Exception) @@ -697,7 +705,7 @@ namespace MEDCoupling { return MEDCoupling_DataArrayFloat_New__SWIG_1(elt0,nbOfTuples,elt2); } - + DataArrayFloatIterator *__iter__() throw(INTERP_KERNEL::Exception) { return self->iterator(); @@ -739,6 +747,18 @@ namespace MEDCoupling int nbOfComp(self->getNumberOfComponents()),nbOfTuples(self->getNumberOfTuples()); return convertDblArrToPyListOfTuple(vals,nbOfComp,nbOfTuples); } + + PyObject *isEqualIfNotWhy(const DataArrayFloat& other, float prec) const throw(INTERP_KERNEL::Exception) + { + std::string ret1; + bool ret0=self->isEqualIfNotWhy(other,prec,ret1); + PyObject *ret=PyTuple_New(2); + PyObject *ret0Py=ret0?Py_True:Py_False; + Py_XINCREF(ret0Py); + PyTuple_SetItem(ret,0,ret0Py); + PyTuple_SetItem(ret,1,PyString_FromString(ret1.c_str())); + return ret; + } PyObject *__getitem__(PyObject *obj) throw(INTERP_KERNEL::Exception) { @@ -765,6 +785,11 @@ namespace MEDCoupling return DataArrayT_imul(trueSelf,obj,self); } + DataArrayFloat *__rmul__(PyObject *obj) throw(INTERP_KERNEL::Exception) + { + return DataArrayFPT_rmul(self,obj); + } + PyObject *___idiv___(PyObject *trueSelf, PyObject *obj) throw(INTERP_KERNEL::Exception) { return DataArrayT_idiv(trueSelf,obj,self); @@ -776,7 +801,6 @@ namespace MEDCoupling return ToNumPyArray(self,NPY_FLOAT,"DataArrayFloat"); } #endif - } }; @@ -893,9 +917,8 @@ namespace MEDCoupling void checkNoNullValues() const throw(INTERP_KERNEL::Exception); DataArrayDouble *computeBBoxPerTuple(double epsilon=0.0) const throw(INTERP_KERNEL::Exception); void recenterForMaxPrecision(double eps) throw(INTERP_KERNEL::Exception); - double getMaxValue(int& tupleId) const throw(INTERP_KERNEL::Exception); double getMaxValueInArray() const throw(INTERP_KERNEL::Exception); - double getMinValue(int& tupleId) const throw(INTERP_KERNEL::Exception); + double getMaxAbsValueInArray() const throw(INTERP_KERNEL::Exception); double getMinValueInArray() const throw(INTERP_KERNEL::Exception); int count(double value, double eps) const throw(INTERP_KERNEL::Exception); double getAverageValue() const throw(INTERP_KERNEL::Exception); @@ -1022,6 +1045,22 @@ namespace MEDCoupling } } + PyObject *asArcOfCircle() const throw(INTERP_KERNEL::Exception) + { + double center[2],radius,ang; + self->asArcOfCircle(center,radius,ang); + PyObject *ret(PyTuple_New(3)); + { + PyObject *ret0(PyList_New(2)); + PyList_SetItem(ret0,0,PyFloat_FromDouble(center[0])); + PyList_SetItem(ret0,1,PyFloat_FromDouble(center[1])); + PyTuple_SetItem(ret,0,ret0); + } + PyTuple_SetItem(ret,1,PyFloat_FromDouble(radius)); + PyTuple_SetItem(ret,2,PyFloat_FromDouble(ang)); + return ret; + } + DataArrayDoubleIterator *__iter__() throw(INTERP_KERNEL::Exception) { return self->iterator(); @@ -1105,6 +1144,28 @@ namespace MEDCoupling return convertDblArrToPyListOfTuple(vals,nbOfComp,nbOfTuples); } + static PyObject *ComputeIntegralOfSeg2IntoTri3(PyObject *seg2, PyObject *tri3) throw(INTERP_KERNEL::Exception) + { + const char msg[]="Python wrap of DataArrayDouble::ComputeIntegralOfSeg2IntoTri3 : "; + double val,val2; + DataArrayDouble *a,*a2; + DataArrayDoubleTuple *aa,*aa2; + std::vector bb,bb2; + int sw; + const double *seg2Ptr(convertObjToPossibleCpp5_Safe(seg2,sw,val,a,aa,bb,msg,2,2,true)); + const double *tri3Ptr(convertObjToPossibleCpp5_Safe(tri3,sw,val2,a2,aa2,bb2,msg,3,2,true)); + // + double res0[3],res1; + DataArrayDouble::ComputeIntegralOfSeg2IntoTri3(seg2Ptr,tri3Ptr,res0,res1); + PyObject *ret(PyTuple_New(2)),*ret0(PyTuple_New(3)); + PyTuple_SetItem(ret0,0,PyFloat_FromDouble(res0[0])); + PyTuple_SetItem(ret0,1,PyFloat_FromDouble(res0[1])); + PyTuple_SetItem(ret0,2,PyFloat_FromDouble(res0[2])); + PyTuple_SetItem(ret,0,ret0); + PyTuple_SetItem(ret,1,PyFloat_FromDouble(res1)); + return ret; + } + DataArrayDouble *symmetry3DPlane(PyObject *point, PyObject *normalVector) throw(INTERP_KERNEL::Exception) { const char msg[]="Python wrap of DataArrayDouble::symmetry3DPlane : "; @@ -1254,6 +1315,16 @@ namespace MEDCoupling return ret; } + PyObject *getMaxAbsValue() const throw(INTERP_KERNEL::Exception) + { + std::size_t tmp; + double r1=self->getMaxAbsValue(tmp); + PyObject *ret=PyTuple_New(2); + PyTuple_SetItem(ret,0,PyFloat_FromDouble(r1)); + PyTuple_SetItem(ret,1,PyInt_FromLong(tmp)); + return ret; + } + PyObject *getMaxValue2() const throw(INTERP_KERNEL::Exception) { DataArrayInt *tmp; @@ -1292,6 +1363,14 @@ namespace MEDCoupling PyObject *ret=convertDblArrToPyListOfTuple(tmp,2,nbOfCompo); return ret; } + + PyObject *normMaxPerComponent() const throw(INTERP_KERNEL::Exception) + { + int nbOfCompo(self->getNumberOfComponents()); + INTERP_KERNEL::AutoPtr tmp(new double[nbOfCompo]); + self->normMaxPerComponent(tmp); + return convertDblArrToPyList(tmp,nbOfCompo); + } PyObject *accumulate() const throw(INTERP_KERNEL::Exception) { @@ -1385,7 +1464,7 @@ namespace MEDCoupling int nbComp=self->getNumberOfComponents(),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); - MCAuto inpu=DataArrayDouble::New(); inpu->useArray(pos,false,CPP_DEALLOC,nbTuples,nbComp); + MCAuto inpu=DataArrayDouble::New(); inpu->useArray(pos,false,DeallocType::CPP_DEALLOC,nbTuples,nbComp); DataArrayInt *c=0,*cI=0; self->computeTupleIdsNearTuples(inpu,eps,c,cI); PyObject *ret=PyTuple_New(2); @@ -1467,7 +1546,7 @@ namespace MEDCoupling } case 4: { - MCAuto aaa=DataArrayDouble::New(); aaa->useArray(&bb[0],false,CPP_DEALLOC,1,(int)bb.size()); + MCAuto aaa=DataArrayDouble::New(); aaa->useArray(&bb[0],false,DeallocType::CPP_DEALLOC,1,(int)bb.size()); return SWIG_NewPointerObj(SWIG_as_voidptr(DataArrayDouble::Add(self,aaa)),SWIGTYPE_p_MEDCoupling__DataArrayDouble, SWIG_POINTER_OWN | 0 ); } default: @@ -1499,7 +1578,7 @@ namespace MEDCoupling } case 4: { - MCAuto aaa=DataArrayDouble::New(); aaa->useArray(&bb[0],false,CPP_DEALLOC,1,(int)bb.size()); + MCAuto aaa=DataArrayDouble::New(); aaa->useArray(&bb[0],false,DeallocType::CPP_DEALLOC,1,(int)bb.size()); return DataArrayDouble::Add(self,aaa); } default: @@ -1558,7 +1637,7 @@ namespace MEDCoupling } case 4: { - MCAuto aaa=DataArrayDouble::New(); aaa->useArray(&bb[0],false,CPP_DEALLOC,1,(int)bb.size()); + MCAuto aaa=DataArrayDouble::New(); aaa->useArray(&bb[0],false,DeallocType::CPP_DEALLOC,1,(int)bb.size()); return SWIG_NewPointerObj(SWIG_as_voidptr(DataArrayDouble::Substract(self,aaa)),SWIGTYPE_p_MEDCoupling__DataArrayDouble, SWIG_POINTER_OWN | 0 ); } default: @@ -1590,7 +1669,7 @@ namespace MEDCoupling } case 4: { - MCAuto aaa=DataArrayDouble::New(); aaa->useArray(&bb[0],false,CPP_DEALLOC,1,(int)bb.size()); + MCAuto aaa=DataArrayDouble::New(); aaa->useArray(&bb[0],false,DeallocType::CPP_DEALLOC,1,(int)bb.size()); return DataArrayDouble::Substract(aaa,self); } default: @@ -1649,7 +1728,7 @@ namespace MEDCoupling } case 4: { - MCAuto aaa=DataArrayDouble::New(); aaa->useArray(&bb[0],false,CPP_DEALLOC,1,(int)bb.size()); + MCAuto aaa=DataArrayDouble::New(); aaa->useArray(&bb[0],false,DeallocType::CPP_DEALLOC,1,(int)bb.size()); return SWIG_NewPointerObj(SWIG_as_voidptr(DataArrayDouble::Multiply(self,aaa)),SWIGTYPE_p_MEDCoupling__DataArrayDouble, SWIG_POINTER_OWN | 0 ); } default: @@ -1659,34 +1738,7 @@ namespace MEDCoupling DataArrayDouble *__rmul__(PyObject *obj) throw(INTERP_KERNEL::Exception) { - const char msg[]="Unexpected situation in __rmul__ !"; - double val; - DataArrayDouble *a; - DataArrayDoubleTuple *aa; - std::vector bb; - int sw; - convertDoubleStarLikePyObjToCpp_2(obj,sw,val,a,aa,bb); - switch(sw) - { - case 1: - { - MCAuto ret=self->deepCopy(); - ret->applyLin(val,0.); - return ret.retn(); - } - case 3: - { - MCAuto aaa=aa->buildDADouble(1,self->getNumberOfComponents()); - return DataArrayDouble::Multiply(self,aaa); - } - case 4: - { - MCAuto aaa=DataArrayDouble::New(); aaa->useArray(&bb[0],false,CPP_DEALLOC,1,(int)bb.size()); - return DataArrayDouble::Multiply(self,aaa); - } - default: - throw INTERP_KERNEL::Exception(msg); - } + return DataArrayFPT_rmul(self,obj); } PyObject *___imul___(PyObject *trueSelf, PyObject *obj) throw(INTERP_KERNEL::Exception) @@ -1742,7 +1794,7 @@ namespace MEDCoupling } case 4: { - MCAuto aaa=DataArrayDouble::New(); aaa->useArray(&bb[0],false,CPP_DEALLOC,1,(int)bb.size()); + MCAuto aaa=DataArrayDouble::New(); aaa->useArray(&bb[0],false,DeallocType::CPP_DEALLOC,1,(int)bb.size()); return SWIG_NewPointerObj(SWIG_as_voidptr(DataArrayDouble::Divide(self,aaa)),SWIGTYPE_p_MEDCoupling__DataArrayDouble, SWIG_POINTER_OWN | 0 ); } default: @@ -1774,7 +1826,7 @@ namespace MEDCoupling } case 4: { - MCAuto aaa=DataArrayDouble::New(); aaa->useArray(&bb[0],false,CPP_DEALLOC,1,(int)bb.size()); + MCAuto aaa=DataArrayDouble::New(); aaa->useArray(&bb[0],false,DeallocType::CPP_DEALLOC,1,(int)bb.size()); return DataArrayDouble::Divide(aaa,self); } default: @@ -1815,7 +1867,7 @@ namespace MEDCoupling } case 4: { - MCAuto aaa=DataArrayDouble::New(); aaa->useArray(&bb[0],false,CPP_DEALLOC,1,(int)bb.size()); + MCAuto aaa=DataArrayDouble::New(); aaa->useArray(&bb[0],false,DeallocType::CPP_DEALLOC,1,(int)bb.size()); return DataArrayDouble::Pow(self,aaa); } default: @@ -1847,7 +1899,7 @@ namespace MEDCoupling } case 4: { - MCAuto aaa=DataArrayDouble::New(); aaa->useArray(&bb[0],false,CPP_DEALLOC,1,(int)bb.size()); + MCAuto aaa=DataArrayDouble::New(); aaa->useArray(&bb[0],false,DeallocType::CPP_DEALLOC,1,(int)bb.size()); return DataArrayDouble::Pow(aaa,self); } default: @@ -1887,7 +1939,7 @@ namespace MEDCoupling } case 4: { - MCAuto aaa=DataArrayDouble::New(); aaa->useArray(&bb[0],false,CPP_DEALLOC,1,(int)bb.size()); + MCAuto aaa=DataArrayDouble::New(); aaa->useArray(&bb[0],false,DeallocType::CPP_DEALLOC,1,(int)bb.size()); self->powEqual(aaa); Py_XINCREF(trueSelf); return trueSelf; @@ -1917,31 +1969,6 @@ namespace MEDCoupling PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 )); return ret; } - - // serialization - static PyObject *___new___(PyObject *cls, PyObject *args) throw(INTERP_KERNEL::Exception) - { - return NewMethWrapCallInitOnlyIfDictWithSingleEltInInput(cls,args,"DataArrayDouble"); - } - - PyObject *__getnewargs__() throw(INTERP_KERNEL::Exception) - { -#ifdef WITH_NUMPY - if(!self->isAllocated()) - throw INTERP_KERNEL::Exception("PyWrap of DataArrayDouble.__getnewargs__ : self is not allocated !"); - PyObject *ret(PyTuple_New(1)); - PyObject *ret0(PyDict_New()); - PyObject *numpyArryObj(MEDCoupling_DataArrayDouble_toNumPyArray(self)); - {// create a dict to discriminite in __new__ if __init__ should be called. Not beautiful but not idea ... - PyObject *tmp1(PyInt_FromLong(0)); - PyDict_SetItem(ret0,tmp1,numpyArryObj); Py_DECREF(tmp1); Py_DECREF(numpyArryObj); - PyTuple_SetItem(ret,0,ret0); - } - return ret; -#else - throw INTERP_KERNEL::Exception("PyWrap of DataArrayDouble.__getnewargs__ : not implemented because numpy is not active in your configuration ! No serialization/unserialization available without numpy !"); -#endif - } } }; @@ -2284,6 +2311,8 @@ namespace MEDCoupling DataArrayInt *invertArrayO2N2N2O(int newNbOfElem) const throw(INTERP_KERNEL::Exception); DataArrayInt *invertArrayN2O2O2N(int oldNbOfElem) const throw(INTERP_KERNEL::Exception); DataArrayInt *invertArrayO2N2N2OBis(int newNbOfElem) const throw(INTERP_KERNEL::Exception); + MCAuto< MapII > invertArrayN2O2O2NOptimized() const throw(INTERP_KERNEL::Exception); + MCAuto< MapII > giveN2OOptimized() const throw(INTERP_KERNEL::Exception); DataArrayInt *indicesOfSubPart(const DataArrayInt& partOfThis) const throw(INTERP_KERNEL::Exception); DataArrayInt *fromNoInterlace() const throw(INTERP_KERNEL::Exception); DataArrayInt *toNoInterlace() const throw(INTERP_KERNEL::Exception); @@ -2292,6 +2321,7 @@ namespace MEDCoupling DataArrayInt *buildPermArrPerLevel() const throw(INTERP_KERNEL::Exception); bool isIota(int sizeExpected) const throw(INTERP_KERNEL::Exception); bool isUniform(int val) const throw(INTERP_KERNEL::Exception); + int checkUniformAndGuess() const throw(INTERP_KERNEL::Exception); bool hasUniqueValues() const throw(INTERP_KERNEL::Exception); DataArrayInt *subArray(int tupleIdBg, int tupleIdEnd=-1) const throw(INTERP_KERNEL::Exception); void transpose() throw(INTERP_KERNEL::Exception); @@ -2324,9 +2354,8 @@ namespace MEDCoupling bool presenceOfValue(const std::vector& vals) const throw(INTERP_KERNEL::Exception); int count(int value) const throw(INTERP_KERNEL::Exception); int accumulate(int compId) const throw(INTERP_KERNEL::Exception); - int getMaxValue(int& tupleId) const throw(INTERP_KERNEL::Exception); int getMaxValueInArray() const throw(INTERP_KERNEL::Exception); - int getMinValue(int& tupleId) const throw(INTERP_KERNEL::Exception); + int getMaxAbsValueInArray() const throw(INTERP_KERNEL::Exception); int getMinValueInArray() const throw(INTERP_KERNEL::Exception); void abs() throw(INTERP_KERNEL::Exception); DataArrayInt *computeAbs() const throw(INTERP_KERNEL::Exception); @@ -2545,6 +2574,15 @@ namespace MEDCoupling return self->findIdsEqualTuple(bg,bg+sz); } + DataArrayInt *findIdForEach(PyObject *vals) const throw(INTERP_KERNEL::Exception) + { + int sw,sz,val; + std::vector val2; + const int *bg(convertIntStarLikePyObjToCppIntStar(vals,sw,sz,val,val2)); + MCAuto ret(self->findIdForEach(bg,bg+sz)); + return ret.retn(); + } + PyObject *splitInBalancedSlices(int nbOfSlices) const throw(INTERP_KERNEL::Exception) { std::vector< std::pair > slcs(self->splitInBalancedSlices(nbOfSlices)); @@ -2559,8 +2597,7 @@ namespace MEDCoupling if(!PySlice_Check(slic)) throw INTERP_KERNEL::Exception("DataArrayInt::buildExplicitArrOfSliceOnScaledArr (wrap) : expecting a pyslice as second (first) parameter !"); Py_ssize_t strt=2,stp=2,step=2; - PySliceObject *sly=reinterpret_cast(slic); - GetIndicesOfSliceExplicitely(sly,&strt,&stp,&step,"DataArrayInt::buildExplicitArrOfSliceOnScaledArr (wrap) : the input slice is invalid !"); + GetIndicesOfSliceExplicitely(slic,&strt,&stp,&step,"DataArrayInt::buildExplicitArrOfSliceOnScaledArr (wrap) : the input slice is invalid !"); if(strt==std::numeric_limits::max() || stp==std::numeric_limits::max()) throw INTERP_KERNEL::Exception("DataArrayInt::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); @@ -2597,7 +2634,7 @@ namespace MEDCoupling std::vector stdvecTyyppArr; const int *arrPtr(convertIntStarLikePyObjToCppIntStar(arr,sw,szArr,iTypppArr,stdvecTyyppArr)); int *pt(MEDCoupling::DataArrayInt::CheckAndPreparePermutation(arrPtr,arrPtr+szArr)); - ret->useArray(pt,true,MEDCoupling::C_DEALLOC,szArr,1); + ret->useArray(pt,true,MEDCoupling::DeallocType::C_DEALLOC,szArr,1); return ret.retn(); } @@ -2699,12 +2736,21 @@ namespace MEDCoupling void transformWithIndArr(PyObject *li) throw(INTERP_KERNEL::Exception) { void *da=0; - int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_MEDCoupling__DataArrayInt, 0 | 0 ); + int res1(SWIG_ConvertPtr(li,&da,SWIGTYPE_p_MEDCoupling__DataArrayInt, 0 | 0 )); if (!SWIG_IsOK(res1)) { - int size; - INTERP_KERNEL::AutoPtr tmp=convertPyToNewIntArr2(li,&size); - self->transformWithIndArr(tmp,tmp+size); + int res2(SWIG_ConvertPtr(li,&da,SWIGTYPE_p_MEDCoupling__MapII, 0 | 0 )); + if(SWIG_IsOK(res2)) + { + MapII *m=reinterpret_cast(da); + self->transformWithIndArr(*m); + } + else + { + int size; + INTERP_KERNEL::AutoPtr tmp=convertPyToNewIntArr2(li,&size); + self->transformWithIndArr(tmp,tmp+size); + } } else { @@ -2965,6 +3011,16 @@ namespace MEDCoupling PyTuple_SetItem(ret,1,PyInt_FromLong(tmp)); return ret; } + + PyObject *getMaxAbsValue(std::size_t& tupleId) const throw(INTERP_KERNEL::Exception) + { + std::size_t tmp; + int r1=self->getMaxAbsValue(tmp); + PyObject *ret=PyTuple_New(2); + PyTuple_SetItem(ret,0,PyInt_FromLong(r1)); + PyTuple_SetItem(ret,1,PyInt_FromLong(tmp)); + return ret; + } PyObject *getMinValue() const throw(INTERP_KERNEL::Exception) { @@ -3164,7 +3220,7 @@ namespace MEDCoupling return self; case 2: tmp=DataArrayInt::New(); - tmp->useArray(&v1[0],false,CPP_DEALLOC,1,v1.size()); + tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size()); self->setPartOfValues1(tmp,it1,it1+1,1,0,nbOfComponents,1,false); return self; case 3: @@ -3188,7 +3244,7 @@ namespace MEDCoupling return self; case 2: tmp=DataArrayInt::New(); - tmp->useArray(&v1[0],false,CPP_DEALLOC,1,v1.size()); + tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size()); self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),0,nbOfComponents,1,false); return self; case 3: @@ -3212,7 +3268,7 @@ namespace MEDCoupling return self; case 2: tmp=DataArrayInt::New(); - tmp->useArray(&v1[0],false,CPP_DEALLOC,1,v1.size()); + tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size()); self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,0,nbOfComponents,1,false); return self; case 3: @@ -3236,7 +3292,7 @@ namespace MEDCoupling return self; case 2: tmp=DataArrayInt::New(); - tmp->useArray(&v1[0],false,CPP_DEALLOC,1,v1.size()); + tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size()); self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),0,nbOfComponents,1,false); return self; case 3: @@ -3260,7 +3316,7 @@ namespace MEDCoupling return self; case 2: tmp=DataArrayInt::New(); - tmp->useArray(&v1[0],false,CPP_DEALLOC,1,v1.size()); + tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size()); self->setPartOfValues1(tmp,it1,it1+1,1,ic1,ic1+1,1,false); return self; case 3: @@ -3284,7 +3340,7 @@ namespace MEDCoupling return self; case 2: tmp=DataArrayInt::New(); - tmp->useArray(&v1[0],false,CPP_DEALLOC,1,v1.size()); + tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size()); self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),ic1,ic1+1,1,false); return self; case 3: @@ -3308,7 +3364,7 @@ namespace MEDCoupling return self; case 2: tmp=DataArrayInt::New(); - tmp->useArray(&v1[0],false,CPP_DEALLOC,1,v1.size()); + tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size()); self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,ic1,ic1+1,1,false); return self; case 3: @@ -3332,7 +3388,7 @@ namespace MEDCoupling return self; case 2: tmp=DataArrayInt::New(); - tmp->useArray(&v1[0],false,CPP_DEALLOC,1,v1.size()); + tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size()); self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),ic1,ic1+1,1,false); return self; case 3: @@ -3356,7 +3412,7 @@ namespace MEDCoupling return self; case 2: tmp=DataArrayInt::New(); - tmp->useArray(&v1[0],false,CPP_DEALLOC,1,v1.size()); + tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size()); self->setPartOfValues2(tmp,&it1,&it1+1,&vc1[0],&vc1[0]+vc1.size(),false); return self; case 3: @@ -3380,7 +3436,7 @@ namespace MEDCoupling return self; case 2: tmp=DataArrayInt::New(); - tmp->useArray(&v1[0],false,CPP_DEALLOC,1,v1.size()); + tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size()); self->setPartOfValues2(tmp,&vt1[0],&vt1[0]+vt1.size(),&vc1[0],&vc1[0]+vc1.size(),false); return self; case 3: @@ -3404,7 +3460,7 @@ namespace MEDCoupling return self; case 2: tmp=DataArrayInt::New(); - tmp->useArray(&v1[0],false,CPP_DEALLOC,1,v1.size()); + tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size()); self->setPartOfValues4(tmp,pt1.first,pt1.second.first,pt1.second.second,&vc1[0],&vc1[0]+vc1.size(),false); return self; case 3: @@ -3428,7 +3484,7 @@ namespace MEDCoupling return self; case 2: tmp=DataArrayInt::New(); - tmp->useArray(&v1[0],false,CPP_DEALLOC,1,v1.size()); + tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size()); self->setPartOfValues2(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),&vc1[0],&vc1[0]+vc1.size(),false); return self; case 3: @@ -3452,7 +3508,7 @@ namespace MEDCoupling return self; case 2: tmp=DataArrayInt::New(); - tmp->useArray(&v1[0],false,CPP_DEALLOC,1,v1.size()); + tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size()); self->setPartOfValues1(tmp,it1,it1+1,1,pc1.first,pc1.second.first,pc1.second.second,false); return self; case 3: @@ -3476,7 +3532,7 @@ namespace MEDCoupling return self; case 2: tmp=DataArrayInt::New(); - tmp->useArray(&v1[0],false,CPP_DEALLOC,1,v1.size()); + tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size()); self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),pc1.first,pc1.second.first,pc1.second.second,false); return self; case 3: @@ -3500,7 +3556,7 @@ namespace MEDCoupling return self; case 2: tmp=DataArrayInt::New(); - tmp->useArray(&v1[0],false,CPP_DEALLOC,1,v1.size()); + tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size()); self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,pc1.first,pc1.second.first,pc1.second.second,false); return self; case 3: @@ -3524,7 +3580,7 @@ namespace MEDCoupling return self; case 2: tmp=DataArrayInt::New(); - tmp->useArray(&v1[0],false,CPP_DEALLOC,1,v1.size()); + tmp->useArray(&v1[0],false,DeallocType::CPP_DEALLOC,1,v1.size()); self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),pc1.first,pc1.second.first,pc1.second.second,false); return self; case 3: @@ -3569,7 +3625,7 @@ namespace MEDCoupling } case 2: { - MCAuto aaaa=DataArrayInt::New(); aaaa->useArray(&aa[0],false,CPP_DEALLOC,1,(int)aa.size()); + MCAuto aaaa=DataArrayInt::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,(int)aa.size()); return DataArrayInt::Add(self,aaaa); } case 3: @@ -3605,7 +3661,7 @@ namespace MEDCoupling } case 2: { - MCAuto aaaa=DataArrayInt::New(); aaaa->useArray(&aa[0],false,CPP_DEALLOC,1,(int)aa.size()); + MCAuto aaaa=DataArrayInt::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,(int)aa.size()); return DataArrayInt::Add(self,aaaa); } case 4: @@ -3637,7 +3693,7 @@ namespace MEDCoupling } case 2: { - MCAuto bb=DataArrayInt::New(); bb->useArray(&aa[0],false,CPP_DEALLOC,1,(int)aa.size()); + MCAuto bb=DataArrayInt::New(); bb->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,(int)aa.size()); self->addEqual(bb); Py_XINCREF(trueSelf); return trueSelf; @@ -3679,7 +3735,7 @@ namespace MEDCoupling } case 2: { - MCAuto aaaa=DataArrayInt::New(); aaaa->useArray(&aa[0],false,CPP_DEALLOC,1,(int)aa.size()); + MCAuto aaaa=DataArrayInt::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,(int)aa.size()); return DataArrayInt::Substract(self,aaaa); } case 3: @@ -3715,7 +3771,7 @@ namespace MEDCoupling } case 2: { - MCAuto aaaa=DataArrayInt::New(); aaaa->useArray(&aa[0],false,CPP_DEALLOC,1,(int)aa.size()); + MCAuto aaaa=DataArrayInt::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,(int)aa.size()); return DataArrayInt::Substract(aaaa,self); } case 4: @@ -3747,7 +3803,7 @@ namespace MEDCoupling } case 2: { - MCAuto bb=DataArrayInt::New(); bb->useArray(&aa[0],false,CPP_DEALLOC,1,(int)aa.size()); + MCAuto bb=DataArrayInt::New(); bb->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,(int)aa.size()); self->substractEqual(bb); Py_XINCREF(trueSelf); return trueSelf; @@ -3789,7 +3845,7 @@ namespace MEDCoupling } case 2: { - MCAuto aaaa=DataArrayInt::New(); aaaa->useArray(&aa[0],false,CPP_DEALLOC,1,(int)aa.size()); + MCAuto aaaa=DataArrayInt::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,(int)aa.size()); return DataArrayInt::Multiply(self,aaaa); } case 3: @@ -3825,7 +3881,7 @@ namespace MEDCoupling } case 2: { - MCAuto aaaa=DataArrayInt::New(); aaaa->useArray(&aa[0],false,CPP_DEALLOC,1,(int)aa.size()); + MCAuto aaaa=DataArrayInt::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,(int)aa.size()); return DataArrayInt::Multiply(self,aaaa); } case 4: @@ -3857,7 +3913,7 @@ namespace MEDCoupling } case 2: { - MCAuto bb=DataArrayInt::New(); bb->useArray(&aa[0],false,CPP_DEALLOC,1,(int)aa.size()); + MCAuto bb=DataArrayInt::New(); bb->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,(int)aa.size()); self->multiplyEqual(bb); Py_XINCREF(trueSelf); return trueSelf; @@ -3899,7 +3955,7 @@ namespace MEDCoupling } case 2: { - MCAuto aaaa=DataArrayInt::New(); aaaa->useArray(&aa[0],false,CPP_DEALLOC,1,(int)aa.size()); + MCAuto aaaa=DataArrayInt::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,(int)aa.size()); return DataArrayInt::Divide(self,aaaa); } case 3: @@ -3935,7 +3991,7 @@ namespace MEDCoupling } case 2: { - MCAuto aaaa=DataArrayInt::New(); aaaa->useArray(&aa[0],false,CPP_DEALLOC,1,(int)aa.size()); + MCAuto aaaa=DataArrayInt::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,(int)aa.size()); return DataArrayInt::Divide(aaaa,self); } case 4: @@ -3967,7 +4023,7 @@ namespace MEDCoupling } case 2: { - MCAuto bb=DataArrayInt::New(); bb->useArray(&aa[0],false,CPP_DEALLOC,1,(int)aa.size()); + MCAuto bb=DataArrayInt::New(); bb->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,(int)aa.size()); self->divideEqual(bb); Py_XINCREF(trueSelf); return trueSelf; @@ -4009,7 +4065,7 @@ namespace MEDCoupling } case 2: { - MCAuto aaaa=DataArrayInt::New(); aaaa->useArray(&aa[0],false,CPP_DEALLOC,1,(int)aa.size()); + MCAuto aaaa=DataArrayInt::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,(int)aa.size()); return DataArrayInt::Modulus(self,aaaa); } case 3: @@ -4045,7 +4101,7 @@ namespace MEDCoupling } case 2: { - MCAuto aaaa=DataArrayInt::New(); aaaa->useArray(&aa[0],false,CPP_DEALLOC,1,(int)aa.size()); + MCAuto aaaa=DataArrayInt::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,(int)aa.size()); return DataArrayInt::Modulus(aaaa,self); } case 3: @@ -4116,7 +4172,7 @@ namespace MEDCoupling } case 2: { - MCAuto aaaa=DataArrayInt::New(); aaaa->useArray(&aa[0],false,CPP_DEALLOC,1,(int)aa.size()); + MCAuto aaaa=DataArrayInt::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,(int)aa.size()); return DataArrayInt::Pow(self,aaaa); } case 3: @@ -4152,7 +4208,7 @@ namespace MEDCoupling } case 2: { - MCAuto aaaa=DataArrayInt::New(); aaaa->useArray(&aa[0],false,CPP_DEALLOC,1,(int)aa.size()); + MCAuto aaaa=DataArrayInt::New(); aaaa->useArray(&aa[0],false,DeallocType::CPP_DEALLOC,1,(int)aa.size()); return DataArrayInt::Pow(aaaa,self); } case 3: @@ -4265,31 +4321,6 @@ namespace MEDCoupling PyTuple_SetItem(pyRet,1,ret1Py); return pyRet; } - - // serialization - static PyObject *___new___(PyObject *cls, PyObject *args) throw(INTERP_KERNEL::Exception) - { - return NewMethWrapCallInitOnlyIfDictWithSingleEltInInput(cls,args,"DataArrayInt"); - } - - PyObject *__getnewargs__() throw(INTERP_KERNEL::Exception) - { -#ifdef WITH_NUMPY - if(!self->isAllocated()) - throw INTERP_KERNEL::Exception("PyWrap of DataArrayInt.__getnewargs__ : self is not allocated !"); - PyObject *ret(PyTuple_New(1)); - PyObject *ret0(PyDict_New()); - PyObject *numpyArryObj(MEDCoupling_DataArrayInt_toNumPyArray(self)); - {// create a dict to discriminite in __new__ if __init__ should be called. Not beautiful but not idea ... - PyObject *tmp1(PyInt_FromLong(0)); - PyDict_SetItem(ret0,tmp1,numpyArryObj); Py_DECREF(tmp1); Py_DECREF(numpyArryObj); - PyTuple_SetItem(ret,0,ret0); - } - return ret; -#else - throw INTERP_KERNEL::Exception("PyWrap of DataArrayInt.__getnewargs__ : not implemented because numpy is not active in your configuration ! No serialization/unserialization available without numpy !"); -#endif - } } }; @@ -4361,7 +4392,6 @@ namespace MEDCoupling Py_XINCREF(trueSelf); return trueSelf; } - PyObject *___idiv___(PyObject *trueSelf, PyObject *obj) throw(INTERP_KERNEL::Exception) { MCAuto ret=self->buildDAInt(1,self->getNumberOfCompo()); @@ -5057,31 +5087,6 @@ namespace MEDCoupling } #endif - // serialization - static PyObject *___new___(PyObject *cls, PyObject *args) throw(INTERP_KERNEL::Exception) - { - return NewMethWrapCallInitOnlyIfDictWithSingleEltInInput(cls,args,"DataArrayByte"); - } - - PyObject *__getnewargs__() throw(INTERP_KERNEL::Exception) - { -#ifdef WITH_NUMPY - if(!self->isAllocated()) - throw INTERP_KERNEL::Exception("PyWrap of DataArrayByte.__getnewargs__ : self is not allocated !"); - PyObject *ret(PyTuple_New(1)); - PyObject *ret0(PyDict_New()); - PyObject *numpyArryObj(MEDCoupling_DataArrayByte_toNumPyArray(self)); - {// create a dict to discriminite in __new__ if __init__ should be called. Not beautiful but not idea ... - PyObject *tmp1(PyInt_FromLong(0)); - PyDict_SetItem(ret0,tmp1,numpyArryObj); Py_DECREF(tmp1); Py_DECREF(numpyArryObj); - PyTuple_SetItem(ret,0,ret0); - } - return ret; -#else - throw INTERP_KERNEL::Exception("PyWrap of DataArrayByte.__getnewargs__ : not implemented because numpy is not active in your configuration ! No serialization/unserialization available without numpy !"); -#endif - } - DataArrayByte *__setitem__(PyObject *obj, PyObject *value) throw(INTERP_KERNEL::Exception) { self->checkAllocated(); @@ -5397,6 +5402,19 @@ namespace MEDCoupling else throw INTERP_KERNEL::Exception(msg); } +%#if PY_VERSION_HEX >= 0x03000000 + else if(PyUnicode_Check(nbOfTuples)) + { + if(PyUnicode_GET_LENGTH(nbOfTuples)!=1) + throw INTERP_KERNEL::Exception(msg); + //DataArrayAsciiChar.New(["abc","de","fghi"],"t") + std::vector tmp; + if(fillStringVector(elt0,tmp)) + return DataArrayAsciiChar::New(tmp,PyUnicode_AsUTF8(nbOfTuples)[0]); + else + throw INTERP_KERNEL::Exception(msg); + } +%#endif else throw INTERP_KERNEL::Exception(msg); } @@ -5505,6 +5523,15 @@ namespace MEDCoupling std::copy(PyString_AsString(tupl),PyString_AsString(tupl)+sz,vals.begin()); return self->presenceOfTuple(vals); } +%#if PY_VERSION_HEX >= 0x03000000 + else if(PyUnicode_Check(tupl)) + { + Py_ssize_t sz=PyUnicode_GET_LENGTH(tupl); + std::vector vals(sz); + std::copy(PyUnicode_AsUTF8(tupl),PyUnicode_AsUTF8(tupl)+sz,vals.begin()); + return self->presenceOfTuple(vals); + } +%#endif else throw INTERP_KERNEL::Exception("DataArrayAsciiChar::presenceOfTuple : only strings in input supported !"); } @@ -5518,6 +5545,15 @@ namespace MEDCoupling std::copy(PyString_AsString(vals),PyString_AsString(vals)+sz,vals2.begin()); return self->presenceOfValue(vals2); } +%#if PY_VERSION_HEX >= 0x03000000 + if(PyUnicode_Check(vals)) + { + Py_ssize_t sz=PyUnicode_GET_LENGTH(vals); + std::vector vals2(sz); + std::copy(PyUnicode_AsUTF8(vals),PyUnicode_AsUTF8(vals)+sz,vals2.begin()); + return self->presenceOfValue(vals2); + } +%#endif else throw INTERP_KERNEL::Exception("DataArrayAsciiChar::presenceOfValue : only strings in input supported !"); } @@ -5531,6 +5567,15 @@ namespace MEDCoupling std::copy(PyString_AsString(vals),PyString_AsString(vals)+sz,vals2.begin()); return self->findIdFirstEqual(vals2); } +%#if PY_VERSION_HEX >= 0x03000000 + if(PyUnicode_Check(vals)) + { + Py_ssize_t sz=PyUnicode_GET_LENGTH(vals); + std::vector vals2(sz); + std::copy(PyUnicode_AsUTF8(vals),PyUnicode_AsUTF8(vals)+sz,vals2.begin()); + return self->findIdFirstEqual(vals2); + } +%#endif else throw INTERP_KERNEL::Exception("DataArrayAsciiChar::findIdFirstEqual : only strings in input supported !"); } @@ -5544,6 +5589,15 @@ namespace MEDCoupling std::copy(PyString_AsString(tupl),PyString_AsString(tupl)+sz,vals.begin()); return self->findIdFirstEqualTuple(vals); } +%#if PY_VERSION_HEX >= 0x03000000 + if(PyUnicode_Check(tupl)) + { + Py_ssize_t sz=PyUnicode_GET_LENGTH(tupl); + std::vector vals(sz); + std::copy(PyUnicode_AsUTF8(tupl),PyUnicode_AsUTF8(tupl)+sz,vals.begin()); + return self->findIdFirstEqualTuple(vals); + } +%#endif else throw INTERP_KERNEL::Exception("DataArrayAsciiChar::findIdFirstEqualTuple : only strings in input supported !"); } @@ -5557,6 +5611,15 @@ namespace MEDCoupling std::copy(PyString_AsString(strOrListOfInt),PyString_AsString(strOrListOfInt)+sz,vals.begin()); return self->findIdSequence(vals); } +%#if PY_VERSION_HEX >= 0x03000000 + else if(PyUnicode_Check(strOrListOfInt)) + { + Py_ssize_t sz=PyUnicode_GET_LENGTH(strOrListOfInt); + std::vector vals(sz); + std::copy(PyUnicode_AsUTF8(strOrListOfInt),PyUnicode_AsUTF8(strOrListOfInt)+sz,vals.begin()); + return self->findIdSequence(vals); + } +%#endif else throw INTERP_KERNEL::Exception("DataArrayAsciiChar::search : only strings in input supported !"); } @@ -5607,6 +5670,17 @@ namespace MEDCoupling else throw INTERP_KERNEL::Exception("DataArrayAsciiChar::index : 'this' contains one component and trying to find a string with size different from 1 !"); } +%#if PY_VERSION_HEX >= 0x03000000 + if(PyUnicode_Check(obj)) + { + Py_ssize_t sz; + char *pt=PyUnicode_AsUTF8AndSize(obj, &sz); + if(sz==1) + return self->findIdFirstEqual(pt[0]); + else + throw INTERP_KERNEL::Exception("DataArrayAsciiChar::index : 'this' contains one component and trying to find a string with size different from 1 !"); + } +%#endif else throw INTERP_KERNEL::Exception("DataArrayAsciiChar::index : 'this' contains one component and trying to find an element which is not an integer !"); } @@ -5633,6 +5707,17 @@ namespace MEDCoupling else throw INTERP_KERNEL::Exception("DataArrayAsciiChar::__contains__ : 'this' contains one component and trying to find a string with size different from 1 !"); } +%#if PY_VERSION_HEX >= 0x03000000 + if(PyUnicode_Check(obj)) + { + Py_ssize_t sz; + char *pt=PyUnicode_AsUTF8AndSize(obj, &sz); + if(sz==1) + return self->presenceOfValue(pt[0]); + else + throw INTERP_KERNEL::Exception("DataArrayAsciiChar::__contains__ : 'this' contains one component and trying to find a string with size different from 1 !"); + } +%#endif else throw INTERP_KERNEL::Exception("DataArrayAsciiChar::__contains__ : 'this' contains one component and trying to find an element which is not an integer !"); } @@ -5865,3 +5950,32 @@ namespace MEDCoupling } }; } + +%pythoncode %{ +def MEDCouplingStdReduceFunct(cls,params): + a,b=params + ret=object.__new__(cls) + ret.__init__(*a) + ret.__setstate__(b) + return ret + +def MEDCouplingDataArrayDoubleReduce(self): + if not MEDCouplingHasNumPyBindings(): + raise InterpKernelException("PyWrap of DataArrayDouble.__reduce__ : not implemented because numpy is not active in your configuration ! No serialization/unserialization available without numpy !") + return MEDCouplingStdReduceFunct,(DataArrayDouble,((self.toNumPyArray(),),(self.__getstate__()),)) + +def MEDCouplingDataArrayIntReduce(self): + if not MEDCouplingHasNumPyBindings(): + raise InterpKernelException("PyWrap of DataArrayInt.__reduce__ : not implemented because numpy is not active in your configuration ! No serialization/unserialization available without numpy !") + return MEDCouplingStdReduceFunct,(DataArrayInt,((self.toNumPyArray(),),(self.__getstate__()),)) + +def MEDCouplingDataArrayByteReduce(self): + if not MEDCouplingHasNumPyBindings(): + raise InterpKernelException("PyWrap of DataArrayByte.__reduce__ : not implemented because numpy is not active in your configuration ! No serialization/unserialization available without numpy !") + return MEDCouplingStdReduceFunct,(DataArrayByte,((self.toNumPyArray(),),(self.__getstate__()),)) + +def MEDCouplingDataArrayFloatReduce(self): + if not MEDCouplingHasNumPyBindings(): + raise InterpKernelException("PyWrap of DataArrayFloat.__reduce__ : not implemented because numpy is not active in your configuration ! No serialization/unserialization available without numpy !") + return MEDCouplingStdReduceFunct,(DataArrayFloat,((self.toNumPyArray(),),(self.__getstate__()),)) +%}