%newobject ParaMEDMEM::MEDCouplingUMesh::getNodalConnectivityIndex;
%newobject ParaMEDMEM::MEDCouplingUMesh::clone;
%newobject ParaMEDMEM::MEDCouplingUMesh::__iter__;
+%newobject ParaMEDMEM::MEDCouplingUMesh::__getitem__;
%newobject ParaMEDMEM::MEDCouplingUMesh::cellsByType;
%newobject ParaMEDMEM::MEDCouplingUMesh::zipConnectivityTraducer;
%newobject ParaMEDMEM::MEDCouplingUMesh::buildDescendingConnectivity;
return self->cellIterator();
}
+ MEDCouplingPointSet *__getitem__(PyObject *listOrDataArrI) throw(INTERP_KERNEL::Exception)
+ {
+ int sw;
+ int singleVal;
+ std::vector<int> multiVal;
+ std::pair<int, std::pair<int,int> > slic;
+ ParaMEDMEM::DataArrayInt *daIntTyypp=0;
+ int nbc=self->getNumberOfCells();
+ convertObjToPossibleCpp2(listOrDataArrI,nbc,sw,singleVal,multiVal,slic,daIntTyypp);
+ switch(sw)
+ {
+ case 1:
+ {
+ if(singleVal>=nbc)
+ {
+ std::ostringstream oss;
+ oss << "Requesting for cell id " << singleVal << " having only " << nbc << " cells !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ if(singleVal>=0)
+ return self->buildPartOfMySelf(&singleVal,&singleVal+1,true);
+ else
+ {
+ if(nbc+singleVal>0)
+ {
+ int tmp=nbc+singleVal;
+ return self->buildPartOfMySelf(&tmp,&tmp+1,true);
+ }
+ else
+ {
+ std::ostringstream oss;
+ oss << "Requesting for cell id " << singleVal << " having only " << nbc << " cells !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ }
+ case 2:
+ {
+ return static_cast<MEDCouplingUMesh *>(self->buildPartOfMySelf(&multiVal[0],&multiVal[0]+multiVal.size(),true));
+ }
+ case 3:
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> d0=DataArrayInt::Range(slic.first,slic.second.first,slic.second.second);
+ return self->buildPartOfMySelf(d0->begin(),d0->end(),true);
+ }
+ case 4:
+ {
+ if(!daIntTyypp)
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::__getitem__ : null instance has been given in input !");
+ daIntTyypp->checkAllocated();
+ return self->buildPartOfMySelf(daIntTyypp->begin(),daIntTyypp->end(),true);
+ }
+ default:
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::__getitem__ : unrecognized type in input ! Possibilities are : int, list or tuple of int DataArrayInt instance !");
+ }
+ }
+
void insertNextCell(INTERP_KERNEL::NormalizedCellType type, int size, PyObject *li) throw(INTERP_KERNEL::Exception)
{
int sz;
expected1=[0,1]
self.assertEqual(2,arr1.getNumberOfTuples());
self.assertEqual(1,arr1.getNumberOfComponents());
- self.assertTrue(expected1,arr1.getValues());
+ self.assertEqual(expected1,arr1.getValues());
expected2=[0,3,4,1,2]
arr1=m2_1.rearrange2ConsecutiveCellTypes();
self.assertEqual(5,arr1.getNumberOfTuples());
self.assertEqual(5,len(types));
expected1=[NORM_POLYGON, NORM_TRI3, NORM_QUAD4, NORM_TRI6, NORM_QUAD8]
expected1.sort()
- self.assertTrue(expected1==types);
+ self.assertEqual(expected1,types);
self.assertTrue(mesh.isPresenceOfQuadratic());
self.assertEqual(62,mesh.getMeshLength());
f1=mesh.getMeasureField(False);
self.assertEqual(3,len(types2));
expected2=[NORM_POLYGON, NORM_TRI3, NORM_QUAD4]
expected2.sort()
- self.assertTrue(expected2==types2);
+ self.assertEqual(expected2,types2);
pass
def testCheckGeoEquivalWith(self):
self.assertEqual(10,ret.getNbOfElems());
self.assertEqual(7,newNbTuple);
self.assertEqual(1,ret.getNumberOfComponents());
- self.assertTrue(expected,ret.getValues());
+ self.assertEqual(expected,ret.getValues());
pass
def testDADIReverse1(self):
pass
self.assertEqual(60,m12.getNodalConnectivity().getNumberOfTuples());
self.assertEqual(9,m12.getNodalConnectivityIndex().getNumberOfTuples());
- self.assertTrue(expected3,m12.getNodalConnectivity().getValues());
- self.assertTrue(expected4,m12.getNodalConnectivityIndex().getValues());
+ self.assertEqual(expected3,m12.getNodalConnectivity().getValues());
+ self.assertEqual(expected4,m12.getNodalConnectivityIndex().getValues());
pass
def testIntersect2DMeshesTmp4(self):
expected1=[2,9,16]
self.assertEqual(3,d.getNumberOfTuples());
self.assertEqual(1,d.getNumberOfComponents());
- self.assertTrue(expected1,d.getValues());
+ self.assertEqual(expected1,d.getValues());
#
d=DataArrayInt.Range(2,23,7);
self.assertEqual(3,d.getNumberOfTuples());
self.assertEqual(1,d.getNumberOfComponents());
- self.assertTrue(expected1,d.getValues());
+ self.assertEqual(expected1,d.getValues());
#
d=DataArrayInt.Range(2,24,7);
expected2=[2,9,16,23]
self.assertEqual(4,d.getNumberOfTuples());
self.assertEqual(1,d.getNumberOfComponents());
- self.assertTrue(expected2,d.getValues());
+ self.assertEqual(expected2,d.getValues());
#
d=DataArrayInt.Range(24,2,-7);
expected3=[24,17,10,3]
self.assertEqual(4,d.getNumberOfTuples());
self.assertEqual(1,d.getNumberOfComponents());
- self.assertTrue(expected3,d.getValues());
+ self.assertEqual(expected3,d.getValues());
#
d=DataArrayInt.Range(23,2,-7);
expected4=[23,16,9]
self.assertEqual(3,d.getNumberOfTuples());
self.assertEqual(1,d.getNumberOfComponents());
- self.assertTrue(expected4,d.getValues());
+ self.assertEqual(expected4,d.getValues());
#
d=DataArrayInt.Range(23,22,-7);
self.assertEqual(1,d.getNumberOfTuples());
self.assertRaises(InterpKernelException,DataArrayInt.Range,22,23,0);
pass
+ def testSwigUMeshGetItem1(self):
+ m=MEDCouplingDataForTest.build2DTargetMesh_1();
+ subMesh=m.buildPartOfMySelf([1,3],True);
+ self.assertTrue(isinstance(subMesh,MEDCouplingUMesh))
+ m1=m[[1,3]]
+ self.assertTrue(isinstance(m1,MEDCouplingUMesh))
+ m2=m[(1,3)]
+ self.assertTrue(isinstance(m2,MEDCouplingUMesh))
+ m3=m[1::2]
+ self.assertTrue(isinstance(m3,MEDCouplingUMesh))
+ m4=m[DataArrayInt.New([1,3])]
+ m5_1=m[1]
+ self.assertTrue(isinstance(m5_1,MEDCouplingUMesh))
+ m5_2=m[3]
+ self.assertTrue(isinstance(m5_2,MEDCouplingUMesh))
+ m5=MEDCouplingUMesh.MergeUMeshesOnSameCoords([m5_1,m5_2]);
+ m5.setName(subMesh.getName())
+ self.assertTrue(isinstance(m4,MEDCouplingUMesh))
+ self.assertTrue(subMesh.isEqual(m1,1e-12))
+ self.assertTrue(subMesh.isEqual(m2,1e-12))
+ self.assertTrue(subMesh.isEqual(m3,1e-12))
+ self.assertTrue(subMesh.isEqual(m4,1e-12))
+ self.assertTrue(subMesh.isEqual(m5,1e-12))
+ self.assertRaises(InterpKernelException,m.buildPartOfMySelf,[1,5],True);
+ pass
+
def setUp(self):
pass
pass