From: Anthony Geay Date: Mon, 16 Oct 2017 13:00:49 +0000 (+0200) Subject: All tests are OK now on python3 X-Git-Tag: V9_0_0~44 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=a06317d0bbeffcf1140451c1a00b5c1d9b0973f1;p=tools%2Fmedcoupling.git All tests are OK now on python3 --- diff --git a/src/MEDLoader/Swig/MEDLoader.i b/src/MEDLoader/Swig/MEDLoader.i index 90c5e0f9f..5eb51ebf0 100644 --- a/src/MEDLoader/Swig/MEDLoader.i +++ b/src/MEDLoader/Swig/MEDLoader.i @@ -39,9 +39,6 @@ def MEDCouplingDataArrayDoubleIdiv(self,*args): def MEDCouplingDataArrayDoubleIpow(self,*args): import _MEDLoader return _MEDLoader.DataArrayDouble____ipow___(self, self, *args) -def MEDCouplingFieldDoublenew(cls,*args): - import _MEDLoader - return _MEDLoader.MEDCouplingFieldDouble____new___(cls,args) def MEDCouplingFieldDoubleIadd(self,*args): import _MEDLoader return _MEDLoader.MEDCouplingFieldDouble____iadd___(self, self, *args) @@ -57,18 +54,6 @@ def MEDCouplingFieldDoubleIdiv(self,*args): def MEDCouplingFieldDoubleIpow(self,*args): import _MEDLoader return _MEDLoader.MEDCouplingFieldDouble____ipow___(self, self, *args) -def MEDCouplingFieldIntnew(cls,*args): - import _MEDLoader - return _MEDLoader.MEDCouplingFieldInt____new___(cls,args) -def MEDCouplingFieldFloatnew(cls,*args): - import _MEDLoader - return _MEDLoader.MEDCouplingFieldFloat____new___(cls,args) -def MEDCouplingDataArrayBytenew(cls,*args): - import _MEDLoader - return _MEDLoader.DataArrayByte____new___(cls,args) -def MEDCouplingDataArrayFloatnew(cls,*args): - import _MEDLoader - return _MEDLoader.DataArrayFloat____new___(cls,args) def MEDCouplingDataArrayFloatIadd(self,*args): import _MEDLoader return _MEDLoader.DataArrayFloat____iadd___(self, self, *args) @@ -81,9 +66,6 @@ def MEDCouplingDataArrayFloatImul(self,*args): def MEDCouplingDataArrayFloatIdiv(self,*args): import _MEDLoader return _MEDLoader.DataArrayFloat____idiv___(self, self, *args) -def MEDCouplingDataArrayIntnew(cls,*args): - import _MEDLoader - return _MEDLoader.DataArrayInt____new___(cls,args) def MEDCouplingDataArrayIntIadd(self,*args): import _MEDLoader return _MEDLoader.DataArrayInt____iadd___(self, self, *args) @@ -135,45 +117,12 @@ def ParaMEDMEMDenseMatrixIadd(self,*args): def ParaMEDMEMDenseMatrixIsub(self,*args): import _MEDLoader return _MEDLoader.DenseMatrix____isub___(self, self, *args) -def MEDCouplingUMeshnew(cls,*args): - import _MEDLoader - return _MEDLoader.MEDCouplingUMesh____new___(cls,args) -def MEDCoupling1DGTUMeshnew(cls,*args): - import _MEDLoader - return _MEDLoader.MEDCoupling1DGTUMesh____new___(cls,args) -def MEDCoupling1SGTUMeshnew(cls,*args): - import _MEDLoader - return _MEDLoader.MEDCoupling1SGTUMesh____new___(cls,args) -def MEDCouplingCurveLinearMeshnew(cls,*args): - import _MEDLoader - return _MEDLoader.MEDCouplingCurveLinearMesh____new___(cls,args) -def MEDCouplingCMeshnew(cls,*args): - import _MEDLoader - return _MEDLoader.MEDCouplingCMesh____new___(cls,args) -def MEDCouplingIMeshnew(cls,*args): - import _MEDLoader - return _MEDLoader.MEDCouplingIMesh____new___(cls,args) -def MEDCouplingExtrudedMeshnew(cls,*args): - import _MEDLoader - return _MEDLoader.MEDCouplingMappedExtrudedMesh____new___(cls,args) %} %pythoncode %{ -def MEDCouplingMEDFileUMeshnew(cls,*args): - import _MEDLoader - return _MEDLoader.MEDFileUMesh____new___(cls,args) -def MEDCouplingMEDFileCMeshnew(cls,*args): - import _MEDLoader - return _MEDLoader.MEDFileCMesh____new___(cls,args) -def MEDCouplingMEDFileCurveLinearMeshnew(cls,*args): - import _MEDLoader - return _MEDLoader.MEDFileCurveLinearMesh____new___(cls,args) def MEDCouplingMEDFileMeshesnew(cls,*args): import _MEDLoader return _MEDLoader.MEDFileMeshes____new___(cls,args) -def MEDCouplingMEDFileDatanew(cls,*args): - import _MEDLoader - return _MEDLoader.MEDFileData____new___(cls,args) def MEDCouplingMEDFileFieldsnew(cls,*args): import _MEDLoader return _MEDLoader.MEDFileFields____new___(cls,args) @@ -209,30 +158,54 @@ MEDFileFieldsIterator.__next__ = MEDFileFieldsIterator.next %} %pythoncode %{ -MEDFileUMesh.__new__=classmethod(MEDCouplingMEDFileUMeshnew) -del MEDCouplingMEDFileUMeshnew -MEDFileCMesh.__new__=classmethod(MEDCouplingMEDFileCMeshnew) -del MEDCouplingMEDFileCMeshnew -MEDFileCurveLinearMesh.__new__=classmethod(MEDCouplingMEDFileCurveLinearMeshnew) -del MEDCouplingMEDFileCurveLinearMeshnew -MEDFileData.__new__=classmethod(MEDCouplingMEDFileDatanew) -del MEDCouplingMEDFileDatanew -MEDFileMeshes.__new__=classmethod(MEDCouplingMEDFileMeshesnew) -del MEDCouplingMEDFileMeshesnew -MEDFileFields.__new__=classmethod(MEDCouplingMEDFileFieldsnew) -del MEDCouplingMEDFileFieldsnew -MEDFileField1TS.__new__=classmethod(MEDCouplingMEDFileField1TSnew) -del MEDCouplingMEDFileField1TSnew -MEDFileFieldMultiTS.__new__=classmethod(MEDCouplingMEDFileFieldMultiTSnew) -del MEDCouplingMEDFileFieldMultiTSnew -MEDFileIntField1TS.__new__=classmethod(MEDCouplingMEDFileIntField1TSnew) -del MEDCouplingMEDFileIntField1TSnew -MEDFileIntFieldMultiTS.__new__=classmethod(MEDCouplingMEDFileIntFieldMultiTSnew) -del MEDCouplingMEDFileIntFieldMultiTSnew -MEDFileFloatField1TS.__new__=classmethod(MEDCouplingMEDFileFloatField1TSnew) -del MEDCouplingMEDFileFloatField1TSnew -MEDFileFloatFieldMultiTS.__new__=classmethod(MEDCouplingMEDFileFloatFieldMultiTSnew) -del MEDCouplingMEDFileFloatFieldMultiTSnew -MEDFileParameters.__new__=classmethod(MEDCouplingMEDFileParametersnew) -del MEDCouplingMEDFileParametersnew +def MEDCouplingMEDFileUMeshReduce(self): + return MEDCouplingStdReduceFunct,(MEDFileUMesh,((),(self.__getstate__()),)) +MEDFileUMesh.__reduce__=MEDCouplingMEDFileUMeshReduce +del MEDCouplingMEDFileUMeshReduce +def MEDCouplingMEDFileCMeshReduce(self): + return MEDCouplingStdReduceFunct,(MEDFileCMesh,((self.serialize(),),(self.__getstate__()),)) +MEDFileCMesh.__reduce__=MEDCouplingMEDFileCMeshReduce +del MEDCouplingMEDFileCMeshReduce +def MEDCouplingMEDFileCurveLinearMeshReduce(self): + return MEDCouplingStdReduceFunct,(MEDFileCurveLinearMesh,((self.serialize(),),(self.__getstate__()),)) +MEDFileCurveLinearMesh.__reduce__=MEDCouplingMEDFileCurveLinearMeshReduce +del MEDCouplingMEDFileCurveLinearMeshReduce +def MEDCouplingMEDFileDataReduce(self):#"PyWrap of MEDFileData.__getnewargs__ : not implemented because numpy is not active in your configuration ! No serialization/unserialization available without numpy !" + return MEDCouplingStdReduceFunct,(MEDFileData,((self.serialize(),),(self.__getstate__()),)) +MEDFileData.__reduce__=MEDCouplingMEDFileDataReduce +del MEDCouplingMEDFileDataReduce +def MEDCouplingMEDFileMeshesReduce(self): + return MEDCouplingStdReduceFunct,(MEDFileMeshes,((self.serialize(),),(self.__getstate__()),)) +MEDFileMeshes.__reduce__=MEDCouplingMEDFileMeshesReduce +del MEDCouplingMEDFileMeshesReduce +def MEDCouplingMEDFileFieldsReduce(self): + return MEDCouplingStdReduceFunct,(MEDFileFields,((self.serialize(),),(self.__getstate__()),)) +MEDFileFields.__reduce__=MEDCouplingMEDFileFieldsReduce +del MEDCouplingMEDFileFieldsReduce +def MEDCouplingMEDFileField1TSReduce(self): + return MEDCouplingStdReduceFunct,(MEDFileField1TS,((self.serialize(),),(self.__getstate__()),)) +MEDFileField1TS.__reduce__=MEDCouplingMEDFileField1TSReduce +del MEDCouplingMEDFileField1TSReduce +def MEDCouplingMEDFileFieldMultiTSReduce(self): + return MEDCouplingStdReduceFunct,(MEDFileFieldMultiTS,((self.serialize(),),(self.__getstate__()),)) +MEDFileFieldMultiTS.__reduce__=MEDCouplingMEDFileFieldMultiTSReduce +del MEDCouplingMEDFileFieldMultiTSReduce +def MEDCouplingMEDFileIntField1TSReduce(self): + return MEDCouplingStdReduceFunct,(MEDFileIntField1TS,((self.serialize(),),(self.__getstate__()),)) +MEDFileIntField1TS.__reduce__=MEDCouplingMEDFileIntField1TSReduce +def MEDCouplingMEDFileIntFieldMultiTSReduce(self): + return MEDCouplingStdReduceFunct,(MEDFileIntFieldMultiTS,((self.serialize(),),(self.__getstate__()),)) +MEDFileIntFieldMultiTS.__reduce__=MEDCouplingMEDFileIntFieldMultiTSReduce +del MEDCouplingMEDFileIntFieldMultiTSReduce +def MEDCouplingMEDFileFloatField1TSReduce(self): + return MEDCouplingStdReduceFunct,(MEDFileFloatField1TS,((self.serialize(),),(self.__getstate__()),)) +MEDFileFloatField1TS.__reduce__=MEDCouplingMEDFileFloatField1TSReduce +def MEDCouplingMEDFileFloatFieldMultiTSReduce(self): + return MEDCouplingStdReduceFunct,(MEDFileFloatFieldMultiTS,((self.serialize(),),(self.__getstate__()),)) +MEDFileFloatFieldMultiTS.__reduce__=MEDCouplingMEDFileFloatFieldMultiTSReduce +del MEDCouplingMEDFileFloatFieldMultiTSReduce +def MEDCouplingMEDFileParametersReduce(self): + return MEDCouplingStdReduceFunct,(MEDFileParameters,((self.serialize(),),(self.__getstate__()),)) +MEDFileParameters.__reduce__=MEDCouplingMEDFileParametersReduce +del MEDCouplingMEDFileParametersReduce %} diff --git a/src/MEDLoader/Swig/MEDLoaderCommon.i b/src/MEDLoader/Swig/MEDLoaderCommon.i index e2bf73373..fd8b3c25e 100644 --- a/src/MEDLoader/Swig/MEDLoaderCommon.i +++ b/src/MEDLoader/Swig/MEDLoaderCommon.i @@ -622,24 +622,6 @@ namespace MEDCoupling void __setstate__(PyObject *inp) throw(INTERP_KERNEL::Exception) { } - - PyObject *__getnewargs__() throw(INTERP_KERNEL::Exception) - { -#ifdef WITH_NUMPY - PyObject *ret(PyTuple_New(1)); - PyObject *ret0(PyDict_New()); - DataArrayByte *retCpp(MEDCoupling_MEDFileWritableStandAlone_serialize(self)); - PyObject *numpyArryObj=SWIG_NewPointerObj(SWIG_as_voidptr(retCpp),SWIGTYPE_p_MEDCoupling__DataArrayByte, SWIG_POINTER_OWN | 0 ); - {// 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 MEDFileData.__getnewargs__ : not implemented because numpy is not active in your configuration ! No serialization/unserialization available without numpy !"); -#endif - } } }; @@ -1440,12 +1422,6 @@ namespace MEDCoupling return MEDFileUMesh::New(); } - // serialization - static PyObject *___new___(PyObject *cls, PyObject *args) throw(INTERP_KERNEL::Exception) - { - return NewMethWrapCallInitOnlyIfEmptyDictInInput(cls,args,"MEDFileUMesh"); - } - static MEDFileUMesh *LoadPartOf(const std::string& fileName, const std::string& mName, PyObject *types, const std::vector& slicPerTyp, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0) throw(INTERP_KERNEL::Exception) { std::vector typesCpp1; @@ -1457,14 +1433,6 @@ namespace MEDCoupling return MEDFileUMesh::LoadPartOf(fileName,mName,typesCpp2,slicPerTyp,dt,it,mrs); } - 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__() throw(INTERP_KERNEL::Exception) { std::vector a0; @@ -1724,12 +1692,6 @@ namespace MEDCoupling { return MEDFileCMesh::New(db); } - - // serialization - static PyObject *___new___(PyObject *cls, PyObject *args) throw(INTERP_KERNEL::Exception) - { - return NewMethWrapCallInitOnlyIfDictWithSingleEltInInput(cls,args,"MEDFileCMesh"); - } PyObject *getMesh() const throw(INTERP_KERNEL::Exception) { @@ -1770,12 +1732,6 @@ namespace MEDCoupling { return MEDFileCurveLinearMesh::New(db); } - - // serialization - static PyObject *___new___(PyObject *cls, PyObject *args) throw(INTERP_KERNEL::Exception) - { - return NewMethWrapCallInitOnlyIfDictWithSingleEltInInput(cls,args,"MEDFileCurveLinearMesh"); - } PyObject *getMesh() const throw(INTERP_KERNEL::Exception) { @@ -1879,12 +1835,6 @@ namespace MEDCoupling return MEDFileMeshes::New(db); } - // serialization - static PyObject *___new___(PyObject *cls, PyObject *args) throw(INTERP_KERNEL::Exception) - { - return NewMethWrapCallInitOnlyIfDictWithSingleEltInInput(cls,args,"MEDFileMeshes"); - } - std::string __str__() const throw(INTERP_KERNEL::Exception) { return self->simpleRepr(); @@ -2310,12 +2260,6 @@ namespace MEDCoupling { return MEDFileField1TS::New(); } - - // serialization - static PyObject *___new___(PyObject *cls, PyObject *args) throw(INTERP_KERNEL::Exception) - { - return NewMethWrapCallInitOnlyIfDictWithSingleEltInInput(cls,args,"MEDFileField1TS"); - } void copyTinyInfoFrom(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception) { @@ -2429,12 +2373,6 @@ namespace MEDCoupling return MEDFileIntField1TS::New(db); } - // serialization - static PyObject *___new___(PyObject *cls, PyObject *args) throw(INTERP_KERNEL::Exception) - { - return NewMethWrapCallInitOnlyIfDictWithSingleEltInInput(cls,args,"MEDFileIntField1TS"); - } - std::string __str__() const throw(INTERP_KERNEL::Exception) { return self->simpleRepr(); @@ -2505,12 +2443,6 @@ namespace MEDCoupling return MEDFileFloatField1TS::New(db); } - // serialization - static PyObject *___new___(PyObject *cls, PyObject *args) throw(INTERP_KERNEL::Exception) - { - return NewMethWrapCallInitOnlyIfDictWithSingleEltInInput(cls,args,"MEDFileFloatField1TS"); - } - std::string __str__() const throw(INTERP_KERNEL::Exception) { return self->simpleRepr(); @@ -2965,12 +2897,6 @@ namespace MEDCoupling { return MEDFileFieldMultiTS::New(db); } - - // serialization - static PyObject *___new___(PyObject *cls, PyObject *args) throw(INTERP_KERNEL::Exception) - { - return NewMethWrapCallInitOnlyIfDictWithSingleEltInInput(cls,args,"MEDFileFieldMultiTS"); - } static MEDFileFieldMultiTS *LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, PyObject *entities, bool loadAll=true) { @@ -3128,12 +3054,6 @@ namespace MEDCoupling return MEDFileIntFieldMultiTS::New(db); } - // serialization - static PyObject *___new___(PyObject *cls, PyObject *args) throw(INTERP_KERNEL::Exception) - { - return NewMethWrapCallInitOnlyIfDictWithSingleEltInInput(cls,args,"MEDFileIntFieldMultiTS"); - } - static MEDFileIntFieldMultiTS *LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, PyObject *entities, bool loadAll=true) { std::vector > tmp(convertTimePairIdsFromPy(entities)); @@ -3205,12 +3125,6 @@ namespace MEDCoupling return MEDFileFloatFieldMultiTS::New(db); } - // serialization - static PyObject *___new___(PyObject *cls, PyObject *args) throw(INTERP_KERNEL::Exception) - { - return NewMethWrapCallInitOnlyIfDictWithSingleEltInInput(cls,args,"MEDFileFloatFieldMultiTS"); - } - static MEDFileFloatFieldMultiTS *LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, PyObject *entities, bool loadAll=true) { std::vector > tmp(convertTimePairIdsFromPy(entities)); @@ -3325,12 +3239,6 @@ namespace MEDCoupling return MEDFileFields::NewAdv(fileName,loadAll,entities); } - // serialization - static PyObject *___new___(PyObject *cls, PyObject *args) throw(INTERP_KERNEL::Exception) - { - return NewMethWrapCallInitOnlyIfDictWithSingleEltInInput(cls,args,"MEDFileFields"); - } - std::string __str__() const throw(INTERP_KERNEL::Exception) { return self->simpleRepr(); @@ -3820,12 +3728,6 @@ namespace MEDCoupling { return MEDFileParameters::New(db); } - - // serialization - static PyObject *___new___(PyObject *cls, PyObject *args) throw(INTERP_KERNEL::Exception) - { - return NewMethWrapCallInitOnlyIfDictWithSingleEltInInput(cls,args,"MEDFileParameters"); - } std::string __str__() const throw(INTERP_KERNEL::Exception) { @@ -3962,12 +3864,6 @@ namespace MEDCoupling MCAuto ret(MEDFileData::Aggregate(mfdsCpp)); return ret.retn(); } - - // serialization - static PyObject *___new___(PyObject *cls, PyObject *args) throw(INTERP_KERNEL::Exception) - { - return NewMethWrapCallInitOnlyIfDictWithSingleEltInInput(cls,args,"MEDFileData"); - } } };