self.assertTrue(d.convertToFloatArr().isEqual(DataArrayFloat([-5,-4,-3,-2,-1,0,1,2,3,4]),1e-7))
self.assertTrue(d.convertToFloatArr().convertToDblArr().isEqual(d,1e-12))
pass
+
+ def testMapII1(self):
+ """ Test optimized maps for renumbering. Typical usage local to global in parallel mode"""
+ d=DataArrayInt([1003,1007])
+ m=d.invertArrayN2O2O2NOptimized()
+ d2=DataArrayInt([1003,1003,1007,1003,1007])
+ d2.transformWithIndArr(m)
+ self.assertTrue(d2.isEqual(DataArrayInt([0,0,1,0,1])))
+ pass
+
pass
if __name__ == '__main__':
DataArrayInt *invertArrayO2N2N2O(int newNbOfElem) const throw(INTERP_KERNEL::Exception);
DataArrayInt *invertArrayN2O2O2N(int oldNbOfElem) const throw(INTERP_KERNEL::Exception);
DataArrayInt *invertArrayO2N2N2OBis(int newNbOfElem) const throw(INTERP_KERNEL::Exception);
+ MCAuto< MapII > invertArrayN2O2O2NOptimized() const throw(INTERP_KERNEL::Exception);
DataArrayInt *indicesOfSubPart(const DataArrayInt& partOfThis) const throw(INTERP_KERNEL::Exception);
DataArrayInt *fromNoInterlace() const throw(INTERP_KERNEL::Exception);
DataArrayInt *toNoInterlace() const throw(INTERP_KERNEL::Exception);
void transformWithIndArr(PyObject *li) throw(INTERP_KERNEL::Exception)
{
void *da=0;
- int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_MEDCoupling__DataArrayInt, 0 | 0 );
+ int res1(SWIG_ConvertPtr(li,&da,SWIGTYPE_p_MEDCoupling__DataArrayInt, 0 | 0 ));
if (!SWIG_IsOK(res1))
{
- int size;
- INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
- self->transformWithIndArr(tmp,tmp+size);
+ int res2(SWIG_ConvertPtr(li,&da,SWIGTYPE_p_MEDCoupling__MapII, 0 | 0 ));
+ if(SWIG_IsOK(res2))
+ {
+ MapII *m=reinterpret_cast<MapII *>(da);
+ self->transformWithIndArr(*m);
+ }
+ else
+ {
+ int size;
+ INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+ self->transformWithIndArr(tmp,tmp+size);
+ }
}
else
{