From: Anthony Geay Date: Mon, 2 Mar 2015 10:04:33 +0000 (+0100) Subject: Pickelization of (squashed merge of agy/PyPickelingOfMCObj) : X-Git-Tag: V7_6_0a1~8 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=bc7f96d177083a4d1172f0b686a73d2e95bba3e2;p=modules%2Fmed.git Pickelization of (squashed merge of agy/PyPickelingOfMCObj) : - DataArrayDouble, DataArrayInt - MEDCouplingUMesh, MEDCoupling1SGTUMesh, MEDCoupling1DGTUMesh, MEDCouplingCMesh, MEDCouplingIMesh, MEDCouplingCurveLinearMesh, MEDCouplingExtrudedMesh - MEDCouplingFieldDouble - InterpKernelException For multiprocessing users and to ease exchange of data across PyNodes in YACS. --- diff --git a/src/MEDCalculator/Swig/MEDCalculator.i b/src/MEDCalculator/Swig/MEDCalculator.i index d33d669b5..b5e287a87 100644 --- a/src/MEDCalculator/Swig/MEDCalculator.i +++ b/src/MEDCalculator/Swig/MEDCalculator.i @@ -315,6 +315,9 @@ namespace ParaMEDMEM } %pythoncode %{ +def ParaMEDMEMDataArrayDoublenew(cls,*args): + import _MEDCalculator + return _MEDCalculator.DataArrayDouble____new___(cls,args) def ParaMEDMEMDataArrayDoubleIadd(self,*args): import _MEDCalculator return _MEDCalculator.DataArrayDouble____iadd___(self, self, *args) @@ -342,6 +345,9 @@ def ParaMEDMEMDataArrayDoubleTupleImul(self,*args): def ParaMEDMEMDataArrayDoubleTupleIdiv(self,*args): import _MEDCalculator return _MEDCalculator.DataArrayDoubleTuple____idiv___(self, self, *args) +def ParaMEDMEMMEDCouplingFieldDoublenew(cls,*args): + import _MEDCalculator + return _MEDCalculator.MEDCouplingFieldDouble____new___(cls,args) def ParaMEDMEMMEDCouplingFieldDoubleIadd(self,*args): import _MEDCalculator return _MEDCalculator.MEDCouplingFieldDouble____iadd___(self, self, *args) @@ -357,6 +363,9 @@ def ParaMEDMEMMEDCouplingFieldDoubleIdiv(self,*args): def ParaMEDMEMMEDCouplingFieldDoubleIpow(self,*args): import _MEDCalculator return _MEDCalculator.MEDCouplingFieldDouble____ipow___(self, self, *args) +def ParaMEDMEMDataArrayIntnew(cls,*args): + import _MEDCalculator + return _MEDCalculator.DataArrayInt____new___(cls,args) def ParaMEDMEMDataArrayIntIadd(self,*args): import _MEDCalculator return _MEDCalculator.DataArrayInt____iadd___(self, self, *args) @@ -390,6 +399,33 @@ def ParaMEDMEMDataArrayIntTupleIdiv(self,*args): def ParaMEDMEMDataArrayIntTupleImod(self,*args): import _MEDCalculator return _MEDCalculator.DataArrayIntTuple____imod___(self, self, *args) +def ParaMEDMEMDenseMatrixIadd(self,*args): + import _MEDCalculator + return _MEDCalculator.DenseMatrix____iadd___(self, self, *args) +def ParaMEDMEMDenseMatrixIsub(self,*args): + import _MEDCalculator + return _MEDCalculator.DenseMatrix____isub___(self, self, *args) +def ParaMEDMEMMEDCouplingUMeshnew(cls,*args): + import _MEDCalculator + return _MEDCalculator.MEDCouplingUMesh____new___(cls,args) +def ParaMEDMEMMEDCoupling1DGTUMeshnew(cls,*args): + import _MEDCalculator + return _MEDCalculator.MEDCoupling1DGTUMesh____new___(cls,args) +def ParaMEDMEMMEDCoupling1SGTUMeshnew(cls,*args): + import _MEDCalculator + return _MEDCalculator.MEDCoupling1SGTUMesh____new___(cls,args) +def ParaMEDMEMMEDCouplingCurveLinearMeshnew(cls,*args): + import _MEDCalculator + return _MEDCalculator.MEDCouplingCurveLinearMesh____new___(cls,args) +def ParaMEDMEMMEDCouplingCMeshnew(cls,*args): + import _MEDCalculator + return _MEDCalculator.MEDCouplingCMesh____new___(cls,args) +def ParaMEDMEMMEDCouplingIMeshnew(cls,*args): + import _MEDCalculator + return _MEDCalculator.MEDCouplingIMesh____new___(cls,args) +def ParaMEDMEMMEDCouplingExtrudedMeshnew(cls,*args): + import _MEDCalculator + return _MEDCalculator.MEDCouplingExtrudedMesh____new___(cls,args) %} %include "MEDCouplingFinalize.i" diff --git a/src/MEDCoupling/MEDCouplingFieldDiscretization.cxx b/src/MEDCoupling/MEDCouplingFieldDiscretization.cxx index aed5885e0..0be106c75 100644 --- a/src/MEDCoupling/MEDCouplingFieldDiscretization.cxx +++ b/src/MEDCoupling/MEDCouplingFieldDiscretization.cxx @@ -347,6 +347,13 @@ void MEDCouplingFieldDiscretization::resizeForUnserialization(const std::vector< arr=0; } +/*! + * Empty : Not a bug + */ +void MEDCouplingFieldDiscretization::checkForUnserialization(const std::vector& tinyInfo, const DataArrayInt *arr) +{ +} + /*! * Empty : Not a bug */ @@ -1609,18 +1616,24 @@ void MEDCouplingFieldDiscretizationGauss::resizeForUnserialization(const std::ve else _discr_per_cell=0; arr=_discr_per_cell; - int nbOfLoc=tinyInfo[1]; - _loc.clear(); - int dim=tinyInfo[2]; - int delta=-1; - if(nbOfLoc>0) - delta=((int)tinyInfo.size()-3)/nbOfLoc; - for(int i=0;i& tinyInfo, const DataArrayInt *arr) +{ + static const char MSG[]="MEDCouplingFieldDiscretizationGauss::checkForUnserialization : expect to have one not null DataArrayInt !"; + int val=tinyInfo[0]; + if(val>=0) { - std::vector tmp(tinyInfo.begin()+3+i*delta,tinyInfo.begin()+3+(i+1)*delta); - MEDCouplingGaussLocalization elt=MEDCouplingGaussLocalization::BuildNewInstanceFromTinyInfo(dim,tmp); - _loc.push_back(elt); + if(!arr) + throw INTERP_KERNEL::Exception(MSG); + arr->checkNbOfTuplesAndComp(val,1,MSG); + _discr_per_cell=const_cast(arr); + _discr_per_cell->incrRef(); } + else + _discr_per_cell=0; + commonUnserialization(tinyInfo); } void MEDCouplingFieldDiscretizationGauss::finishUnserialization(const std::vector& tinyInfo) @@ -2061,6 +2074,22 @@ void MEDCouplingFieldDiscretizationGauss::zipGaussLocalizations() _loc=tmpLoc; } +void MEDCouplingFieldDiscretizationGauss::commonUnserialization(const std::vector& tinyInfo) +{ + int nbOfLoc=tinyInfo[1]; + _loc.clear(); + int dim=tinyInfo[2]; + int delta=-1; + if(nbOfLoc>0) + delta=((int)tinyInfo.size()-3)/nbOfLoc; + for(int i=0;i tmp(tinyInfo.begin()+3+i*delta,tinyInfo.begin()+3+(i+1)*delta); + MEDCouplingGaussLocalization elt=MEDCouplingGaussLocalization::BuildNewInstanceFromTinyInfo(dim,tmp); + _loc.push_back(elt); + } +} + MEDCouplingFieldDiscretizationGaussNE::MEDCouplingFieldDiscretizationGaussNE() { } diff --git a/src/MEDCoupling/MEDCouplingFieldDiscretization.hxx b/src/MEDCoupling/MEDCouplingFieldDiscretization.hxx index bf369faed..e4868efe4 100644 --- a/src/MEDCoupling/MEDCouplingFieldDiscretization.hxx +++ b/src/MEDCoupling/MEDCouplingFieldDiscretization.hxx @@ -92,6 +92,7 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT virtual void getTinySerializationDbleInformation(std::vector& tinyInfo) const; MEDCOUPLING_EXPORT virtual void finishUnserialization(const std::vector& tinyInfo); MEDCOUPLING_EXPORT virtual void resizeForUnserialization(const std::vector& tinyInfo, DataArrayInt *& arr); + MEDCOUPLING_EXPORT virtual void checkForUnserialization(const std::vector& tinyInfo, const DataArrayInt *arr); MEDCOUPLING_EXPORT virtual void setGaussLocalizationOnType(const MEDCouplingMesh *m, INTERP_KERNEL::NormalizedCellType type, const std::vector& refCoo, const std::vector& gsCoo, const std::vector& wg); MEDCOUPLING_EXPORT virtual void setGaussLocalizationOnCells(const MEDCouplingMesh *m, const int *begin, const int *end, const std::vector& refCoo, @@ -251,6 +252,7 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT void finishUnserialization(const std::vector& tinyInfo); MEDCOUPLING_EXPORT void getSerializationIntArray(DataArrayInt *& arr) const; MEDCOUPLING_EXPORT void resizeForUnserialization(const std::vector& tinyInfo, DataArrayInt *& arr); + MEDCOUPLING_EXPORT void checkForUnserialization(const std::vector& tinyInfo, const DataArrayInt *arr); MEDCOUPLING_EXPORT double getIJK(const MEDCouplingMesh *mesh, const DataArrayDouble *da, int cellId, int nodeIdInCell, int compoId) const; MEDCOUPLING_EXPORT void checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArray *da) const; MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getMeasureField(const MEDCouplingMesh *mesh, bool isAbs) const; @@ -285,6 +287,7 @@ namespace ParaMEDMEM void zipGaussLocalizations(); int getOffsetOfCell(int cellId) const; void checkLocalizationId(int locId) const; + void commonUnserialization(const std::vector& tinyInfo); public: static const char REPR[]; static const TypeOfField TYPE; diff --git a/src/MEDCoupling/MEDCouplingFieldDouble.cxx b/src/MEDCoupling/MEDCouplingFieldDouble.cxx index 984769723..3fbd09d47 100644 --- a/src/MEDCoupling/MEDCouplingFieldDouble.cxx +++ b/src/MEDCoupling/MEDCouplingFieldDouble.cxx @@ -2088,6 +2088,7 @@ void MEDCouplingFieldDouble::getTinySerializationDbleInformation(std::vector& tinyInfoI, DataArrayInt *&dataInt, std::vector& arrays) { @@ -2104,6 +2105,25 @@ void MEDCouplingFieldDouble::resizeForUnserialization(const std::vector& ti _type->resizeForUnserialization(tinyInfoITmp3,dataInt); } +/*! + * This method is extremely close to resizeForUnserialization except that here the arrays in \a dataInt and in \a arrays are attached in \a this + * after having checked that size is correct. This method is used in python pickeling context to avoid copy of data. + * \sa resizeForUnserialization + */ +void MEDCouplingFieldDouble::checkForUnserialization(const std::vector& tinyInfoI, const DataArrayInt *dataInt, const std::vector& arrays) +{ + if(!((const MEDCouplingFieldDiscretization *)_type)) + throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform resizeForUnserialization !"); + std::vector tinyInfoITmp(tinyInfoI); + int sz=tinyInfoITmp.back(); + tinyInfoITmp.pop_back(); + std::vector tinyInfoITmp2(tinyInfoITmp.begin(),tinyInfoITmp.end()-sz); + std::vector tinyInfoI2(tinyInfoITmp2.begin()+3,tinyInfoITmp2.end()); + _time_discr->checkForUnserialization(tinyInfoI2,arrays); + std::vector tinyInfoITmp3(tinyInfoITmp.end()-sz,tinyInfoITmp.end()); + _type->checkForUnserialization(tinyInfoITmp3,dataInt); +} + void MEDCouplingFieldDouble::finishUnserialization(const std::vector& tinyInfoI, const std::vector& tinyInfoD, const std::vector& tinyInfoS) { if(!((const MEDCouplingFieldDiscretization *)_type)) diff --git a/src/MEDCoupling/MEDCouplingFieldDouble.hxx b/src/MEDCoupling/MEDCouplingFieldDouble.hxx index b62dd66e6..ee9a2506a 100644 --- a/src/MEDCoupling/MEDCouplingFieldDouble.hxx +++ b/src/MEDCoupling/MEDCouplingFieldDouble.hxx @@ -140,6 +140,7 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT void getTinySerializationDbleInformation(std::vector& tinyInfo) const; MEDCOUPLING_EXPORT void getTinySerializationStrInformation(std::vector& tinyInfo) const; MEDCOUPLING_EXPORT void resizeForUnserialization(const std::vector& tinyInfoI, DataArrayInt *&dataInt, std::vector& arrays); + MEDCOUPLING_EXPORT void checkForUnserialization(const std::vector& tinyInfoI, const DataArrayInt *dataInt, const std::vector& arrays); MEDCOUPLING_EXPORT void finishUnserialization(const std::vector& tinyInfoI, const std::vector& tinyInfoD, const std::vector& tinyInfoS); MEDCOUPLING_EXPORT void serialize(DataArrayInt *&dataInt, std::vector& arrays) const; // diff --git a/src/MEDCoupling/MEDCouplingTimeDiscretization.cxx b/src/MEDCoupling/MEDCouplingTimeDiscretization.cxx index 6cff3a51b..cb456a024 100644 --- a/src/MEDCoupling/MEDCouplingTimeDiscretization.cxx +++ b/src/MEDCoupling/MEDCouplingTimeDiscretization.cxx @@ -258,6 +258,24 @@ void MEDCouplingTimeDiscretization::resizeForUnserialization(const std::vector& tinyInfoI, const std::vector& arrays) +{ + static const char MSG[]="MEDCouplingTimeDiscretization::checkForUnserialization : arrays in input is expected to have size one !"; + if(arrays.size()!=1) + throw INTERP_KERNEL::Exception(MSG); + if(_array!=0) + _array->decrRef(); + _array=0; + if(tinyInfoI[0]!=-1 && tinyInfoI[1]!=-1) + { + if(!arrays[0]) + throw INTERP_KERNEL::Exception(MSG); + arrays[0]->checkNbOfTuplesAndComp(tinyInfoI[0],tinyInfoI[1],MSG); + _array=arrays[0]; + _array->incrRef(); + } +} + void MEDCouplingTimeDiscretization::finishUnserialization(const std::vector& tinyInfoI, const std::vector& tinyInfoD, const std::vector& tinyInfoS) { _time_tolerance=tinyInfoD[0]; @@ -2465,6 +2483,32 @@ void MEDCouplingTwoTimeSteps::resizeForUnserialization(const std::vector& t arrays[1]=arr; } +void MEDCouplingTwoTimeSteps::checkForUnserialization(const std::vector& tinyInfoI, const std::vector& arrays) +{ + static const char MSG[]="MEDCouplingTimeDiscretization::checkForUnserialization : arrays in input is expected to have size two !"; + if(arrays.size()!=2) + throw INTERP_KERNEL::Exception(MSG); + if(_array!=0) + _array->decrRef(); + if(_end_array!=0) + _end_array->decrRef(); + _array=0; _end_array=0; + if(tinyInfoI[0]!=-1 && tinyInfoI[1]!=-1) + { + if(!arrays[0]) + throw INTERP_KERNEL::Exception(MSG); + arrays[0]->checkNbOfTuplesAndComp(tinyInfoI[0],tinyInfoI[1],MSG); + _array=arrays[0]; _array->incrRef(); + } + if(tinyInfoI[6]!=-1 && tinyInfoI[7]!=-1) + { + if(!arrays[1]) + throw INTERP_KERNEL::Exception(MSG); + arrays[1]->checkNbOfTuplesAndComp(tinyInfoI[0],tinyInfoI[1],MSG); + _end_array=arrays[1]; _end_array->incrRef(); + } +} + void MEDCouplingTwoTimeSteps::finishUnserialization(const std::vector& tinyInfoI, const std::vector& tinyInfoD, const std::vector& tinyInfoS) { MEDCouplingTimeDiscretization::finishUnserialization(tinyInfoI,tinyInfoD,tinyInfoS); diff --git a/src/MEDCoupling/MEDCouplingTimeDiscretization.hxx b/src/MEDCoupling/MEDCouplingTimeDiscretization.hxx index 91fde2e43..3bf7b82ad 100644 --- a/src/MEDCoupling/MEDCouplingTimeDiscretization.hxx +++ b/src/MEDCoupling/MEDCouplingTimeDiscretization.hxx @@ -82,6 +82,7 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT virtual void getTinySerializationDbleInformation(std::vector& tinyInfo) const; MEDCOUPLING_EXPORT virtual void getTinySerializationStrInformation(std::vector& tinyInfo) const; MEDCOUPLING_EXPORT virtual void resizeForUnserialization(const std::vector& tinyInfoI, std::vector& arrays); + MEDCOUPLING_EXPORT virtual void checkForUnserialization(const std::vector& tinyInfoI, const std::vector& arrays); MEDCOUPLING_EXPORT virtual void finishUnserialization(const std::vector& tinyInfoI, const std::vector& tinyInfoD, const std::vector& tinyInfoS); MEDCOUPLING_EXPORT virtual void getTinySerializationIntInformation2(std::vector& tinyInfo) const = 0; MEDCOUPLING_EXPORT virtual void getTinySerializationDbleInformation2(std::vector& tinyInfo) const = 0; @@ -396,6 +397,7 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT void getTinySerializationDbleInformation(std::vector& tinyInfo) const; MEDCOUPLING_EXPORT void getTinySerializationStrInformation(std::vector& tinyInfo) const; MEDCOUPLING_EXPORT void resizeForUnserialization(const std::vector& tinyInfoI, std::vector& arrays); + MEDCOUPLING_EXPORT void checkForUnserialization(const std::vector& tinyInfoI, const std::vector& arrays); MEDCOUPLING_EXPORT void finishUnserialization(const std::vector& tinyInfoI, const std::vector& tinyInfoD, const std::vector& tinyInfoS); MEDCOUPLING_EXPORT void getTinySerializationIntInformation2(std::vector& tinyInfo) const; MEDCOUPLING_EXPORT void getTinySerializationDbleInformation2(std::vector& tinyInfo) const; diff --git a/src/MEDCouplingCorba_Swig/Client/MEDCouplingClient.i b/src/MEDCouplingCorba_Swig/Client/MEDCouplingClient.i index 726bbb263..ab8ba1476 100644 --- a/src/MEDCouplingCorba_Swig/Client/MEDCouplingClient.i +++ b/src/MEDCouplingCorba_Swig/Client/MEDCouplingClient.i @@ -555,6 +555,9 @@ namespace ParaMEDMEM } %pythoncode %{ +def ParaMEDMEMDataArrayDoublenew(cls,*args): + import _MEDCouplingClient + return _MEDCouplingClient.DataArrayDouble____new___(cls,args) def ParaMEDMEMDataArrayDoubleIadd(self,*args): import _MEDCouplingClient return _MEDCouplingClient.DataArrayDouble____iadd___(self, self, *args) @@ -570,6 +573,9 @@ def ParaMEDMEMDataArrayDoubleIdiv(self,*args): def ParaMEDMEMDataArrayDoubleIpow(self,*args): import _MEDCouplingClient return _MEDCouplingClient.DataArrayDouble____ipow___(self, self, *args) +def ParaMEDMEMMEDCouplingFieldDoublenew(cls,*args): + import _MEDCouplingClient + return _MEDCouplingClient.MEDCouplingFieldDouble____new___(cls,args) def ParaMEDMEMMEDCouplingFieldDoubleIadd(self,*args): import _MEDCouplingClient return _MEDCouplingClient.MEDCouplingFieldDouble____iadd___(self, self, *args) @@ -585,6 +591,9 @@ def ParaMEDMEMMEDCouplingFieldDoubleIdiv(self,*args): def ParaMEDMEMMEDCouplingFieldDoubleIpow(self,*args): import _MEDCouplingClient return _MEDCouplingClient.MEDCouplingFieldDouble____ipow___(self, self, *args) +def ParaMEDMEMDataArrayIntnew(cls,*args): + import _MEDCouplingClient + return _MEDCouplingClient.DataArrayInt____new___(cls,args) def ParaMEDMEMDataArrayIntIadd(self,*args): import _MEDCouplingClient return _MEDCouplingClient.DataArrayInt____iadd___(self, self, *args) @@ -636,6 +645,27 @@ def ParaMEDMEMDenseMatrixIadd(self,*args): def ParaMEDMEMDenseMatrixIsub(self,*args): import _MEDCouplingClient return _MEDCouplingClient.DenseMatrix____isub___(self, self, *args) +def ParaMEDMEMMEDCouplingUMeshnew(cls,*args): + import _MEDCouplingClient + return _MEDCouplingClient.MEDCouplingUMesh____new___(cls,args) +def ParaMEDMEMMEDCoupling1DGTUMeshnew(cls,*args): + import _MEDCouplingClient + return _MEDCouplingClient.MEDCoupling1DGTUMesh____new___(cls,args) +def ParaMEDMEMMEDCoupling1SGTUMeshnew(cls,*args): + import _MEDCouplingClient + return _MEDCouplingClient.MEDCoupling1SGTUMesh____new___(cls,args) +def ParaMEDMEMMEDCouplingCurveLinearMeshnew(cls,*args): + import _MEDCouplingClient + return _MEDCouplingClient.MEDCouplingCurveLinearMesh____new___(cls,args) +def ParaMEDMEMMEDCouplingCMeshnew(cls,*args): + import _MEDCouplingClient + return _MEDCouplingClient.MEDCouplingCMesh____new___(cls,args) +def ParaMEDMEMMEDCouplingIMeshnew(cls,*args): + import _MEDCouplingClient + return _MEDCouplingClient.MEDCouplingIMesh____new___(cls,args) +def ParaMEDMEMMEDCouplingExtrudedMeshnew(cls,*args): + import _MEDCouplingClient + return _MEDCouplingClient.MEDCouplingExtrudedMesh____new___(cls,args) %} %include "MEDCouplingFinalize.i" diff --git a/src/MEDCouplingCorba_Swig/MEDCouplingCorba.i b/src/MEDCouplingCorba_Swig/MEDCouplingCorba.i index 3ca70dcbd..a57298512 100644 --- a/src/MEDCouplingCorba_Swig/MEDCouplingCorba.i +++ b/src/MEDCouplingCorba_Swig/MEDCouplingCorba.i @@ -315,6 +315,9 @@ namespace ParaMEDMEM } %pythoncode %{ +def ParaMEDMEMDataArrayDoublenew(cls,*args): + import _MEDCouplingCorba + return _MEDCouplingCorba.DataArrayDouble____new___(cls,args) def ParaMEDMEMDataArrayDoubleIadd(self,*args): import _MEDCouplingCorba return _MEDCouplingCorba.DataArrayDouble____iadd___(self, self, *args) @@ -330,6 +333,9 @@ def ParaMEDMEMDataArrayDoubleIdiv(self,*args): def ParaMEDMEMDataArrayDoubleIpow(self,*args): import _MEDCouplingCorba return _MEDCouplingCorba.DataArrayDouble____ipow___(self, self, *args) +def ParaMEDMEMMEDCouplingFieldDoublenew(cls,*args): + import _MEDCouplingCorba + return _MEDCouplingCorba.MEDCouplingFieldDouble____new___(cls,args) def ParaMEDMEMMEDCouplingFieldDoubleIadd(self,*args): import _MEDCouplingCorba return _MEDCouplingCorba.MEDCouplingFieldDouble____iadd___(self, self, *args) @@ -345,6 +351,9 @@ def ParaMEDMEMMEDCouplingFieldDoubleIdiv(self,*args): def ParaMEDMEMMEDCouplingFieldDoubleIpow(self,*args): import _MEDCouplingCorba return _MEDCouplingCorba.MEDCouplingFieldDouble____ipow___(self, self, *args) +def ParaMEDMEMDataArrayIntnew(cls,*args): + import _MEDCouplingCorba + return _MEDCouplingCorba.DataArrayInt____new___(cls,args) def ParaMEDMEMDataArrayIntIadd(self,*args): import _MEDCouplingCorba return _MEDCouplingCorba.DataArrayInt____iadd___(self, self, *args) @@ -396,6 +405,27 @@ def ParaMEDMEMDenseMatrixIadd(self,*args): def ParaMEDMEMDenseMatrixIsub(self,*args): import _MEDCouplingCorba return _MEDCouplingCorba.DenseMatrix____isub___(self, self, *args) +def ParaMEDMEMMEDCouplingUMeshnew(cls,*args): + import _MEDCouplingCorba + return _MEDCouplingCorba.MEDCouplingUMesh____new___(cls,args) +def ParaMEDMEMMEDCoupling1DGTUMeshnew(cls,*args): + import _MEDCouplingCorba + return _MEDCouplingCorba.MEDCoupling1DGTUMesh____new___(cls,args) +def ParaMEDMEMMEDCoupling1SGTUMeshnew(cls,*args): + import _MEDCouplingCorba + return _MEDCouplingCorba.MEDCoupling1SGTUMesh____new___(cls,args) +def ParaMEDMEMMEDCouplingCurveLinearMeshnew(cls,*args): + import _MEDCouplingCorba + return _MEDCouplingCorba.MEDCouplingCurveLinearMesh____new___(cls,args) +def ParaMEDMEMMEDCouplingCMeshnew(cls,*args): + import _MEDCouplingCorba + return _MEDCouplingCorba.MEDCouplingCMesh____new___(cls,args) +def ParaMEDMEMMEDCouplingIMeshnew(cls,*args): + import _MEDCouplingCorba + return _MEDCouplingCorba.MEDCouplingIMesh____new___(cls,args) +def ParaMEDMEMMEDCouplingExtrudedMeshnew(cls,*args): + import _MEDCouplingCorba + return _MEDCouplingCorba.MEDCouplingExtrudedMesh____new___(cls,args) %} %include "MEDCouplingFinalize.i" diff --git a/src/MEDCoupling_Swig/CMakeLists.txt b/src/MEDCoupling_Swig/CMakeLists.txt index 28c1d951a..108897c53 100644 --- a/src/MEDCoupling_Swig/CMakeLists.txt +++ b/src/MEDCoupling_Swig/CMakeLists.txt @@ -90,4 +90,6 @@ SET_TESTS_PROPERTIES(MEDCouplingRemapperTest PROPERTIES ENVIRONMENT "${tests_env IF(NUMPY_FOUND) ADD_TEST(MEDCouplingNumPyTest ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/MEDCouplingNumPyTest.py) SET_TESTS_PROPERTIES(MEDCouplingNumPyTest PROPERTIES ENVIRONMENT "${tests_env}") + ADD_TEST(MEDCouplingPickleTest ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/MEDCouplingPickleTest.py) + SET_TESTS_PROPERTIES(MEDCouplingPickleTest PROPERTIES ENVIRONMENT "${tests_env}") ENDIF(NUMPY_FOUND) diff --git a/src/MEDCoupling_Swig/MEDCoupling.i b/src/MEDCoupling_Swig/MEDCoupling.i index 577c576ce..d6450452e 100644 --- a/src/MEDCoupling_Swig/MEDCoupling.i +++ b/src/MEDCoupling_Swig/MEDCoupling.i @@ -20,6 +20,9 @@ %include "MEDCouplingCommon.i" %pythoncode %{ +def ParaMEDMEMDataArrayDoublenew(cls,*args): + import _MEDCoupling + return _MEDCoupling.DataArrayDouble____new___(cls,args) def ParaMEDMEMDataArrayDoubleIadd(self,*args): import _MEDCoupling return _MEDCoupling.DataArrayDouble____iadd___(self, self, *args) @@ -35,6 +38,9 @@ def ParaMEDMEMDataArrayDoubleIdiv(self,*args): def ParaMEDMEMDataArrayDoubleIpow(self,*args): import _MEDCoupling return _MEDCoupling.DataArrayDouble____ipow___(self, self, *args) +def ParaMEDMEMMEDCouplingFieldDoublenew(cls,*args): + import _MEDCoupling + return _MEDCoupling.MEDCouplingFieldDouble____new___(cls,args) def ParaMEDMEMMEDCouplingFieldDoubleIadd(self,*args): import _MEDCoupling return _MEDCoupling.MEDCouplingFieldDouble____iadd___(self, self, *args) @@ -50,6 +56,9 @@ def ParaMEDMEMMEDCouplingFieldDoubleIdiv(self,*args): def ParaMEDMEMMEDCouplingFieldDoubleIpow(self,*args): import _MEDCoupling return _MEDCoupling.MEDCouplingFieldDouble____ipow___(self, self, *args) +def ParaMEDMEMDataArrayIntnew(cls,*args): + import _MEDCoupling + return _MEDCoupling.DataArrayInt____new___(cls,args) def ParaMEDMEMDataArrayIntIadd(self,*args): import _MEDCoupling return _MEDCoupling.DataArrayInt____iadd___(self, self, *args) @@ -101,6 +110,27 @@ def ParaMEDMEMDenseMatrixIadd(self,*args): def ParaMEDMEMDenseMatrixIsub(self,*args): import _MEDCoupling return _MEDCoupling.DenseMatrix____isub___(self, self, *args) +def ParaMEDMEMMEDCouplingUMeshnew(cls,*args): + import _MEDCoupling + return _MEDCoupling.MEDCouplingUMesh____new___(cls,args) +def ParaMEDMEMMEDCoupling1DGTUMeshnew(cls,*args): + import _MEDCoupling + return _MEDCoupling.MEDCoupling1DGTUMesh____new___(cls,args) +def ParaMEDMEMMEDCoupling1SGTUMeshnew(cls,*args): + import _MEDCoupling + return _MEDCoupling.MEDCoupling1SGTUMesh____new___(cls,args) +def ParaMEDMEMMEDCouplingCurveLinearMeshnew(cls,*args): + import _MEDCoupling + return _MEDCoupling.MEDCouplingCurveLinearMesh____new___(cls,args) +def ParaMEDMEMMEDCouplingCMeshnew(cls,*args): + import _MEDCoupling + return _MEDCoupling.MEDCouplingCMesh____new___(cls,args) +def ParaMEDMEMMEDCouplingIMeshnew(cls,*args): + import _MEDCoupling + return _MEDCoupling.MEDCouplingIMesh____new___(cls,args) +def ParaMEDMEMMEDCouplingExtrudedMeshnew(cls,*args): + import _MEDCoupling + return _MEDCoupling.MEDCouplingExtrudedMesh____new___(cls,args) %} %include "MEDCouplingFinalize.i" diff --git a/src/MEDCoupling_Swig/MEDCouplingCommon.i b/src/MEDCoupling_Swig/MEDCouplingCommon.i index 0639745d3..cb242a15b 100644 --- a/src/MEDCoupling_Swig/MEDCouplingCommon.i +++ b/src/MEDCoupling_Swig/MEDCouplingCommon.i @@ -586,6 +586,7 @@ namespace ParaMEDMEM virtual MEDCouplingMesh *mergeMyselfWith(const MEDCouplingMesh *other) const throw(INTERP_KERNEL::Exception); virtual bool areCompatibleForMerge(const MEDCouplingMesh *other) const throw(INTERP_KERNEL::Exception); virtual DataArrayInt *simplexize(int policy) throw(INTERP_KERNEL::Exception); + virtual void unserialization(const std::vector& tinyInfoD, const std::vector& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2, const std::vector& littleStrings) throw(INTERP_KERNEL::Exception); static MEDCouplingMesh *MergeMeshes(const MEDCouplingMesh *mesh1, const MEDCouplingMesh *mesh2) throw(INTERP_KERNEL::Exception); static bool IsStaticGeometricType(INTERP_KERNEL::NormalizedCellType type) throw(INTERP_KERNEL::Exception); static bool IsLinearGeometricType(INTERP_KERNEL::NormalizedCellType type) throw(INTERP_KERNEL::Exception); @@ -610,7 +611,7 @@ namespace ParaMEDMEM PyList_SetItem(res,2,SWIG_From_int(tmp2)); return res; } - + int getCellContainingPoint(PyObject *p, double eps) const throw(INTERP_KERNEL::Exception) { double val; @@ -976,6 +977,102 @@ namespace ParaMEDMEM PyList_SetItem(res,i,PyInt_FromLong(*iL)); return res; } + + virtual PyObject *getTinySerializationInformation() const throw(INTERP_KERNEL::Exception) + { + std::vector a0; + std::vector a1; + std::vector a2; + self->getTinySerializationInformation(a0,a1,a2); + PyObject *ret(PyTuple_New(3)); + PyTuple_SetItem(ret,0,convertDblArrToPyList2(a0)); + PyTuple_SetItem(ret,1,convertIntArrToPyList2(a1)); + int sz(a2.size()); + PyObject *ret2(PyList_New(sz)); + { + for(int i=0;iserialize(a0Tmp,a1Tmp); + PyObject *ret(PyTuple_New(2)); + PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(a0Tmp),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); + PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(a1Tmp),SWIGTYPE_p_ParaMEDMEM__DataArrayDouble, SWIG_POINTER_OWN | 0 )); + return ret; + } + + void resizeForUnserialization(const std::vector& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2) const throw(INTERP_KERNEL::Exception) + { + std::vector littleStrings; + self->resizeForUnserialization(tinyInfo,a1,a2,littleStrings); + } + + PyObject *__getnewargs__() throw(INTERP_KERNEL::Exception) + {// put an empty dict in input to say to __new__ to call __init__... + PyObject *ret(PyTuple_New(1)); + PyObject *ret0(PyDict_New()); + PyTuple_SetItem(ret,0,ret0); + return ret; + } + + PyObject *__getstate__() const throw(INTERP_KERNEL::Exception) + { + PyObject *ret0(ParaMEDMEM_MEDCouplingMesh_getTinySerializationInformation(self)); + PyObject *ret1(ParaMEDMEM_MEDCouplingMesh_serialize(self)); + PyObject *ret(PyTuple_New(2)); + PyTuple_SetItem(ret,0,ret0); + PyTuple_SetItem(ret,1,ret1); + return ret; + } + + void __setstate__(PyObject *inp) throw(INTERP_KERNEL::Exception) + { + static const char MSG[]="MEDCouplingMesh.__setstate__ : expected input is a tuple of size 2 !"; + if(!PyTuple_Check(inp)) + throw INTERP_KERNEL::Exception(MSG); + int sz(PyTuple_Size(inp)); + if(sz!=2) + throw INTERP_KERNEL::Exception(MSG); + PyObject *elt0(PyTuple_GetItem(inp,0)); + PyObject *elt1(PyTuple_GetItem(inp,1)); + std::vector a0; + std::vector a1; + std::vector a2; + DataArrayInt *b0(0); + DataArrayDouble *b1(0); + { + if(!PyTuple_Check(elt0) && PyTuple_Size(elt0)!=3) + throw INTERP_KERNEL::Exception(MSG); + PyObject *a0py(PyTuple_GetItem(elt0,0)),*a1py(PyTuple_GetItem(elt0,1)),*a2py(PyTuple_GetItem(elt0,2)); + int tmp(-1); + fillArrayWithPyListDbl3(a0py,tmp,a0); + convertPyToNewIntArr3(a1py,a1); + fillStringVector(a2py,a2); + } + { + if(!PyTuple_Check(elt1) && PyTuple_Size(elt1)!=2) + throw INTERP_KERNEL::Exception(MSG); + PyObject *b0py(PyTuple_GetItem(elt1,0)),*b1py(PyTuple_GetItem(elt1,1)); + void *argp(0); + int status(SWIG_ConvertPtr(b0py,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayInt,0|0)); + if(!SWIG_IsOK(status)) + throw INTERP_KERNEL::Exception(MSG); + b0=reinterpret_cast(argp); + status=SWIG_ConvertPtr(b1py,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayDouble,0|0); + if(!SWIG_IsOK(status)) + throw INTERP_KERNEL::Exception(MSG); + b1=reinterpret_cast(argp); + } + // useless here to call resizeForUnserialization because arrays are well resized. + self->unserialization(a0,a1,b0,b1,a2); + } static MEDCouplingMesh *MergeMeshes(PyObject *li) throw(INTERP_KERNEL::Exception) { @@ -1704,7 +1801,13 @@ namespace ParaMEDMEM { return MEDCouplingUMesh::New(meshName,meshDim); } - + + // serialization + static PyObject *___new___(PyObject *cls, PyObject *args) throw(INTERP_KERNEL::Exception) + { + return NewMethWrapCallInitOnlyIfEmptyDictInInput(cls,args,"MEDCouplingUMesh"); + } + std::string __str__() const throw(INTERP_KERNEL::Exception) { return self->simpleRepr(); @@ -2672,6 +2775,16 @@ namespace ParaMEDMEM { return MEDCouplingExtrudedMesh::New(mesh3D,mesh2D,cell2DId); } + + MEDCouplingExtrudedMesh() + { + return MEDCouplingExtrudedMesh::New(); + } + + static PyObject *___new___(PyObject *cls, PyObject *args) throw(INTERP_KERNEL::Exception) + { + return NewMethWrapCallInitOnlyIfEmptyDictInInput(cls,args,"MEDCouplingExtrudedMesh"); + } std::string __str__() const throw(INTERP_KERNEL::Exception) { @@ -2762,6 +2875,11 @@ namespace ParaMEDMEM DataArrayInt *sortHexa8EachOther() throw(INTERP_KERNEL::Exception); %extend { + MEDCoupling1SGTUMesh() + { + return MEDCoupling1SGTUMesh::New(); + } + MEDCoupling1SGTUMesh(const std::string& name, INTERP_KERNEL::NormalizedCellType type) throw(INTERP_KERNEL::Exception) { return MEDCoupling1SGTUMesh::New(name,type); @@ -2772,6 +2890,11 @@ namespace ParaMEDMEM return MEDCoupling1SGTUMesh::New(m); } + static PyObject *___new___(PyObject *cls, PyObject *args) throw(INTERP_KERNEL::Exception) + { + return NewMethWrapCallInitOnlyIfEmptyDictInInput(cls,args,"MEDCoupling1SGTUMesh"); + } + std::string __str__() const throw(INTERP_KERNEL::Exception) { return self->simpleRepr(); @@ -2825,6 +2948,10 @@ namespace ParaMEDMEM bool isPacked() const throw(INTERP_KERNEL::Exception); %extend { + MEDCoupling1DGTUMesh() + { + return MEDCoupling1DGTUMesh::New(); + } MEDCoupling1DGTUMesh(const std::string& name, INTERP_KERNEL::NormalizedCellType type) throw(INTERP_KERNEL::Exception) { return MEDCoupling1DGTUMesh::New(name,type); @@ -2835,6 +2962,11 @@ namespace ParaMEDMEM return MEDCoupling1DGTUMesh::New(m); } + static PyObject *___new___(PyObject *cls, PyObject *args) throw(INTERP_KERNEL::Exception) + { + return NewMethWrapCallInitOnlyIfEmptyDictInInput(cls,args,"MEDCoupling1DGTUMesh"); + } + std::string __str__() const throw(INTERP_KERNEL::Exception) { return self->simpleRepr(); @@ -3177,6 +3309,11 @@ namespace ParaMEDMEM { return MEDCouplingCMesh::New(meshName); } + // serialization + static PyObject *___new___(PyObject *cls, PyObject *args) throw(INTERP_KERNEL::Exception) + { + return NewMethWrapCallInitOnlyIfEmptyDictInInput(cls,args,"MEDCouplingCMesh"); + } std::string __str__() const throw(INTERP_KERNEL::Exception) { return self->simpleRepr(); @@ -3217,6 +3354,10 @@ namespace ParaMEDMEM { return MEDCouplingCurveLinearMesh::New(meshName); } + static PyObject *___new___(PyObject *cls, PyObject *args) throw(INTERP_KERNEL::Exception) + { + return NewMethWrapCallInitOnlyIfEmptyDictInInput(cls,args,"MEDCouplingCurveLinearMesh"); + } std::string __str__() const throw(INTERP_KERNEL::Exception) { return self->simpleRepr(); @@ -3294,6 +3435,11 @@ namespace ParaMEDMEM return ParaMEDMEM_MEDCouplingIMesh_New__SWIG_1(meshName,spaceDim,nodeStrct,origin,dxyz); } + static PyObject *___new___(PyObject *cls, PyObject *args) throw(INTERP_KERNEL::Exception) + { + return NewMethWrapCallInitOnlyIfEmptyDictInInput(cls,args,"MEDCouplingIMesh"); + } + void setNodeStruct(PyObject *nodeStrct) throw(INTERP_KERNEL::Exception) { int sw,sz,val0; @@ -4659,6 +4805,160 @@ namespace ParaMEDMEM convertFromPyObjVectorOfObj(li,SWIGTYPE_p_ParaMEDMEM__MEDCouplingFieldDouble,"MEDCouplingFieldDouble",tmp); return MEDCouplingFieldDouble::WriteVTK(fileName,tmp,isBinary); } + + PyObject *getTinySerializationInformation() const throw(INTERP_KERNEL::Exception) + { + std::vector a0; + std::vector a1; + std::vector a2; + self->getTinySerializationDbleInformation(a0); + self->getTinySerializationIntInformation(a1); + self->getTinySerializationStrInformation(a2); + // + PyObject *ret(PyTuple_New(3)); + PyTuple_SetItem(ret,0,convertDblArrToPyList2(a0)); + PyTuple_SetItem(ret,1,convertIntArrToPyList2(a1)); + int sz(a2.size()); + PyObject *ret2(PyList_New(sz)); + { + for(int i=0;i ret1; + self->serialize(ret0,ret1); + if(ret0) + ret0->incrRef(); + std::size_t sz(ret1.size()); + PyObject *ret(PyTuple_New(2)); + PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); + PyObject *ret1Py(PyList_New(sz)); + for(std::size_t i=0;iincrRef(); + PyList_SetItem(ret1Py,i,SWIG_NewPointerObj(SWIG_as_voidptr(ret1[i]),SWIGTYPE_p_ParaMEDMEM__DataArrayDouble, SWIG_POINTER_OWN | 0 )); + } + PyTuple_SetItem(ret,1,ret1Py); + return ret; + } + + static PyObject *___new___(PyObject *cls, PyObject *args) throw(INTERP_KERNEL::Exception) + { + static const char MSG[]="MEDCouplingFieldDouble.__new__ : the args in input is expected to be a tuple !"; + if(!PyTuple_Check(args)) + throw INTERP_KERNEL::Exception(MSG); + PyObject *builtinsd(PyEval_GetBuiltins());//borrowed + PyObject *obj(PyDict_GetItemString(builtinsd,"object"));//borrowed + PyObject *selfMeth(PyObject_GetAttrString(obj,"__new__")); + // + PyObject *tmp0(PyTuple_New(1)); + PyTuple_SetItem(tmp0,0,cls); Py_XINCREF(cls); + PyObject *instance(PyObject_CallObject(selfMeth,tmp0)); + Py_DECREF(tmp0); + Py_DECREF(selfMeth); + if(PyTuple_Size(args)==2 && PyDict_Check(PyTuple_GetItem(args,1)) && PyDict_Size(PyTuple_GetItem(args,1))==1 ) + {// NOT general case. only true if in unpickeling context ! call __init__. Because for all other cases, __init__ is called right after __new__ ! + PyObject *initMeth(PyObject_GetAttrString(instance,"__init__")); + //// + PyObject *a(PyInt_FromLong(0)); + PyObject *uniqueElt(PyDict_GetItem(PyTuple_GetItem(args,1),a)); + Py_DECREF(a); + if(!uniqueElt) + throw INTERP_KERNEL::Exception(MSG); + if(!PyTuple_Check(uniqueElt) || PyTuple_Size(uniqueElt)!=2) + throw INTERP_KERNEL::Exception(MSG); + PyObject *tmp2(PyObject_CallObject(initMeth,uniqueElt)); + Py_XDECREF(tmp2); + //// + Py_DECREF(initMeth); + } + return instance; + } + + PyObject *__getnewargs__() throw(INTERP_KERNEL::Exception) + {// put an empty dict in input to say to __new__ to call __init__... + self->checkCoherency(); + PyObject *ret(PyTuple_New(1)); + PyObject *ret0(PyDict_New()); + { + PyObject *a(PyInt_FromLong(0)),*b(PyInt_FromLong(self->getTypeOfField())),*c(PyInt_FromLong(self->getTimeDiscretization())); + PyObject *d(PyTuple_New(2)); PyTuple_SetItem(d,0,b); PyTuple_SetItem(d,1,c); + PyDict_SetItem(ret0,a,d); + Py_DECREF(a); Py_DECREF(d); + } + PyTuple_SetItem(ret,0,ret0); + return ret; + } + + PyObject *__getstate__() const throw(INTERP_KERNEL::Exception) + { + self->checkCoherency(); + PyObject *ret0(ParaMEDMEM_MEDCouplingFieldDouble_getTinySerializationInformation(self)); + PyObject *ret1(ParaMEDMEM_MEDCouplingFieldDouble_serialize(self)); + const MEDCouplingMesh *mesh(self->getMesh()); + if(mesh) + mesh->incrRef(); + PyObject *ret(PyTuple_New(3)); + PyTuple_SetItem(ret,0,ret0); + PyTuple_SetItem(ret,1,ret1); + PyTuple_SetItem(ret,2,convertMesh(const_cast(mesh),SWIG_POINTER_OWN | 0 )); + return ret; + } + + void __setstate__(PyObject *inp) throw(INTERP_KERNEL::Exception) + { + static const char MSG[]="MEDCouplingFieldDouble.__setstate__ : expected input is a tuple of size 3 !"; + if(!PyTuple_Check(inp)) + throw INTERP_KERNEL::Exception(MSG); + int sz(PyTuple_Size(inp)); + if(sz!=3) + throw INTERP_KERNEL::Exception(MSG); + // mesh + PyObject *elt2(PyTuple_GetItem(inp,2)); + void *argp=0; + int status(SWIG_ConvertPtr(elt2,&argp,SWIGTYPE_p_ParaMEDMEM__MEDCouplingMesh,0|0)); + if(!SWIG_IsOK(status)) + throw INTERP_KERNEL::Exception(MSG); + self->setMesh(reinterpret_cast< const MEDCouplingUMesh * >(argp)); + // + PyObject *elt0(PyTuple_GetItem(inp,0)); + PyObject *elt1(PyTuple_GetItem(inp,1)); + std::vector a0; + std::vector a1; + std::vector a2; + DataArrayInt *b0(0); + std::vectorb1; + { + if(!PyTuple_Check(elt0) && PyTuple_Size(elt0)!=3) + throw INTERP_KERNEL::Exception(MSG); + PyObject *a0py(PyTuple_GetItem(elt0,0)),*a1py(PyTuple_GetItem(elt0,1)),*a2py(PyTuple_GetItem(elt0,2)); + int tmp(-1); + fillArrayWithPyListDbl3(a0py,tmp,a0); + convertPyToNewIntArr3(a1py,a1); + fillStringVector(a2py,a2); + } + { + if(!PyTuple_Check(elt1) && PyTuple_Size(elt1)!=2) + throw INTERP_KERNEL::Exception(MSG); + PyObject *b0py(PyTuple_GetItem(elt1,0)),*b1py(PyTuple_GetItem(elt1,1)); + void *argp(0); + int status(SWIG_ConvertPtr(b0py,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayInt,0|0)); + if(!SWIG_IsOK(status)) + throw INTERP_KERNEL::Exception(MSG); + b0=reinterpret_cast(argp); + convertFromPyObjVectorOfObj(b1py,SWIGTYPE_p_ParaMEDMEM__DataArrayDouble,"DataArrayDouble",b1); + } + self->checkForUnserialization(a1,b0,b1); + // useless here to call resizeForUnserialization because arrays are well resized. + self->finishUnserialization(a1,a0,a2); + } } }; diff --git a/src/MEDCoupling_Swig/MEDCouplingDataArrayTypemaps.i b/src/MEDCoupling_Swig/MEDCouplingDataArrayTypemaps.i index 05722176c..21f462ba0 100644 --- a/src/MEDCoupling_Swig/MEDCouplingDataArrayTypemaps.i +++ b/src/MEDCoupling_Swig/MEDCouplingDataArrayTypemaps.i @@ -82,7 +82,7 @@ void numarrdeal(void *pt, void *wron) { Py_XINCREF(obj); PyArrayObject *objC=reinterpret_cast(obj); - objC->flags|=NPY_OWNDATA; + objC->flags|=NPY_ARRAY_OWNDATA; Py_XDECREF(weakRefOnOwner); Py_XDECREF(obj); } @@ -282,24 +282,36 @@ MCData *BuildNewInstance(PyObject *elt0, int npyObjectType, PyTypeObject *pytype if(PyArray_ISBEHAVED(elt0))//aligned and writeable and in machine byte-order { PyArrayObject *elt0C=reinterpret_cast(elt0); - PyArrayObject *eltOwning=(PyArray_FLAGS(elt0C) & NPY_OWNDATA)?elt0C:NULL; - int mask=NPY_OWNDATA; mask=~mask; + PyArrayObject *eltOwning=(PyArray_FLAGS(elt0C) & NPY_ARRAY_OWNDATA)?elt0C:NULL; + int mask=NPY_ARRAY_OWNDATA; mask=~mask; elt0C->flags&=mask; PyObject *deepestObj=elt0; PyObject *base=elt0C->base; if(base) deepestObj=base; + bool isSpetialCase(false); while(base) { if(PyArray_Check(base)) { PyArrayObject *baseC=reinterpret_cast(base); - eltOwning=(PyArray_FLAGS(baseC) & NPY_OWNDATA)?baseC:eltOwning; + eltOwning=(PyArray_FLAGS(baseC) & NPY_ARRAY_OWNDATA)?baseC:eltOwning; baseC->flags&=mask; base=baseC->base; if(base) deepestObj=base; } else - break; + { + isSpetialCase=true; + break; + } + } + if(isSpetialCase) + {// this case is present for numpy arrayint coming from load of pickelized string. The owner of elt0 is not an array -> A copy is requested. + std::size_t nbOfElems(sz0*sz1); + T *dataCpy=(T*)malloc(sizeof(T)*nbOfElems); + std::copy(reinterpret_cast(data),reinterpret_cast(data)+nbOfElems,dataCpy); + ret->useArray(dataCpy,true,ParaMEDMEM::C_DEALLOC,sz0,sz1); + return ret.retn(); } typename ParaMEDMEM::MemArray& mma=ret->accessToMemArray(); if(eltOwning==NULL) @@ -363,7 +375,7 @@ int NumpyArrSetBaseObjectExt(PyArrayObject *arr, PyObject *obj) /* If this array owns its own data, stop collapsing */ - if (PyArray_CHKFLAGS(obj_arr, NPY_OWNDATA)) { + if (PyArray_CHKFLAGS(obj_arr, NPY_ARRAY_OWNDATA )) { break; } diff --git a/src/MEDCoupling_Swig/MEDCouplingFinalize.i b/src/MEDCoupling_Swig/MEDCouplingFinalize.i index 26097c097..393dec9c8 100644 --- a/src/MEDCoupling_Swig/MEDCouplingFinalize.i +++ b/src/MEDCoupling_Swig/MEDCouplingFinalize.i @@ -18,12 +18,15 @@ // %pythoncode %{ +InterpKernelException.__reduce__=INTERPKERNELExceptionReduce +DataArrayDouble.__new__=classmethod(ParaMEDMEMDataArrayDoublenew) DataArrayDouble.__iadd__=ParaMEDMEMDataArrayDoubleIadd DataArrayDouble.__isub__=ParaMEDMEMDataArrayDoubleIsub DataArrayDouble.__imul__=ParaMEDMEMDataArrayDoubleImul DataArrayDouble.__idiv__=ParaMEDMEMDataArrayDoubleIdiv DataArrayDouble.__ipow__=ParaMEDMEMDataArrayDoubleIpow +DataArrayInt.__new__=classmethod(ParaMEDMEMDataArrayIntnew) DataArrayInt.__iadd__=ParaMEDMEMDataArrayIntIadd DataArrayInt.__isub__=ParaMEDMEMDataArrayIntIsub DataArrayInt.__imul__=ParaMEDMEMDataArrayIntImul @@ -51,6 +54,17 @@ DataArrayIntTuple.__imod__=ParaMEDMEMDataArrayIntTupleImod DenseMatrix.__iadd__=ParaMEDMEMDenseMatrixIadd DenseMatrix.__isub__=ParaMEDMEMDenseMatrixIsub +MEDCouplingUMesh.__new__=classmethod(ParaMEDMEMMEDCouplingUMeshnew) +MEDCoupling1DGTUMesh.__new__=classmethod(ParaMEDMEMMEDCoupling1DGTUMeshnew) +MEDCoupling1SGTUMesh.__new__=classmethod(ParaMEDMEMMEDCoupling1SGTUMeshnew) +MEDCouplingCurveLinearMesh.__new__=classmethod(ParaMEDMEMMEDCouplingCurveLinearMeshnew) +MEDCouplingCMesh.__new__=classmethod(ParaMEDMEMMEDCouplingCMeshnew) +MEDCouplingIMesh.__new__=classmethod(ParaMEDMEMMEDCouplingIMeshnew) +MEDCouplingExtrudedMesh.__new__=classmethod(ParaMEDMEMMEDCouplingExtrudedMeshnew) +MEDCouplingFieldDouble.__new__=classmethod(ParaMEDMEMMEDCouplingFieldDoublenew) + +del INTERPKERNELExceptionReduce +del ParaMEDMEMDataArrayDoublenew del ParaMEDMEMDataArrayDoubleIadd del ParaMEDMEMDataArrayDoubleIsub del ParaMEDMEMDataArrayDoubleImul @@ -60,6 +74,7 @@ del ParaMEDMEMMEDCouplingFieldDoubleIsub del ParaMEDMEMMEDCouplingFieldDoubleImul del ParaMEDMEMMEDCouplingFieldDoubleIdiv del ParaMEDMEMMEDCouplingFieldDoubleIpow +del ParaMEDMEMDataArrayIntnew del ParaMEDMEMDataArrayIntIadd del ParaMEDMEMDataArrayIntIsub del ParaMEDMEMDataArrayIntImul @@ -76,4 +91,12 @@ del ParaMEDMEMDataArrayIntTupleIdiv del ParaMEDMEMDataArrayIntTupleImod del ParaMEDMEMDenseMatrixIadd del ParaMEDMEMDenseMatrixIsub +del ParaMEDMEMMEDCouplingUMeshnew +del ParaMEDMEMMEDCoupling1DGTUMeshnew +del ParaMEDMEMMEDCoupling1SGTUMeshnew +del ParaMEDMEMMEDCouplingCurveLinearMeshnew +del ParaMEDMEMMEDCouplingCMeshnew +del ParaMEDMEMMEDCouplingIMeshnew +del ParaMEDMEMMEDCouplingExtrudedMeshnew +del ParaMEDMEMMEDCouplingFieldDoublenew %} diff --git a/src/MEDCoupling_Swig/MEDCouplingMemArray.i b/src/MEDCoupling_Swig/MEDCouplingMemArray.i index 104f46304..cbf759e94 100644 --- a/src/MEDCoupling_Swig/MEDCouplingMemArray.i +++ b/src/MEDCoupling_Swig/MEDCouplingMemArray.i @@ -476,6 +476,41 @@ namespace ParaMEDMEM GetIndicesOfSlice(sly,self->getNumberOfTuples(),&strt,&stp,&step,"DataArray::getNumberOfItemGivenBESRelative (wrap) : the input slice is invalid !"); return DataArray::GetNumberOfItemGivenBESRelative(strt,stp,step,""); } + + PyObject *__getstate__() const throw(INTERP_KERNEL::Exception) + { + PyObject *ret(PyTuple_New(2)); + std::string a0(self->getName()); + const std::vector &a1(self->getInfoOnComponents()); + PyTuple_SetItem(ret,0,PyString_FromString(a0.c_str())); + // + int sz(a1.size()); + PyObject *ret1(PyList_New(sz)); + for(int i=0;i a1cpp; + if(!fillStringVector(a1,a1cpp)) + throw INTERP_KERNEL::Exception(MSG); + self->setName(PyString_AsString(a0)); + self->setInfoOnComponents(a1cpp); + } } }; @@ -2174,6 +2209,59 @@ namespace ParaMEDMEM PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); return ret; } + + // serialization + static PyObject *___new___(PyObject *cls, PyObject *args) throw(INTERP_KERNEL::Exception) + { + static const char MSG[]="DataArrayDouble.__new__ : the args in input is expected to be a tuple !"; + if(!PyTuple_Check(args)) + throw INTERP_KERNEL::Exception(MSG); + PyObject *builtinsd(PyEval_GetBuiltins());//borrowed + PyObject *obj(PyDict_GetItemString(builtinsd,"object"));//borrowed + PyObject *selfMeth(PyObject_GetAttrString(obj,"__new__")); + // + PyObject *tmp0(PyTuple_New(1)); + PyTuple_SetItem(tmp0,0,cls); Py_XINCREF(cls); + PyObject *instance(PyObject_CallObject(selfMeth,tmp0)); + Py_DECREF(tmp0); + Py_DECREF(selfMeth); + PyObject *initMeth(PyObject_GetAttrString(instance,"__init__")); + int sz(PyTuple_Size(args)); + + if(PyTuple_Size(args)==2 && PyDict_Check(PyTuple_GetItem(args,1)) && PyDict_Size(PyTuple_GetItem(args,1))==1 ) + {// NOT general case. only true if in unpickeling context ! call __init__. Because for all other cases, __init__ is called right after __new__ ! + PyObject *zeNumpyRepr(0); + PyObject *tmp1(PyInt_FromLong(0)); + zeNumpyRepr=PyDict_GetItem(PyTuple_GetItem(args,1),tmp1);//borrowed + Py_DECREF(tmp1); + PyObject *tmp3(PyTuple_New(1)); + PyTuple_SetItem(tmp3,0,zeNumpyRepr); Py_XINCREF(zeNumpyRepr); + PyObject *tmp2(PyObject_CallObject(initMeth,tmp3)); + Py_XDECREF(tmp2); + Py_DECREF(tmp3); + } + Py_DECREF(initMeth); + return instance; + } + + 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(ParaMEDMEM_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 + } } }; @@ -4478,6 +4566,59 @@ namespace ParaMEDMEM PyTuple_SetItem(pyRet,1,ret1Py); return pyRet; } + + // serialization + static PyObject *___new___(PyObject *cls, PyObject *args) throw(INTERP_KERNEL::Exception) + { + static const char MSG[]="DataArrayInt.__new__ : the args in input is expected to be a tuple !"; + if(!PyTuple_Check(args)) + throw INTERP_KERNEL::Exception(MSG); + PyObject *builtinsd(PyEval_GetBuiltins());//borrowed + PyObject *obj(PyDict_GetItemString(builtinsd,"object"));//borrowed + PyObject *selfMeth(PyObject_GetAttrString(obj,"__new__")); + // + PyObject *tmp0(PyTuple_New(1)); + PyTuple_SetItem(tmp0,0,cls); Py_XINCREF(cls); + PyObject *instance(PyObject_CallObject(selfMeth,tmp0)); + Py_DECREF(tmp0); + Py_DECREF(selfMeth); + PyObject *initMeth(PyObject_GetAttrString(instance,"__init__")); + int sz(PyTuple_Size(args)); + + if(PyTuple_Size(args)==2 && PyDict_Check(PyTuple_GetItem(args,1)) && PyDict_Size(PyTuple_GetItem(args,1))==1 ) + {// NOT general case. only true if in unpickeling context ! call __init__. Because for all other cases, __init__ is called right after __new__ ! + PyObject *zeNumpyRepr(0); + PyObject *tmp1(PyInt_FromLong(0)); + zeNumpyRepr=PyDict_GetItem(PyTuple_GetItem(args,1),tmp1);//borrowed + Py_DECREF(tmp1); + PyObject *tmp3(PyTuple_New(1)); + PyTuple_SetItem(tmp3,0,zeNumpyRepr); Py_XINCREF(zeNumpyRepr); + PyObject *tmp2(PyObject_CallObject(initMeth,tmp3)); + Py_XDECREF(tmp2); + Py_DECREF(tmp3); + } + Py_DECREF(initMeth); + return instance; + } + + 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(ParaMEDMEM_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 + } } }; diff --git a/src/MEDCoupling_Swig/MEDCouplingPickleTest.py b/src/MEDCoupling_Swig/MEDCouplingPickleTest.py new file mode 100644 index 000000000..677b11082 --- /dev/null +++ b/src/MEDCoupling_Swig/MEDCouplingPickleTest.py @@ -0,0 +1,300 @@ +# -*- coding: iso-8859-1 -*- +# Copyright (C) 2007-2015 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 +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +from MEDCoupling import * +from MEDCouplingDataForTest import MEDCouplingDataForTest + +if MEDCouplingHasNumPyBindings(): + from numpy import * + pass + +from platform import architecture +from sys import getrefcount + +import os,gc,weakref,cPickle,unittest + +class MEDCouplingPickleTest(unittest.TestCase): + @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy") + def test1(self): + """ Test of a simple DataArrayDouble.""" + x=DataArrayDouble(10,1) ; x.iota() ; x.rearrange(2) ; x.setInfoOnComponents(["aa","bbb"]) + x.setName("toto") + pickled=cPickle.dumps(x,cPickle.HIGHEST_PROTOCOL) + xx=cPickle.loads(pickled) + self.assertTrue(xx.isEqual(x,1e-16)) + # Bigger to check that the behavior is OK for large strings. + x=DataArrayDouble(1200) ; x.iota() ; x.setInfoOnComponents(["aa"]) + x.setName("titi") + pickled=cPickle.dumps(x,cPickle.HIGHEST_PROTOCOL) + xx=cPickle.loads(pickled) + self.assertTrue(xx.isEqual(x,1e-16)) + pass + + @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy") + def test2(self): + """ Test of a simple DataArrayInt.""" + x=DataArrayInt(10) ; x.iota() ; x.rearrange(2) ; x.setInfoOnComponents(["aa","bbb"]) + x.setName("toto") + pickled=cPickle.dumps(x,cPickle.HIGHEST_PROTOCOL) + xx=cPickle.loads(pickled) + self.assertTrue(xx.isEqual(x)) + # Bigger to check that the behavior is OK for large strings. + x=DataArrayInt(1200) ; x.iota() ; x.setInfoOnComponents(["aa"]) + x.setName("titi") + pickled=cPickle.dumps(x,cPickle.HIGHEST_PROTOCOL) + xx=cPickle.loads(pickled) + self.assertTrue(xx.isEqual(x)) + pass + + @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy") + def test3(self): + """ Test of a MEDCouplingUMesh pickeling.""" + arr=DataArrayDouble(10) ; arr.iota() + m=MEDCouplingCMesh() ; m.setCoords(arr,arr,arr) + m=m.buildUnstructured() + m.setName("mesh") + m.getCoords().setInfoOnComponents(["aa","bbb","ddddd"]) + m.checkCoherency() + st=cPickle.dumps(m,cPickle.HIGHEST_PROTOCOL) + m2=cPickle.loads(st) + self.assertTrue(m2.isEqual(m,1e-16)) + pass + + @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy") + def test4(self): + """ Idem test3 except that here serialization/deserialization is done explicitely.""" + arr=DataArrayDouble(10) ; arr.iota() + m=MEDCouplingCMesh() ; m.setCoords(arr,arr,arr) + m=m.buildUnstructured() + m.setName("mesh") + m.getCoords().setInfoOnComponents(["aa","bbb","ddddd"]) + m.checkCoherency() + # + a0,a1,a2=m.getTinySerializationInformation() + b0,b1=m.serialize() + m2=MEDCouplingUMesh() + m2.unserialization(a0,a1,b0,b1,a2); + self.assertTrue(m2.isEqual(m,1e-16)) + pass + + @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy") + def test5(self): + """ Test of a MEDCouplingCMesh pickeling.""" + arrX=DataArrayDouble(10) ; arrX.iota() ; arrX.setInfoOnComponents(["aa"]) + arrY=DataArrayDouble(5) ; arrY.iota() ; arrY.setInfoOnComponents(["bbb"]) + arrZ=DataArrayDouble(7) ; arrZ.iota() ; arrZ.setInfoOnComponents(["cccc"]) + # + m=MEDCouplingCMesh() ; m.setCoords(arrX,arrY,arrZ) + m.setName("mesh") + m.checkCoherency() + st=cPickle.dumps(m,cPickle.HIGHEST_PROTOCOL) + m2=cPickle.loads(st) + self.assertTrue(m2.isEqual(m,1e-16)) + self.assertTrue(m2.getCoordsAt(0).isEqual(arrX,1e-16)) + pass + + @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy") + def test6(self): + """ Test of a MEDCoupling1SGTUMesh pickeling.""" + arr=DataArrayDouble(10) ; arr.iota() + m=MEDCouplingCMesh() ; m.setCoords(arr,arr) + m=m.build1SGTUnstructured() + self.assertTrue(isinstance(m,MEDCoupling1SGTUMesh)) + st=cPickle.dumps(m,cPickle.HIGHEST_PROTOCOL) + m2=cPickle.loads(st) + self.assertTrue(m2.isEqual(m,1e-16)) + pass + + @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy") + def test7(self): + """ Test of a MEDCoupling1DGTUMesh pickeling.""" + arr=DataArrayDouble(10) ; arr.iota() + m=MEDCouplingCMesh() ; m.setCoords(arr,arr) + m=m.buildUnstructured() ; m.convertAllToPoly() + m=MEDCoupling1DGTUMesh(m) + self.assertTrue(isinstance(m,MEDCoupling1DGTUMesh)) + st=cPickle.dumps(m,cPickle.HIGHEST_PROTOCOL) + m2=cPickle.loads(st) + self.assertTrue(m2.isEqual(m,1e-16)) + pass + + @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy") + def test8(self): + """ Test of a MEDCouplingExtrudedMesh pickeling.""" + arrX=DataArrayDouble(10) ; arrX.iota() ; arrX.setInfoOnComponents(["aa"]) + arrY=DataArrayDouble(5) ; arrY.iota() ; arrY.setInfoOnComponents(["bbb"]) + arrZ=DataArrayDouble(7) ; arrZ.iota() ; arrZ.setInfoOnComponents(["cccc"]) + m=MEDCouplingCMesh() ; m.setCoords(arrX,arrY,arrZ) + mesh3D=m.buildUnstructured() ; del m + # + m=MEDCouplingCMesh() ; m.setCoords(arrX,arrY) + mesh2D=m.buildUnstructured() ; del m + # + mesh2D.setCoords(mesh3D.getCoords()) + mesh=MEDCouplingExtrudedMesh(mesh3D,mesh2D,0) ; del mesh3D,mesh2D + self.assertTrue(isinstance(mesh,MEDCouplingExtrudedMesh)) + st=cPickle.dumps(mesh,cPickle.HIGHEST_PROTOCOL) + m2=cPickle.loads(st) + self.assertTrue(m2.isEqual(mesh,1e-16)) + pass + + @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy") + def test9(self): + """ Test of a MEDCouplingCurveLinearMesh pickeling.""" + arrX=DataArrayDouble(10) ; arrX.iota() ; arrX.setInfoOnComponents(["aa"]) + arrY=DataArrayDouble(5) ; arrY.iota() ; arrY.setInfoOnComponents(["bbb"]) + m=MEDCouplingCMesh() ; m.setCoords(arrX,arrY) + m=m.buildUnstructured() + # + mesh=MEDCouplingCurveLinearMesh() ; mesh.setCoords(m.getCoords()) ; del m + mesh.setNodeGridStructure([10,5]) + st=cPickle.dumps(mesh,cPickle.HIGHEST_PROTOCOL) + m2=cPickle.loads(st) + self.assertTrue(m2.isEqual(mesh,1e-16)) + pass + + @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy") + def test10(self): + """ Test of a MEDCouplingIMesh pickeling.""" + m=MEDCouplingIMesh("mesh",3,DataArrayInt([3,1,4]),DataArrayDouble([1.5,2.5,3.5]),DataArrayDouble((0.5,1.,0.25))) ; m.setAxisUnit("km") + m.checkCoherency() + st=cPickle.dumps(m,cPickle.HIGHEST_PROTOCOL) + m2=cPickle.loads(st) + self.assertTrue(m2.isEqual(m,1e-16)) + self.assertEqual(m2.getName(),m.getName()) + pass + + @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy") + def test11(self): + """ Test of MEDCouplingFieldDouble lying on MEDCouplingCMesh pickeling. """ + arrX=DataArrayDouble(10) ; arrX.iota() ; arrX.setInfoOnComponents(["aa"]) + arrY=DataArrayDouble(5) ; arrY.iota() ; arrY.setInfoOnComponents(["bbb"]) + m=MEDCouplingCMesh() ; m.setCoords(arrX,arrY) + f=m.getMeasureField(True) + f.setName("aname") + a=f.getArray() + b=a[:] ; b.iota(7000.) + f.setArray(DataArrayDouble.Meld(a,b)) + f.getArray().setInfoOnComponents(["u1","vv2"]) + f.checkCoherency(); + # + st=cPickle.dumps(f,cPickle.HIGHEST_PROTOCOL) + f2=cPickle.loads(st) + self.assertTrue(f2.isEqual(f,1e-16,1e-16)) + self.assertTrue(f2.getMesh().isEqual(f.getMesh(),1e-16)) + pass + + @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy") + def test12(self): + """ Test of MEDCouplingFieldDouble on Gauss Points lying on MEDCouplingUMesh pickeling.""" + _a=0.446948490915965; + _b=0.091576213509771; + _p1=0.11169079483905; + _p2=0.0549758718227661; + refCoo1=[ 0.,0., 1.,0., 0.,1. ] + gsCoo1=[ 2*_b-1, 1-4*_b, 2*_b-1, 2.07*_b-1, 1-4*_b, + 2*_b-1, 1-4*_a, 2*_a-1, 2*_a-1, 1-4*_a, 2*_a-1, 2*_a-1 ] + wg1=[ 4*_p2, 4*_p2, 4*_p2, 4*_p1, 4*_p1, 4*_p1 ] + _refCoo1=refCoo1 + _gsCoo1=gsCoo1 + _wg1=wg1 + # + m=MEDCouplingDataForTest.build2DTargetMesh_1(); + f=MEDCouplingFieldDouble.New(ON_GAUSS_PT,NO_TIME); + f.setMesh(m); + self.assertEqual(5,f.getNumberOfMeshPlacesExpected()); + self.assertEqual(0,f.getNbOfGaussLocalization()); + f.setGaussLocalizationOnType(NORM_TRI3,_refCoo1,_gsCoo1,_wg1); + f.setGaussLocalizationOnType(NORM_TRI3,_refCoo1,_gsCoo1,_wg1); # not a bug only to check that it works well + self.assertRaises(InterpKernelException,f.setGaussLocalizationOnType,NORM_QUAD4,_refCoo1,_gsCoo1,_wg1) + self.assertEqual(1,f.getNbOfGaussLocalization()); + refCoo2=[ 0.,0., 1.,0., 1.,1., 0.,1. ] + _refCoo2=refCoo2 + _gsCoo1=_gsCoo1[0:4] + _wg1=_wg1[0:2] + f.setGaussLocalizationOnType(NORM_QUAD4,_refCoo2,_gsCoo1,_wg1); + self.assertEqual(2,f.getNbOfGaussLocalization()); + array=DataArrayDouble.New(); + ptr=18*2*[None] + for i in xrange(18*2): + ptr[i]=float(i+1) + array.setValues(ptr,18,2); + ptr=array.getPointer(); + f.setArray(array); + f.setName("MyFirstFieldOnGaussPoint"); + f.checkCoherency(); + self.assertAlmostEqual(27.,f.getIJK(2,5,0),14); + self.assertAlmostEqual(16.,f.getIJK(1,5,1),14); + # + f.clearGaussLocalizations(); + self.assertEqual(0,f.getNbOfGaussLocalization()); + self.assertRaises(InterpKernelException,f.checkCoherency); + ids1=[0,1,3,4] + self.assertRaises(InterpKernelException,f.setGaussLocalizationOnCells,ids1,_refCoo2,_gsCoo1,_wg1); + self.assertEqual(0,f.getNbOfGaussLocalization()); + ids2=[0,4] + f.setGaussLocalizationOnCells(ids2,_refCoo2,_gsCoo1,_wg1); + self.assertEqual(1,f.getNbOfGaussLocalization()); + self.assertEqual(0,f.getGaussLocalizationIdOfOneCell(0)); + self.assertRaises(InterpKernelException,f.getGaussLocalizationIdOfOneCell,1); + ids3=[1,2] + f.setGaussLocalizationOnCells(ids3,_refCoo1,_gsCoo1,_wg1); + self.assertEqual(2,f.getNbOfGaussLocalization()); + self.assertEqual(0,f.getGaussLocalizationIdOfOneCell(0)); + self.assertEqual(1,f.getGaussLocalizationIdOfOneCell(1)); + self.assertEqual(1,f.getGaussLocalizationIdOfOneCell(2)); + self.assertRaises(InterpKernelException,f.checkCoherency);#<- cell 3 has no localization + ids4=[3] + _gsCoo2=_gsCoo1; + _wg2=_wg1; + _gsCoo2[0]=0.8888777776666; + _wg2[0]=0.1234567892377; + f.setGaussLocalizationOnCells(ids4,_refCoo2,_gsCoo2,_wg2); + self.assertEqual(3,f.getNbOfGaussLocalization()); + tmpIds=f.getCellIdsHavingGaussLocalization(0); + self.assertEqual(ids2,list(tmpIds.getValues())); + self.assertRaises(InterpKernelException,f.checkCoherency);#<- it's always not ok because undelying array not with the good size. + array2=f.getArray().substr(0,10); + f.setArray(array2); + f.checkCoherency(); + #### + st=cPickle.dumps(f,cPickle.HIGHEST_PROTOCOL) + f2=cPickle.loads(st) + self.assertTrue(f2.isEqual(f,1e-16,1e-16)) + self.assertTrue(f2.getMesh().isEqual(f.getMesh(),1e-16)) + pass + + def test13(self): + eStr="This is an exception." + e=InterpKernelException(eStr) + self.assertEqual(e.what(),eStr) + st=cPickle.dumps(e,cPickle.HIGHEST_PROTOCOL) + e2=cPickle.loads(st) + self.assertTrue(e is not e2) + self.assertTrue(isinstance(e2,InterpKernelException)) + self.assertEqual(e2.what(),eStr) + pass + + def setUp(self): + pass + pass + +if __name__=="__main__": + unittest.main() diff --git a/src/MEDCoupling_Swig/MEDCouplingRefCountObject.i b/src/MEDCoupling_Swig/MEDCouplingRefCountObject.i index 75881f9a4..48003ef55 100644 --- a/src/MEDCoupling_Swig/MEDCouplingRefCountObject.i +++ b/src/MEDCoupling_Swig/MEDCouplingRefCountObject.i @@ -29,9 +29,9 @@ namespace INTERP_KERNEL %extend { std::string __str__() const - { - return std::string(self->what()); - } + { + return std::string(self->what()); + } } }; } @@ -157,3 +157,12 @@ namespace ParaMEDMEM return std::string(script); } } + +%pythoncode %{ +def INTERPKERNELExceptionReduceFunct(a,b): + ret=InterpKernelException.__new__(a) + ret.__init__(*b) + return ret +def INTERPKERNELExceptionReduce(self): + return INTERPKERNELExceptionReduceFunct,(InterpKernelException,(self.what(),)) +%} diff --git a/src/MEDCoupling_Swig/MEDCouplingRemapper.i b/src/MEDCoupling_Swig/MEDCouplingRemapper.i index e9ad002c8..135958b88 100644 --- a/src/MEDCoupling_Swig/MEDCouplingRemapper.i +++ b/src/MEDCoupling_Swig/MEDCouplingRemapper.i @@ -103,6 +103,9 @@ namespace ParaMEDMEM } %pythoncode %{ +def ParaMEDMEMDataArrayDoublenew(cls,*args): + import _MEDCouplingRemapper + return _MEDCouplingRemapper.DataArrayDouble____new___(cls,args) def ParaMEDMEMDataArrayDoubleIadd(self,*args): import _MEDCouplingRemapper return _MEDCouplingRemapper.DataArrayDouble____iadd___(self, self, *args) @@ -118,6 +121,9 @@ def ParaMEDMEMDataArrayDoubleIdiv(self,*args): def ParaMEDMEMDataArrayDoubleIpow(self,*args): import _MEDCouplingRemapper return _MEDCouplingRemapper.DataArrayDouble____ipow___(self, self, *args) +def ParaMEDMEMMEDCouplingFieldDoublenew(cls,*args): + import _MEDCouplingRemapper + return _MEDCouplingRemapper.MEDCouplingFieldDouble____new___(cls,args) def ParaMEDMEMMEDCouplingFieldDoubleIadd(self,*args): import _MEDCouplingRemapper return _MEDCouplingRemapper.MEDCouplingFieldDouble____iadd___(self, self, *args) @@ -133,6 +139,12 @@ def ParaMEDMEMMEDCouplingFieldDoubleIdiv(self,*args): def ParaMEDMEMMEDCouplingFieldDoubleIpow(self,*args): import _MEDCouplingRemapper return _MEDCouplingRemapper.MEDCouplingFieldDouble____ipow___(self, self, *args) +def ParaMEDMEMDataArrayIntnew(cls,*args): + import _MEDCouplingRemapper + return _MEDCouplingRemapper.DataArrayInt____new___(cls,args) +def ParaMEDMEMDataArrayIntnew(cls,*args): + import _MEDCoupling + return _MEDCoupling.DataArrayInt____new___(cls,args) def ParaMEDMEMDataArrayIntIadd(self,*args): import _MEDCouplingRemapper return _MEDCouplingRemapper.DataArrayInt____iadd___(self, self, *args) @@ -184,6 +196,27 @@ def ParaMEDMEMDenseMatrixIadd(self,*args): def ParaMEDMEMDenseMatrixIsub(self,*args): import _MEDCouplingRemapper return _MEDCouplingRemapper.DenseMatrix____isub___(self, self, *args) +def ParaMEDMEMMEDCouplingUMeshnew(cls,*args): + import _MEDCouplingRemapper + return _MEDCouplingRemapper.MEDCouplingUMesh____new___(cls,args) +def ParaMEDMEMMEDCoupling1DGTUMeshnew(cls,*args): + import _MEDCouplingRemapper + return _MEDCouplingRemapper.MEDCoupling1DGTUMesh____new___(cls,args) +def ParaMEDMEMMEDCoupling1SGTUMeshnew(cls,*args): + import _MEDCouplingRemapper + return _MEDCouplingRemapper.MEDCoupling1SGTUMesh____new___(cls,args) +def ParaMEDMEMMEDCouplingCurveLinearMeshnew(cls,*args): + import _MEDCouplingRemapper + return _MEDCouplingRemapper.MEDCouplingCurveLinearMesh____new___(cls,args) +def ParaMEDMEMMEDCouplingCMeshnew(cls,*args): + import _MEDCouplingRemapper + return _MEDCouplingRemapper.MEDCouplingCMesh____new___(cls,args) +def ParaMEDMEMMEDCouplingIMeshnew(cls,*args): + import _MEDCouplingRemapper + return _MEDCouplingRemapper.MEDCouplingIMesh____new___(cls,args) +def ParaMEDMEMMEDCouplingExtrudedMeshnew(cls,*args): + import _MEDCouplingRemapper + return _MEDCouplingRemapper.MEDCouplingExtrudedMesh____new___(cls,args) %} %include "MEDCouplingFinalize.i" diff --git a/src/MEDCoupling_Swig/MEDCouplingTypemaps.i b/src/MEDCoupling_Swig/MEDCouplingTypemaps.i index ce6eed11c..94bed84df 100644 --- a/src/MEDCoupling_Swig/MEDCouplingTypemaps.i +++ b/src/MEDCoupling_Swig/MEDCouplingTypemaps.i @@ -427,3 +427,31 @@ ParaMEDMEM::MEDCouplingFieldDouble *ParaMEDMEM_MEDCouplingFieldDouble___rdiv__Im { throw INTERP_KERNEL::Exception(msg); } } } + +static PyObject *NewMethWrapCallInitOnlyIfEmptyDictInInput(PyObject *cls, PyObject *args, const char *clsName) +{ + if(!PyTuple_Check(args)) + { + std::ostringstream oss; oss << clsName << ".__new__ : the args in input is expected to be a tuple !"; + throw INTERP_KERNEL::Exception(oss.str().c_str()); + } + PyObject *builtinsd(PyEval_GetBuiltins());//borrowed + PyObject *obj(PyDict_GetItemString(builtinsd,"object"));//borrowed + PyObject *selfMeth(PyObject_GetAttrString(obj,"__new__")); + // + PyObject *tmp0(PyTuple_New(1)); + PyTuple_SetItem(tmp0,0,cls); Py_XINCREF(cls); + PyObject *instance(PyObject_CallObject(selfMeth,tmp0)); + Py_DECREF(tmp0); + Py_DECREF(selfMeth); + if(PyTuple_Size(args)==2 && PyDict_Check(PyTuple_GetItem(args,1)) && PyDict_Size(PyTuple_GetItem(args,1))==0 ) + {// NOT general case. only true if in unpickeling context ! call __init__. Because for all other cases, __init__ is called right after __new__ ! + PyObject *initMeth(PyObject_GetAttrString(instance,"__init__")); + PyObject *tmp3(PyTuple_New(0)); + PyObject *tmp2(PyObject_CallObject(initMeth,tmp3)); + Py_XDECREF(tmp2); + Py_DECREF(tmp3); + Py_DECREF(initMeth); + } + return instance; +} diff --git a/src/MEDLoader/Swig/MEDLoader.i b/src/MEDLoader/Swig/MEDLoader.i index 546c67b9a..ab8d676ed 100644 --- a/src/MEDLoader/Swig/MEDLoader.i +++ b/src/MEDLoader/Swig/MEDLoader.i @@ -21,6 +21,9 @@ %include "MEDLoaderCommon.i" %pythoncode %{ +def ParaMEDMEMDataArrayDoublenew(cls,*args): + import _MEDLoader + return _MEDLoader.DataArrayDouble____new___(cls,args) def ParaMEDMEMDataArrayDoubleIadd(self,*args): import _MEDLoader return _MEDLoader.DataArrayDouble____iadd___(self, self, *args) @@ -36,6 +39,9 @@ def ParaMEDMEMDataArrayDoubleIdiv(self,*args): def ParaMEDMEMDataArrayDoubleIpow(self,*args): import _MEDLoader return _MEDLoader.DataArrayDouble____ipow___(self, self, *args) +def ParaMEDMEMMEDCouplingFieldDoublenew(cls,*args): + import _MEDLoader + return _MEDLoader.MEDCouplingFieldDouble____new___(cls,args) def ParaMEDMEMMEDCouplingFieldDoubleIadd(self,*args): import _MEDLoader return _MEDLoader.MEDCouplingFieldDouble____iadd___(self, self, *args) @@ -51,6 +57,9 @@ def ParaMEDMEMMEDCouplingFieldDoubleIdiv(self,*args): def ParaMEDMEMMEDCouplingFieldDoubleIpow(self,*args): import _MEDLoader return _MEDLoader.MEDCouplingFieldDouble____ipow___(self, self, *args) +def ParaMEDMEMDataArrayIntnew(cls,*args): + import _MEDLoader + return _MEDLoader.DataArrayInt____new___(cls,args) def ParaMEDMEMDataArrayIntIadd(self,*args): import _MEDLoader return _MEDLoader.DataArrayInt____iadd___(self, self, *args) @@ -102,6 +111,27 @@ def ParaMEDMEMDenseMatrixIadd(self,*args): def ParaMEDMEMDenseMatrixIsub(self,*args): import _MEDLoader return _MEDLoader.DenseMatrix____isub___(self, self, *args) +def ParaMEDMEMMEDCouplingUMeshnew(cls,*args): + import _MEDLoader + return _MEDLoader.MEDCouplingUMesh____new___(cls,args) +def ParaMEDMEMMEDCoupling1DGTUMeshnew(cls,*args): + import _MEDLoader + return _MEDLoader.MEDCoupling1DGTUMesh____new___(cls,args) +def ParaMEDMEMMEDCoupling1SGTUMeshnew(cls,*args): + import _MEDLoader + return _MEDLoader.MEDCoupling1SGTUMesh____new___(cls,args) +def ParaMEDMEMMEDCouplingCurveLinearMeshnew(cls,*args): + import _MEDLoader + return _MEDLoader.MEDCouplingCurveLinearMesh____new___(cls,args) +def ParaMEDMEMMEDCouplingCMeshnew(cls,*args): + import _MEDLoader + return _MEDLoader.MEDCouplingCMesh____new___(cls,args) +def ParaMEDMEMMEDCouplingIMeshnew(cls,*args): + import _MEDLoader + return _MEDLoader.MEDCouplingIMesh____new___(cls,args) +def ParaMEDMEMMEDCouplingExtrudedMeshnew(cls,*args): + import _MEDLoader + return _MEDLoader.MEDCouplingExtrudedMesh____new___(cls,args) %} %include "MEDCouplingFinalize.i" diff --git a/src/ParaMEDMEM_Swig/ParaMEDMEM.i b/src/ParaMEDMEM_Swig/ParaMEDMEM.i index 9b4396395..38f4c4751 100644 --- a/src/ParaMEDMEM_Swig/ParaMEDMEM.i +++ b/src/ParaMEDMEM_Swig/ParaMEDMEM.i @@ -259,6 +259,9 @@ int MPI_Finalize(); %} %pythoncode %{ +def ParaMEDMEMDataArrayDoublenew(cls,*args): + import _ParaMEDMEM + return _ParaMEDMEM.DataArrayDouble____new___(cls,args) def ParaMEDMEMDataArrayDoubleIadd(self,*args): import _ParaMEDMEM return _ParaMEDMEM.DataArrayDouble____iadd___(self, self, *args) @@ -286,6 +289,9 @@ def ParaMEDMEMDataArrayDoubleTupleImul(self,*args): def ParaMEDMEMDataArrayDoubleTupleIdiv(self,*args): import _ParaMEDMEM return _ParaMEDMEM.DataArrayDoubleTuple____idiv___(self, self, *args) +def ParaMEDMEMMEDCouplingFieldDoublenew(cls,*args): + import _ParaMEDMEM + return _ParaMEDMEM.MEDCouplingFieldDouble____new___(cls,args) def ParaMEDMEMMEDCouplingFieldDoubleIadd(self,*args): import _ParaMEDMEM return _ParaMEDMEM.MEDCouplingFieldDouble____iadd___(self, self, *args) @@ -301,6 +307,9 @@ def ParaMEDMEMMEDCouplingFieldDoubleIdiv(self,*args): def ParaMEDMEMMEDCouplingFieldDoubleIpow(self,*args): import _ParaMEDMEM return _ParaMEDMEM.MEDCouplingFieldDouble____ipow___(self, self, *args) +def ParaMEDMEMDataArrayIntnew(cls,*args): + import _ParaMEDMEM + return _ParaMEDMEM.DataArrayInt____new___(cls,args) def ParaMEDMEMDataArrayIntIadd(self,*args): import _ParaMEDMEM return _ParaMEDMEM.DataArrayInt____iadd___(self, self, *args) diff --git a/src/RENUMBER_Swig/MEDRenumber.i b/src/RENUMBER_Swig/MEDRenumber.i index 23cc5ea13..9ba28d274 100644 --- a/src/RENUMBER_Swig/MEDRenumber.i +++ b/src/RENUMBER_Swig/MEDRenumber.i @@ -20,75 +20,85 @@ %include "MEDRenumberCommon.i" %pythoncode %{ +def ParaMEDMEMDataArrayDoublenew(cls,*args): + import _MEDRenumber + return _MEDRenumber.DataArrayDouble____new___(cls,args) def ParaMEDMEMDataArrayDoubleIadd(self,*args): - import _MEDCoupling - return _MEDCoupling.DataArrayDouble____iadd___(self, self, *args) + import _MEDRenumber + return _MEDRenumber.DataArrayDouble____iadd___(self, self, *args) def ParaMEDMEMDataArrayDoubleIsub(self,*args): - import _MEDCoupling - return _MEDCoupling.DataArrayDouble____isub___(self, self, *args) + import _MEDRenumber + return _MEDRenumber.DataArrayDouble____isub___(self, self, *args) def ParaMEDMEMDataArrayDoubleImul(self,*args): - import _MEDCoupling - return _MEDCoupling.DataArrayDouble____imul___(self, self, *args) + import _MEDRenumber + return _MEDRenumber.DataArrayDouble____imul___(self, self, *args) def ParaMEDMEMDataArrayDoubleIdiv(self,*args): - import _MEDCoupling - return _MEDCoupling.DataArrayDouble____idiv___(self, self, *args) + import _MEDRenumber + return _MEDRenumber.DataArrayDouble____idiv___(self, self, *args) def ParaMEDMEMDataArrayDoubleIpow(self,*args): - import _MEDCoupling - return _MEDCoupling.DataArrayDouble____ipow___(self, self, *args) + import _MEDRenumber + return _MEDRenumber.DataArrayDouble____ipow___(self, self, *args) +def ParaMEDMEMDataArrayIntnew(cls,*args): + import _MEDRenumber + return _MEDRenumber.DataArrayInt____new___(cls,args) def ParaMEDMEMDataArrayIntIadd(self,*args): - import _MEDCoupling - return _MEDCoupling.DataArrayInt____iadd___(self, self, *args) + import _MEDRenumber + return _MEDRenumber.DataArrayInt____iadd___(self, self, *args) def ParaMEDMEMDataArrayIntIsub(self,*args): - import _MEDCoupling - return _MEDCoupling.DataArrayInt____isub___(self, self, *args) + import _MEDRenumber + return _MEDRenumber.DataArrayInt____isub___(self, self, *args) def ParaMEDMEMDataArrayIntImul(self,*args): - import _MEDCoupling - return _MEDCoupling.DataArrayInt____imul___(self, self, *args) + import _MEDRenumber + return _MEDRenumber.DataArrayInt____imul___(self, self, *args) def ParaMEDMEMDataArrayIntIdiv(self,*args): - import _MEDCoupling - return _MEDCoupling.DataArrayInt____idiv___(self, self, *args) + import _MEDRenumber + return _MEDRenumber.DataArrayInt____idiv___(self, self, *args) def ParaMEDMEMDataArrayIntImod(self,*args): - import _MEDCoupling - return _MEDCoupling.DataArrayInt____imod___(self, self, *args) + import _MEDRenumber + return _MEDRenumber.DataArrayInt____imod___(self, self, *args) def ParaMEDMEMDataArrayIntIpow(self,*args): - import _MEDCoupling - return _MEDCoupling.DataArrayInt____ipow___(self, self, *args) + import _MEDRenumber + return _MEDRenumber.DataArrayInt____ipow___(self, self, *args) def ParaMEDMEMDataArrayDoubleTupleIadd(self,*args): - import _MEDCoupling - return _MEDCoupling.DataArrayDoubleTuple____iadd___(self, self, *args) + import _MEDRenumber + return _MEDRenumber.DataArrayDoubleTuple____iadd___(self, self, *args) def ParaMEDMEMDataArrayDoubleTupleIsub(self,*args): - import _MEDCoupling - return _MEDCoupling.DataArrayDoubleTuple____isub___(self, self, *args) + import _MEDRenumber + return _MEDRenumber.DataArrayDoubleTuple____isub___(self, self, *args) def ParaMEDMEMDataArrayDoubleTupleImul(self,*args): - import _MEDCoupling - return _MEDCoupling.DataArrayDoubleTuple____imul___(self, self, *args) + import _MEDRenumber + return _MEDRenumber.DataArrayDoubleTuple____imul___(self, self, *args) def ParaMEDMEMDataArrayDoubleTupleIdiv(self,*args): - import _MEDCoupling - return _MEDCoupling.DataArrayDoubleTuple____idiv___(self, self, *args) + import _MEDRenumber + return _MEDRenumber.DataArrayDoubleTuple____idiv___(self, self, *args) def ParaMEDMEMDataArrayIntTupleIadd(self,*args): - import _MEDCoupling - return _MEDCoupling.DataArrayIntTuple____iadd___(self, self, *args) + import _MEDRenumber + return _MEDRenumber.DataArrayIntTuple____iadd___(self, self, *args) def ParaMEDMEMDataArrayIntTupleIsub(self,*args): - import _MEDCoupling - return _MEDCoupling.DataArrayIntTuple____isub___(self, self, *args) + import _MEDRenumber + return _MEDRenumber.DataArrayIntTuple____isub___(self, self, *args) def ParaMEDMEMDataArrayIntTupleImul(self,*args): - import _MEDCoupling - return _MEDCoupling.DataArrayIntTuple____imul___(self, self, *args) + import _MEDRenumber + return _MEDRenumber.DataArrayIntTuple____imul___(self, self, *args) def ParaMEDMEMDataArrayIntTupleIdiv(self,*args): - import _MEDCoupling - return _MEDCoupling.DataArrayIntTuple____idiv___(self, self, *args) + import _MEDRenumber + return _MEDRenumber.DataArrayIntTuple____idiv___(self, self, *args) def ParaMEDMEMDataArrayIntTupleImod(self,*args): - import _MEDCoupling - return _MEDCoupling.DataArrayIntTuple____imod___(self, self, *args) + import _MEDRenumber + return _MEDRenumber.DataArrayIntTuple____imod___(self, self, *args) %} + %pythoncode %{ +InterpKernelException.__reduce__=INTERPKERNELExceptionReduce +DataArrayDouble.__new__=classmethod(ParaMEDMEMDataArrayDoublenew) DataArrayDouble.__iadd__=ParaMEDMEMDataArrayDoubleIadd DataArrayDouble.__isub__=ParaMEDMEMDataArrayDoubleIsub DataArrayDouble.__imul__=ParaMEDMEMDataArrayDoubleImul DataArrayDouble.__idiv__=ParaMEDMEMDataArrayDoubleIdiv DataArrayDouble.__ipow__=ParaMEDMEMDataArrayDoubleIpow +DataArrayInt.__new__=classmethod(ParaMEDMEMDataArrayIntnew) DataArrayInt.__iadd__=ParaMEDMEMDataArrayIntIadd DataArrayInt.__isub__=ParaMEDMEMDataArrayIntIsub DataArrayInt.__imul__=ParaMEDMEMDataArrayIntImul @@ -107,10 +117,13 @@ DataArrayIntTuple.__imul__=ParaMEDMEMDataArrayIntTupleImul DataArrayIntTuple.__idiv__=ParaMEDMEMDataArrayIntTupleIdiv DataArrayIntTuple.__imod__=ParaMEDMEMDataArrayIntTupleImod +del INTERPKERNELExceptionReduce +del ParaMEDMEMDataArrayDoublenew del ParaMEDMEMDataArrayDoubleIadd del ParaMEDMEMDataArrayDoubleIsub del ParaMEDMEMDataArrayDoubleImul del ParaMEDMEMDataArrayDoubleIdiv +del ParaMEDMEMDataArrayIntnew del ParaMEDMEMDataArrayIntIadd del ParaMEDMEMDataArrayIntIsub del ParaMEDMEMDataArrayIntImul