From: Gilles DAVID Date: Mon, 15 May 2017 12:30:11 +0000 (+0200) Subject: Merge branch 'master' into gdd/py3 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=5ce60f945bf9e862921297136a1a4282a8bffde8;p=tools%2Fmedcoupling.git Merge branch 'master' into gdd/py3 Conflicts: src/MEDLoader/Swig/MEDLoaderTest3.py --- 5ce60f945bf9e862921297136a1a4282a8bffde8 diff --cc src/MEDCoupling_Swig/MEDCouplingDataArrayTypemaps.i index 00ec3d71d,b410892c4..28465ef76 --- a/src/MEDCoupling_Swig/MEDCouplingDataArrayTypemaps.i +++ b/src/MEDCoupling_Swig/MEDCouplingDataArrayTypemaps.i @@@ -21,11 -21,8 +21,12 @@@ #ifndef __MEDCOUPLINGDATAARRAYTYPEMAPS_I__ #define __MEDCOUPLINGDATAARRAYTYPEMAPS_I__ +#if PY_VERSION_HEX >= 0x03000000 +#define PyInt_AS_LONG PyLong_AS_LONG +#endif + #include "InterpKernelAutoPtr.hxx" + #include "MEDCouplingDataArrayTraits.hxx" #include diff --cc src/MEDCoupling_Swig/MEDCouplingFinalize.i index 0f9a8c5a2,6d84db1f6..57de04b74 --- a/src/MEDCoupling_Swig/MEDCouplingFinalize.i +++ b/src/MEDCoupling_Swig/MEDCouplingFinalize.i @@@ -53,13 -48,11 +60,17 @@@ MEDCouplingFieldDouble.__isub__=MEDCoup MEDCouplingFieldDouble.__imul__=MEDCouplingFieldDoubleImul MEDCouplingFieldDouble.__idiv__=MEDCouplingFieldDoubleIdiv MEDCouplingFieldDouble.__ipow__=MEDCouplingFieldDoubleIpow +MEDCouplingFieldDouble.__truediv__=MEDCouplingFieldDouble.__div__ +MEDCouplingFieldDouble.__rtruediv__=MEDCouplingFieldDouble.__rdiv__ +MEDCouplingFieldDouble.__itruediv__=MEDCouplingFieldDoubleIdiv +MEDCouplingFieldDouble.__floordiv__=MEDCouplingFieldDouble.__div__ +MEDCouplingFieldDouble.__rfloordiv__=MEDCouplingFieldDouble.__rdiv__ +MEDCouplingFieldDouble.__ifloordiv__=MEDCouplingFieldDoubleIdiv + MEDCouplingFieldInt.__new__=classmethod(MEDCouplingFieldIntnew) + + MEDCouplingFieldFloat.__new__=classmethod(MEDCouplingFieldFloatnew) + DataArrayDoubleTuple.__iadd__=MEDCouplingDataArrayDoubleTupleIadd DataArrayDoubleTuple.__isub__=MEDCouplingDataArrayDoubleTupleIsub DataArrayDoubleTuple.__imul__=MEDCouplingDataArrayDoubleTupleImul @@@ -85,14 -74,7 +96,13 @@@ MEDCouplingCurveLinearMesh.__new__=clas MEDCouplingCMesh.__new__=classmethod(MEDCouplingCMeshnew) MEDCouplingIMesh.__new__=classmethod(MEDCouplingIMeshnew) MEDCouplingMappedExtrudedMesh.__new__=classmethod(MEDCouplingExtrudedMeshnew) - MEDCouplingFieldDouble.__new__=classmethod(MEDCouplingFieldDoublenew) +DataArrayAsciiCharIterator.__next__ = DataArrayAsciiCharIterator.next +DataArrayIntIterator.__next__ = DataArrayIntIterator.next +DataArrayDoubleIterator.__next__ = DataArrayDoubleIterator.next +MEDCouplingUMeshCellIterator.__next__ = MEDCouplingUMeshCellIterator.next +MEDCouplingUMeshCellByTypeIterator.__next__ = MEDCouplingUMeshCellByTypeIterator.next + del INTERPKERNELExceptionReduce del MEDCouplingDataArrayDoublenew del MEDCouplingDataArrayDoubleIadd diff --cc src/MEDLoader/Swig/MEDLoaderTest3.py index 52a518156,55fd117f1..7ee67284d --- a/src/MEDLoader/Swig/MEDLoaderTest3.py +++ b/src/MEDLoader/Swig/MEDLoaderTest3.py @@@ -2153,30 -2143,30 +2153,30 @@@ class MEDLoaderTest3(unittest.TestCase) m=m.buildUnstructured() m.setName("mm") f=m.getMeasureField(False) - self.assertIn(m.getHeapMemorySize(), list(range(3552 - 100, 3552 + 100 + 4 * strMulFac))) - self.assertIn(f.getHeapMemorySize(), list(range(4215 - 100, 4215 + 100 + 8 * strMulFac))) - self.assertIn(m.getHeapMemorySize(),xrange(3552-100,3552+100+4*strMulFac)) - self.assertIn(f.getHeapMemorySize(),xrange(4215-100,4215+100+8*strMulFac)) ++ self.assertIn(m.getHeapMemorySize(),range(3552-100,3552+100+4*strMulFac)) ++ self.assertIn(f.getHeapMemorySize(),range(4215-100,4215+100+8*strMulFac)) # mm=MEDFileUMesh() mm.setMeshAtLevel(0,m) - self.assertIn(mm.getHeapMemorySize(), list(range(3889 - 100, 4225 + 100 + 10 * strMulFac))) - self.assertIn(mm.getHeapMemorySize(),xrange(3889-100,4225+100+10*strMulFac)) ++ self.assertIn(mm.getHeapMemorySize(),range(3889-100,4225+100+10*strMulFac)) ff=MEDFileField1TS() ff.setFieldNoProfileSBT(f) - self.assertIn(ff.getHeapMemorySize(), list(range(771 - 40, 871 + 21 + (4 + 1) * strMulFac))) - self.assertIn(ff.getHeapMemorySize(),xrange(771-40,871+21+(4+1)*strMulFac)) ++ self.assertIn(ff.getHeapMemorySize(),range(771-40,871+21+(4+1)*strMulFac)) # fff=MEDFileFieldMultiTS() fff.appendFieldNoProfileSBT(f) - self.assertIn(fff.getHeapMemorySize(), list(range(815 - 50, 915 + 30 + (6 + 2) * strMulFac))) - self.assertIn(fff.getHeapMemorySize(),xrange(815-50,915+30+(6+2)*strMulFac)) ++ self.assertIn(fff.getHeapMemorySize(),range(815-50,915+30+(6+2)*strMulFac)) f.setTime(1.,0,-1) fff.appendFieldNoProfileSBT(f) - self.assertIn(fff.getHeapMemorySize(), list(range(1594 - 90, 1794 + 50 + (10 + 1) * strMulFac))) - self.assertIn(fff[0, -1].getHeapMemorySize(), list(range(771 - 40, 871 + 20 + (4 + 1) * strMulFac))) - self.assertIn(fff.getHeapMemorySize(),xrange(1594-90,1794+50+(10+1)*strMulFac)) - self.assertIn(fff[0,-1].getHeapMemorySize(),xrange(771-40,871+20+(4+1)*strMulFac)) ++ self.assertIn(fff.getHeapMemorySize(),range(1594-90,1794+50+(10+1)*strMulFac)) ++ self.assertIn(fff[0,-1].getHeapMemorySize(),range(771-40,871+20+(4+1)*strMulFac)) f2=f[:50] f2.setTime(2.,1,-1) pfl=DataArrayInt.Range(0,50,1) ; pfl.setName("pfl") fff.appendFieldProfile(f2,mm,0,pfl) - self.assertIn(fff.getHeapMemorySize(), list(range(2348 - 130, 2608 + 100 + (10 + 2) * strMulFac))) - self.assertIn(fff.getProfile("pfl").getHeapMemorySize(), list(range(204 - 10, 204 + 10 + 2 * strMulFac))) - self.assertIn(fff[1, -1].getHeapMemorySize(), list(range(738 - 50, 838 + 30 + 4 * strMulFac))) - self.assertIn(fff.getHeapMemorySize(),xrange(2348-130,2608+100+(10+2)*strMulFac)) - self.assertIn(fff.getProfile("pfl").getHeapMemorySize(),xrange(204-10,204+10+2*strMulFac)) - self.assertIn(fff[1,-1].getHeapMemorySize(),xrange(738-50,838+30+4*strMulFac)) ++ self.assertIn(fff.getHeapMemorySize(),range(2348-130,2608+100+(10+2)*strMulFac)) ++ self.assertIn(fff.getProfile("pfl").getHeapMemorySize(),range(204-10,204+10+2*strMulFac)) ++ self.assertIn(fff[1,-1].getHeapMemorySize(),range(738-50,838+30+4*strMulFac)) pass def testCurveLinearMesh1(self): @@@ -2284,20 -2274,20 +2284,20 @@@ mm.setMeshAtLevel(0,m) mm.setMeshAtLevel(-1,m1) namesCellL0=DataArrayAsciiChar(6,16) - namesCellL0[:] = ["CellL0#%.3d " % (i) for i in range(6)] - namesCellL0[:]=["CellL0#%.3d "%(i) for i in xrange(6)] ++ namesCellL0[:]=["CellL0#%.3d "%(i) for i in range(6)] mm.setNameFieldAtLevel(0,namesCellL0) namesCellL1=DataArrayAsciiChar.Aggregate([namesCellL0,namesCellL0,namesCellL0.subArray(2)]) - namesCellL1[:] = ["CellLM1#%.3d " % (i) for i in range(16)] - namesCellL1[:]=["CellLM1#%.3d "%(i) for i in xrange(16)] ++ namesCellL1[:]=["CellLM1#%.3d "%(i) for i in range(16)] mm.setNameFieldAtLevel(-1,namesCellL1) namesNodes=namesCellL1.subArray(4,16) - namesNodes[:] = ["Node#%.3d " % (i) for i in range(12)] - namesNodes[:]=["Node#%.3d "%(i) for i in xrange(12)] ++ namesNodes[:]=["Node#%.3d "%(i) for i in range(12)] mm.setNameFieldAtLevel(1,namesNodes) mm.write(fname,2) # mmr=MEDFileMesh.New(fname) - self.assertTrue(mm.getNameFieldAtLevel(0).isEqual(DataArrayAsciiChar(["CellL0#%.3d " % (i) for i in range(6)]))) - self.assertTrue(mm.getNameFieldAtLevel(-1).isEqual(DataArrayAsciiChar(["CellLM1#%.3d " % (i) for i in range(16)]))) - self.assertTrue(mm.getNameFieldAtLevel(1).isEqual(DataArrayAsciiChar(["Node#%.3d " % (i) for i in range(12)]))) - self.assertTrue(mm.getNameFieldAtLevel(0).isEqual(DataArrayAsciiChar(["CellL0#%.3d "%(i) for i in xrange(6)]))) - self.assertTrue(mm.getNameFieldAtLevel(-1).isEqual(DataArrayAsciiChar(["CellLM1#%.3d "%(i) for i in xrange(16)]))) - self.assertTrue(mm.getNameFieldAtLevel(1).isEqual(DataArrayAsciiChar(["Node#%.3d "%(i) for i in xrange(12)]))) ++ self.assertTrue(mm.getNameFieldAtLevel(0).isEqual(DataArrayAsciiChar(["CellL0#%.3d "%(i) for i in range(6)]))) ++ self.assertTrue(mm.getNameFieldAtLevel(-1).isEqual(DataArrayAsciiChar(["CellLM1#%.3d "%(i) for i in range(16)]))) ++ self.assertTrue(mm.getNameFieldAtLevel(1).isEqual(DataArrayAsciiChar(["Node#%.3d "%(i) for i in range(12)]))) self.assertTrue(mm.isEqual(mmr,1e-12)[0]) mmr.getNameFieldAtLevel(1).setIJ(0,0,'M') self.assertTrue(not mm.isEqual(mmr,1e-12)[0]) @@@ -2314,7 -2304,7 +2314,7 @@@ mm.write(fname,2) mmr=MEDFileMesh.New(fname) self.assertEqual(mmr.getNameFieldAtLevel(1),None) - self.assertTrue(mmr.getNameFieldAtLevel(0).isEqual(DataArrayAsciiChar(["CellL0#%.3d " % (i) for i in range(6)]))) - self.assertTrue(mmr.getNameFieldAtLevel(0).isEqual(DataArrayAsciiChar(["CellL0#%.3d "%(i) for i in xrange(6)]))) ++ self.assertTrue(mmr.getNameFieldAtLevel(0).isEqual(DataArrayAsciiChar(["CellL0#%.3d "%(i) for i in range(6)]))) self.assertEqual(mmr.getNameFieldAtLevel(-1),None) # c=MEDCouplingCMesh() @@@ -2323,12 -2313,12 +2323,12 @@@ c.setName("cmesh") cc=MEDFileCMesh() cc.setMesh(c) - cc.setNameFieldAtLevel(0, DataArrayAsciiChar(["Cell#%.3d " % (i) for i in range(4)])) - cc.setNameFieldAtLevel(1, DataArrayAsciiChar(["Node#%.3d " % (i) for i in range(9)])) - cc.setNameFieldAtLevel(0,DataArrayAsciiChar(["Cell#%.3d "%(i) for i in xrange(4)])) - cc.setNameFieldAtLevel(1,DataArrayAsciiChar(["Node#%.3d "%(i) for i in xrange(9)])) ++ cc.setNameFieldAtLevel(0,DataArrayAsciiChar(["Cell#%.3d "%(i) for i in range(4)])) ++ cc.setNameFieldAtLevel(1,DataArrayAsciiChar(["Node#%.3d "%(i) for i in range(9)])) cc.write(fname2,2) ccr=MEDFileMesh.New(fname2) - self.assertTrue(ccr.getNameFieldAtLevel(0).isEqual(DataArrayAsciiChar(["Cell#%.3d " % (i) for i in range(4)]))) - self.assertTrue(ccr.getNameFieldAtLevel(1).isEqual(DataArrayAsciiChar(["Node#%.3d " % (i) for i in range(9)]))) - self.assertTrue(ccr.getNameFieldAtLevel(0).isEqual(DataArrayAsciiChar(["Cell#%.3d "%(i) for i in xrange(4)]))) - self.assertTrue(ccr.getNameFieldAtLevel(1).isEqual(DataArrayAsciiChar(["Node#%.3d "%(i) for i in xrange(9)]))) ++ self.assertTrue(ccr.getNameFieldAtLevel(0).isEqual(DataArrayAsciiChar(["Cell#%.3d "%(i) for i in range(4)]))) ++ self.assertTrue(ccr.getNameFieldAtLevel(1).isEqual(DataArrayAsciiChar(["Node#%.3d "%(i) for i in range(9)]))) self.assertTrue(cc.isEqual(ccr,1e-12)[0]) ccr.getNameFieldAtLevel(1).setIJ(0,0,'M') self.assertTrue(not cc.isEqual(ccr,1e-12)[0]) @@@ -2620,7 -2610,7 +2620,7 @@@ self.assertTrue(a.isEqual(f1,1e-12,1e-12)) a=ffs1.getFieldOnMeshAtLevel(ON_CELLS,0,1,0,mm1) self.assertTrue(a.isEqual(f1,1e-12,1e-12)) - it = ffs1.__iter__() ; next(it) ; ff2bis = next(it) - it=ffs1.__iter__() ; it.next() ; ff2bis=it.next() ++ it=ffs1.__iter__() ; next(it) ; ff2bis=next(it) a=ff2bis.getFieldOnMeshAtLevel(0,ON_CELLS,mm1) self.assertTrue(a.getArray().isEqual(2*f1.getArray())) f1.setTime(3.,1,2) ; f1.getArray()[:]*=2 @@@ -2634,7 -2624,7 +2634,7 @@@ nf1=MEDCouplingFieldInt(ON_NODES) nf1.setTime(9.,10,-1) nf1.setMesh(f1.getMesh()) - narr = DataArrayInt(12, 2) ; narr.setInfoOnComponents(["aa [u1]", "bbbvv [ppp]"]) ; narr[:, 0] = list(range(12)) ; narr[:, 1] = 2 * narr[:, 0] - narr=DataArrayInt(12,2) ; narr.setInfoOnComponents(["aa [u1]","bbbvv [ppp]"]) ; narr[:,0]=range(12) ; narr[:,1]=2*narr[:,0] ++ narr=DataArrayInt(12,2) ; narr.setInfoOnComponents(["aa [u1]","bbbvv [ppp]"]) ; narr[:,0]=list(range(12)) ; narr[:,1]=2*narr[:,0] nf1.setName("VectorFieldOnNodes") ; nf1.setArray(narr) nff1=MEDFileIntField1TS.New() nff1.setFieldNoProfileSBT(nf1) @@@ -2645,7 -2635,7 +2645,7 @@@ nf2=MEDCouplingFieldInt(ON_NODES) nf2.setTime(19.,20,-11) nf2.setMesh(f1.getMesh()) - narr2 = DataArrayInt(8, 2) ; narr.setInfoOnComponents(["aapfl [u1]", "bbbvvpfl [ppp]"]) ; narr2[:, 0] = list(range(8)) ; narr2[:, 0] += 10 ; narr2[:, 1] = 3 * narr2[:, 0] - narr2=DataArrayInt(8,2) ; narr.setInfoOnComponents(["aapfl [u1]","bbbvvpfl [ppp]"]) ; narr2[:,0]=range(8) ; narr2[:,0]+=10 ; narr2[:,1]=3*narr2[:,0] ++ narr2=DataArrayInt(8,2) ; narr.setInfoOnComponents(["aapfl [u1]","bbbvvpfl [ppp]"]) ; narr2[:,0]=list(range(8)) ; narr2[:,0]+=10 ; narr2[:,1]=3*narr2[:,0] nf2.setName("VectorFieldOnNodesPfl") ; narr2.setName(nf2.getName()) ; nf2.setArray(narr2) nff2=MEDFileIntField1TS.New() npfl=DataArrayInt([1,2,4,5,6,7,10,11]) ; npfl.setName("npfl") @@@ -2704,7 -2694,7 +2704,7 @@@ c=DataArrayDouble(12) ; c.iota(); m=MEDCouplingCMesh() ; m.setCoordsAt(0,c) ; m.setName("mesh") mm=MEDFileCMesh() ; mm.setMesh(m) ; mm.write(fname,2) f1.setMesh(m) - arr = DataArrayDouble(12, 2) ; arr.setInfoOnComponents(["aa [u1]", "bbbvv [ppp]"]) ; arr[:, 0] = list(range(12)) ; arr[:, 1] = 2 * arr[:, 0] - arr=DataArrayDouble(12,2) ; arr.setInfoOnComponents(["aa [u1]","bbbvv [ppp]"]) ; arr[:,0]=range(12) ; arr[:,1]=2*arr[:,0] ++ arr=DataArrayDouble(12,2) ; arr.setInfoOnComponents(["aa [u1]","bbbvv [ppp]"]) ; arr[:,0]=list(range(12)) ; arr[:,1]=2*arr[:,0] f1.setArray(arr) f1.setName("Field1") ff1=MEDFileField1TS.New() @@@ -2738,13 -2728,13 +2738,13 @@@ tri=MEDCouplingUMesh("tri",2) tri.allocateCells() ; tri.insertNextCell(NORM_TRI3,[0,1,2]) tri.setCoords(DataArrayDouble([(0.,0.),(0.,1.),(1.,0.)])) - tris = [tri.deepCopy() for i in range(4)] - tris=[tri.deepCopy() for i in xrange(4)] ++ tris=[tri.deepCopy() for i in range(4)] for i,elt in enumerate(tris): elt.translate([i,0]) tris=MEDCouplingUMesh.MergeUMeshes(tris) quad=MEDCouplingUMesh("quad",2) quad.allocateCells() ; quad.insertNextCell(NORM_QUAD4,[0,1,2,3]) quad.setCoords(DataArrayDouble([(0.,0.),(0.,1.),(1.,1.),(1.,0.)])) - quads = [quad.deepCopy() for i in range(5)] - quads=[quad.deepCopy() for i in xrange(5)] ++ quads=[quad.deepCopy() for i in range(5)] for i,elt in enumerate(quads): elt.translate([5+i,0]) quads=MEDCouplingUMesh.MergeUMeshes(quads) m=MEDCouplingUMesh.MergeUMeshes(tris,quads) @@@ -2816,13 -2806,13 +2816,13 @@@ tri=MEDCouplingUMesh("tri",2) tri.allocateCells() ; tri.insertNextCell(NORM_TRI3,[0,1,2]) tri.setCoords(DataArrayDouble([(0.,0.),(0.,1.),(1.,0.)])) - tris = [tri.deepCopy() for i in range(4)] - tris=[tri.deepCopy() for i in xrange(4)] ++ tris=[tri.deepCopy() for i in range(4)] for i,elt in enumerate(tris): elt.translate([i,0]) tris=MEDCouplingUMesh.MergeUMeshes(tris) quad=MEDCouplingUMesh("quad",2) quad.allocateCells() ; quad.insertNextCell(NORM_QUAD4,[0,1,2,3]) quad.setCoords(DataArrayDouble([(0.,0.),(0.,1.),(1.,1.),(1.,0.)])) - quads = [quad.deepCopy() for i in range(5)] - quads=[quad.deepCopy() for i in xrange(5)] ++ quads=[quad.deepCopy() for i in range(5)] for i,elt in enumerate(quads): elt.translate([5+i,0]) quads=MEDCouplingUMesh.MergeUMeshes(quads) m=MEDCouplingUMesh.MergeUMeshes(tris,quads) @@@ -2881,13 -2871,13 +2881,13 @@@ tri=MEDCouplingUMesh("tri",2) tri.allocateCells() ; tri.insertNextCell(NORM_TRI3,[0,1,2]) tri.setCoords(DataArrayDouble([(0.,0.),(0.,1.),(1.,0.)])) - tris = [tri.deepCopy() for i in range(4)] - tris=[tri.deepCopy() for i in xrange(4)] ++ tris=[tri.deepCopy() for i in range(4)] for i,elt in enumerate(tris): elt.translate([i,0]) tris=MEDCouplingUMesh.MergeUMeshes(tris) quad=MEDCouplingUMesh("quad",2) quad.allocateCells() ; quad.insertNextCell(NORM_QUAD4,[0,1,2,3]) quad.setCoords(DataArrayDouble([(0.,0.),(0.,1.),(1.,1.),(1.,0.)])) - quads = [quad.deepCopy() for i in range(5)] - quads=[quad.deepCopy() for i in xrange(5)] ++ quads=[quad.deepCopy() for i in range(5)] for i,elt in enumerate(quads): elt.translate([5+i,0]) quads=MEDCouplingUMesh.MergeUMeshes(quads) m=MEDCouplingUMesh.MergeUMeshes(tris,quads) @@@ -2950,13 -2940,13 +2950,13 @@@ tri=MEDCouplingUMesh("tri",2) tri.allocateCells() ; tri.insertNextCell(NORM_TRI3,[0,1,2]) tri.setCoords(DataArrayDouble([(0.,0.),(0.,1.),(1.,0.)])) - tris = [tri.deepCopy() for i in range(4)] - tris=[tri.deepCopy() for i in xrange(4)] ++ tris=[tri.deepCopy() for i in range(4)] for i,elt in enumerate(tris): elt.translate([i,0]) tris=MEDCouplingUMesh.MergeUMeshes(tris) quad=MEDCouplingUMesh("quad",2) quad.allocateCells() ; quad.insertNextCell(NORM_QUAD4,[0,1,2,3]) quad.setCoords(DataArrayDouble([(0.,0.),(0.,1.),(1.,1.),(1.,0.)])) - quads = [quad.deepCopy() for i in range(5)] - quads=[quad.deepCopy() for i in xrange(5)] ++ quads=[quad.deepCopy() for i in range(5)] for i,elt in enumerate(quads): elt.translate([5+i,0]) quads=MEDCouplingUMesh.MergeUMeshes(quads) m=MEDCouplingUMesh.MergeUMeshes(tris,quads) @@@ -3052,13 -3042,13 +3052,13 @@@ tri=MEDCouplingUMesh("tri",2) tri.allocateCells() ; tri.insertNextCell(NORM_TRI3,[0,1,2]) tri.setCoords(DataArrayDouble([(0.,0.),(0.,1.),(1.,0.)])) - tris = [tri.deepCopy() for i in range(30)] - tris=[tri.deepCopy() for i in xrange(30)] ++ tris=[tri.deepCopy() for i in range(30)] for i,elt in enumerate(tris): elt.translate([i,0]) tris=MEDCouplingUMesh.MergeUMeshes(tris) quad=MEDCouplingUMesh("quad",2) quad.allocateCells() ; quad.insertNextCell(NORM_QUAD4,[0,1,2,3]) quad.setCoords(DataArrayDouble([(0.,0.),(0.,1.),(1.,1.),(1.,0.)])) - quads = [quad.deepCopy() for i in range(40)] - quads=[quad.deepCopy() for i in xrange(40)] ++ quads=[quad.deepCopy() for i in range(40)] for i,elt in enumerate(quads): elt.translate([40+i,0]) quads=MEDCouplingUMesh.MergeUMeshes(quads) m=MEDCouplingUMesh.MergeUMeshes(tris,quads) @@@ -3088,7 -3078,7 +3088,7 @@@ self.assertTrue(not ff0.getUndergroundDataArray().isAllocated()) self.assertEqual(ff0.getUndergroundDataArray().getInfoOnComponents(),['X [km]','YY [mm]']) heap_memory_ref=ff0.getHeapMemorySize() - self.assertIn(heap_memory_ref, list(range(182, 465 + 2 * strMulFac))) - self.assertIn(heap_memory_ref,xrange(182,481+2*strMulFac)) ++ self.assertIn(heap_memory_ref,range(182,481+2*strMulFac)) ff0.loadArrays() ## arr=DataArrayDouble(140) ; arr.iota() ; arr.rearrange(2) self.assertTrue(ff0.getUndergroundDataArray().isEqualWithoutConsideringStr(arr,1e-14)) @@@ -3097,7 -3087,7 +3097,7 @@@ ff0=MEDFileField1TS(fname,"FieldCellPfl",False) self.assertEqual(ff0.getUndergroundDataArray().getInfoOnComponents(),["XX [pm]","YYY [hm]"]) heap_memory_ref=ff0.getHeapMemorySize() - self.assertIn(heap_memory_ref, list(range(350, 520 + 6 * strMulFac))) - self.assertIn(heap_memory_ref,xrange(350,536+6*strMulFac)) ++ self.assertIn(heap_memory_ref,range(350,536+6*strMulFac)) ff0.loadArrays() ## arr=DataArrayDouble(100) ; arr.iota() ; arr.rearrange(2) self.assertTrue(ff0.getUndergroundDataArray().isEqualWithoutConsideringStr(arr,1e-14)) @@@ -3115,7 -3105,7 +3115,7 @@@ self.assertEqual(ff0.getUndergroundDataArray().getIJ(30,1),5.5) self.assertTrue(not ff0.getUndergroundDataArray().isEqualWithoutConsideringStr(arr,1e-14)) heap_memory_ref=ff0.getHeapMemorySize() - self.assertIn(heap_memory_ref, list(range(1100, 1384 + 2 * strMulFac))) - self.assertIn(heap_memory_ref,xrange(1100,1400+2*strMulFac)) ++ self.assertIn(heap_memory_ref,range(1100,1400+2*strMulFac)) ff0.unloadArrays() hmd=ff0.getHeapMemorySize()-heap_memory_ref self.assertEqual(hmd,-800) # -50*8*2 @@@ -3124,7 -3114,7 +3124,7 @@@ # ff0=MEDFileField1TS(fname,"FieldCellPfl",-1,-1,False) heap_memory_ref=ff0.getHeapMemorySize() - self.assertIn(heap_memory_ref, list(range(299, 520 + 6 * strMulFac))) - self.assertIn(heap_memory_ref,xrange(299,536+6*strMulFac)) ++ self.assertIn(heap_memory_ref,range(299,536+6*strMulFac)) ff0.loadArrays() ## self.assertTrue(ff0.getUndergroundDataArray().isEqualWithoutConsideringStr(arr,1e-14)) self.assertEqual(ff0.getHeapMemorySize()-heap_memory_ref,50*8*2) @@@ -3141,14 -3131,14 +3141,14 @@@ # ff0=MEDFileAnyTypeFieldMultiTS.New(fname,fieldName,False) heap_memory_ref=ff0.getHeapMemorySize() - self.assertIn(heap_memory_ref,list(range(5536,8212+(80+26+1)*strMulFac))) - self.assertIn(heap_memory_ref,xrange(5536,10242+(80+26+1)*strMulFac)) ++ self.assertIn(heap_memory_ref,range(5536,10242+(80+26+1)*strMulFac)) ff0.loadArrays() self.assertEqual(ff0.getHeapMemorySize()-heap_memory_ref,20*70*8*2) del ff0 # ffs=MEDFileFields(fname,False) heap_memory_ref=ffs.getHeapMemorySize() - self.assertIn(heap_memory_ref,list(range(5335,9031+(80+50+len(ffs))*strMulFac))) - self.assertIn(heap_memory_ref,xrange(5335,11507+(80+50+len(ffs))*strMulFac)) ++ self.assertIn(heap_memory_ref,range(5335,11507+(80+50+len(ffs))*strMulFac)) ffs.loadArrays() self.assertEqual(ffs.getHeapMemorySize()-heap_memory_ref,20*70*8*2+70*8*2+50*8*2) pass @@@ -3320,13 -3310,13 +3320,13 @@@ tri=MEDCouplingUMesh("tri",2) tri.allocateCells() ; tri.insertNextCell(NORM_TRI3,[0,1,2]) tri.setCoords(DataArrayDouble([(0.,0.),(0.,1.),(1.,0.)])) - tris = [tri.deepCopy() for i in range(4)] - tris=[tri.deepCopy() for i in xrange(4)] ++ tris=[tri.deepCopy() for i in range(4)] for i,elt in enumerate(tris): elt.translate([i,0]) tris=MEDCouplingUMesh.MergeUMeshes(tris) quad=MEDCouplingUMesh("quad",2) quad.allocateCells() ; quad.insertNextCell(NORM_QUAD4,[0,1,2,3]) quad.setCoords(DataArrayDouble([(0.,0.),(0.,1.),(1.,1.),(1.,0.)])) - quads = [quad.deepCopy() for i in range(5)] - quads=[quad.deepCopy() for i in xrange(5)] ++ quads=[quad.deepCopy() for i in range(5)] for i,elt in enumerate(quads): elt.translate([5+i,0]) quads=MEDCouplingUMesh.MergeUMeshes(quads) m=MEDCouplingUMesh.MergeUMeshes(tris,quads) @@@ -3435,13 -3425,13 +3435,13 @@@ tri=MEDCouplingUMesh("tri",2) tri.allocateCells() ; tri.insertNextCell(NORM_TRI3,[0,1,2]) tri.setCoords(DataArrayDouble([(0.,0.),(0.,1.),(1.,0.)])) - tris = [tri.deepCopy() for i in range(4)] - tris=[tri.deepCopy() for i in xrange(4)] ++ tris=[tri.deepCopy() for i in range(4)] for i,elt in enumerate(tris): elt.translate([i,0]) tris=MEDCouplingUMesh.MergeUMeshes(tris) quad=MEDCouplingUMesh("quad",2) quad.allocateCells() ; quad.insertNextCell(NORM_QUAD4,[0,1,2,3]) quad.setCoords(DataArrayDouble([(0.,0.),(0.,1.),(1.,1.),(1.,0.)])) - quads = [quad.deepCopy() for i in range(5)] - quads=[quad.deepCopy() for i in xrange(5)] ++ quads=[quad.deepCopy() for i in range(5)] for i,elt in enumerate(quads): elt.translate([5+i,0]) quads=MEDCouplingUMesh.MergeUMeshes(quads) m=MEDCouplingUMesh.MergeUMeshes(tris,quads) @@@ -3519,7 -3509,7 +3519,7 @@@ m00=MEDCouplingUMesh("mesh",1) ; m00.setCoords(m0.getCoords()) ; m00.allocateCells(0) m=MEDFileUMesh() m.setMeshAtLevel(0,m00) - m.setRenumFieldArr(1, DataArrayInt(list(range(10, 26)))) - m.setRenumFieldArr(1,DataArrayInt(range(10,26))) ++ m.setRenumFieldArr(1,DataArrayInt(list(range(10,26)))) m.setFamilyFieldArr(1,DataArrayInt([-1,-1,-1,-1,-1,-2,-2,-2,-2,-2,-2,0,-1,-3,-3,-3])) m.write(fname,2) del m,a,c,m0,m00 @@@ -3527,7 -3517,7 +3527,7 @@@ m=MEDFileMesh.New(fname) self.assertEqual((),m.getNonEmptyLevels()) self.assertTrue(m.getCoords().isEqual(DataArrayDouble([(0,0),(1,0),(2,0),(3,0),(0,1),(1,1),(2,1),(3,1),(0,2),(1,2),(2,2),(3,2),(0,3),(1,3),(2,3),(3,3)]),1e-12)) - self.assertTrue(m.getNumberFieldAtLevel(1).isEqual(DataArrayInt(list(range(10, 26))))) - self.assertTrue(m.getNumberFieldAtLevel(1).isEqual(DataArrayInt(range(10,26)))) ++ self.assertTrue(m.getNumberFieldAtLevel(1).isEqual(DataArrayInt(list(range(10,26))))) self.assertTrue(m.getFamilyFieldAtLevel(1).isEqual(DataArrayInt([-1,-1,-1,-1,-1,-2,-2,-2,-2,-2,-2,0,-1,-3,-3,-3]))) pass @@@ -3537,14 -3527,14 +3537,14 @@@ m.insertNextCell([0,2,1,3]) m.setCoords(DataArrayDouble([0.,0.,1.,1.,1.,0.,0.,1.],4,2)) # - ms = [m.deepCopy() for i in range(4)] - ms=[m.deepCopy() for i in xrange(4)] ++ ms=[m.deepCopy() for i in range(4)] for i,elt in enumerate(ms): elt.translate([float(i)*1.5,0.]) pass m0=MEDCoupling1SGTUMesh.Merge1SGTUMeshes(ms).buildUnstructured() m0.convertAllToPoly() # - ms = [m.deepCopy() for i in range(5)] - ms=[m.deepCopy() for i in xrange(5)] ++ ms=[m.deepCopy() for i in range(5)] for i,elt in enumerate(ms): elt.translate([float(i)*1.5,1.5]) pass @@@ -3831,7 -3821,7 +3831,7 @@@ renum0=DataArrayInt([3,6,7,10,11,0,2,1,9,8,5,4,12,13,14,24,23,22,21,20,19,18,17,16,15]) famField0=DataArrayInt([-3,-6,-7,-10,-11,0,-2,-1,-9,-8,-5,-4,-12,-13,-14,-24,-23,-22,-21,-20,-19,-18,-17,-16,-15]) namesCellL0=DataArrayAsciiChar(25,16) - namesCellL0[:] = ["Cell#%.3d " % (i) for i in range(25)] - namesCellL0[:]=["Cell#%.3d "%(i) for i in xrange(25)] ++ namesCellL0[:]=["Cell#%.3d "%(i) for i in range(25)] renumM1=DataArrayInt([3,4,0,2,1]) famFieldM1=DataArrayInt([-3,-4,0,-2,-1]) mm.setRenumFieldArr(0,renum0) @@@ -3842,7 -3832,7 +3842,7 @@@ renum1=DataArrayInt([13,16,17,20,21,10,12,11,19,18,15,14,22,23,24,34,33,32,31,30,29,28,27,26,25,45,44,43,42,41,40,39,38,37,36,35]) famField1=DataArrayInt([-13,-16,-17,-20,-21,-10,-12,-11,-19,-18,-15,-14,-22,-23,-24,-34,-33,-32,-31,-30,-29,-28,-27,-26,-25,-45,-44,-43,-42,-41,-40,-39,-38,-37,-36,-35]) namesNodes=DataArrayAsciiChar(36,16) - namesNodes[:] = ["Node#%.3d " % (i) for i in range(36)] - namesNodes[:]=["Node#%.3d "%(i) for i in xrange(36)] ++ namesNodes[:]=["Node#%.3d "%(i) for i in range(36)] mm.setRenumFieldArr(1,renum1) mm.setFamilyFieldArr(1,famField1) mm.setNameFieldAtLevel(1,namesNodes) @@@ -3910,15 -3900,15 +3910,15 @@@ f=MEDCouplingFieldDouble(ON_CELLS,ONE_TIME) ; f.setMesh(m) f.setName("Field") arr=DataArrayDouble(25,2) ; arr.setInfoOnComponents(compos) - arr[:, 0] = list(range(25)) - arr[:, 1] = list(range(100, 125)) - arr[:,0]=range(25) - arr[:,1]=range(100,125) ++ arr[:,0]=list(range(25)) ++ arr[:,1]=list(range(100,125)) f.setArray(arr) WriteField(fileName,f,True) f=MEDCouplingFieldDouble(ON_NODES,ONE_TIME) ; f.setMesh(m) f.setName("FieldNode") arr=DataArrayDouble(36,2) ; arr.setInfoOnComponents(compos) - arr[:, 0] = list(range(200, 236)) - arr[:, 1] = list(range(300, 336)) - arr[:,0]=range(200,236) - arr[:,1]=range(300,336) ++ arr[:,0]=list(range(200,236)) ++ arr[:,1]=list(range(300,336)) f.setArray(arr) f.checkConsistencyLight() WriteFieldUsingAlreadyWrittenMesh(fileName,f) @@@ -3935,11 -3925,11 +3935,11 @@@ fs=MEDFileFields.LoadPartOf(fileName,False,ms) fs=fs.deepCopy() fs[0][0].loadArrays() - arr = DataArrayDouble(12, 2) ; arr[:, 0] = list(range(3, 15)) ; arr[:, 1] = list(range(103, 115)) - arr=DataArrayDouble(12,2) ; arr[:,0]=range(3,15) ; arr[:,1]=range(103,115) ++ arr=DataArrayDouble(12,2) ; arr[:,0]=range(3,15) ; arr[:,1]=list(range(103,115)) arr.setInfoOnComponents(compos) self.assertTrue(fs[0][0].getUndergroundDataArray().isEqual(arr,1e-12)) fs[1][0].loadArrays() - arr = DataArrayDouble(21, 2) ; arr[:, 0] = list(range(203, 224)) ; arr[:, 1] = list(range(303, 324)) - arr=DataArrayDouble(21,2) ; arr[:,0]=range(203,224) ; arr[:,1]=range(303,324) ++ arr=DataArrayDouble(21,2) ; arr[:,0]=range(203,224) ; arr[:,1]=list(range(303,324)) arr.setInfoOnComponents(compos) self.assertTrue(fs[1][0].getUndergroundDataArray().isEqual(arr,1e-12)) pass @@@ -3975,15 -3965,15 +3975,15 @@@ f=MEDCouplingFieldDouble(ON_CELLS,ONE_TIME) ; f.setMesh(m) f.setName("Field") arr=DataArrayDouble(25,2) ; arr.setInfoOnComponents(compos) - arr[:, 0] = list(range(25)) - arr[:, 1] = list(range(100, 125)) - arr[:,0]=range(25) - arr[:,1]=range(100,125) ++ arr[:,0]=list(range(25)) ++ arr[:,1]=list(range(100,125)) f.setArray(arr) WriteField(fileName,f,True) f=MEDCouplingFieldDouble(ON_NODES,ONE_TIME) ; f.setMesh(m) f.setName("FieldNode") arr=DataArrayDouble(36,2) ; arr.setInfoOnComponents(compos) - arr[:, 0] = list(range(200, 236)) - arr[:, 1] = list(range(300, 336)) - arr[:,0]=range(200,236) - arr[:,1]=range(300,336) ++ arr[:,0]=list(range(200,236)) ++ arr[:,1]=list(range(300,336)) f.setArray(arr) f.checkConsistencyLight() WriteFieldUsingAlreadyWrittenMesh(fileName,f) @@@ -4168,10 -4159,10 +4169,10 @@@ g2_1.setName("G2") mm.setGroupsAtLevel(-1,[g1_1,g2_1],False) g1_N=DataArrayInt.New() - g1_N.setValues(list(range(8)), 8, 1) - g1_N.setValues(range(8),8,1) ++ g1_N.setValues(list(range(8)),8,1) g1_N.setName("G1") g2_N=DataArrayInt.New() - g2_N.setValues(list(range(9)), 9, 1) - g2_N.setValues(range(9),9,1) ++ g2_N.setValues(list(range(9)),9,1) g2_N.setName("G2") mm.setGroupsAtLevel(1,[g1_N,g2_N],False) mm.createGroupOnAll(0,"GrpOnAllCell") @@@ -4286,12 -4277,12 +4287,12 @@@ m=m.buildUnstructured() m.setName(meshName) # - nbOfField = nbPdt // maxPdt - nbOfField=nbPdt/maxPdt ++ nbOfField=nbPdt//maxPdt fs=MEDFileFields() - for j in xrange(nbOfField): + for j in range(nbOfField): fmts=MEDFileFieldMultiTS() s=DataArray.GetSlice(slice(0,nbPdt,1),j,nbOfField) - for i in range(s.start, s.stop, s.step): - for i in xrange(s.start,s.stop,s.step): ++ for i in range(s.start,s.stop,s.step): f=MEDCouplingFieldDouble(ON_NODES) f.setMesh(m) arr=DataArrayDouble(nbNodes) ; arr.iota() ; arr*=i @@@ -4345,7 -4336,7 +4346,7 @@@ zeResu.setName(k) fs2.pushField(zeResu) pass - self.assertEqual(fs2[0].getTimeSteps(), [(i, 0, float(i)) for i in range(nbPdt)]) - self.assertEqual(fs2[0].getTimeSteps(),[(i,0,float(i)) for i in xrange(nbPdt)]) ++ self.assertEqual(fs2[0].getTimeSteps(),[(i,0,float(i)) for i in range(nbPdt)]) pass def testMEDFileMeshRearrangeFamIds1(self):