From: Anthony Geay Date: Mon, 16 Oct 2017 09:59:12 +0000 (+0200) Subject: On the road X-Git-Tag: V9_0_0~46 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=730fb0db9239604a3a012b55fce738a54bf06912;p=tools%2Fmedcoupling.git On the road --- diff --git a/src/MEDCoupling_Swig/MEDCoupling.i b/src/MEDCoupling_Swig/MEDCoupling.i index 41eab4b45..13e0b6eaf 100644 --- a/src/MEDCoupling_Swig/MEDCoupling.i +++ b/src/MEDCoupling_Swig/MEDCoupling.i @@ -20,9 +20,6 @@ %include "MEDCouplingCommon.i" %pythoncode %{ -def MEDCouplingDataArrayDoublenew(cls,*args): - import _MEDCoupling - return _MEDCoupling.DataArrayDouble____new___(cls,args) def MEDCouplingDataArrayDoubleIadd(self,*args): import _MEDCoupling return _MEDCoupling.DataArrayDouble____iadd___(self, self, *args) @@ -38,9 +35,6 @@ def MEDCouplingDataArrayDoubleIdiv(self,*args): def MEDCouplingDataArrayDoubleIpow(self,*args): import _MEDCoupling return _MEDCoupling.DataArrayDouble____ipow___(self, self, *args) -def MEDCouplingFieldDoublenew(cls,*args): - import _MEDCoupling - return _MEDCoupling.MEDCouplingFieldDouble____new___(cls,args) def MEDCouplingFieldDoubleIadd(self,*args): import _MEDCoupling return _MEDCoupling.MEDCouplingFieldDouble____iadd___(self, self, *args) @@ -56,15 +50,6 @@ def MEDCouplingFieldDoubleIdiv(self,*args): def MEDCouplingFieldDoubleIpow(self,*args): import _MEDCoupling return _MEDCoupling.MEDCouplingFieldDouble____ipow___(self, self, *args) -def MEDCouplingFieldIntnew(cls,*args): - import _MEDCoupling - return _MEDCoupling.MEDCouplingFieldInt____new___(cls,args) -def MEDCouplingFieldFloatnew(cls,*args): - import _MEDCoupling - return _MEDCoupling.MEDCouplingFieldFloat____new___(cls,args) -def MEDCouplingDataArrayIntnew(cls,*args): - import _MEDCoupling - return _MEDCoupling.DataArrayInt____new___(cls,args) def MEDCouplingDataArrayIntIadd(self,*args): import _MEDCoupling return _MEDCoupling.DataArrayInt____iadd___(self, self, *args) @@ -83,12 +68,6 @@ def MEDCouplingDataArrayIntImod(self,*args): def MEDCouplingDataArrayIntIpow(self,*args): import _MEDCoupling return _MEDCoupling.DataArrayInt____ipow___(self, self, *args) -def MEDCouplingDataArrayBytenew(cls,*args): - import _MEDCoupling - return _MEDCoupling.DataArrayByte____new___(cls,args) -def MEDCouplingDataArrayFloatnew(cls,*args): - import _MEDCoupling - return _MEDCoupling.DataArrayFloat____new___(cls,args) def MEDCouplingDataArrayFloatIadd(self,*args): import _MEDCoupling return _MEDCoupling.DataArrayFloat____iadd___(self, self, *args) @@ -134,27 +113,6 @@ def ParaMEDMEMDenseMatrixIadd(self,*args): def ParaMEDMEMDenseMatrixIsub(self,*args): import _MEDCoupling return _MEDCoupling.DenseMatrix____isub___(self, self, *args) -def MEDCouplingUMeshnew(cls,*args): - import _MEDCoupling - return _MEDCoupling.MEDCouplingUMesh____new___(cls,args) -def MEDCoupling1DGTUMeshnew(cls,*args): - import _MEDCoupling - return _MEDCoupling.MEDCoupling1DGTUMesh____new___(cls,args) -def MEDCoupling1SGTUMeshnew(cls,*args): - import _MEDCoupling - return _MEDCoupling.MEDCoupling1SGTUMesh____new___(cls,args) -def MEDCouplingCurveLinearMeshnew(cls,*args): - import _MEDCoupling - return _MEDCoupling.MEDCouplingCurveLinearMesh____new___(cls,args) -def MEDCouplingCMeshnew(cls,*args): - import _MEDCoupling - return _MEDCoupling.MEDCouplingCMesh____new___(cls,args) -def MEDCouplingIMeshnew(cls,*args): - import _MEDCoupling - return _MEDCoupling.MEDCouplingIMesh____new___(cls,args) -def MEDCouplingExtrudedMeshnew(cls,*args): - import _MEDCoupling - return _MEDCoupling.MEDCouplingMappedExtrudedMesh____new___(cls,args) %} %include "MEDCouplingFinalize.i" diff --git a/src/MEDCoupling_Swig/MEDCouplingCommon.i b/src/MEDCoupling_Swig/MEDCouplingCommon.i index 445dc331e..d59771988 100644 --- a/src/MEDCoupling_Swig/MEDCouplingCommon.i +++ b/src/MEDCoupling_Swig/MEDCouplingCommon.i @@ -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) %module MEDCoupling @@ -1083,14 +1083,6 @@ namespace MEDCoupling 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(MEDCoupling_MEDCouplingMesh_getTinySerializationInformation(self)); @@ -2007,12 +1999,6 @@ namespace MEDCoupling 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(); @@ -3071,11 +3057,6 @@ namespace MEDCoupling { return MEDCouplingMappedExtrudedMesh::New(); } - - static PyObject *___new___(PyObject *cls, PyObject *args) throw(INTERP_KERNEL::Exception) - { - return NewMethWrapCallInitOnlyIfEmptyDictInInput(cls,args,"MEDCouplingMappedExtrudedMesh"); - } std::string __str__() const throw(INTERP_KERNEL::Exception) { @@ -3181,11 +3162,6 @@ namespace MEDCoupling 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(); @@ -3253,11 +3229,6 @@ namespace MEDCoupling 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(); @@ -3602,11 +3573,6 @@ namespace MEDCoupling { 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(); @@ -3646,10 +3612,6 @@ namespace MEDCoupling { 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(); @@ -3727,11 +3689,6 @@ namespace MEDCoupling return MEDCoupling_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; @@ -5057,16 +5014,6 @@ namespace MEDCoupling return field_serialize(self); } - static PyObject *___new___(PyObject *cls, PyObject *args) throw(INTERP_KERNEL::Exception) - { - return NewMethWrapCallInitOnlyIfDictWithSingleEltInInputGeneral(cls,args,"MEDCouplingFieldDouble"); - } - - PyObject *__getnewargs__() throw(INTERP_KERNEL::Exception) - {// put an empty dict in input to say to __new__ to call __init__... - return field__getnewargs__(self); - } - PyObject *__getstate__() const throw(INTERP_KERNEL::Exception) { return field__getstate__(self,MEDCoupling_MEDCouplingFieldDouble_getTinySerializationInformation,MEDCoupling_MEDCouplingFieldDouble_serialize); @@ -5326,16 +5273,6 @@ namespace MEDCoupling return field_serialize(self); } - static PyObject *___new___(PyObject *cls, PyObject *args) throw(INTERP_KERNEL::Exception) - { - return NewMethWrapCallInitOnlyIfDictWithSingleEltInInputGeneral(cls,args,"MEDCouplingFieldInt"); - } - - PyObject *__getnewargs__() throw(INTERP_KERNEL::Exception) - {// put an empty dict in input to say to __new__ to call __init__... - return field__getnewargs__(self); - } - PyObject *__getstate__() const throw(INTERP_KERNEL::Exception) { return field__getstate__(self,MEDCoupling_MEDCouplingFieldInt_getTinySerializationInformation,MEDCoupling_MEDCouplingFieldInt_serialize); @@ -5437,16 +5374,6 @@ namespace MEDCoupling { return field_serialize(self); } - - static PyObject *___new___(PyObject *cls, PyObject *args) throw(INTERP_KERNEL::Exception) - { - return NewMethWrapCallInitOnlyIfDictWithSingleEltInInputGeneral(cls,args,"MEDCouplingFieldFloat"); - } - - PyObject *__getnewargs__() throw(INTERP_KERNEL::Exception) - {// put an empty dict in input to say to __new__ to call __init__... - return field__getnewargs__(self); - } PyObject *__getstate__() const throw(INTERP_KERNEL::Exception) { @@ -6056,6 +5983,35 @@ namespace MEDCoupling }; } +%pythoncode %{ +def MEDCouplingUMeshReduce(self): + return MEDCouplingStdReduceFunct,(MEDCouplingUMesh,((),(self.__getstate__()),)) +def MEDCouplingCMeshReduce(self): + return MEDCouplingStdReduceFunct,(MEDCouplingCMesh,((),(self.__getstate__()),)) +def MEDCouplingIMeshReduce(self): + return MEDCouplingStdReduceFunct,(MEDCouplingIMesh,((),(self.__getstate__()),)) +def MEDCouplingMappedExtrudedMeshReduce(self): + return MEDCouplingStdReduceFunct,(MEDCouplingMappedExtrudedMesh,((),(self.__getstate__()),)) +def MEDCouplingCurveLinearMeshReduce(self): + return MEDCouplingStdReduceFunct,(MEDCouplingCurveLinearMesh,((),(self.__getstate__()),)) +def MEDCoupling1SGTUMeshReduce(self): + return MEDCouplingStdReduceFunct,(MEDCoupling1SGTUMesh,((),(self.__getstate__()),)) +def MEDCoupling1DGTUMeshReduce(self): + return MEDCouplingStdReduceFunct,(MEDCoupling1DGTUMesh,((),(self.__getstate__()),)) +def MEDCouplingFieldDoubleReduce(self): + self.checkConsistencyLight() + d={0:(self.getTypeOfField(),self.getTimeDiscretization())} + return MEDCouplingStdReduceFunct,(MEDCouplingFieldDouble,((d,),(self.__getstate__()),)) +def MEDCouplingFieldIntReduce(self): + self.checkConsistencyLight() + d={0:(self.getTypeOfField(),self.getTimeDiscretization())} + return MEDCouplingStdReduceFunct,(MEDCouplingFieldInt,((d,),(self.__getstate__()),)) +def MEDCouplingFieldFloatReduce(self): + self.checkConsistencyLight() + d={0:(self.getTypeOfField(),self.getTimeDiscretization())} + return MEDCouplingStdReduceFunct,(MEDCouplingFieldFloat,((d,),(self.__getstate__()),)) +%} + %pythoncode %{ import os __filename=os.environ.get('PYTHONSTARTUP') diff --git a/src/MEDCoupling_Swig/MEDCouplingFinalize.i b/src/MEDCoupling_Swig/MEDCouplingFinalize.i index 34c624c78..b442ece3a 100644 --- a/src/MEDCoupling_Swig/MEDCouplingFinalize.i +++ b/src/MEDCoupling_Swig/MEDCouplingFinalize.i @@ -19,7 +19,8 @@ %pythoncode %{ InterpKernelException.__reduce__=INTERPKERNELExceptionReduce -DataArrayDouble.__new__=classmethod(MEDCouplingDataArrayDoublenew) + +DataArrayDouble.__reduce__=MEDCouplingDataArrayDoubleReduce DataArrayDouble.__iadd__=MEDCouplingDataArrayDoubleIadd DataArrayDouble.__isub__=MEDCouplingDataArrayDoubleIsub DataArrayDouble.__imul__=MEDCouplingDataArrayDoubleImul @@ -31,7 +32,7 @@ DataArrayDouble.__rtruediv__=DataArrayDouble.__rdiv__ DataArrayDouble.__floordiv__=DataArrayDouble.__div__ DataArrayDouble.__ifloordiv__=MEDCouplingDataArrayDoubleIdiv DataArrayDouble.__rfloordiv__=DataArrayDouble.__rdiv__ - + DataArrayInt.__reduce__=MEDCouplingDataArrayIntReduce DataArrayInt.__iadd__=MEDCouplingDataArrayIntIadd DataArrayInt.__isub__=MEDCouplingDataArrayIntIsub @@ -46,9 +47,9 @@ DataArrayInt.__floordiv__=DataArrayInt.__div__ DataArrayInt.__ifloordiv__=MEDCouplingDataArrayIntIdiv DataArrayInt.__rfloordiv__=DataArrayInt.__rdiv__ -DataArrayByte.__new__=classmethod(MEDCouplingDataArrayBytenew) - -DataArrayFloat.__new__=classmethod(MEDCouplingDataArrayFloatnew) +DataArrayByte.__reduce__=MEDCouplingDataArrayByteReduce + +DataArrayFloat.__reduce__=MEDCouplingDataArrayFloatReduce DataArrayFloat.__iadd__=MEDCouplingDataArrayFloatIadd DataArrayFloat.__isub__=MEDCouplingDataArrayFloatIsub DataArrayFloat.__imul__=MEDCouplingDataArrayFloatImul @@ -56,7 +57,7 @@ DataArrayFloat.__idiv__=MEDCouplingDataArrayFloatIdiv DataArrayFloat.__itruediv__=MEDCouplingDataArrayFloatIdiv DataArrayFloat.__ifloordiv__=MEDCouplingDataArrayFloatIdiv -MEDCouplingFieldDouble.__new__=classmethod(MEDCouplingFieldDoublenew) +MEDCouplingFieldDouble.__reduce__=MEDCouplingFieldDoubleReduce MEDCouplingFieldDouble.__iadd__=MEDCouplingFieldDoubleIadd MEDCouplingFieldDouble.__isub__=MEDCouplingFieldDoubleIsub MEDCouplingFieldDouble.__imul__=MEDCouplingFieldDoubleImul @@ -69,9 +70,9 @@ MEDCouplingFieldDouble.__floordiv__=MEDCouplingFieldDouble.__div__ MEDCouplingFieldDouble.__rfloordiv__=MEDCouplingFieldDouble.__rdiv__ MEDCouplingFieldDouble.__ifloordiv__=MEDCouplingFieldDoubleIdiv -MEDCouplingFieldInt.__new__=classmethod(MEDCouplingFieldIntnew) +MEDCouplingFieldInt.__reduce__=MEDCouplingFieldIntReduce -MEDCouplingFieldFloat.__new__=classmethod(MEDCouplingFieldFloatnew) +MEDCouplingFieldFloat.__reduce__=MEDCouplingFieldFloatReduce DataArrayDoubleTuple.__iadd__=MEDCouplingDataArrayDoubleTupleIadd DataArrayDoubleTuple.__isub__=MEDCouplingDataArrayDoubleTupleIsub @@ -91,13 +92,13 @@ DataArrayIntTuple.__imod__=MEDCouplingDataArrayIntTupleImod DenseMatrix.__iadd__=ParaMEDMEMDenseMatrixIadd DenseMatrix.__isub__=ParaMEDMEMDenseMatrixIsub -MEDCouplingUMesh.__new__=classmethod(MEDCouplingUMeshnew) -MEDCoupling1DGTUMesh.__new__=classmethod(MEDCoupling1DGTUMeshnew) -MEDCoupling1SGTUMesh.__new__=classmethod(MEDCoupling1SGTUMeshnew) -MEDCouplingCurveLinearMesh.__new__=classmethod(MEDCouplingCurveLinearMeshnew) -MEDCouplingCMesh.__new__=classmethod(MEDCouplingCMeshnew) -MEDCouplingIMesh.__new__=classmethod(MEDCouplingIMeshnew) -MEDCouplingMappedExtrudedMesh.__new__=classmethod(MEDCouplingExtrudedMeshnew) +MEDCouplingUMesh.__reduce__=MEDCouplingUMeshReduce +MEDCoupling1DGTUMesh.__reduce__=MEDCoupling1DGTUMeshReduce +MEDCoupling1SGTUMesh.__reduce__=MEDCoupling1SGTUMeshReduce +MEDCouplingCurveLinearMesh.__reduce__=MEDCouplingCurveLinearMeshReduce +MEDCouplingCMesh.__reduce__=MEDCouplingCMeshReduce +MEDCouplingIMesh.__reduce__=MEDCouplingIMeshReduce +MEDCouplingMappedExtrudedMesh.__reduce__=MEDCouplingMappedExtrudedMeshReduce DataArrayAsciiCharIterator.__next__ = DataArrayAsciiCharIterator.next DataArrayIntIterator.__next__ = DataArrayIntIterator.next @@ -106,7 +107,19 @@ MEDCouplingUMeshCellIterator.__next__ = MEDCouplingUMeshCellIterator.next MEDCouplingUMeshCellByTypeIterator.__next__ = MEDCouplingUMeshCellByTypeIterator.next del INTERPKERNELExceptionReduce -del MEDCouplingDataArrayDoublenew +del MEDCouplingDataArrayDoubleReduce +del MEDCouplingDataArrayFloatReduce +del MEDCouplingDataArrayIntReduce +del MEDCouplingUMeshReduce +del MEDCouplingCMeshReduce +del MEDCouplingIMeshReduce +del MEDCouplingMappedExtrudedMeshReduce +del MEDCouplingCurveLinearMeshReduce +del MEDCoupling1SGTUMeshReduce +del MEDCoupling1DGTUMeshReduce +del MEDCouplingFieldDoubleReduce +del MEDCouplingFieldFloatReduce +del MEDCouplingFieldIntReduce del MEDCouplingDataArrayDoubleIadd del MEDCouplingDataArrayDoubleIsub del MEDCouplingDataArrayDoubleImul @@ -116,14 +129,11 @@ del MEDCouplingFieldDoubleIsub del MEDCouplingFieldDoubleImul del MEDCouplingFieldDoubleIdiv del MEDCouplingFieldDoubleIpow -del MEDCouplingDataArrayIntnew del MEDCouplingDataArrayIntIadd del MEDCouplingDataArrayIntIsub del MEDCouplingDataArrayIntImul del MEDCouplingDataArrayIntIdiv del MEDCouplingDataArrayIntImod -del MEDCouplingDataArrayBytenew -del MEDCouplingDataArrayFloatnew del MEDCouplingDataArrayFloatIadd del MEDCouplingDataArrayFloatIsub del MEDCouplingDataArrayFloatImul @@ -139,12 +149,4 @@ del MEDCouplingDataArrayIntTupleIdiv del MEDCouplingDataArrayIntTupleImod del ParaMEDMEMDenseMatrixIadd del ParaMEDMEMDenseMatrixIsub -del MEDCouplingUMeshnew -del MEDCoupling1DGTUMeshnew -del MEDCoupling1SGTUMeshnew -del MEDCouplingCurveLinearMeshnew -del MEDCouplingCMeshnew -del MEDCouplingIMeshnew -del MEDCouplingExtrudedMeshnew -del MEDCouplingFieldDoublenew %} diff --git a/src/MEDCoupling_Swig/MEDCouplingMemArray.i b/src/MEDCoupling_Swig/MEDCouplingMemArray.i index f814d5a0e..ca7543efa 100644 --- a/src/MEDCoupling_Swig/MEDCouplingMemArray.i +++ b/src/MEDCoupling_Swig/MEDCouplingMemArray.i @@ -800,31 +800,6 @@ namespace MEDCoupling return ToNumPyArray(self,NPY_FLOAT,"DataArrayFloat"); } #endif - - // serialization - static PyObject *___new___(PyObject *cls, PyObject *args) throw(INTERP_KERNEL::Exception) - { - return NewMethWrapCallInitOnlyIfDictWithSingleEltInInput(cls,args,"DataArrayFloat"); - } - - PyObject *__getnewargs__() throw(INTERP_KERNEL::Exception) - { -#ifdef WITH_NUMPY - if(!self->isAllocated()) - throw INTERP_KERNEL::Exception("PyWrap of DataArrayFloat.__getnewargs__ : self is not allocated !"); - PyObject *ret(PyTuple_New(1)); - PyObject *ret0(PyDict_New()); - PyObject *numpyArryObj(MEDCoupling_DataArrayFloat_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 - } } }; @@ -1938,31 +1913,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 - } } }; @@ -5062,31 +5012,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(); @@ -5952,14 +5877,30 @@ namespace MEDCoupling } %pythoncode %{ -def MEDCouplingDataArrayIntReduceFunct(cls,params): +def MEDCouplingStdReduceFunct(cls,params): a,b=params - ret=DataArrayInt.__new__(cls) + 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.__getnewargs__ : not implemented because numpy is not active in your configuration ! No serialization/unserialization available without numpy !") - return MEDCouplingDataArrayIntReduceFunct,(DataArrayInt,((self.toNumPyArray(),),(self.__getstate__()),)) + 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__()),)) %}