From: ageay Date: Tue, 19 Feb 2013 16:49:36 +0000 (+0000) Subject: Correct bugs in DataArray*::__setitem__ python API when pylist or pytuple in argument. X-Git-Tag: V6_main_FINAL~347 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=28b28005fc1581113dcd83b96863fd00ef176d07;p=tools%2Fmedcoupling.git Correct bugs in DataArray*::__setitem__ python API when pylist or pytuple in argument. --- diff --git a/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py b/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py index 4e20c5a6c..63eb79e26 100644 --- a/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py +++ b/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py @@ -149,6 +149,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): targetMesh.insertNextCell(NORM_POINT1,1,[7]); targetMesh.insertNextCell(NORM_POINT1,1,[6]); targetMesh.finishInsertingCells(); + self.assertRaises(InterpKernelException,targetMesh.checkCoherency); myCoords=DataArrayDouble.New(); myCoords.setValues(targetCoords,9,3); targetMesh.setCoords(myCoords); @@ -11133,6 +11134,39 @@ class MEDCouplingBasicsTest(unittest.TestCase): self.assertTrue(dv.isEqual(DataArrayInt([2,1,0,0,4,3,0,0,6,5,0,0,0,0,0,0],4,4))) pass + def testSwigSetItem3(self): + # 1-2 false + d=DataArrayDouble([0,0,0,0,0,0,0,0,0,0,0,0],6,2) + d[3]=[1,2] + self.assertTrue(d.isEqual(DataArrayDouble([0,0,0,0,0,0,1,2,0,0,0,0],6,2),1e-14)) + # 2-2 false + d=DataArrayDouble([0,0,0,0,0,0,0,0,0,0,0,0],6,2) + d[[5,3]]=[1,2] + self.assertTrue(d.isEqual(DataArrayDouble([0,0,0,0,0,0,1,2,0,0,1,2],6,2),1e-14)) + # 3-2 false + d=DataArrayDouble([0,0,0,0,0,0,0,0,0,0,0,0],6,2) + d[:]=[1,2] + self.assertTrue(d.isEqual(DataArrayDouble([1,2,1,2,1,2,1,2,1,2,1,2],6,2),1e-14)) + # 4-2 false + d=DataArrayDouble([0,0,0,0,0,0,0,0,0,0,0,0],6,2) + d[DataArrayInt([0,3,4])]=[1,2] + self.assertTrue(d.isEqual(DataArrayDouble([1,2,0,0,0,0,1,2,1,2,0,0],6,2),1e-14)) + # 5-2 + d=DataArrayDouble([0,0,0,0,0,0,0,0,0,0,0,0],6,2) + d[5,1]=[7] + self.assertTrue(d.isEqual(DataArrayDouble([0,0,0,0,0,0,0,0,0,0,0,7],6,2),1e-14)) + # 6-2 false + d=DataArrayDouble([0,0,0,0,0,0,0,0,0,0,0,0],6,2) + d[[3,5],1]=[7] + self.assertTrue(d.isEqual(DataArrayDouble([0,0,0,0,0,0,0,7,0,0,0,7],6,2),1e-14)) + # 7-2 false + d=DataArrayDouble([0,0,0,0,0,0,0,0,0,0,0,0],6,2) + d[:-1:2,1]=[7] + self.assertTrue(d.isEqual(DataArrayDouble([0,7,0,0,0,7,0,0,0,7,0,0],6,2),1e-14)) + # 8-2 + + pass + def setUp(self): pass pass diff --git a/src/MEDCoupling_Swig/MEDCouplingCommon.i b/src/MEDCoupling_Swig/MEDCouplingCommon.i index 08f54bc23..bdfc8d283 100644 --- a/src/MEDCoupling_Swig/MEDCouplingCommon.i +++ b/src/MEDCoupling_Swig/MEDCouplingCommon.i @@ -3507,7 +3507,7 @@ namespace ParaMEDMEM return self; case 2: tmp=DataArrayDouble::New(); - tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1); + tmp->useArray(&v1[0],false,CPP_DEALLOC,1,v1.size()); self->setPartOfValues1(tmp,it1,it1+1,1,0,nbOfComponents,1,false); return self; case 3: @@ -3547,7 +3547,7 @@ namespace ParaMEDMEM return self; case 2: tmp=DataArrayDouble::New(); - tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1); + tmp->useArray(&v1[0],false,CPP_DEALLOC,1,v1.size()); self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,0,nbOfComponents,1,false); return self; case 3: @@ -3587,7 +3587,7 @@ namespace ParaMEDMEM return self; case 2: tmp=DataArrayDouble::New(); - tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1); + tmp->useArray(&v1[0],false,CPP_DEALLOC,1,v1.size()); self->setPartOfValues1(tmp,it1,it1+1,1,ic1,ic1+1,1,false); return self; case 3: @@ -3627,7 +3627,7 @@ namespace ParaMEDMEM return self; case 2: tmp=DataArrayDouble::New(); - tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1); + tmp->useArray(&v1[0],false,CPP_DEALLOC,1,v1.size()); self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,ic1,ic1+1,1,false); return self; case 3: @@ -3756,7 +3756,7 @@ namespace ParaMEDMEM return self; case 2: tmp=DataArrayDouble::New(); - tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1); + tmp->useArray(&v1[0],false,CPP_DEALLOC,1,v1.size()); self->setPartOfValues1(tmp,it1,it1+1,1,pc1.first,pc1.second.first,pc1.second.second,false); return self; case 3: @@ -3796,7 +3796,7 @@ namespace ParaMEDMEM return self; case 2: tmp=DataArrayDouble::New(); - tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1); + tmp->useArray(&v1[0],false,CPP_DEALLOC,1,v1.size()); self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,pc1.first,pc1.second.first,pc1.second.second,false); return self; case 3: @@ -5391,7 +5391,7 @@ namespace ParaMEDMEM return self; case 2: tmp=DataArrayInt::New(); - tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1); + tmp->useArray(&v1[0],false,CPP_DEALLOC,1,v1.size()); self->setPartOfValues1(tmp,it1,it1+1,1,0,nbOfComponents,1,false); return self; case 3: @@ -5439,7 +5439,7 @@ namespace ParaMEDMEM return self; case 2: tmp=DataArrayInt::New(); - tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1); + tmp->useArray(&v1[0],false,CPP_DEALLOC,1,v1.size()); self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,0,nbOfComponents,1,false); return self; case 3: @@ -5487,7 +5487,7 @@ namespace ParaMEDMEM return self; case 2: tmp=DataArrayInt::New(); - tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1); + tmp->useArray(&v1[0],false,CPP_DEALLOC,1,v1.size()); self->setPartOfValues1(tmp,it1,it1+1,1,ic1,ic1+1,1,false); return self; case 3: @@ -5535,7 +5535,7 @@ namespace ParaMEDMEM return self; case 2: tmp=DataArrayInt::New(); - tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1); + tmp->useArray(&v1[0],false,CPP_DEALLOC,1,v1.size()); self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,ic1,ic1+1,1,false); return self; case 3: @@ -5688,7 +5688,7 @@ namespace ParaMEDMEM return self; case 2: tmp=DataArrayInt::New(); - tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1); + tmp->useArray(&v1[0],false,CPP_DEALLOC,1,v1.size()); self->setPartOfValues1(tmp,it1,it1+1,1,pc1.first,pc1.second.first,pc1.second.second,false); return self; case 3: @@ -5736,7 +5736,7 @@ namespace ParaMEDMEM return self; case 2: tmp=DataArrayInt::New(); - tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1); + tmp->useArray(&v1[0],false,CPP_DEALLOC,1,v1.size()); self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,pc1.first,pc1.second.first,pc1.second.second,false); return self; case 3: