From: Anthony Geay Date: Wed, 3 May 2017 12:44:03 +0000 (+0200) Subject: On the road X-Git-Tag: V8_4_0a1~61 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c5215e4b2e51b32334451e59784347769a9b8251;p=tools%2Fmedcoupling.git On the road --- diff --git a/src/MEDCoupling_Swig/MEDCoupling.i b/src/MEDCoupling_Swig/MEDCoupling.i index 1b97cd31d..1342d2aac 100644 --- a/src/MEDCoupling_Swig/MEDCoupling.i +++ b/src/MEDCoupling_Swig/MEDCoupling.i @@ -80,6 +80,9 @@ def MEDCouplingDataArrayIntIpow(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) diff --git a/src/MEDCoupling_Swig/MEDCouplingFinalize.i b/src/MEDCoupling_Swig/MEDCouplingFinalize.i index 467597ee4..384c448e1 100644 --- a/src/MEDCoupling_Swig/MEDCouplingFinalize.i +++ b/src/MEDCoupling_Swig/MEDCouplingFinalize.i @@ -36,11 +36,13 @@ DataArrayInt.__ipow__=MEDCouplingDataArrayIntIpow DataArrayByte.__new__=classmethod(MEDCouplingDataArrayBytenew) +DataArrayFloat.__new__=MEDCouplingDataArrayFloatnew DataArrayFloat.__iadd__=MEDCouplingDataArrayFloatIadd DataArrayFloat.__isub__=MEDCouplingDataArrayFloatIsub DataArrayFloat.__imul__=MEDCouplingDataArrayFloatImul DataArrayFloat.__idiv__=MEDCouplingDataArrayFloatIdiv +MEDCouplingFieldDouble.__new__=classmethod(MEDCouplingFieldDoublenew) MEDCouplingFieldDouble.__iadd__=MEDCouplingFieldDoubleIadd MEDCouplingFieldDouble.__isub__=MEDCouplingFieldDoubleIsub MEDCouplingFieldDouble.__imul__=MEDCouplingFieldDoubleImul @@ -68,7 +70,6 @@ MEDCouplingCurveLinearMesh.__new__=classmethod(MEDCouplingCurveLinearMeshnew) MEDCouplingCMesh.__new__=classmethod(MEDCouplingCMeshnew) MEDCouplingIMesh.__new__=classmethod(MEDCouplingIMeshnew) MEDCouplingMappedExtrudedMesh.__new__=classmethod(MEDCouplingExtrudedMeshnew) -MEDCouplingFieldDouble.__new__=classmethod(MEDCouplingFieldDoublenew) del INTERPKERNELExceptionReduce del MEDCouplingDataArrayDoublenew @@ -88,6 +89,7 @@ del MEDCouplingDataArrayIntImul del MEDCouplingDataArrayIntIdiv del MEDCouplingDataArrayIntImod del MEDCouplingDataArrayBytenew +del MEDCouplingDataArrayFloatnew del MEDCouplingDataArrayFloatIadd del MEDCouplingDataArrayFloatIsub del MEDCouplingDataArrayFloatImul diff --git a/src/MEDCoupling_Swig/MEDCouplingMemArray.i b/src/MEDCoupling_Swig/MEDCouplingMemArray.i index fcad0d7c0..f7b62cdd5 100644 --- a/src/MEDCoupling_Swig/MEDCouplingMemArray.i +++ b/src/MEDCoupling_Swig/MEDCouplingMemArray.i @@ -697,7 +697,7 @@ namespace MEDCoupling { return MEDCoupling_DataArrayFloat_New__SWIG_1(elt0,nbOfTuples,elt2); } - + DataArrayFloatIterator *__iter__() throw(INTERP_KERNEL::Exception) { return self->iterator(); @@ -776,7 +776,31 @@ 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 + } } }; diff --git a/src/MEDCoupling_Swig/MEDCouplingRemapper.i b/src/MEDCoupling_Swig/MEDCouplingRemapper.i index 71d4ad564..7bbd61cd7 100644 --- a/src/MEDCoupling_Swig/MEDCouplingRemapper.i +++ b/src/MEDCoupling_Swig/MEDCouplingRemapper.i @@ -142,6 +142,9 @@ def MEDCouplingFieldDoubleIpow(self,*args): def MEDCouplingDataArrayBytenew(cls,*args): import _MEDCouplingRemapper return _MEDCouplingRemapper.DataArrayByte____new___(cls,args) +def MEDCouplingDataArrayFloatnew(cls,*args): + import _MEDCouplingRemapper + return _MEDCouplingRemapper.DataArrayFloat____new___(cls,args) def MEDCouplingDataArrayFloatIadd(self,*args): import _MEDCouplingRemapper return _MEDCouplingRemapper.DataArrayFloat____iadd___(self, self, *args) diff --git a/src/MEDLoader/Swig/MEDLoader.i b/src/MEDLoader/Swig/MEDLoader.i index c00b24538..250022c4e 100644 --- a/src/MEDLoader/Swig/MEDLoader.i +++ b/src/MEDLoader/Swig/MEDLoader.i @@ -60,6 +60,9 @@ def MEDCouplingFieldDoubleIpow(self,*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) diff --git a/src/RENUMBER_Swig/MEDRenumber.i b/src/RENUMBER_Swig/MEDRenumber.i index 54ab2c996..82667ea27 100644 --- a/src/RENUMBER_Swig/MEDRenumber.i +++ b/src/RENUMBER_Swig/MEDRenumber.i @@ -62,6 +62,9 @@ def MEDCouplingDataArrayIntIpow(self,*args): def MEDCouplingDataArrayBytenew(cls,*args): import _MEDRenumber return _MEDRenumber.DataArrayByte____new___(cls,args) +def MEDCouplingDataArrayFloatnew(cls,*args): + import _MEDRenumber + return _MEDRenumber.DataArrayFloat____new___(cls,args) def MEDCouplingDataArrayFloatIadd(self,*args): import _MEDRenumber return _MEDRenumber.DataArrayFloat____iadd___(self, self, *args)