}
}
+void DataArrayDouble::setPartOfValues4(const DataArrayDouble *a, int bgTuples, int endTuples, int stepTuples, const int *bgComp, const int *endComp, bool strictCompoCompare) throw(INTERP_KERNEL::Exception)
+{
+ if(!a)
+ throw INTERP_KERNEL::Exception("DataArrayDouble::setPartOfValues4 : input DataArrayDouble is NULL !");
+ const char msg[]="DataArrayDouble::setPartOfValues4";
+ checkAllocated();
+ a->checkAllocated();
+ int newNbOfTuples=DataArray::GetNumberOfItemGivenBES(bgTuples,endTuples,stepTuples,msg);
+ int newNbOfComp=(int)std::distance(bgComp,endComp);
+ int nbComp=getNumberOfComponents();
+ for(const int *z=bgComp;z!=endComp;z++)
+ DataArray::CheckValueInRange(nbComp,*z,"invalid component id");
+ int nbOfTuples=getNumberOfTuples();
+ DataArray::CheckValueInRangeEx(nbOfTuples,bgTuples,endTuples,"invalid tuple value");
+ bool assignTech=true;
+ if(a->getNbOfElems()==newNbOfTuples*newNbOfComp)
+ {
+ if(strictCompoCompare)
+ a->checkNbOfTuplesAndComp(newNbOfTuples,newNbOfComp,msg);
+ }
+ else
+ {
+ a->checkNbOfTuplesAndComp(1,newNbOfComp,msg);
+ assignTech=false;
+ }
+ const double *srcPt=a->getConstPointer();
+ double *pt=getPointer()+bgTuples*nbComp;
+ if(assignTech)
+ {
+ for(int i=0;i<newNbOfTuples;i++,pt+=stepTuples*nbComp)
+ for(const int *z=bgComp;z!=endComp;z++,srcPt++)
+ pt[*z]=*srcPt;
+ }
+ else
+ {
+ for(int i=0;i<newNbOfTuples;i++,pt+=stepTuples*nbComp)
+ {
+ const double *srcPt2=srcPt;
+ for(const int *z=bgComp;z!=endComp;z++,srcPt2++)
+ pt[*z]=*srcPt2;
+ }
+ }
+}
+
+void DataArrayDouble::setPartOfValuesSimple4(double a, int bgTuples, int endTuples, int stepTuples, const int *bgComp, const int *endComp) throw(INTERP_KERNEL::Exception)
+{
+ const char msg[]="DataArrayDouble::setPartOfValuesSimple4";
+ checkAllocated();
+ int newNbOfTuples=DataArray::GetNumberOfItemGivenBES(bgTuples,endTuples,stepTuples,msg);
+ int nbComp=getNumberOfComponents();
+ for(const int *z=bgComp;z!=endComp;z++)
+ DataArray::CheckValueInRange(nbComp,*z,"invalid component id");
+ int nbOfTuples=getNumberOfTuples();
+ DataArray::CheckValueInRangeEx(nbOfTuples,bgTuples,endTuples,"invalid tuple value");
+ double *pt=getPointer()+bgTuples*nbComp;
+ for(int i=0;i<newNbOfTuples;i++,pt+=stepTuples*nbComp)
+ for(const int *z=bgComp;z!=endComp;z++)
+ pt[*z]=a;
+}
+
/*!
* 'this', 'a' and 'tuplesSelec' are expected to be defined. If not an exception will be thrown.
* @param a is an array having exactly the same number of components than 'this'
}
}
+void DataArrayInt::setPartOfValues4(const DataArrayInt *a, int bgTuples, int endTuples, int stepTuples, const int *bgComp, const int *endComp, bool strictCompoCompare) throw(INTERP_KERNEL::Exception)
+{
+ if(!a)
+ throw INTERP_KERNEL::Exception("DataArrayInt::setPartOfValues4 : input DataArrayInt is NULL !");
+ const char msg[]="DataArrayInt::setPartOfValues4";
+ checkAllocated();
+ a->checkAllocated();
+ int newNbOfTuples=DataArray::GetNumberOfItemGivenBES(bgTuples,endTuples,stepTuples,msg);
+ int newNbOfComp=(int)std::distance(bgComp,endComp);
+ int nbComp=getNumberOfComponents();
+ for(const int *z=bgComp;z!=endComp;z++)
+ DataArray::CheckValueInRange(nbComp,*z,"invalid component id");
+ int nbOfTuples=getNumberOfTuples();
+ DataArray::CheckValueInRangeEx(nbOfTuples,bgTuples,endTuples,"invalid tuple value");
+ bool assignTech=true;
+ if(a->getNbOfElems()==newNbOfTuples*newNbOfComp)
+ {
+ if(strictCompoCompare)
+ a->checkNbOfTuplesAndComp(newNbOfTuples,newNbOfComp,msg);
+ }
+ else
+ {
+ a->checkNbOfTuplesAndComp(1,newNbOfComp,msg);
+ assignTech=false;
+ }
+ const int *srcPt=a->getConstPointer();
+ int *pt=getPointer()+bgTuples*nbComp;
+ if(assignTech)
+ {
+ for(int i=0;i<newNbOfTuples;i++,pt+=stepTuples*nbComp)
+ for(const int *z=bgComp;z!=endComp;z++,srcPt++)
+ pt[*z]=*srcPt;
+ }
+ else
+ {
+ for(int i=0;i<newNbOfTuples;i++,pt+=stepTuples*nbComp)
+ {
+ const int *srcPt2=srcPt;
+ for(const int *z=bgComp;z!=endComp;z++,srcPt2++)
+ pt[*z]=*srcPt2;
+ }
+ }
+}
+
+void DataArrayInt::setPartOfValuesSimple4(int a, int bgTuples, int endTuples, int stepTuples, const int *bgComp, const int *endComp) throw(INTERP_KERNEL::Exception)
+{
+ const char msg[]="DataArrayInt::setPartOfValuesSimple4";
+ checkAllocated();
+ int newNbOfTuples=DataArray::GetNumberOfItemGivenBES(bgTuples,endTuples,stepTuples,msg);
+ int nbComp=getNumberOfComponents();
+ for(const int *z=bgComp;z!=endComp;z++)
+ DataArray::CheckValueInRange(nbComp,*z,"invalid component id");
+ int nbOfTuples=getNumberOfTuples();
+ DataArray::CheckValueInRangeEx(nbOfTuples,bgTuples,endTuples,"invalid tuple value");
+ int *pt=getPointer()+bgTuples*nbComp;
+ for(int i=0;i<newNbOfTuples;i++,pt+=stepTuples*nbComp)
+ for(const int *z=bgComp;z!=endComp;z++)
+ pt[*z]=a;
+}
+
/*!
* 'this', 'a' and 'tuplesSelec' are expected to be defined. If not an exception will be thrown.
* @param a is an array having exactly the same number of components than 'this'
pass
def testSwigSetItem3(self):
- # 1-2 false
+ # 1-2
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))
+ d[[5,3,2]]=[1,2]
+ self.assertTrue(d.isEqual(DataArrayDouble([0,0,0,0,1,2,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]
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
-
+ # 8-2 false
+ d=DataArrayDouble([0,0,0,0,0,0,0,0,0,0,0,0],6,2)
+ d[DataArrayInt([0,3,4]),1]=[7]
+ self.assertTrue(d.isEqual(DataArrayDouble([0,7,0,0,0,0,0,7,0,7,0,0],6,2),1e-14))
+ # 9-2
+ d=DataArrayDouble([0,0,0,0,0,0,0,0,0,0,0,0],6,2)
+ d[3,[1,0]]=[7,8]
+ self.assertTrue(d.isEqual(DataArrayDouble([0,0,0,0,0,0,8,7,0,0,0,0],6,2),1e-14))
+ # 10-2 false
+ d=DataArrayDouble([0,0,0,0,0,0,0,0,0,0,0,0],6,2)
+ d[[1,3,4],[1,0]]=[7,8]
+ self.assertTrue(d.isEqual(DataArrayDouble([0,0,8,7,0,0,8,7,8,7,0,0],6,2),1e-14))
+ # 11-2 false
+ d=DataArrayDouble([0,0,0,0,0,0,0,0,0,0,0,0],6,2)
+ d[1::2,[1,0]]=[7,8]
+ self.assertTrue(d.isEqual(DataArrayDouble([0,0,8,7,0,0,8,7,0,0,8,7],6,2),1e-14))
+ # 12-2 false
+ d=DataArrayDouble([0,0,0,0,0,0,0,0,0,0,0,0],6,2)
+ d[DataArrayInt([1,4]),[1,0]]=[7,8]
+ self.assertTrue(d.isEqual(DataArrayDouble([0,0,8,7,0,0,0,0,8,7,0,0],6,2),1e-14))
+ # 13-2
+ d=DataArrayDouble([0,0,0,0,0,0,0,0,0,0,0,0],6,2)
+ d[1,:-1]=[9]
+ self.assertTrue(d.isEqual(DataArrayDouble([0,0,9,0,0,0,0,0,0,0,0,0],6,2),1e-14))
+ # 14-2 false
+ d=DataArrayDouble([0,0,0,0,0,0,0,0,0,0,0,0],6,2)
+ d[[1,4,5],:]=[7,8]
+ self.assertTrue(d.isEqual(DataArrayDouble([0,0,7,8,0,0,0,0,7,8,7,8],6,2),1e-14))
+ # 15-2 false
+ d=DataArrayDouble([0,0,0,0,0,0,0,0,0,0,0,0],6,2)
+ d[1::2,:]=[3,9]
+ self.assertTrue(d.isEqual(DataArrayDouble([0,0,3,9,0,0,3,9,0,0,3,9],6,2),1e-14))
+ # 1-2
+ d=DataArrayInt([0,0,0,0,0,0,0,0,0,0,0,0],6,2)
+ d[3]=[1,2]
+ self.assertTrue(d.isEqual(DataArrayInt([0,0,0,0,0,0,1,2,0,0,0,0],6,2)))
+ # 2-2 false
+ d=DataArrayInt([0,0,0,0,0,0,0,0,0,0,0,0],6,2)
+ d[[5,3,2]]=[1,2]
+ self.assertTrue(d.isEqual(DataArrayInt([0,0,0,0,1,2,1,2,0,0,1,2],6,2)))
+ # 3-2 false
+ d=DataArrayInt([0,0,0,0,0,0,0,0,0,0,0,0],6,2)
+ d[:]=[1,2]
+ self.assertTrue(d.isEqual(DataArrayInt([1,2,1,2,1,2,1,2,1,2,1,2],6,2)))
+ # 4-2 false
+ d=DataArrayInt([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(DataArrayInt([1,2,0,0,0,0,1,2,1,2,0,0],6,2)))
+ # 5-2
+ d=DataArrayInt([0,0,0,0,0,0,0,0,0,0,0,0],6,2)
+ d[5,1]=[7]
+ self.assertTrue(d.isEqual(DataArrayInt([0,0,0,0,0,0,0,0,0,0,0,7],6,2)))
+ # 6-2 false
+ d=DataArrayInt([0,0,0,0,0,0,0,0,0,0,0,0],6,2)
+ d[[3,5],1]=[7]
+ self.assertTrue(d.isEqual(DataArrayInt([0,0,0,0,0,0,0,7,0,0,0,7],6,2)))
+ # 7-2 false
+ d=DataArrayInt([0,0,0,0,0,0,0,0,0,0,0,0],6,2)
+ d[:-1:2,1]=[7]
+ self.assertTrue(d.isEqual(DataArrayInt([0,7,0,0,0,7,0,0,0,7,0,0],6,2)))
+ # 8-2 false
+ d=DataArrayInt([0,0,0,0,0,0,0,0,0,0,0,0],6,2)
+ d[DataArrayInt([0,3,4]),1]=[7]
+ self.assertTrue(d.isEqual(DataArrayInt([0,7,0,0,0,0,0,7,0,7,0,0],6,2)))
+ # 9-2
+ d=DataArrayInt([0,0,0,0,0,0,0,0,0,0,0,0],6,2)
+ d[3,[1,0]]=[7,8]
+ self.assertTrue(d.isEqual(DataArrayInt([0,0,0,0,0,0,8,7,0,0,0,0],6,2)))
+ # 10-2 false
+ d=DataArrayInt([0,0,0,0,0,0,0,0,0,0,0,0],6,2)
+ d[[1,3,4],[1,0]]=[7,8]
+ self.assertTrue(d.isEqual(DataArrayInt([0,0,8,7,0,0,8,7,8,7,0,0],6,2)))
+ # 11-2 false
+ d=DataArrayInt([0,0,0,0,0,0,0,0,0,0,0,0],6,2)
+ d[1::2,[1,0]]=[7,8]
+ self.assertTrue(d.isEqual(DataArrayInt([0,0,8,7,0,0,8,7,0,0,8,7],6,2)))
+ # 12-2 false
+ d=DataArrayInt([0,0,0,0,0,0,0,0,0,0,0,0],6,2)
+ d[DataArrayInt([1,4]),[1,0]]=[7,8]
+ self.assertTrue(d.isEqual(DataArrayInt([0,0,8,7,0,0,0,0,8,7,0,0],6,2)))
+ # 13-2
+ d=DataArrayInt([0,0,0,0,0,0,0,0,0,0,0,0],6,2)
+ d[1,:-1]=[9]
+ self.assertTrue(d.isEqual(DataArrayInt([0,0,9,0,0,0,0,0,0,0,0,0],6,2)))
+ # 14-2 false
+ d=DataArrayInt([0,0,0,0,0,0,0,0,0,0,0,0],6,2)
+ d[[1,4,5],:]=[7,8]
+ self.assertTrue(d.isEqual(DataArrayInt([0,0,7,8,0,0,0,0,7,8,7,8],6,2)))
+ # 15-2 false
+ d=DataArrayInt([0,0,0,0,0,0,0,0,0,0,0,0],6,2)
+ d[1::2,:]=[3,9]
+ self.assertTrue(d.isEqual(DataArrayInt([0,0,3,9,0,0,3,9,0,0,3,9],6,2)))
pass
def setUp(self):