From: geay Date: Wed, 9 Apr 2014 14:09:21 +0000 (+0200) Subject: Py binding of static method DataArrayInt.CheckAndPreparePermutation. X-Git-Tag: V7_4_0b1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=e6bf214f5843573d9ff9c2a9742c471a71320bec;p=tools%2Fmedcoupling.git Py binding of static method DataArrayInt.CheckAndPreparePermutation. --- diff --git a/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py b/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py index 1f58aec18..5ae3883ea 100644 --- a/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py +++ b/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py @@ -14724,6 +14724,15 @@ class MEDCouplingBasicsTest(unittest.TestCase): self.assertTrue(m.getNodalConnectivityIndex().isEqual(DataArrayInt([0,5]))) pass + def testSwig2CheckAndPreparePermutation2(self): + a=DataArrayInt([10003,9999999,5,67]) + self.assertTrue(DataArrayInt.CheckAndPreparePermutation(a).isEqual(DataArrayInt([2,3,0,1]))) + a=DataArrayInt([10003,-9999999,5,67]) + self.assertTrue(DataArrayInt.CheckAndPreparePermutation(a).isEqual(DataArrayInt([3,0,1,2]))) + a=DataArrayInt([]) + self.assertTrue(DataArrayInt.checkAndPreparePermutation(a).isEqual(DataArrayInt([]))) + pass + def setUp(self): pass pass diff --git a/src/MEDCoupling_Swig/MEDCouplingMemArray.i b/src/MEDCoupling_Swig/MEDCouplingMemArray.i index c17ed322b..a47188a90 100644 --- a/src/MEDCoupling_Swig/MEDCouplingMemArray.i +++ b/src/MEDCoupling_Swig/MEDCouplingMemArray.i @@ -102,6 +102,7 @@ %newobject ParaMEDMEM::DataArrayInt::buildPermArrPerLevel; %newobject ParaMEDMEM::DataArrayInt::getDifferentValues; %newobject ParaMEDMEM::DataArrayInt::FindPermutationFromFirstToSecond; +%newobject ParaMEDMEM::DataArrayInt::CheckAndPreparePermutation; %newobject ParaMEDMEM::DataArrayInt::__neg__; %newobject ParaMEDMEM::DataArrayInt::__add__; %newobject ParaMEDMEM::DataArrayInt::__radd__; @@ -2787,6 +2788,17 @@ namespace ParaMEDMEM return ret; } + static DataArrayInt *CheckAndPreparePermutation(PyObject *arr) throw(INTERP_KERNEL::Exception) + { + MEDCouplingAutoRefCountObjectPtr ret(DataArrayInt::New()); + int szArr,sw,iTypppArr; + std::vector stdvecTyyppArr; + const int *arrPtr(convertObjToPossibleCpp1_Safe(arr,sw,szArr,iTypppArr,stdvecTyyppArr)); + int *pt(ParaMEDMEM::DataArrayInt::CheckAndPreparePermutation(arrPtr,arrPtr+szArr)); + ret->useArray(pt,true,ParaMEDMEM::C_DEALLOC,szArr,1); + return ret.retn(); + } + void setValues(PyObject *li, PyObject *nbOfTuples=0, PyObject *nbOfComp=0) throw(INTERP_KERNEL::Exception) { const char *msg="ParaMEDMEM::DataArrayInt::setValues : Available API are : \n-DataArrayInt.setValues([1,3,4])\n-DataArrayInt.setValues([1,3,4],3)\n-DataArrayInt.setValues([1,3,4,5],2,2)\n-DataArrayInt.New(5)\n !";