From: Nicolas Geimer Date: Mon, 27 Mar 2017 15:00:02 +0000 (+0200) Subject: [PY3] 2to3 -w -n . X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=5a28616584286d9311758762a3e1359639ece1e2;p=tools%2Fmedcoupling.git [PY3] 2to3 -w -n . --- diff --git a/doc/user/doxygen/BuildPyExamplesFromCPP.py b/doc/user/doxygen/BuildPyExamplesFromCPP.py index 9b4f59317..2f957e10c 100644 --- a/doc/user/doxygen/BuildPyExamplesFromCPP.py +++ b/doc/user/doxygen/BuildPyExamplesFromCPP.py @@ -66,7 +66,7 @@ def discardPythonFrom(contents): # Usage: BuildPyExamplesFromCPP.py -fCpp=file(sys.argv[1],"r") +fCpp=open(sys.argv[1],"r") cppCont=fCpp.readlines() ; del fCpp pyCont=cppCont[:] pyCont=[elt.replace("medcouplingcppexamples","medcouplingpyexamples") for elt in pyCont] @@ -79,8 +79,8 @@ cppCont=discardPythonFrom(cppCont) # remove Python-only contents from Cpp # Save CPP and PY examples in two separate dox files outFileName=os.path.join(sys.argv[2],os.path.basename(sys.argv[1])) -f=file(os.path.splitext(outFileName)[0]+"CPP.dox","w") +f=open(os.path.splitext(outFileName)[0]+"CPP.dox","w") f.writelines(cppCont) ; del f -f=file(os.path.splitext(outFileName)[0]+"PY.dox","w") +f=open(os.path.splitext(outFileName)[0]+"PY.dox","w") f.writelines(pyCont) ; del f diff --git a/doc/user/doxygen/doxy2swig/doxy2swig.py b/doc/user/doxygen/doxy2swig/doxy2swig.py index b7c7755d6..ede076a9a 100755 --- a/doc/user/doxygen/doxy2swig/doxy2swig.py +++ b/doc/user/doxygen/doxy2swig/doxy2swig.py @@ -150,7 +150,7 @@ class Doxy2SWIG: def add_text(self, value): """Adds text corresponding to `value` into `self.pieces`.""" - if type(value) in (types.ListType, types.TupleType): + if type(value) in (list, tuple): self.pieces.extend(value) else: self.pieces.append(value) @@ -210,17 +210,17 @@ class Doxy2SWIG: kind = node.attributes['kind'].value if kind in ('class', 'struct'): prot = node.attributes['prot'].value - if prot <> 'public': + if prot != 'public': return names = ('compoundname', 'briefdescription', 'detaileddescription', 'includes') first = self.get_specific_nodes(node, names) for n in names: - if first.has_key(n): + if n in first: self.parse(first[n]) self.add_text(['";','\n']) for n in node.childNodes: - if n not in first.values(): + if n not in list(first.values()): self.parse(n) elif kind in ('file', 'namespace'): nodes = node.getElementsByTagName('sectiondef') @@ -233,7 +233,7 @@ class Doxy2SWIG: def do_parameterlist(self, node): text='unknown' - for key, val in node.attributes.items(): + for key, val in list(node.attributes.items()): if key == 'kind': if val == 'param': text = 'Parameters' elif val == 'exception': text = 'Exceptions' @@ -280,7 +280,7 @@ class Doxy2SWIG: if name[:8] == 'operator': # Don't handle operators yet. return - if not first.has_key('definition') or \ + if 'definition' not in first or \ kind in ['variable', 'typedef']: return @@ -308,7 +308,7 @@ class Doxy2SWIG: self.add_text(' %s::%s "\n%s'%(cname, name, defn)) for n in node.childNodes: - if n not in first.values(): + if n not in list(first.values()): self.parse(n) self.add_text(['";', '\n']) @@ -375,7 +375,7 @@ class Doxy2SWIG: if not os.path.exists(fname): fname = os.path.join(self.my_dir, fname) if not self.quiet: - print "parsing file: %s"%fname + print("parsing file: %s"%fname) p = Doxy2SWIG(fname, self.include_function_definition, self.quiet) p.generate() self.pieces.extend(self.clean_pieces(p.pieces)) diff --git a/src/INTERP_KERNEL/GaussPoints/CleanUpGauss.py b/src/INTERP_KERNEL/GaussPoints/CleanUpGauss.py index 7a2c28e53..a5c18a116 100644 --- a/src/INTERP_KERNEL/GaussPoints/CleanUpGauss.py +++ b/src/INTERP_KERNEL/GaussPoints/CleanUpGauss.py @@ -39,7 +39,7 @@ if not mEnd: # nbLines=len(lines)-4 casePat=re.compile("[\s]+case[\s]+([\d]+)\:[\s]*$") -entries=filter(lambda (i,x): casePat.match(x),enumerate(lines[offsetLines:-1])) +entries=[i_x for i_x in enumerate(lines[offsetLines:-1]) if casePat.match(i_x[1])] # nbPts=len(entries) if nbLines%nbPts!=0: @@ -56,7 +56,7 @@ zeTab=(nbPts*dim)*[None] for lineId,ptId in entries: endLine=lines[offsetLines+lineId+1+dim] assert(partEndEntries.match(endLine)) - for j in xrange(dim): + for j in range(dim): curLine=lines[offsetLines+lineId+1+j] m=zePat.match(curLine) assert(m) @@ -68,11 +68,11 @@ assert(None not in zeTab) patInit="Init" assert(m0.group(1)[-len(patInit):]==patInit) varName="%s_REF"%((m0.group(1)[:-len(patInit)]).upper()) -print("const double %s[%d]={%s};"%(varName,len(zeTab),", ".join(zeTab))) -for i in xrange(nbPts): - print(" case %d:"%(i)) - for j in xrange(dim): - print(" coords[%d] = %s[%d];"%(j,varName,i*dim+j)) +print(("const double %s[%d]={%s};"%(varName,len(zeTab),", ".join(zeTab)))) +for i in range(nbPts): + print((" case %d:"%(i))) + for j in range(dim): + print((" coords[%d] = %s[%d];"%(j,varName,i*dim+j))) pass print(" break;") diff --git a/src/MEDCoupling_Swig/MEDCouplingBasicsTest1.py b/src/MEDCoupling_Swig/MEDCouplingBasicsTest1.py index cdc756551..b96d1e767 100644 --- a/src/MEDCoupling_Swig/MEDCouplingBasicsTest1.py +++ b/src/MEDCoupling_Swig/MEDCouplingBasicsTest1.py @@ -60,21 +60,21 @@ class MEDCouplingBasicsTest1(unittest.TestCase): self.assertEqual(7,arr4.getNumberOfTuples()); self.assertEqual(2,arr4.getNumberOfComponents()); tmp=arr4.getValues() - for i in xrange(14): + for i in range(14): self.assertTrue(abs(arr4Ref[i]-tmp[i])<1e-14); pass arr5=arr4.subArray(3); self.assertEqual(4,arr5.getNumberOfTuples()); self.assertEqual(2,arr5.getNumberOfComponents()); tmp=arr5.getValues() - for i in xrange(8): + for i in range(8): self.assertTrue(abs(arr4Ref[6+i]-tmp[i])<1e-14); pass arr6=arr4.subArray(2,5); self.assertEqual(3,arr6.getNumberOfTuples()); self.assertEqual(2,arr6.getNumberOfComponents()); tmp=arr6.getValues() - for i in xrange(6): + for i in range(6): self.assertTrue(abs(arr4Ref[4+i]-tmp[i])<1e-14); pass pass @@ -797,7 +797,7 @@ class MEDCouplingBasicsTest1(unittest.TestCase): self.assertEqual(5,m4.getMesh2D().getNumberOfCells()); self.assertEqual(3,m4.getMesh1D().getNumberOfCells()); m3DIds=m4.getMesh3DIds().getValues(); - self.assertEqual(range(15),list(m3DIds)); + self.assertEqual(list(range(15)),list(m3DIds)); #some random in cells to check that extrusion alg find it correctly expected1=[1,3,2,0,6,5,7,10,11,8,12,9,14,13,4] m3.renumberCells(expected1,False); @@ -853,7 +853,7 @@ class MEDCouplingBasicsTest1(unittest.TestCase): expected2=[0.075,0.0375,0.0375,0.075,0.075, 0.1125,0.05625,0.05625,0.1125,0.1125, 0.0625,0.03125,0.03125,0.0625,0.0625] - for i in xrange(15): + for i in range(15): self.assertAlmostEqual(expected2[rexpected1[i]],arrPtr[i],16); pass m5=m4.build3DUnstructuredMesh(); @@ -864,7 +864,7 @@ class MEDCouplingBasicsTest1(unittest.TestCase): self.assertTrue(isinstance(f.getMesh(),MEDCouplingMappedExtrudedMesh)) arr=f.getArray(); arrPtr=arr.getValues(); - for i in xrange(15): + for i in range(15): self.assertAlmostEqual(expected2[rexpected1[i]],arrPtr[i],15); pass pass @@ -877,7 +877,7 @@ class MEDCouplingBasicsTest1(unittest.TestCase): o2n,newNbOfNodes=targetMesh.buildNewNumberingFromCommonNodesFormat(comm,commI); self.assertEqual(27,newNbOfNodes); self.assertEqual(27,o2n.getNumberOfTuples()); - o2nExp1=range(27) + o2nExp1=list(range(27)) self.assertEqual(o2nExp1,list(o2n.getValues())); # targetMesh=MEDCouplingDataForTest.build3DTargetMeshMergeNode_1(); @@ -992,7 +992,7 @@ class MEDCouplingBasicsTest1(unittest.TestCase): def testMergeMeshOnSameCoords1(self): m1=MEDCouplingDataForTest.build2DTargetMesh_1(); m2=MEDCouplingDataForTest.build2DTargetMesh_1(); - cells=range(5); + cells=list(range(5)); m2.convertToPolyTypes(cells); m1.tryToShareSameCoords(m2,1e-12); m3=MEDCouplingDataForTest.build2DTargetMesh_1(); @@ -1035,7 +1035,7 @@ class MEDCouplingBasicsTest1(unittest.TestCase): values=[0.25,0.125,0.125,0.25,0.25,0.5,0.5] tmp=f3.getArray().getValues(); self.assertEqual(len(values),len(tmp)) - for i in xrange(7): + for i in range(7): self.assertTrue(abs(values[i]-tmp[i])<1e-12) pass pass @@ -1054,7 +1054,7 @@ class MEDCouplingBasicsTest1(unittest.TestCase): values1=[-0.1,0.23333333333333336,0.56666666666666665,0.4,0.9] tmp=f1.getArray().getValues(); self.assertEqual(len(values1),len(tmp)) - for i in xrange(len(tmp)): + for i in range(len(tmp)): self.assertTrue(abs(tmp[i]-values1[i])<1.e-12) pass # @@ -1067,7 +1067,7 @@ class MEDCouplingBasicsTest1(unittest.TestCase): values2=[-0.6,-0.1,0.4,-0.1,0.4,0.9,0.4,0.9,1.4] tmp=f1.getArray().getValues(); self.assertEqual(len(values2),len(tmp)) - for i in xrange(len(tmp)): + for i in range(len(tmp)): self.assertTrue(abs(tmp[i]-values2[i])<1.e-12) pass # @@ -1080,7 +1080,7 @@ class MEDCouplingBasicsTest1(unittest.TestCase): values3=[-0.6,-1.2,-0.1,-0.2,0.4,0.8,-0.1,-0.2,0.4,0.8,0.9,1.8,0.4,0.8,0.9,1.8,1.4,2.8] tmp=f1.getArray().getValues(); self.assertEqual(len(values3),len(tmp)) - for i in xrange(len(tmp)): + for i in range(len(tmp)): self.assertTrue(abs(tmp[i]-values3[i])<1.e-12) pass values4=f1.accumulate(); @@ -1106,7 +1106,7 @@ class MEDCouplingBasicsTest1(unittest.TestCase): values1=[-0.1,0.23333333333333336,0.56666666666666665,0.4,0.9] tmp=f1.getArray().getValues(); self.assertEqual(len(values1),len(tmp)) - for i in xrange(len(values1)): + for i in range(len(values1)): self.assertTrue(abs(values1[i]-tmp[i])<1.e-12); pass # @@ -1119,7 +1119,7 @@ class MEDCouplingBasicsTest1(unittest.TestCase): values2=[-0.9,0.1,1.1,-0.4,0.6,1.6,0.1,1.1,2.1] tmp=f1.getArray().getValues(); self.assertEqual(len(values2),len(tmp)) - for i in xrange(len(values2)): + for i in range(len(values2)): self.assertTrue(abs(values2[i]-tmp[i])<1.e-12); pass f1=m.fillFromAnalytic(ON_NODES,1,"2.*x+y"); @@ -1131,7 +1131,7 @@ class MEDCouplingBasicsTest1(unittest.TestCase): tmp=f1.getArray().getValues(); values2Bis=[-0.9,0.1,1.1,-0.4,0.6,1.6,0.1,1.1,2.1] self.assertEqual(len(values2Bis),len(tmp)) - for i in xrange(len(values2Bis)): + for i in range(len(values2Bis)): self.assertTrue(abs(values2Bis[i]-tmp[i])<1.e-12); pass # @@ -1144,7 +1144,7 @@ class MEDCouplingBasicsTest1(unittest.TestCase): values3=[-0.6,-1.2,-0.1,-0.2,0.4,0.8,-0.1,-0.2,0.4,0.8,0.9,1.8,0.4,0.8,0.9,1.8,1.4,2.8] tmp=f1.getArray().getValues(); self.assertEqual(len(values3),len(tmp)) - for i in xrange(len(values3)): + for i in range(len(values3)): self.assertTrue(abs(values3[i]-tmp[i])<1.e-12); pass values4=f1.accumulate(); @@ -1171,7 +1171,7 @@ class MEDCouplingBasicsTest1(unittest.TestCase): values1=[-1.8,-0.3,1.2,-0.3,1.2,2.7,1.2,2.7,4.2] tmp=f1.getArray().getValues(); self.assertEqual(len(values1),len(tmp)) - for i in xrange(len(tmp)): + for i in range(len(tmp)): self.assertTrue(abs(tmp[i]-values1[i])<1.e-12) pass pass @@ -1201,7 +1201,7 @@ class MEDCouplingBasicsTest1(unittest.TestCase): 5.0423700574830965, 17.435300118916864] tmp=f2.getArray().getValues(); self.assertEqual(len(tmp),len(values2)) - for i in xrange(len(tmp)): + for i in range(len(tmp)): self.assertTrue(abs(tmp[i]-values2[i])<1.e-12) pass # @@ -1213,7 +1213,7 @@ class MEDCouplingBasicsTest1(unittest.TestCase): values1=[-1.8,-0.3,1.2,-0.3,1.2,2.7,1.2,2.7,4.2] tmp=f1.getArray().getValues(); self.assertEqual(len(tmp),len(values1)) - for i in xrange(len(tmp)): + for i in range(len(tmp)): self.assertTrue(abs(tmp[i]-values1[i])<1.e-12) pass pass @@ -1231,7 +1231,7 @@ class MEDCouplingBasicsTest1(unittest.TestCase): values1=[-1.2,-0.2,0.8,-0.2,0.8,1.8,0.8,1.8,2.8] tmp=f3.getArray().getValues(); self.assertEqual(len(values1),len(tmp)) - for i in xrange(len(tmp)): + for i in range(len(tmp)): self.assertTrue(abs(tmp[i]-values1[i])<1.e-12) pass # @@ -1242,7 +1242,7 @@ class MEDCouplingBasicsTest1(unittest.TestCase): values2=[0.36,0.01,0.16,0.01,0.16,0.81,0.16,0.81,1.96] tmp=f3.getArray().getValues(); self.assertEqual(len(values2),len(tmp)) - for i in xrange(len(tmp)): + for i in range(len(tmp)): self.assertTrue(abs(tmp[i]-values2[i])<1.e-12) pass # @@ -1254,7 +1254,7 @@ class MEDCouplingBasicsTest1(unittest.TestCase): values3=[0.6,0.1,-0.4,0.1,-0.4,-0.9,-0.4,-0.9,-1.4] tmp=f4.getArray().getValues(); self.assertEqual(len(values3),len(tmp)) - for i in xrange(len(tmp)): + for i in range(len(tmp)): self.assertTrue(abs(tmp[i]-values3[i])<1.e-12) pass # @@ -1264,7 +1264,7 @@ class MEDCouplingBasicsTest1(unittest.TestCase): self.assertEqual(f4.getTypeOfField(),ON_NODES); self.assertEqual(f4.getTimeDiscretization(),ONE_TIME); tmp=f4.getArray().getValues(); - for i in xrange(len(tmp)): + for i in range(len(tmp)): self.assertTrue(abs(tmp[i]-2.)<1.e-12) pass # @@ -1280,7 +1280,7 @@ class MEDCouplingBasicsTest1(unittest.TestCase): tmp=f3.getArray().getValues(); values4=[-1.2,-0.2,0.8,-0.2,0.8,1.8,0.8,1.8,2.8] self.assertEqual(len(values3),len(tmp)) - for i in xrange(len(tmp)): + for i in range(len(tmp)): self.assertTrue(abs(tmp[i]-values4[i])<1.e-12) pass # @@ -1296,7 +1296,7 @@ class MEDCouplingBasicsTest1(unittest.TestCase): tmp=f3.getArray().getValues(); values5=[-1.2,-0.2,0.8,-0.2,0.8,1.8,0.8,1.8,2.8] self.assertEqual(len(values5),len(tmp)) - for i in xrange(len(tmp)): + for i in range(len(tmp)): self.assertTrue(abs(tmp[i]-values5[i])<1.e-12) pass pass @@ -1316,7 +1316,7 @@ class MEDCouplingBasicsTest1(unittest.TestCase): self.assertEqual(1,f3.getNumberOfComponents()); self.assertEqual(9,f3.getNumberOfTuples()); val=f3.getArray().getValues(); - for i in xrange(9): + for i in range(9): self.assertTrue(abs(expected1[i]-val[i])<1.e-12); # f1=m.buildOrthogonalField(); @@ -1326,13 +1326,13 @@ class MEDCouplingBasicsTest1(unittest.TestCase): f3=f1*f2; expected2=[-0.035355339059327376,0.,0.035355339059327376, 0.2592724864350674,0.,-0.2592724864350674, 0.37712361663282529,0.,-0.37712361663282529, -0.035355339059327376,0.,0.035355339059327376, 0.31819805153394637,0.,-0.31819805153394637] val=f3.getArray().getValues(); - for i in xrange(15): + for i in range(15): self.assertTrue(abs(expected2[i]-val[i])<1.e-12); pass # f3=f2*f1; val=f3.getArray().getValues(); - for i in xrange(15): + for i in range(15): self.assertTrue(abs(expected2[i]-val[i])<1.e-12); pass pass @@ -1351,7 +1351,7 @@ class MEDCouplingBasicsTest1(unittest.TestCase): self.assertEqual(1,f1.getNumberOfComponents()); self.assertEqual(9,f1.getNumberOfTuples()); val=f1.getArray().getValues(); - for i in xrange(9): + for i in range(9): self.assertTrue(abs(expected1[i]-val[i])<1.e-12); pass # @@ -1360,7 +1360,7 @@ class MEDCouplingBasicsTest1(unittest.TestCase): f1*=f2 expected2=[-0.035355339059327376,0.,0.035355339059327376, 0.2592724864350674,0.,-0.2592724864350674, 0.37712361663282529,0.,-0.37712361663282529, -0.035355339059327376,0.,0.035355339059327376, 0.31819805153394637,0.,-0.31819805153394637] val=f1.getArray().getValues(); - for i in xrange(15): + for i in range(15): self.assertTrue(abs(expected2[i]-val[i])<1.e-12); pass # @@ -1546,7 +1546,7 @@ class MEDCouplingBasicsTest1(unittest.TestCase): self.assertEqual(3,len(corr)); expectedVals1=[3,3,2] expectedVals2=[[0,1,2],[3,0,2],[3,0]] - for i in xrange(3): + for i in range(3): arr=corr[i]; self.assertEqual(1,arr.getNumberOfComponents()); nbOfVals=expectedVals1[i]; @@ -1561,7 +1561,7 @@ class MEDCouplingBasicsTest1(unittest.TestCase): self.assertEqual(1,arr2.getNumberOfComponents()); self.assertEqual(4,arr2.getNumberOfTuples()); self.assertEqual(fidExp,list(arr2.getValues())); - for i in xrange(3): + for i in range(3): nbOfVals=expectedVals1[i]; self.assertEqual(list(fidsOfGroups[i]),fidsGrp[i]); pass @@ -1595,7 +1595,7 @@ class MEDCouplingBasicsTest1(unittest.TestCase): self.assertEqual(5,field.getNumberOfTuples()); self.assertEqual(3,field.getNumberOfComponents()); vals=field.getArray().getValues(); - for i in xrange(15): + for i in range(15): self.assertTrue(abs(expected[i%3]-vals[i])<1e-12); # testing targetCoords=[0.,0.,0.,0.5,0.,0.5,1.,0.,1.,0.,1.,0.] @@ -1699,7 +1699,7 @@ class MEDCouplingBasicsTest1(unittest.TestCase): fieldOnCells.setMesh(targetMesh); array=DataArrayDouble.New(); tmp=2*nbOfCells*[None] - for i in xrange(nbOfCells): + for i in range(nbOfCells): tmp[2*i]=7.+float(i); tmp[2*i+1]=17.+float(i) pass @@ -1719,7 +1719,7 @@ class MEDCouplingBasicsTest1(unittest.TestCase): fieldOnNodes.setMesh(targetMesh); array=DataArrayDouble.New(); tmp=2*nbOfNodes*[None] - for i in xrange(nbOfNodes): + for i in range(nbOfNodes): tmp[2*i]=17.+float(i); tmp[2*i+1]=27.+float(i) pass @@ -1765,7 +1765,7 @@ class MEDCouplingBasicsTest1(unittest.TestCase): 7., 4., 6., 7., 9., 5., 7., 8., 10., 7., 9., 10., 12.]; val=fieldOnNodes.getArray().getValues(); - for i in xrange(64): + for i in range(64): self.assertAlmostEqual(expected1[i], val[i], 12) res=fieldOnNodes.getValueOnPos(1, 3, 2); self.assertAlmostEqual(7., res[0], 12); @@ -1776,7 +1776,7 @@ class MEDCouplingBasicsTest1(unittest.TestCase): val=fieldOnCells.getArray().getValues(); expected2=[0, 1.5, 3, 1.5, 3, 4.5, 3, 4.5, 6, 1.5, 3, 4.5, 3, 4.5, 6, 4.5, 6, 7.5, 3, 4.5, 6, 4.5, 6, 7.5, 6, 7.5, 9]; - for i in xrange(27): + for i in range(27): self.assertAlmostEqual(expected2[i], val[i], 12); #res=fieldOnCells.getValueOnPos(1,2,1); #self.assertAlmostEqual(6.,res,12); @@ -1962,7 +1962,7 @@ class MEDCouplingBasicsTest1(unittest.TestCase): -0.05,0.45, 0.2,0.45, 0.45,0.45] val=mesh.getCoords().getValues(); self.assertEqual(18,len(val)) - for i in xrange(18): + for i in range(18): self.assertTrue(abs(expected1[i]-val[i])<1e-12); pass pass @@ -2049,7 +2049,7 @@ class MEDCouplingBasicsTest1(unittest.TestCase): self.assertEqual(3,m1.getSpaceDimension()); expected=[-0.3,-0.3,0., 0.2,-0.3,0., 0.7,-0.3,0., -0.3,0.2,0., 0.2,0.2,0., 0.7,0.2,0., -0.3,0.7,0., 0.2,0.7,0., 0.7,0.7,0.] val=m1.getCoords().getValues(); - for i in xrange(27): + for i in range(27): self.assertTrue(abs(expected[i]-val[i])<1e-14); pass pass @@ -2084,7 +2084,7 @@ class MEDCouplingBasicsTest1(unittest.TestCase): self.assertEqual(2,f.getNbOfGaussLocalization()); array=DataArrayDouble.New(); ptr=18*2*[None] - for i in xrange(18*2): + for i in range(18*2): ptr[i]=float(i+1) array.setValues(ptr,18,2); ptr=array.getPointer(); @@ -2146,7 +2146,7 @@ class MEDCouplingBasicsTest1(unittest.TestCase): f.setDescription("MyDescriptionNE"); array=DataArrayDouble.New(); tmp=18*2*[None] - for i in xrange(18*2): + for i in range(18*2): tmp[i]=float(i+7) pass array.setValues(tmp,18,2); @@ -2228,7 +2228,7 @@ class MEDCouplingBasicsTest1(unittest.TestCase): self.assertEqual(1,f3.getNumberOfComponents()); f3Ptr=f3.getArray().getValues(); expected1=[0.075,0.0375,0.0375,0.075,0.075, 0.1125,0.05625,0.05625,0.1125,0.1125, 0.0625,0.03125,0.03125,0.0625,0.0625]; - for i in xrange(15): + for i in range(15): self.assertTrue(abs(expected1[i]-f3Ptr[i])<1e-12); pass f4=m5.computeCellCenterOfMass(); @@ -2236,7 +2236,7 @@ class MEDCouplingBasicsTest1(unittest.TestCase): self.assertEqual(3,f4.getNumberOfComponents()); f4Ptr=f4.getValues(); expected2=[-0.05,-0.05,0.15, 0.3666666666666667,-0.13333333333333333,0.15, 0.53333333333333333,0.033333333333333333,0.15, -0.05,0.45,0.15, 0.45,0.45,0.15,-0.05,-0.05,0.525, 0.3666666666666667,-0.13333333333333333,0.525, 0.53333333333333333,0.033333333333333333,0.525, -0.05,0.45,0.525, 0.45,0.45,0.525,-0.05,-0.05,0.875, 0.3666666666666667,-0.13333333333333333,0.875, 0.53333333333333333,0.033333333333333333,0.875, -0.05,0.45,0.875, 0.45,0.45,0.875]; - for i in xrange(45): + for i in range(45): self.assertTrue(abs(expected2[i]-f4Ptr[i])<1e-12); pass pass @@ -2284,7 +2284,7 @@ class MEDCouplingBasicsTest1(unittest.TestCase): self.assertEqual(3,da.getNumberOfComponents()); daPtr=da.getValues(); ref=meshN.getCoords().getValues()[24:]; - for i in xrange(3): + for i in range(3): self.assertTrue(abs(ref[i]-daPtr[i])<1e-12); pass # @@ -2293,7 +2293,7 @@ class MEDCouplingBasicsTest1(unittest.TestCase): da=meshN.computeCellCenterOfMass(); daPtr=da.getValues(); ref=meshN.getCoords().getValues()[24:]; - for i in xrange(3): + for i in range(3): self.assertTrue(abs(ref[i]-daPtr[i])<1e-12); pass # @@ -2302,7 +2302,7 @@ class MEDCouplingBasicsTest1(unittest.TestCase): da=meshN.computeCellCenterOfMass(); daPtr=da.getValues(); ref=meshN.getCoords().getValues()[24:]; - for i in xrange(3): + for i in range(3): self.assertTrue(abs(ref[i]-daPtr[i])<1e-12); pass # @@ -2313,7 +2313,7 @@ class MEDCouplingBasicsTest1(unittest.TestCase): da=meshN.computeCellCenterOfMass(); daPtr=da.getValues(); ref=meshN.getCoords().getValues()[24:]; - for i in xrange(3): + for i in range(3): self.assertTrue(abs(ref[i]-daPtr[i])<1e-10); pass pass @@ -2332,7 +2332,7 @@ class MEDCouplingBasicsTest1(unittest.TestCase): self.assertEqual(1,f3.getNumberOfComponents()); expected9=[0.75,5.105,0.8,5.155] ptr=f3.getValues(); - for i in xrange(4): + for i in range(4): self.assertTrue(abs(expected9[i]-ptr[i])<1e-12); pass # @@ -2341,13 +2341,13 @@ class MEDCouplingBasicsTest1(unittest.TestCase): self.assertEqual(1,f2.getNumberOfComponents()); expected1=[0.5,0.21,-0.6,-0.31] ptr=f2.getArray().getValues(); - for i in xrange(4): + for i in range(4): self.assertTrue(abs(expected1[i]-ptr[i])<1e-12); pass expected2=[0.5,0.21,0.6,0.31] f2=m1.getMeasureField(True); ptr=f2.getArray().getValues(); - for i in xrange(4): + for i in range(4): self.assertTrue(abs(expected2[i]-ptr[i])<1e-12); pass #integral @@ -2355,7 +2355,7 @@ class MEDCouplingBasicsTest1(unittest.TestCase): res=f1.integral(False); self.assertTrue(3,len(res)) expected3=[0.9866,-0.3615,0.4217] - for i in xrange(3): + for i in range(3): self.assertTrue(abs(expected3[i]-res[i])<1e-12); pass self.assertTrue(abs(expected3[0]-f1.integral(0,False))<1e-12); @@ -2363,14 +2363,14 @@ class MEDCouplingBasicsTest1(unittest.TestCase): self.assertTrue(abs(expected3[2]-f1.integral(2,False))<1e-12); res=f1.integral(True); expected4=[-3.4152,8.7639,-14.6879] - for i in xrange(3): + for i in range(3): self.assertTrue(abs(expected4[i]-res[i])<1e-12); pass #normL1 res=f1.normL1(); self.assertTrue(3,len(res)) expected5=[6.979506172839505, 16.89018518518518, 27.02969135802469] - for i in xrange(3): + for i in range(3): self.assertTrue(abs(expected5[i]-res[i])<1e-12); pass self.assertTrue(abs(expected5[0]-f1.normL1(0))<1e-12); @@ -2380,7 +2380,7 @@ class MEDCouplingBasicsTest1(unittest.TestCase): res=f1.normL2(); self.assertTrue(3,len(res)) expected7=[7.090910979452395, 16.9275542960123, 27.053271464160858] - for i in xrange(3): + for i in range(3): self.assertTrue(abs(expected7[i]-res[i])<1e-9); pass self.assertTrue(abs(expected7[0]-f1.normL2(0))<1e-9); @@ -2397,14 +2397,14 @@ class MEDCouplingBasicsTest1(unittest.TestCase): self.assertEqual(4,f2.getArray().getNumberOfTuples()); self.assertEqual(1,f2.getNumberOfComponents()); ptr=f2.getArray().getValues(); - for i in xrange(4): + for i in range(4): self.assertTrue(abs(sqrt(2.)*expected2[i]-ptr[i])<1e-12); pass f2=m1.getMeasureField(True); self.assertEqual(4,f2.getArray().getNumberOfTuples()); self.assertEqual(1,f2.getNumberOfComponents()); ptr=f2.getArray().getValues(); - for i in xrange(4): + for i in range(4): self.assertTrue(abs(expected2[i]*sqrt(2.)-ptr[i])<1e-12); pass #bary @@ -2413,7 +2413,7 @@ class MEDCouplingBasicsTest1(unittest.TestCase): self.assertEqual(2,f3.getNumberOfComponents()); expected10=[0.75,0.75,5.105,5.105,0.8,0.8,5.155,5.155] ptr=f3.getValues(); - for i in xrange(8): + for i in range(8): self.assertTrue(abs(expected10[i]-ptr[i])<1e-12); pass # @@ -2423,19 +2423,19 @@ class MEDCouplingBasicsTest1(unittest.TestCase): array.setValues(arr,m1.getNumberOfCells(),3); f1.setArray(array); res=f1.integral(False); - for i in xrange(3): + for i in range(3): self.assertTrue(abs(sqrt(2.)*expected4[i]-res[i])<1e-12); pass res=f1.integral(True); - for i in xrange(3): + for i in range(3): self.assertTrue(abs(sqrt(2.)*expected4[i]-res[i])<1e-12); pass res=f1.normL1(); - for i in xrange(3): + for i in range(3): self.assertTrue(abs(expected5[i]-res[i])<1e-12); pass res=f1.normL2(); - for i in xrange(3): + for i in range(3): self.assertTrue(abs(expected7[i]-res[i])<1e-12); pass pass @@ -2447,12 +2447,12 @@ class MEDCouplingBasicsTest1(unittest.TestCase): self.assertEqual(1,f1.getNumberOfComponents()); expected1=[-0.5,-1,-1.5,-0.5,-1, 0.5,1,1.5,0.5,1] ptr=f1.getArray().getValues(); - for i in xrange(10): + for i in range(10): self.assertTrue(abs(expected1[i]-ptr[i])<1e-12); pass f1=m1.getMeasureField(True); ptr=f1.getArray().getValues(); - for i in xrange(10): + for i in range(10): self.assertTrue(abs(abs(expected1[i])-ptr[i])<1e-12); pass f2=m1.computeCellCenterOfMass(); @@ -2460,7 +2460,7 @@ class MEDCouplingBasicsTest1(unittest.TestCase): self.assertEqual(2,f2.getNumberOfComponents()); expected2=[0.5,0.3333333333333333,0.5,0.5,0.5,0.77777777777777777,0.5,0.3333333333333333,0.5,0.5,0.5,0.3333333333333333,0.5,0.5,0.5,0.77777777777777777,0.5,0.3333333333333333,0.5,0.5] ptr=f2.getValues(); - for i in xrange(20): + for i in range(20): self.assertTrue(abs(expected2[i]-ptr[i])<1e-12); pass m1.changeSpaceDimension(3); @@ -2468,7 +2468,7 @@ class MEDCouplingBasicsTest1(unittest.TestCase): self.assertEqual(10,f1.getArray().getNumberOfTuples()); self.assertEqual(1,f1.getNumberOfComponents()); ptr=f1.getArray().getValues(); - for i in xrange(10): + for i in range(10): self.assertTrue(abs(abs(expected1[i])-ptr[i])<1e-12); pass f2=m1.computeCellCenterOfMass(); @@ -2476,7 +2476,7 @@ class MEDCouplingBasicsTest1(unittest.TestCase): self.assertEqual(3,f2.getNumberOfComponents()); ptr=f2.getValues(); expected3=[0.5,0.3333333333333333,0.,0.5,0.5,0.,0.5,0.77777777777777777,0.,0.5,0.3333333333333333,0.,0.5,0.5,0., 0.5,0.3333333333333333,0.,0.5,0.5,0.,0.5,0.77777777777777777,0.,0.5,0.3333333333333333,0.,0.5,0.5,0.] - for i in xrange(30): + for i in range(30): self.assertTrue(abs(expected3[i]-ptr[i])<1e-12); pass pass @@ -2563,7 +2563,7 @@ class MEDCouplingBasicsTest1(unittest.TestCase): self.assertEqual(4,da.getNumberOfTuples()); self.assertEqual(3,da.getNumberOfComponents()); daPtr=da.getValues(); - for i in xrange(12): + for i in range(12): self.assertTrue(abs(barys[i]-daPtr[i])<1e-12); pass pass @@ -2579,22 +2579,22 @@ class MEDCouplingBasicsTest1(unittest.TestCase): f.setArray(arr); renumber1=[3,1,0,4,2] loc=[-0.05,-0.05, 0.55,-0.25, 0.55,0.15, -0.05,0.45, 0.45,0.45] - for j in xrange(5): + for j in range(5): res=f.getValueOn(loc[2*j:2*j+2]); - for i in xrange(3): + for i in range(3): self.assertTrue(abs(values1[i+3*j]-res[i])<1e-12); pass pass f.renumberCells(renumber1,False); ptr=f.getArray().getValues(); expected1=[9.,109.,10009.,8.,108.,10008.,11.,111.,10011.,7.,107.,10007.,10.,110.,10010.] - for i in xrange(15): + for i in range(15): self.assertTrue(abs(expected1[i]-ptr[i])<1e-12); pass #check that fields remains the same geometrically - for j in xrange(5): + for j in range(5): res=f.getValueOn(loc[2*j:2*(j+1)]); - for i in xrange(3): + for i in range(3): self.assertTrue(abs(values1[i+3*j]-res[i])<1e-12); pass pass @@ -2628,7 +2628,7 @@ class MEDCouplingBasicsTest1(unittest.TestCase): self.assertTrue(not f.isEqual(fCpy,1e-12,1e-12)); expected2=[21.,1021.,22.,1022.,23.,1023.,24.,1024.,25.,1025.,26.,1026., 11.,1011.,12.,1012.,13.,1013.,14.,1014.,15.,1015.,16.,1016., 41.,1041.,42.,1042., 1.,1001.,2.,1002., 31.,1031.,32.,1032.] ptr=f.getArray().getValues(); - for i in xrange(36): + for i in range(36): self.assertTrue(abs(expected2[i]-ptr[i])<1e-12); pass renumber2=[2,1,4,0,3] @@ -2648,7 +2648,7 @@ class MEDCouplingBasicsTest1(unittest.TestCase): self.assertTrue(not f.isEqual(fCpy,1e-12,1e-12)); expected3=[21.,1021.,22.,1022.,23.,1023.,11.,1011.,12.,1012.,13.,1013.,41.,1041.,42.,1042.,43.,1043.,44.,1044.,1.,1001.,2.,1002.,3.,1003.,4.,1004.,31.,1031.,32.,1032.,33.,1033.,34.,1034.] ptr=f.getArray().getValues(); - for i in xrange(36): + for i in range(36): self.assertTrue(abs(expected3[i]-ptr[i])<1e-12); pass f.renumberCells(renumber2,False);#perform reverse operation of renumbering to check that the resulting field is equal. @@ -2670,9 +2670,9 @@ class MEDCouplingBasicsTest1(unittest.TestCase): renumber1=[0,4,1,3,5,2,6,7,8] loc=[0.5432,-0.2432, 0.5478,0.1528] expected1=[9.0272, 109.0272, 10009.0272, 11.4124,111.4124,10011.4124] - for j in xrange(2): + for j in range(2): res=f.getValueOn(loc[2*j:2*j+2]); - for i in xrange(3): + for i in range(3): self.assertTrue(abs(expected1[i+3*j]-res[i])<1e-12); pass pass @@ -2680,14 +2680,14 @@ class MEDCouplingBasicsTest1(unittest.TestCase): self.assertTrue(f.isEqual(fCpy,1e-12,1e-12)); f.renumberNodes(renumber1); self.assertTrue(not f.isEqual(fCpy,1e-12,1e-12)); - for j in xrange(2): + for j in range(2): res=f.getValueOn(loc[2*j:2*j+2]); - for i in xrange(3): + for i in range(3): self.assertTrue(abs(expected1[i+3*j]-res[i])<1e-12); pass pass expected2=[7.,107.,10007.,9.,109.,10009.,12.,112.,10012.,10.,110.,10010.,8.,108.,10008.,11.,111.,10011.,13.,113.,10013.,14.,114.,10014.,15.,115.,10015.] - for i in xrange(27): + for i in range(27): self.assertTrue(abs(expected2[i]-f.getArray().getValues()[i])<1e-12); pass renumber2=[0,2,5,3,1,4,6,7,8] @@ -2824,7 +2824,7 @@ class MEDCouplingBasicsTest1(unittest.TestCase): self.assertEqual(None,cellCor); self.assertNotEqual(None,nodeCor); expected1=[0, 1, 3, 4, 5, 6, 7, 8, 9] - for i in xrange(9): + for i in range(9): self.assertEqual(expected1[i],nodeCor.getIJ(i,0)); pass pass @@ -2943,7 +2943,7 @@ class MEDCouplingBasicsTest1(unittest.TestCase): f2=m2.getMeasureField(False); self.assertEqual(5,f1.getArray().getNumberOfTuples()); self.assertEqual(1,f2.getArray().getNumberOfTuples()); - for i in xrange(5): + for i in range(5): self.assertAlmostEqual(expected1[i],f1.getIJ(i,0),12); pass self.assertAlmostEqual(expected1[0],f2.getIJ(0,0),12); @@ -2954,7 +2954,7 @@ class MEDCouplingBasicsTest1(unittest.TestCase): f2=m2.getMeasureField(False); self.assertEqual(5,f1.getArray().getNumberOfTuples()); self.assertEqual(1,f2.getArray().getNumberOfTuples()); - for i in xrange(5): + for i in range(5): self.assertAlmostEqual(expected1[i],f1.getIJ(i,0),12); pass self.assertAlmostEqual(expected1[0],f2.getIJ(0,0),12); @@ -2978,7 +2978,7 @@ class MEDCouplingBasicsTest1(unittest.TestCase): f1.changeUnderlyingMesh(mesh2,10,1e-12); #self.assertTrue(f1.getMesh()==mesh2); expected1=[7.,107.,9.,109.,8.,108.,10.,110.,11.,111.,12.,112.,13.,113.,15.,115.,14.,114.,16.,116.] - for i in xrange(20): + for i in range(20): self.assertAlmostEqual(expected1[i],f1.getArray().getIJ(0,i),12); pass # @@ -2995,7 +2995,7 @@ class MEDCouplingBasicsTest1(unittest.TestCase): f1.changeUnderlyingMesh(mesh2,10,1e-12); #self.assertTrue(f1.getMesh()==mesh2); expected2=[7.,107.,17.,117.,8.,108.,10.,110.,11.,111.,12.,112.,13.,113.,15.,115.,14.,114.,16.,116.,9.,109.] - for i in xrange(22): + for i in range(22): self.assertAlmostEqual(expected2[i],f1.getArray().getIJ(0,i),12); pass pass @@ -3076,13 +3076,13 @@ class MEDCouplingBasicsTest1(unittest.TestCase): # f3=f1.dot(f2); expected1=[842.,1820.,2816.,3830.,4862.,5912.,6980.,8066.,9170.,10292.] - for i in xrange(10): + for i in range(10): self.assertAlmostEqual(expected1[i],f3.getIJ(i,0),9); pass # f4=f1.crossProduct(f2); expected2=[-93., 186., -93., -392., 784., -392., -691., 1382., -691., -990., 1980., -990., -1289., 2578., -1289., -1588., 3176., -1588., -1887., 3774., -1887., -2186., 4372., -2186., -2485., 4970., -2485., -2784., 5568., -2784.] - for i in xrange(30): + for i in range(30): self.assertAlmostEqual(expected2[i],f4.getIJ(0,i),9); pass pass diff --git a/src/MEDCoupling_Swig/MEDCouplingBasicsTest2.py b/src/MEDCoupling_Swig/MEDCouplingBasicsTest2.py index f48cf9edb..de19d6a4f 100644 --- a/src/MEDCoupling_Swig/MEDCouplingBasicsTest2.py +++ b/src/MEDCoupling_Swig/MEDCouplingBasicsTest2.py @@ -45,13 +45,13 @@ class MEDCouplingBasicsTest2(unittest.TestCase): # f3=f1.max(f2); expected1=[7.,108.,207.,9.,108.,209.,9.,110.,209.,11.,110.,211.,11.,112.,211.,13.,112.,213.,13.,114.,213.,15.,114.,215.,15.,116.,215.,17.,116.,217.] - for i in xrange(30): + for i in range(30): self.assertAlmostEqual(expected1[i],f3.getIJ(0,i),9); pass # f4=f1.min(f2); expected2=[6.,107.,206.,8.,107.,208.,8.,109.,208.,10.,109.,210.,10.,111.,210.,12.,111.,212.,12.,113.,212.,14.,113.,214.,14.,115.,214.,16.,115.,216.] - for i in xrange(30): + for i in range(30): self.assertAlmostEqual(expected2[i],f4.getIJ(0,i),9); pass # @@ -68,7 +68,7 @@ class MEDCouplingBasicsTest2(unittest.TestCase): # f1.applyLin(2.,3.,0); expected1=[17.,107.,19.,108.,21.,109.,23.,110.,25.,111.,27.,112.,29.,113.,31.,114.,33.,115.,35.,116.] - for i in xrange(20): + for i in range(20): self.assertAlmostEqual(expected1[i],f1.getIJ(0,i),9); pass # @@ -80,11 +80,11 @@ class MEDCouplingBasicsTest2(unittest.TestCase): f1.applyLin(4.,5.,1); # expected2=[17.,433.,19.,437.,21.,441.,23.,445.,25.,449.,27.,453.,29.,457.,31.,461.,33.,465.,35.,469.] - for i in xrange(20): + for i in range(20): self.assertAlmostEqual(expected2[i],f1.getIJ(0,i),9); pass expected3=[2.,413.,3.,417.,4.,421.,5.,425.,6.,429.,7.,433.,8.,437.,9.,441.,10.,445.,11.,449.] - for i in xrange(20): + for i in range(20): self.assertAlmostEqual(expected3[i],f1.getEndArray().getIJ(0,i),9); pass # @@ -102,13 +102,13 @@ class MEDCouplingBasicsTest2(unittest.TestCase): # f1.checkConsistencyLight(); da=f1.findIdsInRange(2.9,7.1); - self.failUnlessEqual(5,da.getNbOfElems()); + self.assertEqual(5,da.getNbOfElems()); expected1=[2,3,5,7,9] - self.failUnlessEqual(expected1,list(da.getValues())); + self.assertEqual(expected1,list(da.getValues())); da=f1.findIdsInRange(8.,12.); - self.failUnlessEqual(4,da.getNbOfElems()); + self.assertEqual(4,da.getNbOfElems()); expected2=[1,4,6,8] - self.failUnlessEqual(expected2,list(da.getValues())); + self.assertEqual(expected2,list(da.getValues())); # pass @@ -125,26 +125,26 @@ class MEDCouplingBasicsTest2(unittest.TestCase): part1=[2,1,4] f2=f1[part1]; f2.zipCoords() - self.failUnlessEqual(3,f2.getNumberOfTuples()); - self.failUnlessEqual(2,f2.getNumberOfComponents()); + self.assertEqual(3,f2.getNumberOfTuples()); + self.assertEqual(2,f2.getNumberOfComponents()); expected1=[5.,105.,4.,104.,7.,107.] - for i in xrange(6): + for i in range(6): self.assertAlmostEqual(f2.getIJ(0,i),expected1[i],12); pass - self.failUnlessEqual(3,f2.getMesh().getNumberOfCells()); - self.failUnlessEqual(6,f2.getMesh().getNumberOfNodes()); - self.failUnlessEqual(2,f2.getMesh().getSpaceDimension()); - self.failUnlessEqual(2,f2.getMesh().getMeshDimension()); + self.assertEqual(3,f2.getMesh().getNumberOfCells()); + self.assertEqual(6,f2.getMesh().getNumberOfNodes()); + self.assertEqual(2,f2.getMesh().getSpaceDimension()); + self.assertEqual(2,f2.getMesh().getMeshDimension()); m2C=f2.getMesh(); - self.failUnlessEqual(13,m2C.getNodalConnectivityArrayLen()); + self.assertEqual(13,m2C.getNodalConnectivityArrayLen()); expected2=[0.2, -0.3, 0.7, -0.3, 0.2, 0.2, 0.7, 0.2, 0.2, 0.7, 0.7, 0.7] - for i in xrange(12): + for i in range(12): self.assertAlmostEqual(expected2[i],m2C.getCoords().getIJ(0,i),12); pass expected3=[3,2,3,1,3,0,2,1,4,4,5,3,2] - self.failUnlessEqual(expected3,list(m2C.getNodalConnectivity().getValues())); + self.assertEqual(expected3,list(m2C.getNodalConnectivity().getValues())); expected4=[0,4,8,13] - self.failUnlessEqual(expected4,list(m2C.getNodalConnectivityIndex().getValues())); + self.assertEqual(expected4,list(m2C.getNodalConnectivityIndex().getValues())); # Test with field on nodes. f1=MEDCouplingFieldDouble.New(ON_NODES,ONE_TIME); f1.setTime(2.3,5,6); @@ -155,68 +155,68 @@ class MEDCouplingBasicsTest2(unittest.TestCase): f1.setArray(array); part2=[1,2] f2=f1.buildSubPart(part2); - self.failUnlessEqual(4,f2.getNumberOfTuples()); - self.failUnlessEqual(2,f2.getNumberOfComponents()); + self.assertEqual(4,f2.getNumberOfTuples()); + self.assertEqual(2,f2.getNumberOfComponents()); expected5=[4.,104.,5.,105.,7.,107.,8.,108.] - for i in xrange(8): + for i in range(8): self.assertAlmostEqual(f2.getIJ(0,i),expected5[i],12); pass - self.failUnlessEqual(2,f2.getMesh().getNumberOfCells()); - self.failUnlessEqual(4,f2.getMesh().getNumberOfNodes()); - self.failUnlessEqual(2,f2.getMesh().getSpaceDimension()); - self.failUnlessEqual(2,f2.getMesh().getMeshDimension()); + self.assertEqual(2,f2.getMesh().getNumberOfCells()); + self.assertEqual(4,f2.getMesh().getNumberOfNodes()); + self.assertEqual(2,f2.getMesh().getSpaceDimension()); + self.assertEqual(2,f2.getMesh().getMeshDimension()); m2C=f2.getMesh(); - self.failUnlessEqual(8,m2C.getNodalConnectivityArrayLen()); - for i in xrange(8):#8 is not an error + self.assertEqual(8,m2C.getNodalConnectivityArrayLen()); + for i in range(8):#8 is not an error self.assertAlmostEqual(expected2[i],m2C.getCoords().getIJ(0,i),12); pass - self.failUnlessEqual(expected3[:4],list(m2C.getNodalConnectivity().getValues())[4:]); - self.failUnlessEqual(expected3[4:8],list(m2C.getNodalConnectivity().getValues())[:4]); - self.failUnlessEqual(expected4[:3],list(m2C.getNodalConnectivityIndex().getValues())); + self.assertEqual(expected3[:4],list(m2C.getNodalConnectivity().getValues())[4:]); + self.assertEqual(expected3[4:8],list(m2C.getNodalConnectivity().getValues())[:4]); + self.assertEqual(expected4[:3],list(m2C.getNodalConnectivityIndex().getValues())); #idem previous because nodes of cell#4 are not fully present in part3 part3=[1,2] arrr=DataArrayInt.New(); arrr.setValues(part3,2,1); f2=f1.buildSubPart(arrr); - self.failUnlessEqual(4,f2.getNumberOfTuples()); - self.failUnlessEqual(2,f2.getNumberOfComponents()); - for i in xrange(8): + self.assertEqual(4,f2.getNumberOfTuples()); + self.assertEqual(2,f2.getNumberOfComponents()); + for i in range(8): self.assertAlmostEqual(f2.getIJ(0,i),expected5[i],12); pass - self.failUnlessEqual(2,f2.getMesh().getNumberOfCells()); - self.failUnlessEqual(4,f2.getMesh().getNumberOfNodes()); - self.failUnlessEqual(2,f2.getMesh().getSpaceDimension()); - self.failUnlessEqual(2,f2.getMesh().getMeshDimension()); + self.assertEqual(2,f2.getMesh().getNumberOfCells()); + self.assertEqual(4,f2.getMesh().getNumberOfNodes()); + self.assertEqual(2,f2.getMesh().getSpaceDimension()); + self.assertEqual(2,f2.getMesh().getMeshDimension()); m2C=f2.getMesh(); - self.failUnlessEqual(8,m2C.getNodalConnectivityArrayLen()); - for i in xrange(8):#8 is not an error + self.assertEqual(8,m2C.getNodalConnectivityArrayLen()); + for i in range(8):#8 is not an error self.assertAlmostEqual(expected2[i],m2C.getCoords().getIJ(0,i),12); pass - self.failUnlessEqual(expected3[:4],list(m2C.getNodalConnectivity().getValues())[4:8]); - self.failUnlessEqual(expected3[4:8],list(m2C.getNodalConnectivity().getValues())[:4]); - self.failUnlessEqual(expected4[:3],list(m2C.getNodalConnectivityIndex().getValues())); + self.assertEqual(expected3[:4],list(m2C.getNodalConnectivity().getValues())[4:8]); + self.assertEqual(expected3[4:8],list(m2C.getNodalConnectivity().getValues())[:4]); + self.assertEqual(expected4[:3],list(m2C.getNodalConnectivityIndex().getValues())); # part4=[1,2,4] f2=f1.buildSubPart(part4); - self.failUnlessEqual(6,f2.getNumberOfTuples()); - self.failUnlessEqual(2,f2.getNumberOfComponents()); + self.assertEqual(6,f2.getNumberOfTuples()); + self.assertEqual(2,f2.getNumberOfComponents()); expected6=[4.,104.,5.,105.,7.,107.,8.,108.,10.,110.,11.,111.] - for i in xrange(12): + for i in range(12): self.assertAlmostEqual(f2.getIJ(0,i),expected6[i],12); pass - self.failUnlessEqual(3,f2.getMesh().getNumberOfCells()); - self.failUnlessEqual(6,f2.getMesh().getNumberOfNodes()); - self.failUnlessEqual(2,f2.getMesh().getSpaceDimension()); - self.failUnlessEqual(2,f2.getMesh().getMeshDimension()); + self.assertEqual(3,f2.getMesh().getNumberOfCells()); + self.assertEqual(6,f2.getMesh().getNumberOfNodes()); + self.assertEqual(2,f2.getMesh().getSpaceDimension()); + self.assertEqual(2,f2.getMesh().getMeshDimension()); m2C=f2.getMesh(); - self.failUnlessEqual(13,m2C.getNodalConnectivityArrayLen()); - for i in xrange(12): + self.assertEqual(13,m2C.getNodalConnectivityArrayLen()); + for i in range(12): self.assertAlmostEqual(expected2[i],m2C.getCoords().getIJ(0,i),12); pass - self.failUnlessEqual(expected3[0:4],list(m2C.getNodalConnectivity().getValues())[4:8]); - self.failUnlessEqual(expected3[4:8],list(m2C.getNodalConnectivity().getValues())[0:4]); - self.failUnlessEqual(expected3[8:13],list(m2C.getNodalConnectivity().getValues())[8:13]); - self.failUnlessEqual(expected4,list(m2C.getNodalConnectivityIndex().getValues())); + self.assertEqual(expected3[0:4],list(m2C.getNodalConnectivity().getValues())[4:8]); + self.assertEqual(expected3[4:8],list(m2C.getNodalConnectivity().getValues())[0:4]); + self.assertEqual(expected3[8:13],list(m2C.getNodalConnectivity().getValues())[8:13]); + self.assertEqual(expected4,list(m2C.getNodalConnectivityIndex().getValues())); pass def testDoublyContractedProduct1(self): @@ -233,7 +233,7 @@ class MEDCouplingBasicsTest2(unittest.TestCase): f2.checkConsistencyLight(); self.assertEqual(1,f2.getNumberOfComponents()); self.assertEqual(5,f2.getNumberOfTuples()); - for i in xrange(5): + for i in range(5): self.assertAlmostEqual(3906.56,f2.getIJ(i,0),9); pass # @@ -256,7 +256,7 @@ class MEDCouplingBasicsTest2(unittest.TestCase): self.assertEqual(CONST_ON_TIME_INTERVAL,f2.getTimeDiscretization()); self.assertEqual(1,f2.getNumberOfComponents()); self.assertEqual(5,f2.getNumberOfValues()); - for i in xrange(5): + for i in range(5): self.assertAlmostEqual(-2.42,f2.getIJ(i,0),13); pass #6 components multi arrays with end array not defined @@ -275,7 +275,7 @@ class MEDCouplingBasicsTest2(unittest.TestCase): self.assertEqual(LINEAR_TIME,f2.getTimeDiscretization()); self.assertEqual(1,f2.getArray().getNumberOfComponents()); self.assertEqual(9,f2.getNumberOfTuples()); - for i in xrange(9): + for i in range(9): self.assertAlmostEqual(137.335,f2.getIJ(i,0),10); pass #6 components multi arrays with end array defined @@ -298,7 +298,7 @@ class MEDCouplingBasicsTest2(unittest.TestCase): self.assertAlmostEqual(3.8,time2,12); self.assertEqual(7,it); self.assertEqual(3,order); - for i in xrange(9): + for i in range(9): self.assertAlmostEqual(137.335,f2.getIJ(i,0),10); self.assertAlmostEqual(1289.685,f2.getEndArray().getIJ(i,0),9); pass @@ -321,7 +321,7 @@ class MEDCouplingBasicsTest2(unittest.TestCase): self.assertAlmostEqual(7.8,time2,12); self.assertEqual(10,it); self.assertEqual(2,order); - for i in xrange(5): + for i in range(5): self.assertAlmostEqual(3.267,f2.getIJ(i,0),13); pass pass @@ -341,7 +341,7 @@ class MEDCouplingBasicsTest2(unittest.TestCase): self.assertEqual(3,f2.getNumberOfComponents()); self.assertEqual(5,f2.getNumberOfTuples()); expected1=[13.638813677891717,-4.502313844635971,-2.2364998332557486] - for i in xrange(5): + for i in range(5): self.assertAlmostEqual(expected1[0],f2.getIJ(i,0),13); self.assertAlmostEqual(expected1[1],f2.getIJ(i,1),13); self.assertAlmostEqual(expected1[2],f2.getIJ(i,2),13); @@ -366,7 +366,7 @@ class MEDCouplingBasicsTest2(unittest.TestCase): 0.7381111277307373, 0.06458838384003074, -0.6715804522117897,#eigenvect 1 -0.4012053603397987, 0.8423032781211455, -0.3599436712889738#eigenvect 2 ] - for i in xrange(5): + for i in range(5): self.assertAlmostEqual(expected1[0],f2.getIJ(i,0),13); self.assertAlmostEqual(expected1[1],f2.getIJ(i,1),13); self.assertAlmostEqual(expected1[2],f2.getIJ(i,2),13); @@ -395,7 +395,7 @@ class MEDCouplingBasicsTest2(unittest.TestCase): self.assertEqual(9,f2.getNumberOfComponents()); self.assertEqual(5,f2.getNumberOfTuples()); expected1=[-2.6538108356290113, 2.855831037649208, -1.1111111111111067, 3.461891643709813, -4.775022956841121, 2.2222222222222143, -1.1111111111111054, 2.222222222222214, -1.1111111111111072] - for i in xrange(5): + for i in range(5): self.assertAlmostEqual(expected1[0],f2.getIJ(i,0),13); self.assertAlmostEqual(expected1[1],f2.getIJ(i,1),13); self.assertAlmostEqual(expected1[2],f2.getIJ(i,2),13); @@ -418,7 +418,7 @@ class MEDCouplingBasicsTest2(unittest.TestCase): self.assertEqual(6,f2.getNumberOfComponents()); self.assertEqual(5,f2.getNumberOfTuples()); expected3=[-0.3617705098531818, -0.8678630828458127, -0.026843764174972983, 0.5539957431465833, 0.13133439560823013, -0.05301294502145887] - for i in xrange(5): + for i in range(5): self.assertAlmostEqual(expected3[0],f2.getIJ(i,0),13); self.assertAlmostEqual(expected3[1],f2.getIJ(i,1),13); self.assertAlmostEqual(expected3[2],f2.getIJ(i,2),13); @@ -438,7 +438,7 @@ class MEDCouplingBasicsTest2(unittest.TestCase): self.assertEqual(4,f2.getNumberOfComponents()); self.assertEqual(5,f2.getNumberOfTuples()); expected2=[-1.8595041322314059, 0.9504132231404963, 1.404958677685951, -0.49586776859504156] - for i in xrange(5): + for i in range(5): self.assertAlmostEqual(expected2[0],f2.getIJ(i,0),13); self.assertAlmostEqual(expected2[1],f2.getIJ(i,1),13); self.assertAlmostEqual(expected2[2],f2.getIJ(i,2),13); @@ -461,7 +461,7 @@ class MEDCouplingBasicsTest2(unittest.TestCase): f2.checkConsistencyLight(); self.assertEqual(1,f2.getNumberOfComponents()); self.assertEqual(5,f2.getNumberOfTuples()); - for i in xrange(5): + for i in range(5): self.assertAlmostEqual(15.9,f2.getIJ(i,0),13); pass # @@ -475,7 +475,7 @@ class MEDCouplingBasicsTest2(unittest.TestCase): f2.checkConsistencyLight(); self.assertEqual(1,f2.getNumberOfComponents()); self.assertEqual(5,f2.getNumberOfTuples()); - for i in xrange(5): + for i in range(5): self.assertAlmostEqual(25.8,f2.getIJ(i,0),13); pass # @@ -489,7 +489,7 @@ class MEDCouplingBasicsTest2(unittest.TestCase): f2.checkConsistencyLight(); self.assertEqual(1,f2.getNumberOfComponents()); self.assertEqual(5,f2.getNumberOfTuples()); - for i in xrange(5): + for i in range(5): self.assertAlmostEqual(5.7,f2.getIJ(i,0),13); pass # @@ -510,7 +510,7 @@ class MEDCouplingBasicsTest2(unittest.TestCase): self.assertEqual(6,f2.getNumberOfComponents()); self.assertEqual(5,f2.getNumberOfTuples()); expected1=[-1.1,0.,1.1,4.5,5.6,6.7] - for i in xrange(5): + for i in range(5): self.assertAlmostEqual(expected1[0],f2.getIJ(i,0),13); self.assertAlmostEqual(expected1[1],f2.getIJ(i,1),13); self.assertAlmostEqual(expected1[2],f2.getIJ(i,2),13); @@ -535,7 +535,7 @@ class MEDCouplingBasicsTest2(unittest.TestCase): f2.checkConsistencyLight(); self.assertEqual(1,f2.getNumberOfComponents()); self.assertEqual(5,f2.getNumberOfTuples()); - for i in xrange(5): + for i in range(5): self.assertAlmostEqual(8.3606219864313918,f2.getIJ(i,0),13); pass # @@ -555,14 +555,14 @@ class MEDCouplingBasicsTest2(unittest.TestCase): f2.checkConsistencyLight(); self.assertEqual(1,f2.getNumberOfComponents()); self.assertEqual(5,f2.getNumberOfTuples()); - for i in xrange(5): + for i in range(5): self.assertAlmostEqual(5.6,f2.getIJ(i,0),13); pass # d2,d2I=array.maxPerTupleWithCompoId() self.assertEqual(1,d2.getNumberOfComponents()); self.assertEqual(5,d2.getNumberOfTuples()); - for i in xrange(5): + for i in range(5): self.assertAlmostEqual(5.6,d2.getIJ(i,0),13); pass self.assertTrue(d2I.isEqual(DataArrayInt([4,3,2,0,1]))) @@ -583,7 +583,7 @@ class MEDCouplingBasicsTest2(unittest.TestCase): self.assertEqual(3,f1.getNumberOfComponents()); self.assertEqual(5,f1.getNumberOfTuples()); expected1=[1.2,2.3,3.4, 1.2,3.4,4.5, 3.4,4.5,5.6, 5.6,1.2,2.3, 4.5,5.6,1.2] - for i in xrange(15): + for i in range(15): self.assertAlmostEqual(expected1[i],f1.getIJ(0,i),13); pass f1.changeNbOfComponents(4,7.77); @@ -591,7 +591,7 @@ class MEDCouplingBasicsTest2(unittest.TestCase): self.assertEqual(4,f1.getNumberOfComponents()); self.assertEqual(5,f1.getNumberOfTuples()); expected2=[1.2,2.3,3.4,7.77, 1.2,3.4,4.5,7.77, 3.4,4.5,5.6,7.77, 5.6,1.2,2.3,7.77, 4.5,5.6,1.2,7.77] - for i in xrange(20): + for i in range(20): self.assertAlmostEqual(expected2[i],f1.getIJ(0,i),13); pass # @@ -611,7 +611,7 @@ class MEDCouplingBasicsTest2(unittest.TestCase): f1.checkConsistencyLight(); self.assertEqual(5,f1.getNumberOfComponents()); self.assertEqual(5,f1.getNumberOfTuples()); - for i in xrange(5): + for i in range(5): self.assertAlmostEqual(arr1[0],f1.getIJ(i,0),13); self.assertAlmostEqual(arr1[1],f1.getIJ(i,1),13); self.assertAlmostEqual(arr1[2],f1.getIJ(i,2),13); @@ -623,7 +623,7 @@ class MEDCouplingBasicsTest2(unittest.TestCase): f1.checkConsistencyLight(); self.assertEqual(5,f1.getNumberOfComponents()); self.assertEqual(5,f1.getNumberOfTuples()); - for i in xrange(5): + for i in range(5): self.assertAlmostEqual(arr1[4],f1.getIJ(i,0),13); self.assertAlmostEqual(arr1[3],f1.getIJ(i,1),13); self.assertAlmostEqual(arr1[2],f1.getIJ(i,2),13); @@ -726,7 +726,7 @@ class MEDCouplingBasicsTest2(unittest.TestCase): self.assertEqual(5,f1.getNumberOfTuples()); self.assertEqual(1,f1.getNumberOfComponents()); expected1=[1.,1.4142135623730951, 1.4142135623730951,1.,1.] - for i in xrange(5): + for i in range(5): self.assertAlmostEqual(expected1[i],f1.getIJ(i,0),14); pass # @@ -736,7 +736,7 @@ class MEDCouplingBasicsTest2(unittest.TestCase): self.assertEqual(5,f1.getNumberOfTuples()); self.assertEqual(1,f1.getNumberOfComponents()); expected2=[1.4142135623730951, 1.7320508075688772, 1.7320508075688772, 1.4142135623730951, 1.4142135623730951] - for i in xrange(5): + for i in range(5): self.assertAlmostEqual(expected2[i],f1.getIJ(i,0),14); pass pass @@ -757,7 +757,7 @@ class MEDCouplingBasicsTest2(unittest.TestCase): values1=[-0.1,0.23333333333333336,0.56666666666666665,0.4,0.9] tmp=f1.getArray().getValues(); self.assertEqual(len(values1),len(tmp)) - for i in xrange(len(values1)): + for i in range(len(values1)): self.assertTrue(abs(values1[i]-tmp[i])<1.e-12); pass # @@ -773,7 +773,7 @@ class MEDCouplingBasicsTest2(unittest.TestCase): values2=[-0.9,0.1,1.1,-0.4,0.6,1.6,0.1,1.1,2.1] tmp=f1.getArray().getValues(); self.assertEqual(len(values2),len(tmp)) - for i in xrange(len(values2)): + for i in range(len(values2)): self.assertTrue(abs(values2[i]-tmp[i])<1.e-12); pass f1=MEDCouplingFieldDouble.New(ON_NODES,LINEAR_TIME); @@ -788,12 +788,12 @@ class MEDCouplingBasicsTest2(unittest.TestCase): tmp=f1.getArray().getValues(); values2Bis=[-0.9,0.1,1.1,-0.4,0.6,1.6,0.1,1.1,2.1] self.assertEqual(len(values2Bis),len(tmp)) - for i in xrange(len(values2Bis)): + for i in range(len(values2Bis)): self.assertTrue(abs(values2Bis[i]-tmp[i])<1.e-12); pass tmp=f1.getEndArray().getValues(); self.assertEqual(len(values2Bis),len(tmp)) - for i in xrange(len(values2Bis)): + for i in range(len(values2Bis)): self.assertTrue(abs(values2Bis[i]-tmp[i])<1.e-12); pass # @@ -808,7 +808,7 @@ class MEDCouplingBasicsTest2(unittest.TestCase): values3=[-0.6,-1.2,-0.1,-0.2,0.4,0.8,-0.1,-0.2,0.4,0.8,0.9,1.8,0.4,0.8,0.9,1.8,1.4,2.8] tmp=f1.getArray().getValues(); self.assertEqual(len(values3),len(tmp)) - for i in xrange(len(values3)): + for i in range(len(values3)): self.assertTrue(abs(values3[i]-tmp[i])<1.e-12); pass values4=f1.accumulate(); @@ -832,14 +832,14 @@ class MEDCouplingBasicsTest2(unittest.TestCase): f1.checkConsistencyLight(); self.assertEqual(1,f1.getNumberOfComponents()); self.assertEqual(5,f1.getNumberOfTuples()); - for i in xrange(5): + for i in range(5): self.assertAlmostEqual(0.07,f1.getIJ(i,0),16); pass f1.assign(0.09); f1.checkConsistencyLight(); self.assertEqual(1,f1.getNumberOfComponents()); self.assertEqual(5,f1.getNumberOfTuples()); - for i in xrange(5): + for i in range(5): self.assertAlmostEqual(0.09,f1.getIJ(i,0),16); pass # @@ -850,12 +850,12 @@ class MEDCouplingBasicsTest2(unittest.TestCase): f1.checkConsistencyLight(); self.assertEqual(1,f1.getNumberOfComponents()); self.assertEqual(9,f1.getNumberOfTuples()); - for i in xrange(9): + for i in range(9): self.assertAlmostEqual(0.08,f1.getIJ(i,0),16); pass self.assertEqual(1,f1.getEndArray().getNumberOfComponents()); self.assertEqual(9,f1.getEndArray().getNumberOfTuples()); - for i in xrange(9): + for i in range(9): self.assertAlmostEqual(0.08,f1.getEndArray().getIJ(i,0),16); pass pass @@ -940,20 +940,20 @@ class MEDCouplingBasicsTest2(unittest.TestCase): self.assertEqual(3,f.getNumberOfTuples()); self.assertEqual(1,f.getNumberOfComponents()); expected1=[1.1,2.4,4.4] - for i in xrange(3): + for i in range(3): self.assertAlmostEqual(expected1[i],f.getIJ(i,0),12); pass coords=m.getCoordinatesAndOwner(); self.assertEqual(4,coords.getNumberOfTuples()); self.assertEqual(1,coords.getNumberOfComponents()); - for i in xrange(4): + for i in range(4): self.assertAlmostEqual(discX[i],coords.getIJ(i,0),12); pass coords=m.computeCellCenterOfMass(); self.assertEqual(3,coords.getNumberOfTuples()); self.assertEqual(1,coords.getNumberOfComponents()); expected1_3=[2.85,4.6,8.] - for i in xrange(3): + for i in range(3): self.assertAlmostEqual(expected1_3[i],coords.getIJ(i,0),12); pass # @@ -968,21 +968,21 @@ class MEDCouplingBasicsTest2(unittest.TestCase): self.assertEqual(6,f.getNumberOfTuples()); self.assertEqual(1,f.getNumberOfComponents()); expected2=[12.21,26.64,48.84,24.64,53.76,98.56] - for i in xrange(6): + for i in range(6): self.assertAlmostEqual(expected2[i],f.getIJ(i,0),12); pass coords=m.getCoordinatesAndOwner(); self.assertEqual(12,coords.getNumberOfTuples()); self.assertEqual(2,coords.getNumberOfComponents()); expected2_2=[2.3,12.3,3.4,12.3,5.8,12.3,10.2,12.3, 2.3,23.4,3.4,23.4,5.8,23.4,10.2,23.4, 2.3,45.8,3.4,45.8,5.8,45.8,10.2,45.8] - for i in xrange(24): + for i in range(24): self.assertAlmostEqual(expected2_2[i],coords.getIJ(0,i),12); pass coords=m.computeCellCenterOfMass(); self.assertEqual(6,coords.getNumberOfTuples()); self.assertEqual(2,coords.getNumberOfComponents()); expected2_3=[2.85,17.85,4.6,17.85,8.,17.85, 2.85,34.6,4.6,34.6,8.,34.6] - for i in xrange(12): + for i in range(12): self.assertAlmostEqual(expected2_3[i],coords.getIJ(0,i),12); pass # @@ -997,7 +997,7 @@ class MEDCouplingBasicsTest2(unittest.TestCase): self.assertEqual(24,f.getNumberOfTuples()); self.assertEqual(1,f.getNumberOfComponents()); expected3=[23.199, 50.616, 92.796, 46.816, 102.144, 187.264, 0.6105, 1.332, 2.442, 1.232, 2.688, 4.928, 10.7448, 23.4432, 42.9792, 21.6832, 47.3088, 86.7328, 6.5934, 14.3856, 26.3736, 13.3056, 29.0304, 53.2224] - for i in xrange(24): + for i in range(24): self.assertAlmostEqual(expected3[i],f.getIJ(i,0),12); pass coords=m.getCoordinatesAndOwner(); @@ -1009,7 +1009,7 @@ class MEDCouplingBasicsTest2(unittest.TestCase): 2.3,12.3,1.25, 3.4,12.3,1.25, 5.8,12.3,1.25, 10.2,12.3,1.25, 2.3,23.4,1.25, 3.4,23.4,1.25, 5.8,23.4,1.25, 10.2,23.4,1.25, 2.3,45.8,1.25, 3.4,45.8,1.25, 5.8,45.8,1.25, 10.2,45.8,1.25, 2.3,12.3,2.13, 3.4,12.3,2.13, 5.8,12.3,2.13, 10.2,12.3,2.13, 2.3,23.4,2.13, 3.4,23.4,2.13, 5.8,23.4,2.13, 10.2,23.4,2.13, 2.3,45.8,2.13, 3.4,45.8,2.13, 5.8,45.8,2.13, 10.2,45.8,2.13, 2.3,12.3,2.67, 3.4,12.3,2.67, 5.8,12.3,2.67, 10.2,12.3,2.67, 2.3,23.4,2.67, 3.4,23.4,2.67, 5.8,23.4,2.67, 10.2,23.4,2.67, 2.3,45.8,2.67, 3.4,45.8,2.67, 5.8,45.8,2.67, 10.2,45.8,2.67]; - for i in xrange(180): + for i in range(180): self.assertAlmostEqual(expected3_2[i],coords.getIJ(0,i),12); pass coords=m.computeCellCenterOfMass(); @@ -1020,7 +1020,7 @@ class MEDCouplingBasicsTest2(unittest.TestCase): 2.85,17.85,1.225,4.6,17.85,1.225,8.,17.85,1.225, 2.85,34.6,1.225,4.6,34.6,1.225,8.,34.6,1.225, 2.85,17.85,1.69,4.6,17.85,1.69,8.,17.85,1.69, 2.85,34.6,1.69,4.6,34.6,1.69,8.,34.6,1.69, 2.85,17.85,2.4,4.6,17.85,2.4,8.,17.85,2.4, 2.85,34.6,2.4,4.6,34.6,2.4,8.,34.6,2.4]; - for i in xrange(72): + for i in range(72): self.assertAlmostEqual(expected3_3[i],coords.getIJ(0,i),12); pass pass @@ -1034,18 +1034,18 @@ class MEDCouplingBasicsTest2(unittest.TestCase): self.assertEqual(18,f.getNumberOfTuples()); self.assertEqual(2,f.getNumberOfComponents()); expected1=[-0.6, -0.6, 0.4, 0.4, 1.4, 1.4, -0.6, -0.6, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 1.4, 1.4, -0.6, -0.6, 0.4, 0.4, 1.4, 1.4, -0.6, -0.6, 1.4, 1.4, -0.6, -0.6, 0.4, 0.4, 1.4, 1.4, 0.4, 0.4] - for i in xrange(36): + for i in range(36): self.assertAlmostEqual(expected1[i],f.getIJ(0,i),12); pass self.assertTrue(f.zipCoords()); f.checkConsistencyLight(); expected2=[-0.6, -0.6, 1.4, 1.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 1.4, 1.4, -0.6, -0.6, 0.4, 0.4, 1.4, 1.4, 1.4, 1.4, -0.6, -0.6, 0.4, 0.4, 1.4, 1.4, 0.4, 0.4] - for i in xrange(30): + for i in range(30): self.assertAlmostEqual(expected2[i],f.getIJ(0,i),12); pass self.assertTrue(not f.zipCoords()); f.checkConsistencyLight(); - for i in xrange(30): + for i in range(30): self.assertAlmostEqual(expected2[i],f.getIJ(0,i),12); pass self.assertTrue(f.getArray().getInfoOnComponent(0)=="titi"); @@ -1073,7 +1073,7 @@ class MEDCouplingBasicsTest2(unittest.TestCase): expected1=[-0.05, -0.05, 0.3666666666666667, 0.3666666666666667, 0.53333333333333321, 0.53333333333333321, -0.05, -0.05, 0.45, 0.45, 0.53333333333333321, 0.53333333333333321, -0.05, -0.05, 0.45, 0.45, 0.36666666666666659, 0.36666666666666659, 0.033333333333333326, 0.033333333333333326]; - for i in xrange(20): + for i in range(20): self.assertAlmostEqual(expected1[i],f.getIJ(0,i),12); pass f.getArray().setInfoOnComponent(0,"titi"); @@ -1084,7 +1084,7 @@ class MEDCouplingBasicsTest2(unittest.TestCase): -0.05, -0.05, 0.45, 0.45, 0.36666666666666659, 0.36666666666666659, 0.033333333333333326, 0.033333333333333326]; self.assertEqual(7,f.getNumberOfTuples()); self.assertEqual(2,f.getNumberOfComponents()); - for i in xrange(14): + for i in range(14): self.assertAlmostEqual(expected2[i],f.getIJ(0,i),12); pass self.assertTrue(f.getArray().getInfoOnComponent(0)=="titi"); @@ -1095,13 +1095,13 @@ class MEDCouplingBasicsTest2(unittest.TestCase): -0.3, -0.3, 0.2, 0.2, 0.7, 0.7]; self.assertEqual(9,f2.getNumberOfTuples()); self.assertEqual(2,f2.getNumberOfComponents()); - for i in xrange(18): + for i in range(18): self.assertAlmostEqual(expected3[i],f2.getIJ(0,i),12); pass self.assertTrue(f2.zipConnectivity(0)); self.assertEqual(9,f2.getNumberOfTuples()); self.assertEqual(2,f2.getNumberOfComponents()); - for i in xrange(18): + for i in range(18): self.assertAlmostEqual(expected3[i],f2.getIJ(0,i),12); pass pass @@ -1120,7 +1120,7 @@ class MEDCouplingBasicsTest2(unittest.TestCase): self.assertTrue(b.getInfoOnComponent(0)=="toto"); self.assertTrue(b.getInfoOnComponent(1)=="tata"); expected1=[3.1, 13.1, 2.1, 12.1, 7.1, 17.1, 1.1, 11.1, 6.1, 16.1, 5.1, 15.1, 4.1, 14.1] - for i in xrange(14): + for i in range(14): self.assertAlmostEqual(expected1[i],b.getIJ(0,i),14); pass # @@ -1135,7 +1135,7 @@ class MEDCouplingBasicsTest2(unittest.TestCase): self.assertTrue(d.getInfoOnComponent(0)=="toto"); self.assertTrue(d.getInfoOnComponent(1)=="tata"); expected2=[3, 13, 2, 12, 7, 17, 1, 11, 6, 16, 5, 15, 4, 14] - for i in xrange(14): + for i in range(14): self.assertEqual(expected2[i],d.getIJ(0,i)); pass pass @@ -1154,7 +1154,7 @@ class MEDCouplingBasicsTest2(unittest.TestCase): self.assertTrue(b.getInfoOnComponent(0)=="toto"); self.assertTrue(b.getInfoOnComponent(1)=="tata"); expected1=[5.1,15.1,3.1,13.1,1.1,11.1,7.1,17.1,6.1,16.1] - for i in xrange(10): + for i in range(10): self.assertAlmostEqual(expected1[i],b.getIJ(0,i),14); pass # @@ -1169,7 +1169,7 @@ class MEDCouplingBasicsTest2(unittest.TestCase): self.assertTrue(d.getInfoOnComponent(0)=="toto"); self.assertTrue(d.getInfoOnComponent(1)=="tata"); expected2=[5,15,3,13,1,11,7,17,6,16] - for i in xrange(10): + for i in range(10): self.assertEqual(expected2[i],d.getIJ(0,i)); pass pass @@ -1184,7 +1184,7 @@ class MEDCouplingBasicsTest2(unittest.TestCase): self.assertEqual(7,a.getNumberOfTuples()); self.assertEqual(2,a.getNumberOfComponents()); expected1=[3.1, 13.1, 2.1, 12.1, 7.1, 17.1, 1.1, 11.1, 6.1, 16.1, 5.1, 15.1, 4.1, 14.1] - for i in xrange(14): + for i in range(14): self.assertAlmostEqual(expected1[i],a.getIJ(0,i),14); pass # @@ -1195,7 +1195,7 @@ class MEDCouplingBasicsTest2(unittest.TestCase): self.assertEqual(7,c.getNumberOfTuples()); self.assertEqual(2,c.getNumberOfComponents()); expected2=[3, 13, 2, 12, 7, 17, 1, 11, 6, 16, 5, 15, 4, 14] - for i in xrange(14): + for i in range(14): self.assertEqual(expected2[i],c.getIJ(0,i)); pass pass @@ -1214,7 +1214,7 @@ class MEDCouplingBasicsTest2(unittest.TestCase): self.assertTrue(b.getInfoOnComponent(0)=="toto"); self.assertTrue(b.getInfoOnComponent(1)=="tata"); expected1=[4.1, 14.1, 2.1, 12.1, 1.1, 11.1, 7.1, 17.1, 6.1, 16.1, 5.1, 15.1, 3.1, 13.1] - for i in xrange(14): + for i in range(14): self.assertAlmostEqual(expected1[i],b.getIJ(0,i),14); pass # @@ -1229,7 +1229,7 @@ class MEDCouplingBasicsTest2(unittest.TestCase): self.assertTrue(d.getInfoOnComponent(0)=="toto"); self.assertTrue(d.getInfoOnComponent(1)=="tata"); expected2=[4, 14, 2, 12, 1, 11, 7, 17, 6, 16, 5, 15, 3, 13] - for i in xrange(14): + for i in range(14): self.assertEqual(expected2[i],d.getIJ(0,i)); pass pass @@ -1244,7 +1244,7 @@ class MEDCouplingBasicsTest2(unittest.TestCase): self.assertEqual(7,a.getNumberOfTuples()); self.assertEqual(2,a.getNumberOfComponents()); expected1=[4.1, 14.1, 2.1, 12.1, 1.1, 11.1, 7.1, 17.1, 6.1, 16.1, 5.1, 15.1, 3.1, 13.1] - for i in xrange(14): + for i in range(14): self.assertAlmostEqual(expected1[i],a.getIJ(0,i),14); pass # @@ -1255,7 +1255,7 @@ class MEDCouplingBasicsTest2(unittest.TestCase): self.assertEqual(7,c.getNumberOfTuples()); self.assertEqual(2,c.getNumberOfComponents()); expected2=[4, 14, 2, 12, 1, 11, 7, 17, 6, 16, 5, 15, 3, 13] - for i in xrange(14): + for i in range(14): self.assertEqual(expected2[i],c.getIJ(0,i)); pass pass @@ -1274,7 +1274,7 @@ class MEDCouplingBasicsTest2(unittest.TestCase): self.assertTrue(b.getInfoOnComponent(0)=="toto"); self.assertTrue(b.getInfoOnComponent(1)=="tata"); expected1=[5.1,15.1,3.1,13.1,1.1,11.1,7.1,17.1,6.1,16.1] - for i in xrange(10): + for i in range(10): self.assertAlmostEqual(expected1[i],b.getIJ(0,i),14); pass # @@ -1289,7 +1289,7 @@ class MEDCouplingBasicsTest2(unittest.TestCase): self.assertTrue(d.getInfoOnComponent(0)=="toto"); self.assertTrue(d.getInfoOnComponent(1)=="tata"); expected2=[5,15,3,13,1,11,7,17,6,16] - for i in xrange(10): + for i in range(10): self.assertEqual(expected2[i],d.getIJ(0,i)); pass pass @@ -1306,7 +1306,7 @@ class MEDCouplingBasicsTest2(unittest.TestCase): self.assertEqual(3,ws.getNumberOfTuples()); self.assertEqual(1,ws.getNumberOfComponents()); expected1=[1,4,8] - for i in xrange(3): + for i in range(3): self.assertEqual(expected1[i],ws.getIJ(i,0)); pass a=DataArrayDouble.New(); @@ -1319,7 +1319,7 @@ class MEDCouplingBasicsTest2(unittest.TestCase): self.assertAlmostEqual(-4.56,m,12); self.assertEqual(3,ws.getNumberOfTuples()); self.assertEqual(1,ws.getNumberOfComponents()); - for i in xrange(3): + for i in range(3): self.assertEqual(expected1[i],ws.getIJ(i,0)); pass pass @@ -1342,7 +1342,7 @@ class MEDCouplingBasicsTest2(unittest.TestCase): self.assertEqual(4,ws.getNumberOfTuples()); self.assertEqual(1,ws.getNumberOfComponents()); expected1=[0,3,7,17] - for i in xrange(4): + for i in range(4): self.assertEqual(expected1[i],ws.getIJ(i,0)); pass # @@ -1355,7 +1355,7 @@ class MEDCouplingBasicsTest2(unittest.TestCase): self.assertAlmostEqual(-8.71,m,12); self.assertEqual(4,ws.getNumberOfTuples()); self.assertEqual(1,ws.getNumberOfComponents()); - for i in xrange(4): + for i in range(4): self.assertEqual(expected1[i],ws.getIJ(i,0)); pass pass @@ -1384,7 +1384,7 @@ class MEDCouplingBasicsTest2(unittest.TestCase): self.assertEqual(f2.getNumberOfTuples(),3); self.assertEqual(1,m2.getMeshDimension()); self.assertEqual(1,m2.getSpaceDimension()); - for i in xrange(3): + for i in range(3): self.assertAlmostEqual(f1.getIJ(i,0),f2.getIJ(i,0),10); pass da=DataArrayDouble.New(); @@ -1399,7 +1399,7 @@ class MEDCouplingBasicsTest2(unittest.TestCase): self.assertEqual(f2.getNumberOfTuples(),6); self.assertEqual(2,m2.getMeshDimension()); self.assertEqual(2,m2.getSpaceDimension()); - for i in xrange(6): + for i in range(6): self.assertAlmostEqual(f1.getIJ(i,0),f2.getIJ(i,0),10); pass # @@ -1414,7 +1414,7 @@ class MEDCouplingBasicsTest2(unittest.TestCase): self.assertEqual(f2.getNumberOfTuples(),24); self.assertEqual(3,m2.getMeshDimension()); self.assertEqual(3,m2.getSpaceDimension()); - for i in xrange(24): + for i in range(24): self.assertAlmostEqual(f1.getIJ(i,0),f2.getIJ(i,0),10); pass # @@ -1439,11 +1439,11 @@ class MEDCouplingBasicsTest2(unittest.TestCase): self.assertEqual(6,da2.getNumberOfTuples()); self.assertEqual(1,da2.getNumberOfComponents()); expected1=[1,3,0,5,2,4] - for i in xrange(6): + for i in range(6): self.assertEqual(expected1[i],da2.getIJ(i,0)); pass da3=da2.invertArrayN2O2O2N(6); - for i in xrange(6): + for i in range(6): self.assertEqual(arr1[i],da3.getIJ(i,0)); pass # @@ -1454,11 +1454,11 @@ class MEDCouplingBasicsTest2(unittest.TestCase): self.assertEqual(6,da2.getNumberOfTuples()); self.assertEqual(1,da2.getNumberOfComponents()); expected2=[5,7,8,0,3,2] - for i in xrange(6): + for i in range(6): self.assertEqual(expected2[i],da2.getIJ(i,0)); pass da3=da2.invertArrayN2O2O2N(10); - for i in xrange(10): + for i in range(10): self.assertEqual(arr2[i],da3.getIJ(i,0)); pass pass @@ -1469,7 +1469,7 @@ class MEDCouplingBasicsTest2(unittest.TestCase): a1.setValues(arr1,5,4); expp=[21.,22.,23.,24.] self.assertEqual(4,len(a1.getTuple(2))); - for i in xrange(4): + for i in range(4): self.assertAlmostEqual(expp[i],a1.getTuple(2)[i],12) pass a1.setInfoOnComponent(0,"aaaa"); @@ -1487,7 +1487,7 @@ class MEDCouplingBasicsTest2(unittest.TestCase): self.assertTrue(a2.getInfoOnComponent(4)=="aaaa"); self.assertTrue(a2.getInfoOnComponent(5)=="aaaa"); expected1=[2.,3.,2.,3.,1.,1., 12.,13.,12.,13.,11.,11., 22.,23.,22.,23.,21.,21., 32.,33.,32.,33.,31.,31., 42.,43.,42.,43.,41.,41.] - for i in xrange(30): + for i in range(30): self.assertAlmostEqual(expected1[i],a2.getIJ(0,i),14); pass a3=a1.convertToIntArr(); @@ -1501,7 +1501,7 @@ class MEDCouplingBasicsTest2(unittest.TestCase): self.assertTrue(a4.getInfoOnComponent(3)=="cccc"); self.assertTrue(a4.getInfoOnComponent(4)=="aaaa"); self.assertTrue(a4.getInfoOnComponent(5)=="aaaa"); - for i in xrange(30): + for i in range(30): self.assertEqual(int(expected1[i]),a4.getIJ(0,i)); pass # setSelectedComponents @@ -1520,7 +1520,7 @@ class MEDCouplingBasicsTest2(unittest.TestCase): self.assertTrue(a2.getInfoOnComponent(4)=="aaaa"); self.assertTrue(a2.getInfoOnComponent(5)=="aaaa"); expected2=[2.,4.,3.,3.,1.,1., 12.,14.,13.,13.,11.,11., 22.,24.,23.,23.,21.,21., 32.,34.,33.,33.,31.,31., 42.,44.,43.,43.,41.,41.] - for i in xrange(30): + for i in range(30): self.assertAlmostEqual(expected2[i],a2.getIJ(0,i),14); pass a6=a5.convertToIntArr(); @@ -1535,7 +1535,7 @@ class MEDCouplingBasicsTest2(unittest.TestCase): self.assertTrue(a4.getInfoOnComponent(3)=="cccc"); self.assertTrue(a4.getInfoOnComponent(4)=="aaaa"); self.assertTrue(a4.getInfoOnComponent(5)=="aaaa"); - for i in xrange(30): + for i in range(30): self.assertEqual(int(expected2[i]),a4.getIJ(0,i)); pass # test of throw @@ -1583,7 +1583,7 @@ class MEDCouplingBasicsTest2(unittest.TestCase): self.assertTrue(f2.getArray().getInfoOnComponent(4)=="aaaa"); self.assertTrue(f2.getArray().getInfoOnComponent(5)=="aaaa"); expected1=[2.,3.,2.,3.,1.,1., 12.,13.,12.,13.,11.,11., 22.,23.,22.,23.,21.,21., 32.,33.,32.,33.,31.,31., 42.,43.,42.,43.,41.,41.] - for i in xrange(30): + for i in range(30): self.assertAlmostEqual(expected1[i],f2.getIJ(0,i),14); pass #setSelectedComponents @@ -1609,7 +1609,7 @@ class MEDCouplingBasicsTest2(unittest.TestCase): self.assertTrue(f2.getArray().getInfoOnComponent(4)=="aaaa"); self.assertTrue(f2.getArray().getInfoOnComponent(5)=="aaaa"); expected2=[2.,4.,3.,3.,1.,1., 12.,14.,13.,13.,11.,11., 22.,24.,23.,23.,21.,21., 32.,34.,33.,33.,31.,31., 42.,44.,43.,43.,41.,41.] - for i in xrange(30): + for i in range(30): self.assertAlmostEqual(expected2[i],f2.getIJ(0,i),14); pass # @@ -1831,7 +1831,7 @@ class MEDCouplingBasicsTest2(unittest.TestCase): da4=da3.fromNoInterlace(); self.assertEqual(5,da4.getNumberOfTuples()); self.assertEqual(3,da4.getNumberOfComponents());# it's not a bug. Avoid to have 1 million components ! - for i in xrange(15): + for i in range(15): self.assertAlmostEqual(expected1[i],da4.getIJ(0,i),14); pass pass @@ -1849,7 +1849,7 @@ class MEDCouplingBasicsTest2(unittest.TestCase): da4=da3.toNoInterlace(); self.assertEqual(5,da4.getNumberOfTuples()); self.assertEqual(3,da4.getNumberOfComponents());# it's not a bug. Avoid to have 1 million components ! - for i in xrange(15): + for i in range(15): self.assertAlmostEqual(expected1[i],da4.getIJ(0,i),14); pass pass @@ -1890,7 +1890,7 @@ class MEDCouplingBasicsTest2(unittest.TestCase): da.setValues(tab1,2,2); da2=da.fromPolarToCart(); expected1=[1.9601331556824833,0.39733866159012243, 1.9121054682112213,1.6105442180942275] - for i in xrange(4): + for i in range(4): self.assertAlmostEqual(expected1[i],da2.getIJ(0,i),13); pass pass @@ -1901,7 +1901,7 @@ class MEDCouplingBasicsTest2(unittest.TestCase): da.setValues(tab1,2,3); da2=da.fromCylToCart(); expected1=[1.9601331556824833,0.39733866159012243,4., 1.9121054682112213,1.6105442180942275,9.] - for i in xrange(6): + for i in range(6): self.assertAlmostEqual(expected1[i],da2.getIJ(0,i),13); pass pass @@ -1912,7 +1912,7 @@ class MEDCouplingBasicsTest2(unittest.TestCase): da.setValues(tab1,2,3); da2=da.fromSpherToCart(); expected1=[0.37959212195737485,0.11742160338765303,1.9601331556824833, 1.1220769624465328,1.1553337045129035,1.9121054682112213] - for i in xrange(6): + for i in range(6): self.assertAlmostEqual(expected1[i],da2.getIJ(0,i),13); pass pass @@ -1982,7 +1982,7 @@ class MEDCouplingBasicsTest2(unittest.TestCase): self.assertEqual(NORM_PYRA5,mesh.getTypeOfCell(1)); self.assertEqual(NORM_TETRA4,mesh.getTypeOfCell(2)); self.assertEqual(NORM_PYRA5,mesh.getTypeOfCell(3)); - for i in xrange(4): + for i in range(4): self.assertAlmostEqual(f1.getArray().getIJ(0,i),f2.getArray().getIJ(0,i),5); pass pass @@ -2131,14 +2131,14 @@ class MEDCouplingBasicsTest2(unittest.TestCase): self.assertEqual(24,i.getNumberOfCellsWithType(NORM_QUAD4)); expected1=[0.25,0.75,2.0625] j=i.getMeasureField(True); - for ii in xrange(12): - for k in xrange(3): + for ii in range(12): + for k in range(3): self.assertAlmostEqual(expected1[k],j.getIJ(0,ii*3+k),10); pass pass expected2=[0.62200846792814113, 0.16666666666681595, 1.4513530918323276, 0.38888888888923495, 2.6293994326053212, 0.7045454545460802, 0.45534180126145435, 0.45534180126150181, 1.0624642029433926, 1.0624642029435025, 1.9248539780597826, 1.9248539780599816, 0.16666666666661334, 0.62200846792815856, 0.38888888888876294, 1.4513530918323678, 0.70454545454522521, 2.629399432605394, -0.16666666666674007, 0.62200846792812436, -0.38888888888906142, 1.4513530918322881, -0.70454545454576778, 2.6293994326052488, -0.45534180126154766, 0.45534180126140844, -1.0624642029436118, 1.0624642029432834, -1.9248539780601803, 1.9248539780595841, -0.62200846792817499, 0.1666666666665495, -1.451353091832408, 0.388888888888613, -2.6293994326054668, 0.70454545454495332, -0.62200846792810593, -0.16666666666680507, -1.451353091832247, -0.38888888888921297, -2.6293994326051746, -0.70454545454604123, -0.45534180126135926, -0.45534180126159562, -1.0624642029431723, -1.0624642029437235, -1.9248539780593836, -1.9248539780603811, -0.1666666666664828, -0.62200846792819242, -0.38888888888846079, -1.4513530918324489, -0.70454545454467987, -2.6293994326055397, 0.16666666666687083, -0.62200846792808862, 0.38888888888936374, -1.4513530918322073, 0.70454545454631357, -2.6293994326051022, 0.45534180126164348, -0.45534180126131207, 1.0624642029438327, -1.0624642029430627, 1.9248539780605791, -1.9248539780591853, 0.62200846792821063, -0.16666666666641802, 1.4513530918324888, -0.38888888888831086, 2.6293994326056125, -0.70454545454440853] m=i.computeCellCenterOfMass(); - for i in xrange(72): + for i in range(72): self.assertAlmostEqual(expected2[i],m.getIJ(0,i),10); pass # @@ -2170,12 +2170,12 @@ class MEDCouplingBasicsTest2(unittest.TestCase): g.checkConsistencyLight(); expected1=[ 0.4330127018922193, 0.4330127018922193, 0.649519052838329, 1.2990381056766578, 1.299038105676658, 1.948557158514987, 2.1650635094610955, 2.1650635094610964, 3.2475952641916446, 3.031088913245533, 3.0310889132455352, 4.546633369868303 ] f1=g.getMeasureField(True); - for i in xrange(12): + for i in range(12): self.assertAlmostEqual(expected1[i],f1.getIJ(0,i),12); pass expected2=[0.625, 0.21650635094610962, 1.625, 0.21650635094610959, 2.8750000000000004, 0.21650635094610965, 1.1250000000000002, 1.0825317547305482, 2.125, 1.0825317547305482, 3.3750000000000004, 1.0825317547305484, 2.125, 2.8145825622994254, 3.125, 2.8145825622994254, 4.375, 2.8145825622994254, 3.6250000000000009, 5.4126587736527414, 4.625, 5.4126587736527414, 5.875, 5.4126587736527414] f2=g.computeCellCenterOfMass(); - for i in xrange(24): + for i in range(24): self.assertAlmostEqual(expected2[i],f2.getIJ(0,i),12); pass pass @@ -2216,8 +2216,8 @@ class MEDCouplingBasicsTest2(unittest.TestCase): self.assertTrue(tmp2); self.assertEqual(444,tmp3); expected1=[1.327751058489274, 4.2942574094314701, 13.024068164857139, 1.3069177251569044, 4.1484240761012954, 12.297505664866796, 1.270833333332571, 3.8958333333309674, 11.039062499993179, 1.2291666666659207, 3.6041666666644425, 9.585937499993932, 1.1930822748415895, 3.3515759238941376, 8.3274943351204556, 1.1722489415082769, 3.2057425905609289, 7.6009318351210622, 1.1722489415082862, 3.2057425905609884, 7.6009318351213713, 1.1930822748416161, 3.3515759238943001, 8.3274943351212727, 1.2291666666659564, 3.6041666666646734, 9.5859374999950777, 1.2708333333326081, 3.8958333333311868, 11.039062499994293, 1.3069177251569224, 4.1484240761014384, 12.297505664867627, 1.3277510584902354, 4.2942574094346071, 13.024068164866796] - for ii in xrange(12): - for jj in xrange(36): + for ii in range(12): + for jj in range(36): self.assertAlmostEqual(expected1[jj],f2.getIJ(0,ii*36+jj),9); pass # @@ -2230,7 +2230,7 @@ class MEDCouplingBasicsTest2(unittest.TestCase): self.assertEqual(7,da.getNumberOfTuples()); self.assertEqual(1,da.getNumberOfComponents()); expected2=[0,0,1,2,3,4,4] - for i in xrange(7): + for i in range(7): self.assertEqual(expected2[i],da.getIJ(i,0)); pass m.checkConsistencyLight(); @@ -2244,7 +2244,7 @@ class MEDCouplingBasicsTest2(unittest.TestCase): self.assertEqual(NORM_TRI3,m.getTypeOfCell(6)); expected1=[0.125,0.125,0.125,0.125,0.25,0.125,0.125] f=m.getMeasureField(False); - for i in xrange(7): + for i in range(7): self.assertAlmostEqual(expected1[i]*sqrt(2.),f.getIJ(i,0),10); pass types=m.getAllGeoTypes(); @@ -2255,7 +2255,7 @@ class MEDCouplingBasicsTest2(unittest.TestCase): da=m.simplexize(1); self.assertEqual(7,da.getNumberOfTuples()); self.assertEqual(1,da.getNumberOfComponents()); - for i in xrange(7): + for i in range(7): self.assertEqual(expected2[i],da.getIJ(i,0)); pass m.checkConsistencyLight(); @@ -2270,7 +2270,7 @@ class MEDCouplingBasicsTest2(unittest.TestCase): self.assertEqual(NORM_TRI3,m.getTypeOfCell(5)); self.assertEqual(NORM_TRI3,m.getTypeOfCell(6)); f=m.getMeasureField(False); - for i in xrange(7): + for i in range(7): self.assertAlmostEqual(expected1[i]*sqrt(2.),f.getIJ(i,0),10); pass pass @@ -2289,11 +2289,11 @@ class MEDCouplingBasicsTest2(unittest.TestCase): self.assertTrue(f1.simplexize(0)); f1.checkConsistencyLight(); expected1=[10.,110.,10.,110.,20.,120.,30.,130.,40.,140.,50.,150.,50.,150.] - for i in xrange(14): + for i in range(14): self.assertAlmostEqual(expected1[i],f1.getIJ(0,i),10); pass self.assertTrue(not f1.simplexize(0)); - for i in xrange(14): + for i in range(14): self.assertAlmostEqual(expected1[i],f1.getIJ(0,i),10); pass # @@ -2326,7 +2326,7 @@ class MEDCouplingBasicsTest2(unittest.TestCase): self.assertTrue(da1.getInfoOnComponent(4)=="c2da3"); # expected1=[7.,7.,0.,0.,0., 7.,7.,10.,100.,1000., 7.,7.,20.,200.,2000., 7.,7.,30.,300.,3000., 7.,7.,40.,400.,4000.,7.,7.,50.,500.,5000.,7.,7.,60.,600.,6000.] - for i in xrange(35): + for i in range(35): self.assertAlmostEqual(expected1[i],da1.getIJ(0,i),10); pass # @@ -2340,7 +2340,7 @@ class MEDCouplingBasicsTest2(unittest.TestCase): self.assertTrue(dai1.getInfoOnComponent(2)=="c0da3"); self.assertTrue(dai1.getInfoOnComponent(3)=="c1da3"); self.assertTrue(dai1.getInfoOnComponent(4)=="c2da3"); - for i in xrange(35): + for i in range(35): self.assertEqual(int(expected1[i]),dai1.getIJ(0,i)); pass # test of static method DataArrayDouble::meld @@ -2354,7 +2354,7 @@ class MEDCouplingBasicsTest2(unittest.TestCase): self.assertTrue(da4.getInfoOnComponent(2)=="c0da3"); self.assertTrue(da4.getInfoOnComponent(3)=="c1da3"); self.assertTrue(da4.getInfoOnComponent(4)=="c2da3"); - for i in xrange(35): + for i in range(35): self.assertAlmostEqual(expected1[i],da4.getIJ(0,i),10); pass # test of static method DataArrayInt::meld @@ -2369,7 +2369,7 @@ class MEDCouplingBasicsTest2(unittest.TestCase): self.assertTrue(dai4.getInfoOnComponent(2)=="c0da3"); self.assertTrue(dai4.getInfoOnComponent(3)=="c1da3"); self.assertTrue(dai4.getInfoOnComponent(4)=="c2da3"); - for i in xrange(35): + for i in range(35): self.assertEqual(int(expected1[i]),dai4.getIJ(0,i)); pass pass @@ -2403,7 +2403,7 @@ class MEDCouplingBasicsTest2(unittest.TestCase): self.assertTrue(f3.getArray().getInfoOnComponent(1)=="ccc"); self.assertTrue(f3.getArray().getInfoOnComponent(2)=="aaa"); expected1=[5.,5.,12.,5.,5.,23.,5.,5.,34.,5.,5.,45.,5.,5.,56.] - for i in xrange(15): + for i in range(15): self.assertAlmostEqual(expected1[i],f3.getIJ(0,i),12); pass time,dt,it=f3.getTime(); @@ -2420,7 +2420,7 @@ class MEDCouplingBasicsTest2(unittest.TestCase): self.assertTrue(f6.getArray().getInfoOnComponent(0)=="bbb"); self.assertTrue(f6.getArray().getInfoOnComponent(1)=="ccc"); self.assertTrue(f6.getArray().getInfoOnComponent(2)=="aaa"); - for i in xrange(15): + for i in range(15): self.assertAlmostEqual(expected1[i],f6.getIJ(0,i),12); pass # @@ -2436,7 +2436,7 @@ class MEDCouplingBasicsTest2(unittest.TestCase): da,b,newNbOfNodes=m3.mergeNodesCenter(0.01); self.assertEqual(9,m3.getNumberOfNodes()); expected1=[-0.299,-0.3, 0.201,-0.3, 0.701,-0.3, -0.299,0.2, 0.201,0.2, 0.701,0.2, -0.299,0.7, 0.201,0.7, 0.701,0.7] - for i in xrange(18): + for i in range(18): self.assertAlmostEqual(expected1[i],m3.getCoords().getIJ(0,i),13); pass # @@ -2466,7 +2466,7 @@ class MEDCouplingBasicsTest2(unittest.TestCase): f4=MEDCouplingFieldDouble.MergeFields([f1,f2,f3]); self.assertEqual(15,f4.getMesh().getNumberOfCells()); expected1=[2.,2.,2.,2.,2.,2.,2.,2.,2.,2., 5.,5.,5.,5.,5.,5.,5.,5.,5.,5., 7.,7.,7.,7.,7.,7.,7.,7.,7.,7.] - for i in xrange(30): + for i in range(30): self.assertAlmostEqual(expected1[i],f4.getIJ(0,i),13); pass # @@ -2480,7 +2480,7 @@ class MEDCouplingBasicsTest2(unittest.TestCase): self.assertEqual(8,b.getNumberOfTuples()); self.assertEqual(1,b.getNumberOfComponents()); expected1=[0,2,4,5,6,9,10,11] - for i in xrange(8): + for i in range(8): self.assertEqual(expected1[i],b.getIJ(0,i)); pass pass @@ -2496,14 +2496,14 @@ class MEDCouplingBasicsTest2(unittest.TestCase): self.assertEqual(7,b.getNumberOfTuples()); self.assertEqual(1,b.getNumberOfComponents()); expected1=[0,1,3,5,7,8,18] - for i in xrange(7): + for i in range(7): self.assertEqual(expected1[i],b.getIJ(0,i)); pass b=DataArrayInt.BuildUnion([a,c]); self.assertEqual(7,b.getNumberOfTuples()); self.assertEqual(1,b.getNumberOfComponents()); expected1=[0,1,3,5,7,8,18] - for i in xrange(7): + for i in range(7): self.assertEqual(expected1[i],b.getIJ(0,i)); pass pass @@ -2519,14 +2519,14 @@ class MEDCouplingBasicsTest2(unittest.TestCase): self.assertEqual(2,b.getNumberOfTuples()); self.assertEqual(1,b.getNumberOfComponents()); expected1=[3,8] - for i in xrange(2): + for i in range(2): self.assertEqual(expected1[i],b.getIJ(0,i)); pass b=DataArrayInt.BuildIntersection([a,c]); self.assertEqual(2,b.getNumberOfTuples()); self.assertEqual(1,b.getNumberOfComponents()); expected1=[3,8] - for i in xrange(2): + for i in range(2): self.assertEqual(expected1[i],b.getIJ(0,i)); pass pass @@ -2539,7 +2539,7 @@ class MEDCouplingBasicsTest2(unittest.TestCase): self.assertEqual(6,b.getNumberOfTuples()); self.assertEqual(1,b.getNumberOfComponents()); expected1=[2,3,1,0,2,6] - for i in xrange(6): + for i in range(6): self.assertEqual(expected1[i],b.getIJ(0,i)); pass pass @@ -2558,7 +2558,7 @@ class MEDCouplingBasicsTest2(unittest.TestCase): self.assertTrue(b.getInfoOnComponent(0)=="toto"); self.assertTrue(b.getInfoOnComponent(1)=="tata"); expected1=[5.1,15.1,3.1,13.1,1.1,11.1,7.1,17.1,6.1,16.1] - for i in xrange(10): + for i in range(10): self.assertAlmostEqual(expected1[i],b.getIJ(0,i),14); pass arr4=[4,-1,0,6,5] @@ -2577,7 +2577,7 @@ class MEDCouplingBasicsTest2(unittest.TestCase): self.assertTrue(d.getInfoOnComponent(0)=="toto"); self.assertTrue(d.getInfoOnComponent(1)=="tata"); expected2=[5,15,3,13,1,11,7,17,6,16] - for i in xrange(10): + for i in range(10): self.assertEqual(expected2[i],d.getIJ(0,i)); pass self.assertRaises(InterpKernelException,c.selectByTupleIdSafe,arr4); @@ -2643,7 +2643,7 @@ class MEDCouplingBasicsTest2(unittest.TestCase): self.assertEqual(13,da1.getNumberOfTuples()); # expected1=[-1.,0.,0.,1.,1.,0.,0.,-1.,0.707106781186548,0.707106781186548,0.,-1.,0.,1.,1.,0.,0.,1.,1.,0.,-1.,0.,0.,1.,1.,0.]; - for i in xrange(26): + for i in range(26): self.assertAlmostEqual(expected1[i],da1.getIJ(0,i),14); pass pass @@ -2721,7 +2721,7 @@ class MEDCouplingBasicsTest2(unittest.TestCase): #self.assertRaises(InterpKernelException,f2.__idiv__,f1) # mem leaks self.assertTrue(f1.isEqual(f3,1e-10,1e-10)); expected1=[-0.5, 0.0, 0.0, 0.33333333333333331, 0.25, 0.0, 0.0, -0.20000000000000001, 0.117851130197758, 0.117851130197758, 0.0, -0.14285714285714285, 0.0, 0.125, 0.1111111111111111, 0.0, 0.0, 0.10000000000000001, 0.090909090909090912, 0.0, -0.083333333333333329, 0.0, 0.0, 0.076923076923076927, 0.071428571428571425, 0.0] - for i in xrange(26): + for i in range(26): self.assertAlmostEqual(expected1[i],f3.getIJ(0,i),10); pass pass @@ -2738,14 +2738,14 @@ class MEDCouplingBasicsTest2(unittest.TestCase): self.assertEqual(12,da1.getNbOfElems()); self.assertEqual(4,da1.getNumberOfComponents()); self.assertEqual(3,da1.getNumberOfTuples()); - for i in xrange(12): + for i in range(12): self.assertEqual(i,da1.getIJ(0,i)); # da1.rearrange(6); self.assertEqual(12,da1.getNbOfElems()); self.assertEqual(6,da1.getNumberOfComponents()); self.assertEqual(2,da1.getNumberOfTuples()); - for i in xrange(12): + for i in range(12): self.assertEqual(i,da1.getIJ(0,i)); # self.assertRaises(InterpKernelException,da1.rearrange,7); @@ -2754,14 +2754,14 @@ class MEDCouplingBasicsTest2(unittest.TestCase): self.assertEqual(12,da1.getNbOfElems()); self.assertEqual(12,da1.getNumberOfComponents()); self.assertEqual(1,da1.getNumberOfTuples()); - for i in xrange(12): + for i in range(12): self.assertEqual(i,da1.getIJ(0,i)); # da1.rearrange(3); self.assertEqual(12,da1.getNbOfElems()); self.assertEqual(3,da1.getNumberOfComponents()); self.assertEqual(4,da1.getNumberOfTuples()); - for i in xrange(12): + for i in range(12): self.assertEqual(i,da1.getIJ(0,i)); #double da2=da1.convertToDblArr(); @@ -2774,14 +2774,14 @@ class MEDCouplingBasicsTest2(unittest.TestCase): self.assertEqual(12,da2.getNbOfElems()); self.assertEqual(4,da2.getNumberOfComponents()); self.assertEqual(3,da2.getNumberOfTuples()); - for i in xrange(12): + for i in range(12): self.assertAlmostEqual(float(i),da2.getIJ(0,i),14); # da2.rearrange(6); self.assertEqual(12,da2.getNbOfElems()); self.assertEqual(6,da2.getNumberOfComponents()); self.assertEqual(2,da2.getNumberOfTuples()); - for i in xrange(12): + for i in range(12): self.assertAlmostEqual(float(i),da2.getIJ(0,i),14); # self.assertRaises(InterpKernelException,da2.rearrange,7); @@ -2791,14 +2791,14 @@ class MEDCouplingBasicsTest2(unittest.TestCase): self.assertEqual(12,da2.getNbOfElems()); self.assertEqual(1,da2.getNumberOfComponents()); self.assertEqual(12,da2.getNumberOfTuples()); - for i in xrange(12): + for i in range(12): self.assertAlmostEqual(float(i),da2.getIJ(0,i),14); # da2.rearrange(3); self.assertEqual(12,da2.getNbOfElems()); self.assertEqual(3,da2.getNumberOfComponents()); self.assertEqual(4,da2.getNumberOfTuples()); - for i in xrange(12): + for i in range(12): self.assertAlmostEqual(float(i),da2.getIJ(0,i),14); pass @@ -2867,7 +2867,7 @@ class MEDCouplingBasicsTest2(unittest.TestCase): d.sort() self.assertEqual(5,d.getNumberOfTuples()); self.assertEqual(1,d.getNumberOfComponents()); - for i in xrange(5): + for i in range(5): self.assertAlmostEqual(float(expect3[i]),d.getIJ(i,0),14); pass pass @@ -2896,7 +2896,7 @@ class MEDCouplingBasicsTest2(unittest.TestCase): self.assertEqual(2,b.getNumberOfComponents()); self.assertEqual(3,b.getNumberOfTuples()); expected1=[0.36666666666666665,-0.13333333333333333,-0.05,-0.05,0.45,0.45]; - for i in xrange(6): + for i in range(6): self.assertAlmostEqual(expected1[i],b.getIJ(0,i),14); pass pass @@ -2910,7 +2910,7 @@ class MEDCouplingBasicsTest2(unittest.TestCase): self.assertEqual(1,b.getNumberOfComponents()); self.assertEqual(3,b.getNumberOfTuples()); expected1=[0.125,0.25,0.25]; - for i in xrange(3): + for i in range(3): self.assertAlmostEqual(expected1[i],b.getIJ(0,i),14); pass pass @@ -2925,7 +2925,7 @@ class MEDCouplingBasicsTest2(unittest.TestCase): self.assertEqual(3,b.getArray().getNumberOfComponents()); self.assertEqual(3,b.getArray().getNumberOfTuples()); expected1=[0.,0.,-1.,0.,0.,-1.,0.,0.,-1.]; - for i in xrange(9): + for i in range(9): self.assertAlmostEqual(expected1[i],b.getArray().getIJ(0,i),14); pass pass diff --git a/src/MEDCoupling_Swig/MEDCouplingBasicsTest3.py b/src/MEDCoupling_Swig/MEDCouplingBasicsTest3.py index 9794aa4c1..ea8b1257d 100644 --- a/src/MEDCoupling_Swig/MEDCouplingBasicsTest3.py +++ b/src/MEDCoupling_Swig/MEDCouplingBasicsTest3.py @@ -271,7 +271,7 @@ class MEDCouplingBasicsTest3(unittest.TestCase): da-=8 st2=da.getHiddenCppPointer() self.assertEqual(st1,st2) - self.assertEqual(range(12),da.getValues()) + self.assertEqual(list(range(12)),da.getValues()) da+=da1 st2=da.getHiddenCppPointer() self.assertEqual(st1,st2) @@ -347,7 +347,7 @@ class MEDCouplingBasicsTest3(unittest.TestCase): da-=8 st2=da.getHiddenCppPointer() self.assertEqual(st1,st2) - self.assertEqual(range(12),da.getValues()) + self.assertEqual(list(range(12)),da.getValues()) da+=da1 st2=da.getHiddenCppPointer() self.assertEqual(st1,st2) @@ -492,7 +492,7 @@ class MEDCouplingBasicsTest3(unittest.TestCase): it2=da2.__iter__() i=0 for it in da: - pt=it2.next() + pt=next(it2) it[:]=pt pass self.assertTrue(da.isEqual(da2)) @@ -550,7 +550,7 @@ class MEDCouplingBasicsTest3(unittest.TestCase): it2=da2.__iter__() i=0 for it in da: - pt=it2.next() + pt=next(it2) it[:]=pt pass self.assertTrue(da.isEqual(da2,1e-12)) @@ -616,12 +616,12 @@ class MEDCouplingBasicsTest3(unittest.TestCase): def testDAIAggregateMulti1(self): a=DataArrayInt.New() - a.setValues(range(4),2,2) + a.setValues(list(range(4)),2,2) a.setName("aa") b=DataArrayInt.New() - b.setValues(range(6),3,2) + b.setValues(list(range(6)),3,2) c=DataArrayInt.Aggregate([a,b]) - self.assertEqual(range(4)+range(6),c.getValues()) + self.assertEqual(list(range(4))+list(range(6)),c.getValues()) self.assertEqual("aa",c.getName()) self.assertEqual(5,c.getNumberOfTuples()) self.assertEqual(2,c.getNumberOfComponents()) @@ -682,7 +682,7 @@ class MEDCouplingBasicsTest3(unittest.TestCase): self.assertEqual(0,m.getMeshDimension()); types1=m.getAllGeoTypes(); self.assertEqual([NORM_POINT1],types1); - for i in xrange(4): + for i in range(4): conn=m.getNodeIdsOfCell(i); self.assertEqual([i],conn); self.assertTrue(NORM_POINT1==m.getTypeOfCell(i)); @@ -741,7 +741,7 @@ class MEDCouplingBasicsTest3(unittest.TestCase): hs=dt.getHotSpotsTime(); self.assertEqual(6,len(hs)); expected1=[0.2,0.7,1.2,1.35,1.7,2.7] - for i in xrange(6): + for i in range(6): self.assertAlmostEqual(expected1[i],hs[i],12); pass meshId,arrId,arrIdInField,fieldId=dt.getIdsOnTimeRight(0.2); @@ -805,7 +805,7 @@ class MEDCouplingBasicsTest3(unittest.TestCase): da2=da.checkAndPreparePermutation(); self.assertEqual(8,da2.getNumberOfTuples()); self.assertEqual(1,da2.getNumberOfComponents()); - for i in xrange(8): + for i in range(8): self.assertEqual(expect1[i],da2.getIJ(i,0)); pass # @@ -940,12 +940,12 @@ class MEDCouplingBasicsTest3(unittest.TestCase): self.assertEqual(1,da2.getNumberOfComponents()); self.assertEqual(5,da2.getNumberOfTuples()); expected1=[32.,34.,36.,38.,40.] - for i in xrange(5): + for i in range(5): self.assertAlmostEqual(expected1[i],da2.getIJ(0,i),12); pass da2=da.applyFunc(1,"y+z"); expected2=[12.,14.,16.,18.,20.] - for i in xrange(5): + for i in range(5): self.assertAlmostEqual(expected2[i],da2.getIJ(0,i),12); pass # @@ -954,7 +954,7 @@ class MEDCouplingBasicsTest3(unittest.TestCase): f1.applyFuncCompo(1,"y+z"); self.assertEqual(1,f1.getNumberOfComponents()); self.assertEqual(5,f1.getNumberOfTuples()); - for i in xrange(5): + for i in range(5): self.assertAlmostEqual(expected1[i],f1.getArray().getIJ(0,i),12); pass # @@ -978,7 +978,7 @@ class MEDCouplingBasicsTest3(unittest.TestCase): vs[1]="y"; da2=da.applyFuncNamedCompo(1,vs,"y+z"); expected1=[32.,34.,36.,38.,40.] - for i in xrange(5): + for i in range(5): self.assertAlmostEqual(expected1[i],da2.getIJ(0,i),12); pass self.assertRaises(InterpKernelException, da.applyFuncNamedCompo, 1, ["x","y","z","a"],"x+a") @@ -988,7 +988,7 @@ class MEDCouplingBasicsTest3(unittest.TestCase): f1.applyFuncNamedCompo(1,vs,"y+z"); self.assertEqual(1,f1.getNumberOfComponents()); self.assertEqual(5,f1.getNumberOfTuples()); - for i in xrange(5): + for i in range(5): self.assertAlmostEqual(expected1[i],f1.getArray().getIJ(0,i),12); pass pass @@ -1006,7 +1006,7 @@ class MEDCouplingBasicsTest3(unittest.TestCase): self.assertEqual(1,f1.getNumberOfComponents()); self.assertEqual(9,f1.getNumberOfTuples()); expected1=[0.2, 0.7, 1.2, 0.7, 1.2, 1.7, 1.2, 1.7, 2.2] - for i in xrange(9): + for i in range(9): self.assertAlmostEqual(expected1[i],f1.getArray().getIJ(0,i),12); pass pass @@ -1024,7 +1024,7 @@ class MEDCouplingBasicsTest3(unittest.TestCase): self.assertEqual(1,f1.getNumberOfComponents()); self.assertEqual(9,f1.getNumberOfTuples()); expected1=[0.2, 0.7, 1.2, 0.7, 1.2, 1.7, 1.2, 1.7, 2.2] - for i in xrange(9): + for i in range(9): self.assertAlmostEqual(expected1[i],f1.getArray().getIJ(0,i),12); pass pass @@ -1108,7 +1108,7 @@ class MEDCouplingBasicsTest3(unittest.TestCase): self.assertEqual(3,resToTest.getNumberOfComponents()); self.assertEqual(2,resToTest.getNumberOfTuples()); expected1=[0.6,0.6,0.6, 0.6,0.6,0.6] - for i in xrange(6): + for i in range(6): self.assertAlmostEqual(expected1[i],resToTest.getIJ(0,i),14); pass # @@ -1148,7 +1148,7 @@ class MEDCouplingBasicsTest3(unittest.TestCase): 2.32,1.52,0.0, 1.6,1.32,0.0, 3.52,1.26,0.0,#TRI6 2.6,1.6,0.0, 2.4,1.8,0.0, 2.4,1.2,0.0, 2.3,1.46,0.0,#QUAD4 2.32,2.68,0.0, 2.6,2.42,0.0, 2.8,2.46,0.0, 2.74,2.28,0.0 ];#QUAD8 - for i in xrange(39): + for i in range(39): self.assertAlmostEqual(expected2[i],resToTest.getIJ(0,i),14); pass # @@ -1210,7 +1210,7 @@ class MEDCouplingBasicsTest3(unittest.TestCase): self.assertEqual(3,resToTest.getNumberOfComponents()); self.assertEqual(8,resToTest.getNumberOfTuples());#2+3+4+4 gauss points for resp TRI3,TRI6,QUAD4,QUAD8 expected3=[1.312,3.15,1.02, 0.56,3.3,0.6, 2.18,1.1,0.2, 1.18,1.54,0.98, 1.56,0.3,3.6, 1.613,0.801,4.374, 2.6,2.4,2.3, 2.31232,2.3933985,1.553255] - for i in xrange(24): + for i in range(24): self.assertAlmostEqual(expected3[i],resToTest.getIJ(0,i),14); pass # @@ -1237,7 +1237,7 @@ class MEDCouplingBasicsTest3(unittest.TestCase): loc=[2.27,1.3] locs=f.getValueOnMulti(loc); expected1=[6.0921164547752236, 7.1921164547752232, 8.2921164547752255] - for i in xrange(3): + for i in range(3): self.assertAlmostEqual(expected1[i],locs.getIJ(0,i),12); pass pass @@ -1263,7 +1263,7 @@ class MEDCouplingBasicsTest3(unittest.TestCase): loc=[0.64637931739890486, -0.16185896817550552, 0.22678966365273748] locs=f.getValueOnMulti(loc); expected1=[10.0844021968047] - for i in xrange(1): + for i in range(1): self.assertAlmostEqual(expected1[i],locs.getIJ(0,i),12); pass pass @@ -1282,7 +1282,7 @@ class MEDCouplingBasicsTest3(unittest.TestCase): locs=f.getValueOnMulti(loc); self.assertEqual(5,locs.getNumberOfTuples()); self.assertEqual(3,locs.getNumberOfComponents()); - for j in xrange(15): + for j in range(15): self.assertAlmostEqual(values1[j],locs.getIJ(0,j),12); pass # Testing ON_NODES @@ -1301,7 +1301,7 @@ class MEDCouplingBasicsTest3(unittest.TestCase): locs=f.getValueOnMulti(loc3); self.assertEqual(4,locs.getNumberOfTuples()); self.assertEqual(3,locs.getNumberOfComponents()); - for i in xrange(12): + for i in range(12): self.assertAlmostEqual(expected2[i],locs.getIJ(0,i),12); pass # @@ -1315,7 +1315,7 @@ class MEDCouplingBasicsTest3(unittest.TestCase): self.assertEqual(7,d2.getNumberOfTuples()); self.assertEqual(1,d2.getNumberOfComponents()); expected1=[0,1,3,4,7,8,9] - for i in xrange(7): + for i in range(7): self.assertEqual(expected1[i],d2.getIJ(0,i)); pass d.rearrange(2); @@ -1327,7 +1327,7 @@ class MEDCouplingBasicsTest3(unittest.TestCase): self.assertEqual(5,d3.getNumberOfTuples()); self.assertEqual(1,d3.getNumberOfComponents()); expected2=[0,1,4,8,9] - for i in xrange(5): + for i in range(5): self.assertEqual(expected2[i],d3.getIJ(0,i)); pass pass @@ -1340,7 +1340,7 @@ class MEDCouplingBasicsTest3(unittest.TestCase): d.computeOffsets(); self.assertEqual(6,d.getNumberOfTuples()); self.assertEqual(1,d.getNumberOfComponents()); - for i in xrange(6): + for i in range(6): self.assertEqual(expected1[i],d.getIJ(0,i)); pass pass @@ -1366,7 +1366,7 @@ class MEDCouplingBasicsTest3(unittest.TestCase): self.assertEqual(1,bary.getNumberOfTuples()); self.assertEqual(3,bary.getNumberOfComponents()); expected1=[0.,0.,1.] - for i in xrange(3): + for i in range(3): self.assertAlmostEqual(expected1[i],bary.getIJ(0,i),12); pass d1=DataArrayInt.New(); @@ -1378,7 +1378,7 @@ class MEDCouplingBasicsTest3(unittest.TestCase): expected4=[[1,2,3,4,5,0],[7,6,11,10,9,8],[1,7,8,2],[2,8,9,3],[3,9,10,4],[4,10,11,5],[5,11,6,0],[0,6,7,1]]; expected2=[NORM_POLYGON, NORM_POLYGON, NORM_QUAD4, NORM_QUAD4, NORM_QUAD4, NORM_QUAD4, NORM_QUAD4, NORM_QUAD4]; expected3=[6,6,4,4,4,4,4,4] - for i in xrange(8): + for i in range(8): self.assertTrue(m2.getTypeOfCell(i)==expected2[i]); v=m2.getNodeIdsOfCell(i); self.assertTrue(len(v)==expected3[i]); @@ -1519,7 +1519,7 @@ class MEDCouplingBasicsTest3(unittest.TestCase): d1.transformWithIndArr(d); self.assertEqual(12,d1.getNumberOfTuples()); self.assertEqual(1,d1.getNumberOfComponents()); - for i in xrange(12): + for i in range(12): self.assertEqual(expected[i],d1.getIJ(i,0)); pass # @@ -1527,7 +1527,7 @@ class MEDCouplingBasicsTest3(unittest.TestCase): d1.transformWithIndArr(tab1) self.assertEqual(12,d1.getNumberOfTuples()); self.assertEqual(1,d1.getNumberOfComponents()); - for i in xrange(12): + for i in range(12): self.assertEqual(expected[i],d1.getIJ(i,0)); pass pass @@ -1540,7 +1540,7 @@ class MEDCouplingBasicsTest3(unittest.TestCase): da2=da.buildPermArrPerLevel(); self.assertEqual(12,da2.getNumberOfTuples()); self.assertEqual(1,da2.getNumberOfComponents()); - for i in xrange(12): + for i in range(12): self.assertEqual(expected1[i],da2.getIJ(i,0)); pass pass @@ -1558,17 +1558,17 @@ class MEDCouplingBasicsTest3(unittest.TestCase): self.assertEqual(4,da2.getNumberOfTuples()); self.assertEqual(3,da2.getNumberOfComponents()); expected1=[1,1,8,12,9,9,14,15,14,14,12,14] - for i in xrange(12): + for i in range(12): self.assertEqual(expected1[i],da2.getIJ(0,i)); pass da1.substractEqual(da); expected2=[3,5,0,-2,3,5,2,3,6,8,12,12] - for i in xrange(12): + for i in range(12): self.assertEqual(expected2[i],da1.getIJ(0,i)); pass da1.rearrange(1); da1.iota(2); da1.rearrange(3); da1.addEqual(da); - for i in xrange(12): + for i in range(12): self.assertEqual(expected1[i],da1.getIJ(0,i)); pass da1.rearrange(1); da1.iota(2); da1.rearrange(3); @@ -1576,53 +1576,53 @@ class MEDCouplingBasicsTest3(unittest.TestCase): self.assertEqual(4,da2.getNumberOfTuples()); self.assertEqual(3,da2.getNumberOfComponents()); expected3=[-2,-6,16,35,18,14,48,54,40,33,0,13] - for i in xrange(12): + for i in range(12): self.assertEqual(expected3[i],da2.getIJ(0,i)); pass da.divideEqual(da1); self.assertEqual(4,da.getNumberOfTuples()); self.assertEqual(3,da.getNumberOfComponents()); expected4=[0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0] - for i in xrange(12): + for i in range(12): self.assertEqual(expected4[i],da.getIJ(0,i)); pass da.setValues(arr1,4,3); da1.multiplyEqual(da); self.assertEqual(4,da1.getNumberOfTuples()); self.assertEqual(3,da1.getNumberOfComponents()); - for i in xrange(12): + for i in range(12): self.assertEqual(expected3[i],da1.getIJ(0,i)); pass da1.rearrange(1); da1.iota(2); da1.rearrange(3); da2=DataArrayInt.Divide(da,da1); self.assertEqual(4,da2.getNumberOfTuples()); self.assertEqual(3,da2.getNumberOfComponents()); - for i in xrange(12): + for i in range(12): self.assertEqual(expected4[i],da2.getIJ(0,i)); pass da1.applyInv(321); self.assertEqual(4,da1.getNumberOfTuples()); self.assertEqual(3,da1.getNumberOfComponents()); expected5=[160,107,80,64,53,45,40,35,32,29,26,24] - for i in xrange(12): + for i in range(12): self.assertEqual(expected5[i],da1.getIJ(0,i)); pass da1.applyDivideBy(2); self.assertEqual(4,da1.getNumberOfTuples()); self.assertEqual(3,da1.getNumberOfComponents()); expected6=[80,53,40,32,26,22,20,17,16,14,13,12] - for i in xrange(12): + for i in range(12): self.assertEqual(expected6[i],da1.getIJ(0,i)); pass expected7=[3,4,5,4,5,1,6,3,2,0,6,5] da1.applyModulus(7); - for i in xrange(12): + for i in range(12): self.assertEqual(expected7[i],da1.getIJ(0,i)); pass da1.applyLin(1,1); expected8=[3,3,3,3,3,1,3,3,0,0,3,3] da1.applyRModulus(3); - for i in xrange(12): + for i in range(12): self.assertEqual(expected8[i],da1.getIJ(0,i)); pass pass @@ -1634,37 +1634,37 @@ class MEDCouplingBasicsTest3(unittest.TestCase): expected1=[1,32,29,23,41,36] self.assertEqual(47,da0.getNumberOfTuples()); self.assertEqual(1,da0.getNumberOfComponents()); - for i in xrange(47): + for i in range(47): self.assertEqual(expected0[i],da0.getIJ(0,i)); pass self.assertEqual(6,da5.getNumberOfTuples()); self.assertEqual(1,da5.getNumberOfComponents()); - for i in xrange(6): + for i in range(6): self.assertEqual(expected1[i],da5.getIJ(0,i)); pass expected2=[0,1,2,3,4,0,5,6,7,4,8,9,1,7,10,11,12,13,14,5,15,16,17,8,18,19,20,10,21,22,23,2,13,24,25,21,16,26,27,12,19,28,29,15,22,30,31,18,36,26,28,30,24,37,32,33,34,35,38,36,39,40,41,42,37,38,43,44,45,46] self.assertEqual(70,da1.getNumberOfTuples()); self.assertEqual(1,da1.getNumberOfComponents()); - for i in xrange(70): + for i in range(70): self.assertEqual(expected2[i],da1.getIJ(0,i)); pass expected3=[0,4,8,12,16,20,24,28,32,36,40,44,48,53,58,64,70] self.assertEqual(17,da2.getNumberOfTuples()); self.assertEqual(1,da2.getNumberOfComponents()); - for i in xrange(17): + for i in range(17): self.assertEqual(expected3[i],da2.getIJ(0,i)); pass expected4=[0,2,4,6,7,9,11,12,14,16,17,19,20,22,24,25,27,29,30,32,34,35,37,39,40,42,43,45,46,48,49,51,52,53,54,55,56,58,60,62,63,64,65,66,67,68,69,70] #expected4=[0,2,4,6,7,9,11,12,14,16,17,19,20,22,24,25,27,29,30,32,34,35,37,39,40,42,43,45,46,48,49,51,52,54,56,57,58,59,60,62,63,64,65,66,67,68,69,70]; self.assertEqual(48,da4.getNumberOfTuples()); self.assertEqual(1,da4.getNumberOfComponents()); - for i in xrange(48): + for i in range(48): self.assertEqual(expected4[i],da4.getIJ(0,i)); pass expected5=[0,1,0,3,0,7,0,1,2,1,4,1,2,3,2,5,2,3,6,3,4,9,4,8,4,5,10,5,9,5,6,11,6,10,6,7,8,7,11,7,8,12,8,9,12,9,10,12,10,11,12,11,13,13,13,13,12,14,13,15,14,15,14,14,14,14,15,15,15,15] self.assertEqual(70,da3.getNumberOfTuples()); self.assertEqual(1,da3.getNumberOfComponents()); - for i in xrange(70): + for i in range(70): self.assertEqual(expected5[i],da3.getIJ(0,i)); pass pass @@ -1678,7 +1678,7 @@ class MEDCouplingBasicsTest3(unittest.TestCase): expected1=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,36,37,32,33,34,35,38,39,40,41,42,43,44,45,46] self.assertEqual(47,da0.getNumberOfTuples()); self.assertEqual(1,da0.getNumberOfComponents()); - for i in xrange(47): + for i in range(47): self.assertEqual(expected0[i],da0.getIJ(0,i)); pass self.assertEqual(2,da1.getNumberOfTuples()); @@ -1690,7 +1690,7 @@ class MEDCouplingBasicsTest3(unittest.TestCase): # self.assertEqual(47,da2.getNumberOfTuples()); self.assertEqual(1,da2.getNumberOfComponents()); - for i in xrange(47): + for i in range(47): self.assertEqual(expected1[i],da2.getIJ(0,i)); pass pass @@ -1741,7 +1741,7 @@ class MEDCouplingBasicsTest3(unittest.TestCase): d3=d.transformWithIndArrR(d1); self.assertEqual(6,d3.getNumberOfTuples()); self.assertEqual(1,d3.getNumberOfComponents()); - for i in xrange(6): + for i in range(6): self.assertEqual(expected[i],d3.getIJ(i,0)); pass # @@ -1749,7 +1749,7 @@ class MEDCouplingBasicsTest3(unittest.TestCase): d3=d.transformWithIndArrR(tab2) self.assertEqual(6,d3.getNumberOfTuples()); self.assertEqual(1,d3.getNumberOfComponents()); - for i in xrange(6): + for i in range(6): self.assertEqual(expected[i],d3.getIJ(i,0)); pass pass @@ -1769,7 +1769,7 @@ class MEDCouplingBasicsTest3(unittest.TestCase): # expected1=[1,1,0,0,0,1,1,0,1] expected2=[2,1,0,3,2,3,4,1,0] - for i in xrange(9): + for i in range(9): self.assertEqual(expected1[i],e.getIJ(i,0)); self.assertEqual(expected2[i],f.getIJ(i,0)); pass @@ -1888,7 +1888,7 @@ class MEDCouplingBasicsTest3(unittest.TestCase): self.assertEqual(11,f.getNumberOfTuples()); self.assertEqual(1,f.getNumberOfComponents()); expected1=[0,1,2,6,7,8,9,10,11,12,13] - for i in xrange(11): + for i in range(11): self.assertEqual(expected1[i],f.getIJ(i,0)); pass pass @@ -1901,7 +1901,7 @@ class MEDCouplingBasicsTest3(unittest.TestCase): d.computeOffsetsFull(); self.assertEqual(7,d.getNumberOfTuples()); self.assertEqual(1,d.getNumberOfComponents()); - for i in xrange(7): + for i in range(7): self.assertEqual(expected1[i],d.getIJ(0,i)); pass pass @@ -2188,14 +2188,14 @@ class MEDCouplingBasicsTest3(unittest.TestCase): expected1=[2.301,1.2,1.3,0.8] dv=da.getDifferentValues(1e-2); self.assertEqual(4,dv.getNbOfElems()); - for i in xrange(4): + for i in range(4): self.assertAlmostEqual(expected1[i],dv.getIJ(i,0),14); pass # dv=da.getDifferentValues(2e-1); expected2=[2.301,1.3,0.8] self.assertEqual(3,dv.getNbOfElems()); - for i in xrange(3): + for i in range(3): self.assertAlmostEqual(expected2[i],dv.getIJ(i,0),14); pass pass @@ -2222,12 +2222,12 @@ class MEDCouplingBasicsTest3(unittest.TestCase): a.setValues(arr,6,1); self.assertEqual(2,a.back()); a.reverse(); - for i in xrange(6): + for i in range(6): self.assertEqual(arr[5-i],a.getIJ(i,0)); pass a.setValues(arr[:-1],5,1); a.reverse(); - for i in xrange(5): + for i in range(5): self.assertEqual(arr[4-i],a.getIJ(i,0)); pass # @@ -2235,13 +2235,13 @@ class MEDCouplingBasicsTest3(unittest.TestCase): b=DataArrayDouble.New(); b.setValues(arr2,6,1); b.reverse(); - for i in xrange(6): + for i in range(6): self.assertAlmostEqual(arr2[5-i],b.getIJ(i,0),14); pass b.setValues(arr2[:5],5,1); self.assertAlmostEqual(9.,b.back(),14) b.reverse(); - for i in xrange(5): + for i in range(5): self.assertAlmostEqual(arr2[4-i],b.getIJ(i,0),14); pass pass @@ -2321,7 +2321,7 @@ class MEDCouplingBasicsTest3(unittest.TestCase): self.assertEqual(9,m3.getNodalConnectivityIndex().getNumberOfTuples()); self.assertEqual(expected3,m3.getNodalConnectivity().getValues()); self.assertEqual(expected4,m3.getNodalConnectivityIndex().getValues()); - for i in xrange(44): + for i in range(44): self.assertAlmostEqual(expected5[i],m3.getCoords().getIJ(0,i),12); pass pass @@ -2386,7 +2386,7 @@ class MEDCouplingBasicsTest3(unittest.TestCase): self.assertEqual(10,m3.getNodalConnectivityIndex().getNumberOfTuples()); self.assertEqual(expected3,m3.getNodalConnectivity().getValues()); self.assertEqual(expected4,m3.getNodalConnectivityIndex().getValues()); - for i in xrange(44): + for i in range(44): self.assertAlmostEqual(expected5[i],m3.getCoords().getIJ(0,i),12); pass pass @@ -2421,7 +2421,7 @@ class MEDCouplingBasicsTest3(unittest.TestCase): m2=MEDCouplingUMesh.New(); m2.setMeshDimension(2); m2.allocateCells(8); - for i in xrange(8): + for i in range(8): m2.insertNextCell(NORM_QUAD4,4,m2Conn[4*i:4*(i+1)]) pass m2.finishInsertingCells(); @@ -2448,7 +2448,7 @@ class MEDCouplingBasicsTest3(unittest.TestCase): self.assertEqual(17,m3.getNodalConnectivityIndex().getNumberOfTuples()); self.assertEqual(expected3,m3.getNodalConnectivity().getValues()); self.assertEqual(expected4,m3.getNodalConnectivityIndex().getValues()); - for i in xrange(208): + for i in range(208): self.assertAlmostEqual(expected5[i],m3.getCoords().getIJ(0,i),12); pass pass @@ -2488,7 +2488,7 @@ class MEDCouplingBasicsTest3(unittest.TestCase): expected3=[5,0,3,25,26,1,5,3,4,27,28,2,1,26,25,5,5,29,30,3,0,5,6,31,32,4,3,30,29,5,5,5,0,7,33,34,5,6,5,34,33,7,8,35,36,5,0,1,37,38,7,5,1,2,39,40,8,7,38,37] expected4=[0,6,15,21,30,36,45,51,60] expected5=[0.,0.,1.,0.,1.5,0.,0.,1.,0.,1.5,-1.,0.,-1.5,0.,0.,-1.,0.,-1.5,0.5,0.,1.25,0.,0.7071067811865476,0.7071067811865476,1.0606601717798214,1.0606601717798214,0.,0.5,0.,1.25,-0.7071067811865476,0.7071067811865476,-1.0606601717798214,1.0606601717798214,-0.5,0.,-1.25,0.,-0.7071067811865476,-0.7071067811865476,-1.0606601717798214,-1.0606601717798214,0.,-0.5,0.,-1.25,0.7071067811865476,-0.7071067811865476,1.0606601717798214,-1.0606601717798214,0.479425538604203,0.8775825618903728,0.8414709848078964,0.54030230586814,0.7191383079063044,1.3163738428355591,1.2622064772118446,0.8104534588022099,-0.877582561890373,0.4794255386042027,-0.5403023058681399,0.8414709848078964,-1.3163738428355596,0.7191383079063038,-0.8104534588022098,1.2622064772118446,-0.4794255386042031,-0.8775825618903728,-0.8414709848078965,-0.5403023058681399,-0.7191383079063045,-1.3163738428355591,-1.2622064772118449,-0.8104534588022098,0.8775825618903729,-0.47942553860420295,0.54030230586814,-0.8414709848078964,1.3163738428355594,-0.7191383079063043,0.8104534588022099,-1.2622064772118446] - for i in xrange(82): + for i in range(82): self.assertAlmostEqual(expected5[i],m12.getCoords().getIJ(0,i),12); pass self.assertEqual(60,m12.getNodalConnectivity().getNumberOfTuples()); @@ -2539,7 +2539,7 @@ class MEDCouplingBasicsTest3(unittest.TestCase): m2=MEDCouplingUMesh.New(); m2.setMeshDimension(2); m2.allocateCells(8); - for i in xrange(8): + for i in range(8): m2.insertNextCell(NORM_QUAD4,4,m2Conn[4*i:4*(i+1)]) pass m2.finishInsertingCells(); @@ -2566,7 +2566,7 @@ class MEDCouplingBasicsTest3(unittest.TestCase): self.assertEqual(17,m3.getNodalConnectivityIndex().getNumberOfTuples()); self.assertEqual(expected3,m3.getNodalConnectivity().getValues()); self.assertEqual(expected4,m3.getNodalConnectivityIndex().getValues()); - for i in xrange(208): + for i in range(208): self.assertAlmostEqual(expected5[i],m3.getCoords().getIJ(0,i),12); pass pass @@ -2601,7 +2601,7 @@ class MEDCouplingBasicsTest3(unittest.TestCase): self.assertEqual(expected1,ids.getValues()); self.assertEqual(expected2,slice1.getNodalConnectivity().getValues()); self.assertEqual(expected3,slice1.getNodalConnectivityIndex().getValues()); - for i in xrange(171): + for i in range(171): self.assertAlmostEqual(expected4[i],slice1.getCoords().getIJ(0,i),12); pass # 2nd slice based on already existing nodes of mesh3D. @@ -2621,7 +2621,7 @@ class MEDCouplingBasicsTest3(unittest.TestCase): self.assertEqual(expected1,ids.getValues()); self.assertEqual(expected5,slice1.getNodalConnectivity().getValues()); self.assertEqual(expected6,slice1.getNodalConnectivityIndex().getValues()); - for i in xrange(180): + for i in range(180): self.assertAlmostEqual(expected7[i],slice1.getCoords().getIJ(0,i),12); pass # 3rd slice based on shared face of mesh3D. @@ -2642,7 +2642,7 @@ class MEDCouplingBasicsTest3(unittest.TestCase): self.assertEqual(expected8,ids.getValues()); self.assertEqual(expected9,slice1.getNodalConnectivity().getValues()); self.assertEqual(expected10,slice1.getNodalConnectivityIndex().getValues()); - for i in xrange(135): + for i in range(135): self.assertAlmostEqual(expected11[i],slice1.getCoords().getIJ(0,i),12); pass pass @@ -2667,7 +2667,7 @@ class MEDCouplingBasicsTest3(unittest.TestCase): self.assertEqual(expected1,ids.getValues()); self.assertEqual(expected2,slice1.getNodalConnectivity().getValues()); self.assertEqual(expected3,slice1.getNodalConnectivityIndex().getValues()); - for i in xrange(171): + for i in range(171): self.assertAlmostEqual(expected4[i],slice1.getCoords().getIJ(0,i),12); pass # @@ -2688,7 +2688,7 @@ class MEDCouplingBasicsTest3(unittest.TestCase): self.assertEqual(expected5,ids.getValues()); self.assertEqual(expected6,slice1.getNodalConnectivity().getValues()); self.assertEqual(expected7,slice1.getNodalConnectivityIndex().getValues()); - for i in xrange(135): + for i in range(135): self.assertAlmostEqual(expected8[i],slice1.getCoords().getIJ(0,i),12); pass pass @@ -2713,7 +2713,7 @@ class MEDCouplingBasicsTest3(unittest.TestCase): expected1=[1.,11.,2.,12.,4.,14.,6.,16.,7.,17.] self.assertEqual(5,tmp.getNumberOfTuples()); self.assertEqual(2,tmp.getNumberOfComponents()); - for i in xrange(10): + for i in range(10): self.assertAlmostEqual(expected1[i],tmp.getIJ(0,i),14); pass p=[(0,2),(0,2),(5,6)] @@ -2721,7 +2721,7 @@ class MEDCouplingBasicsTest3(unittest.TestCase): expected2=[1.,11.,2.,12.,1.,11.,2.,12.,6.,16.] self.assertEqual(5,tmp.getNumberOfTuples()); self.assertEqual(2,tmp.getNumberOfComponents()); - for i in xrange(10): + for i in range(10): self.assertAlmostEqual(expected2[i],tmp.getIJ(0,i),14); pass p=[(0,2),(-1,2),(5,6)] @@ -2735,7 +2735,7 @@ class MEDCouplingBasicsTest3(unittest.TestCase): dac=da.deepCopy(); dac.setContigPartOfSelectedValuesSlice(1,da2,2,4,1); expected3=[1.,11.,0.,30.,11.,41.,4.,14.,5.,15.,6.,16.,7.,17.] - for i in xrange(14): + for i in range(14): self.assertAlmostEqual(expected3[i],dac.getIJ(0,i),14); pass # @@ -2745,7 +2745,7 @@ class MEDCouplingBasicsTest3(unittest.TestCase): self.assertRaises(InterpKernelException,dac.setContigPartOfSelectedValuesSlice,3,da2,5,0,1); dac.setContigPartOfSelectedValuesSlice(3,da2,1,5,1); expected4=[1.,11.,2.,12.,3.,13.,9.,39.,0.,30.,11.,41.,12.,42.] - for i in xrange(14): + for i in range(14): self.assertAlmostEqual(expected4[i],dac.getIJ(0,i),14); pass # @@ -2755,7 +2755,7 @@ class MEDCouplingBasicsTest3(unittest.TestCase): ids.setIJ(0,0,2); ids.setIJ(1,0,0); ids.setIJ(2,0,4); dac.setContigPartOfSelectedValues(2,da2,ids); expected5=[1.,11.,2.,12.,0.,30.,8.,38.,12.,42.,6.,16.,7.,17.] - for i in xrange(14): + for i in range(14): self.assertAlmostEqual(expected5[i],dac.getIJ(0,i),14); pass # @@ -2771,7 +2771,7 @@ class MEDCouplingBasicsTest3(unittest.TestCase): dac=da.deepCopy(); dac.setContigPartOfSelectedValues(4,da2,ids); expected6=[1.,11.,2.,12.,3.,13.,4.,14.,0.,30.,0.,30.,9.,39.] - for i in xrange(14): + for i in range(14): self.assertAlmostEqual(expected6[i],dac.getIJ(0,i),14); pass pass @@ -2796,7 +2796,7 @@ class MEDCouplingBasicsTest3(unittest.TestCase): expected1=[1,11,2,12,4,14,6,16,7,17] self.assertEqual(5,tmp.getNumberOfTuples()); self.assertEqual(2,tmp.getNumberOfComponents()); - for i in xrange(10): + for i in range(10): self.assertEqual(expected1[i],tmp.getIJ(0,i)); pass p=[(0,2),(0,2),(5,6)] @@ -2804,7 +2804,7 @@ class MEDCouplingBasicsTest3(unittest.TestCase): expected2=[1,11,2,12,1,11,2,12,6,16] self.assertEqual(5,tmp.getNumberOfTuples()); self.assertEqual(2,tmp.getNumberOfComponents()); - for i in xrange(10): + for i in range(10): self.assertEqual(expected2[i],tmp.getIJ(0,i)); pass p=[(0,2),(-1,2),(5,6)] @@ -2818,7 +2818,7 @@ class MEDCouplingBasicsTest3(unittest.TestCase): dac=da.deepCopy(); dac.setContigPartOfSelectedValuesSlice(1,da2,2,4,1); expected3=[1,11,0,30,11,41,4,14,5,15,6,16,7,17] - for i in xrange(14): + for i in range(14): self.assertEqual(expected3[i],dac.getIJ(0,i)); pass # @@ -2828,7 +2828,7 @@ class MEDCouplingBasicsTest3(unittest.TestCase): self.assertRaises(InterpKernelException,dac.setContigPartOfSelectedValuesSlice,3,da2,5,0,1); dac.setContigPartOfSelectedValuesSlice(3,da2,1,5,1); expected4=[1,11,2,12,3,13,9,39,0,30,11,41,12,42] - for i in xrange(14): + for i in range(14): self.assertEqual(expected4[i],dac.getIJ(0,i)); pass # @@ -2838,7 +2838,7 @@ class MEDCouplingBasicsTest3(unittest.TestCase): ids.setIJ(0,0,2); ids.setIJ(1,0,0); ids.setIJ(2,0,4); dac.setContigPartOfSelectedValues(2,da2,ids); expected5=[1,11,2,12,0,30,8,38,12,42,6,16,7,17] - for i in xrange(14): + for i in range(14): self.assertEqual(expected5[i],dac.getIJ(0,i)); pass # @@ -2854,7 +2854,7 @@ class MEDCouplingBasicsTest3(unittest.TestCase): dac=da.deepCopy(); dac.setContigPartOfSelectedValues(4,da2,ids); expected6=[1,11,2,12,3,13,4,14,0,30,0,30,9,39] - for i in xrange(14): + for i in range(14): self.assertEqual(expected6[i],dac.getIJ(0,i)); pass pass @@ -2899,7 +2899,7 @@ class MEDCouplingBasicsTest3(unittest.TestCase): m1.setCoords(myCoords1); # vec1=[0.,0.,1.] - for i in xrange(18): + for i in range(18): vec2=[3.*cos(pi/9.*i),3.*sin(pi/9.*i)]; m1Cpy=m1.deepCopy(); m1Cpy.translate(vec2); @@ -2918,13 +2918,13 @@ class MEDCouplingBasicsTest3(unittest.TestCase): d2=d1.convertToIntArr(); # d1.abs(); - for i in xrange(12): + for i in range(12): self.assertAlmostEqual(expected1[i],d1.getIJ(0,i),14); pass # expected2=[2,3,5,6,7,8,9,10,11,12,13,15] d2.abs(); - for i in xrange(12): + for i in range(12): self.assertEqual(expected2[i],d2.getIJ(0,i)); pass # @@ -2953,7 +2953,7 @@ class MEDCouplingBasicsTest3(unittest.TestCase): self.assertEqual(5,arr1.getNumberOfTuples()); self.assertEqual(3,arr1.getNumberOfComponents()); expected1=[5.7,57.,570.,6.5,65.,650.,5.,50.,500.,8.,80.,800.,7.,70.,700.] - for i in xrange(15): + for i in range(15): self.assertAlmostEqual(expected1[i],arr1.getIJ(0,i),14); pass pass @@ -2973,7 +2973,7 @@ class MEDCouplingBasicsTest3(unittest.TestCase): m1c.setCoordsAt(0,coordsX); expected1=[[0,1],[1,2],[2,3],[3,4]] self.assertEqual(4,m1c.getNumberOfCells()) - for i in xrange(m1c.getNumberOfCells()): + for i in range(m1c.getNumberOfCells()): self.assertEqual(expected1[i],m1c.getNodeIdsOfCell(i)) pass # test in 2D @@ -2981,7 +2981,7 @@ class MEDCouplingBasicsTest3(unittest.TestCase): self.assertEqual(12,m1c.getNumberOfCells()) self.assertEqual(20,m1c.getNumberOfNodes()) expected2=[[0,1,6,5],[1,2,7,6],[2,3,8,7],[3,4,9,8],[5,6,11,10],[6,7,12,11],[7,8,13,12],[8,9,14,13],[10,11,16,15],[11,12,17,16],[12,13,18,17],[13,14,19,18]] - for i in xrange(m1c.getNumberOfCells()): + for i in range(m1c.getNumberOfCells()): self.assertEqual(expected2[i],m1c.getNodeIdsOfCell(i)) pass # test in 3D @@ -2990,7 +2990,7 @@ class MEDCouplingBasicsTest3(unittest.TestCase): self.assertEqual(60,m1c.getNumberOfNodes()) expected3=[[0,1,6,5,20,21,26,25],[1,2,7,6,21,22,27,26],[2,3,8,7,22,23,28,27],[3,4,9,8,23,24,29,28],[5,6,11,10,25,26,31,30],[6,7,12,11,26,27,32,31],[7,8,13,12,27,28,33,32],[8,9,14,13,28,29,34,33],[10,11,16,15,30,31,36,35],[11,12,17,16,31,32,37,36],[12,13,18,17,32,33,38,37],[13,14,19,18,33,34,39,38],[20,21,26,25,40,41,46,45],[21,22,27,26,41,42,47,46],[22,23,28,27,42,43,48,47],[23,24,29,28,43,44,49,48],[25,26,31,30,45,46,51,50],[26,27,32,31,46,47,52,51],[27,28,33,32,47,48,53,52],[28,29,34,33,48,49,54,53],[30,31,36,35,50,51,56,55],[31,32,37,36,51,52,57,56],[32,33,38,37,52,53,58,57],[33,34,39,38,53,54,59,58]] self.assertEqual(24,m1c.getNumberOfCells()) - for i in xrange(m1c.getNumberOfCells()): + for i in range(m1c.getNumberOfCells()): self.assertEqual(expected3[i],m1c.getNodeIdsOfCell(i)) pass pass diff --git a/src/MEDCoupling_Swig/MEDCouplingBasicsTest4.py b/src/MEDCoupling_Swig/MEDCouplingBasicsTest4.py index 5e46ec46c..108d4c6b9 100644 --- a/src/MEDCoupling_Swig/MEDCouplingBasicsTest4.py +++ b/src/MEDCoupling_Swig/MEDCouplingBasicsTest4.py @@ -50,17 +50,17 @@ def checkFreeMemory(size): class MEDCouplingBasicsTest4(unittest.TestCase): def testSwigDADOp4(self): - da=DataArrayDouble.New(range(6,30),12,2) + da=DataArrayDouble.New(list(range(6,30)),12,2) self.assertEqual(12,da.getNumberOfTuples()); self.assertEqual(2,da.getNumberOfComponents()); - for i in xrange(24): + for i in range(24): self.assertAlmostEqual(da.getIJ(0,i),float(i+6),13) pass # operator transpose da.transpose() self.assertEqual(2,da.getNumberOfTuples()); self.assertEqual(12,da.getNumberOfComponents()); - for i in xrange(24): + for i in range(24): self.assertAlmostEqual(da.getIJ(0,i),float(i+6),13) pass da.transpose() @@ -68,13 +68,13 @@ class MEDCouplingBasicsTest4(unittest.TestCase): da2=DataArrayDouble.New(12,1) da2.iota(0.) dabis=-da - for i in xrange(24): + for i in range(24): self.assertAlmostEqual(dabis.getIJ(0,i),-float(i+6),13) pass # operator+= da+=da2 expected1=[6.,7.,9.,10.,12.,13.,15.,16.,18.,19.,21.,22.,24.,25.,27.,28.,30.,31.,33.,34.,36.,37.,39.,40.] - for i in xrange(24): + for i in range(24): self.assertAlmostEqual(da.getIJ(0,i),expected1[i],13) pass da=-dabis @@ -82,7 +82,7 @@ class MEDCouplingBasicsTest4(unittest.TestCase): expected2=[106.,108.,108.,110.,110.,112.,112.,114.,114.,116.,116.,118.,118.,120.,120.,122.,122.,124.,124.,126.,126.,128.,128.,130.] self.assertEqual(12,da.getNumberOfTuples()); self.assertEqual(2,da.getNumberOfComponents()); - for i in xrange(24): + for i in range(24): self.assertAlmostEqual(da.getIJ(0,i),expected2[i],13) pass for pos,elt in enumerate(dabis): @@ -95,12 +95,12 @@ class MEDCouplingBasicsTest4(unittest.TestCase): self.assertAlmostEqual(li[0],100.,13) ; self.assertAlmostEqual(li[1],101.,13) pass # operator-= - da=DataArrayDouble.New(range(6,30),12,2) - da2=DataArrayDouble.New(range(12),12,1) + da=DataArrayDouble.New(list(range(6,30)),12,2) + da2=DataArrayDouble.New(list(range(12)),12,1) dabis=-da da-=da2 expected1=[6.,7.,7.,8.,8.,9.,9.,10.,10.,11.,11.,12.,12.,13.,13.,14.,14.,15.,15.,16.,16.,17.,17.,18.] - for i in xrange(24): + for i in range(24): self.assertAlmostEqual(da.getIJ(0,i),expected1[i],13) pass da=-dabis @@ -108,7 +108,7 @@ class MEDCouplingBasicsTest4(unittest.TestCase): expected2=[-94.,-94.,-92.,-92.,-90.,-90.,-88.,-88.,-86.,-86.,-84.,-84.,-82.,-82.,-80.,-80.,-78.,-78.,-76.,-76.,-74.,-74.,-72.,-72.] self.assertEqual(12,da.getNumberOfTuples()); self.assertEqual(2,da.getNumberOfComponents()); - for i in xrange(24): + for i in range(24): self.assertAlmostEqual(da.getIJ(0,i),expected2[i],13) pass for pos,elt in enumerate(dabis): @@ -117,16 +117,16 @@ class MEDCouplingBasicsTest4(unittest.TestCase): self.assertEqual(12,da.getNumberOfTuples()); self.assertEqual(2,da.getNumberOfComponents()); expected3=[-88.,-87.,-84.,-83.,-80.,-79.,-76.,-75.,-72.,-71.,-68.,-67.,-64.,-63.,-60.,-59.,-56.,-55.,-52.,-51.,-48.,-47.,-44.,-43.] - for i in xrange(24): + for i in range(24): self.assertAlmostEqual(da.getIJ(0,i),expected3[i],13) pass # operator*= - da=DataArrayDouble.New(range(6,30),12,2) - da2=DataArrayDouble.New(range(12),12,1) + da=DataArrayDouble.New(list(range(6,30)),12,2) + da2=DataArrayDouble.New(list(range(12)),12,1) dabis=-da da*=da2 expected1=[0.,0.,8.,9.,20.,22.,36.,39.,56.,60.,80.,85.,108.,114.,140.,147.,176.,184.,216.,225.,260.,270.,308.,319.] - for i in xrange(24): + for i in range(24): self.assertAlmostEqual(da.getIJ(0,i),expected1[i],13) pass da=-dabis @@ -134,7 +134,7 @@ class MEDCouplingBasicsTest4(unittest.TestCase): expected2=[600.,707.,800.,909.,1000.,1111.,1200.,1313.,1400.,1515.,1600.,1717.,1800.,1919.,2000.,2121.,2200.,2323.,2400.,2525.,2600.,2727.,2800.,2929.] self.assertEqual(12,da.getNumberOfTuples()); self.assertEqual(2,da.getNumberOfComponents()); - for i in xrange(24): + for i in range(24): self.assertAlmostEqual(da.getIJ(0,i),expected2[i],13) pass for pos,elt in enumerate(dabis): @@ -143,16 +143,16 @@ class MEDCouplingBasicsTest4(unittest.TestCase): self.assertEqual(12,da.getNumberOfTuples()); self.assertEqual(2,da.getNumberOfComponents()); expected3=[-3600.,-4949.,-6400.,-8181.,-10000.,-12221.,-14400.,-17069.,-19600.,-22725.,-25600.,-29189.,-32400.,-36461.,-40000.,-44541.,-48400.,-53429.,-57600.,-63125.,-67600.,-73629.,-78400.,-84941.0] - for i in xrange(24): + for i in range(24): self.assertAlmostEqual(da.getIJ(0,i),expected3[i],13) pass # operator/= - da=DataArrayDouble.New(range(6,30),12,2) - da2=DataArrayDouble.New(range(1,13),12,1) + da=DataArrayDouble.New(list(range(6,30)),12,2) + da2=DataArrayDouble.New(list(range(1,13)),12,1) dabis=-da da/=da2 expected1=[6.0,7.0,4.0,4.5,3.3333333333333335,3.6666666666666665,3.0,3.25,2.8,3.0,2.6666666666666665,2.8333333333333335,2.5714285714285716,2.7142857142857144,2.5,2.625,2.4444444444444446,2.5555555555555554,2.4,2.5,2.3636363636363638,2.4545454545454546,2.3333333333333335,2.4166666666666665] - for i in xrange(24): + for i in range(24): self.assertAlmostEqual(da.getIJ(0,i),expected1[i],13) pass da=-dabis @@ -160,7 +160,7 @@ class MEDCouplingBasicsTest4(unittest.TestCase): expected2=[0.06,0.06930693069306931,0.08,0.0891089108910891,0.1,0.10891089108910891,0.12,0.12871287128712872,0.14,0.1485148514851485,0.16,0.16831683168316833,0.18,0.18811881188118812,0.2,0.2079207920792079,0.22,0.22772277227722773,0.24,0.24752475247524752,0.26,0.26732673267326734,0.28,0.2871287128712871] self.assertEqual(12,da.getNumberOfTuples()); self.assertEqual(2,da.getNumberOfComponents()); - for i in xrange(24): + for i in range(24): self.assertAlmostEqual(da.getIJ(0,i),expected2[i],13) pass for pos,elt in enumerate(dabis): @@ -169,23 +169,23 @@ class MEDCouplingBasicsTest4(unittest.TestCase): self.assertEqual(12,da.getNumberOfTuples()); self.assertEqual(2,da.getNumberOfComponents()); expected3=[-0.01, -0.009900990099009901, -0.01, -0.009900990099009901, -0.01, -0.009900990099009901, -0.01, -0.009900990099009901, -0.01, -0.009900990099009901, -0.01, -0.009900990099009901, -0.01, -0.009900990099009901, -0.01, -0.009900990099009901, -0.01, -0.009900990099009901, -0.01, -0.009900990099009901, -0.01, -0.009900990099009901, -0.01, -0.0099009900990099] - for i in xrange(24): + for i in range(24): self.assertAlmostEqual(da.getIJ(0,i),expected3[i],13) pass pass def testSwigDAIOp4(self): - da=DataArrayInt.New(range(6,30),12,2) + da=DataArrayInt.New(list(range(6,30)),12,2) self.assertEqual(12,da.getNumberOfTuples()); self.assertEqual(2,da.getNumberOfComponents()); - for i in xrange(24): + for i in range(24): self.assertEqual(da.getIJ(0,i),i+6) pass # operator transpose da.transpose() self.assertEqual(2,da.getNumberOfTuples()); self.assertEqual(12,da.getNumberOfComponents()); - for i in xrange(24): + for i in range(24): self.assertEqual(da.getIJ(0,i),i+6) pass da.transpose() @@ -193,13 +193,13 @@ class MEDCouplingBasicsTest4(unittest.TestCase): da2=DataArrayInt.New(12,1) da2.iota(0) dabis=-da - for i in xrange(24): + for i in range(24): self.assertEqual(dabis.getIJ(0,i),-(i+6)) pass # operator+= da+=da2 expected1=[6,7,9,10,12,13,15,16,18,19,21,22,24,25,27,28,30,31,33,34,36,37,39,40] - for i in xrange(24): + for i in range(24): self.assertEqual(da.getIJ(0,i),expected1[i]) pass da=-dabis @@ -207,7 +207,7 @@ class MEDCouplingBasicsTest4(unittest.TestCase): expected2=[106,108,108,110,110,112,112,114,114,116,116,118,118,120,120,122,122,124,124,126,126,128,128,130] self.assertEqual(12,da.getNumberOfTuples()); self.assertEqual(2,da.getNumberOfComponents()); - for i in xrange(24): + for i in range(24): self.assertEqual(da.getIJ(0,i),expected2[i]) pass for pos,elt in enumerate(dabis): @@ -220,12 +220,12 @@ class MEDCouplingBasicsTest4(unittest.TestCase): self.assertEqual(li[0],100) ; self.assertEqual(li[1],101) pass # operator-= - da=DataArrayInt.New(range(6,30),12,2) - da2=DataArrayInt.New(range(12),12,1) + da=DataArrayInt.New(list(range(6,30)),12,2) + da2=DataArrayInt.New(list(range(12)),12,1) dabis=-da da-=da2 expected1=[6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,14,14,15,15,16,16,17,17,18] - for i in xrange(24): + for i in range(24): self.assertEqual(da.getIJ(0,i),expected1[i]) pass da=-dabis @@ -233,7 +233,7 @@ class MEDCouplingBasicsTest4(unittest.TestCase): expected2=[-94,-94,-92,-92,-90,-90,-88,-88,-86,-86,-84,-84,-82,-82,-80,-80,-78,-78,-76,-76,-74,-74,-72,-72] self.assertEqual(12,da.getNumberOfTuples()); self.assertEqual(2,da.getNumberOfComponents()); - for i in xrange(24): + for i in range(24): self.assertEqual(da.getIJ(0,i),expected2[i]) pass for pos,elt in enumerate(dabis): @@ -242,16 +242,16 @@ class MEDCouplingBasicsTest4(unittest.TestCase): self.assertEqual(12,da.getNumberOfTuples()); self.assertEqual(2,da.getNumberOfComponents()); expected3=[-88,-87,-84,-83,-80,-79,-76,-75,-72,-71,-68,-67,-64,-63,-60,-59,-56,-55,-52,-51,-48,-47,-44,-43] - for i in xrange(24): + for i in range(24): self.assertEqual(da.getIJ(0,i),expected3[i]) pass # operator*= - da=DataArrayInt.New(range(6,30),12,2) - da2=DataArrayInt.New(range(12),12,1) + da=DataArrayInt.New(list(range(6,30)),12,2) + da2=DataArrayInt.New(list(range(12)),12,1) dabis=-da da*=da2 expected1=[0,0,8,9,20,22,36,39,56,60,80,85,108,114,140,147,176,184,216,225,260,270,308,319] - for i in xrange(24): + for i in range(24): self.assertEqual(da.getIJ(0,i),expected1[i]) pass da=-dabis @@ -259,7 +259,7 @@ class MEDCouplingBasicsTest4(unittest.TestCase): expected2=[600,707,800,909,1000,1111,1200,1313,1400,1515,1600,1717,1800,1919,2000,2121,2200,2323,2400,2525,2600,2727,2800,2929] self.assertEqual(12,da.getNumberOfTuples()); self.assertEqual(2,da.getNumberOfComponents()); - for i in xrange(24): + for i in range(24): self.assertEqual(da.getIJ(0,i),expected2[i]) pass for pos,elt in enumerate(dabis): @@ -268,16 +268,16 @@ class MEDCouplingBasicsTest4(unittest.TestCase): self.assertEqual(12,da.getNumberOfTuples()); self.assertEqual(2,da.getNumberOfComponents()); expected3=[-3600,-4949,-6400,-8181,-10000,-12221,-14400,-17069,-19600,-22725,-25600,-29189,-32400,-36461,-40000,-44541,-48400,-53429,-57600,-63125,-67600,-73629,-78400,-84941.0] - for i in xrange(24): + for i in range(24): self.assertEqual(da.getIJ(0,i),expected3[i]) pass # operator/= - da=DataArrayInt.New(range(6,30),12,2) - da2=DataArrayInt.New(range(1,13),12,1) + da=DataArrayInt.New(list(range(6,30)),12,2) + da2=DataArrayInt.New(list(range(1,13)),12,1) dabis=-da da/=da2 expected1=[6,7,4,4,3,3,3,3,2,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2] - for i in xrange(24): + for i in range(24): self.assertEqual(da.getIJ(0,i),expected1[i]) pass da=-dabis @@ -285,7 +285,7 @@ class MEDCouplingBasicsTest4(unittest.TestCase): self.assertEqual(12,da.getNumberOfTuples()); self.assertEqual(2,da.getNumberOfComponents()); expected2=[3,2,4,3,5,3,6,4,7,5,8,5,9,6,10,7,11,7,12,8,13,9,14,9] - for i in xrange(24): + for i in range(24): self.assertEqual(da.getIJ(0,i),expected2[i]) pass pass @@ -300,13 +300,13 @@ class MEDCouplingBasicsTest4(unittest.TestCase): self.assertEqual(4,da3.getNumberOfTuples()); self.assertEqual(3,da3.getNumberOfComponents()); expected1=[10.,11.,12.,16.,17.,14.,17.,8.,13.,21.,20.,22.] - for i in xrange(12): + for i in range(12): self.assertAlmostEqual(da3.getIJ(0,i),expected1[i],13) pass da3=da2+da self.assertEqual(4,da3.getNumberOfTuples()); self.assertEqual(3,da3.getNumberOfComponents()); - for i in xrange(12): + for i in range(12): self.assertAlmostEqual(da3.getIJ(0,i),expected1[i],13) pass # Test new API of classmethod DataArrayDouble.New @@ -314,31 +314,31 @@ class MEDCouplingBasicsTest4(unittest.TestCase): da=DataArrayDouble.New(vals) self.assertEqual(12,da.getNumberOfTuples()); self.assertEqual(1,da.getNumberOfComponents()); - for i in xrange(12): + for i in range(12): self.assertAlmostEqual(da.getIJ(0,i),vals[i],13) pass da=DataArrayDouble.New(vals,12) self.assertEqual(12,da.getNumberOfTuples()); self.assertEqual(1,da.getNumberOfComponents()); - for i in xrange(12): + for i in range(12): self.assertAlmostEqual(da.getIJ(0,i),vals[i],13) pass da=DataArrayDouble.New(vals,1,12) self.assertEqual(1,da.getNumberOfTuples()); self.assertEqual(12,da.getNumberOfComponents()); - for i in xrange(12): + for i in range(12): self.assertAlmostEqual(da.getIJ(0,i),vals[i],13) pass da=DataArrayDouble.New(vals,6,2) self.assertEqual(6,da.getNumberOfTuples()); self.assertEqual(2,da.getNumberOfComponents()); - for i in xrange(12): + for i in range(12): self.assertAlmostEqual(da.getIJ(0,i),vals[i],13) pass da=DataArrayDouble.New(vals,4,3) self.assertEqual(4,da.getNumberOfTuples()); self.assertEqual(3,da.getNumberOfComponents()); - for i in xrange(12): + for i in range(12): self.assertAlmostEqual(da.getIJ(0,i),vals[i],13) pass self.assertRaises(InterpKernelException,DataArrayDouble.New,vals,11); @@ -357,13 +357,13 @@ class MEDCouplingBasicsTest4(unittest.TestCase): self.assertEqual(4,da3.getNumberOfTuples()); self.assertEqual(3,da3.getNumberOfComponents()); expected1=[10,11,12,16,17,14,17,8,13,21,20,22] - for i in xrange(12): + for i in range(12): self.assertEqual(da3.getIJ(0,i),expected1[i]) pass da3=da2+da self.assertEqual(4,da3.getNumberOfTuples()); self.assertEqual(3,da3.getNumberOfComponents()); - for i in xrange(12): + for i in range(12): self.assertEqual(da3.getIJ(0,i),expected1[i]) pass da3=da+DataArrayInt.New(da2.getValues()) @@ -372,31 +372,31 @@ class MEDCouplingBasicsTest4(unittest.TestCase): da=DataArrayDouble.New(vals) self.assertEqual(12,da.getNumberOfTuples()); self.assertEqual(1,da.getNumberOfComponents()); - for i in xrange(12): + for i in range(12): self.assertEqual(da.getIJ(0,i),vals[i]) pass da=DataArrayDouble.New(vals,12) self.assertEqual(12,da.getNumberOfTuples()); self.assertEqual(1,da.getNumberOfComponents()); - for i in xrange(12): + for i in range(12): self.assertEqual(da.getIJ(0,i),vals[i]) pass da=DataArrayDouble.New(vals,1,12) self.assertEqual(1,da.getNumberOfTuples()); self.assertEqual(12,da.getNumberOfComponents()); - for i in xrange(12): + for i in range(12): self.assertEqual(da.getIJ(0,i),vals[i]) pass da=DataArrayDouble.New(vals,6,2) self.assertEqual(6,da.getNumberOfTuples()); self.assertEqual(2,da.getNumberOfComponents()); - for i in xrange(12): + for i in range(12): self.assertEqual(da.getIJ(0,i),vals[i]) pass da=DataArrayDouble.New(vals,4,3) self.assertEqual(4,da.getNumberOfTuples()); self.assertEqual(3,da.getNumberOfComponents()); - for i in xrange(12): + for i in range(12): self.assertEqual(da.getIJ(0,i),vals[i]) pass self.assertRaises(InterpKernelException,DataArrayDouble.New,vals,11); @@ -502,7 +502,7 @@ class MEDCouplingBasicsTest4(unittest.TestCase): self.assertEqual(8,da2.getNumberOfTuples()); self.assertEqual(1,da2.getNumberOfComponents()); expected1=[8,11,12,9,4,5,6,7] - for i in xrange(8): + for i in range(8): self.assertEqual(expected1[i],da2.getIJ(i,0)); pass # @@ -510,7 +510,7 @@ class MEDCouplingBasicsTest4(unittest.TestCase): self.assertTrue(da1==None); self.assertEqual(9,da2.getNumberOfTuples()); self.assertEqual(1,da2.getNumberOfComponents()); - for i in xrange(9): + for i in range(9): self.assertEqual(8+i,da2.getIJ(i,0)); pass # @@ -533,7 +533,7 @@ class MEDCouplingBasicsTest4(unittest.TestCase): self.assertEqual(expected2,mesh3D_4.getNodalConnectivity().getValues()); self.assertEqual(expected3,mesh2D_4.getNodalConnectivity().getValues()); self.assertEqual(expected4,mesh2D_5.getNodalConnectivity().getValues()); - for i in xrange(78): + for i in range(78): self.assertAlmostEqual(expected5[i],mesh3D_4.getCoords().getIJ(0,i),12); pass # @@ -555,7 +555,7 @@ class MEDCouplingBasicsTest4(unittest.TestCase): self.assertEqual(expected6,mesh3D_4.getNodalConnectivity().getValues()); self.assertEqual(expected7,mesh2D_4.getNodalConnectivity().getValues()); self.assertEqual(expected8,mesh2D_5.getNodalConnectivity().getValues()); - for i in xrange(57): + for i in range(57): self.assertAlmostEqual(expected9[i],mesh3D_4.getCoords().getIJ(0,i),12); pass # @@ -754,12 +754,12 @@ class MEDCouplingBasicsTest4(unittest.TestCase): res=d1.getMinMaxPerComponent(); self.assertTrue(isinstance(res,list)) self.assertEqual(3,len(res)) - for i in xrange(3): + for i in range(3): self.assertTrue(isinstance(res[i],tuple)) self.assertEqual(2,len(res[i])) pass expected1=[-0.9,1.3,1.7,2.1,3.,3.] - for i in xrange(6): + for i in range(6): self.assertAlmostEqual(expected1[i],res[i/2][i%2],14) pass # @@ -767,12 +767,12 @@ class MEDCouplingBasicsTest4(unittest.TestCase): res=d1.getMinMaxPerComponent(); self.assertTrue(isinstance(res,list)) self.assertEqual(2,len(res)) - for i in xrange(2): + for i in range(2): self.assertTrue(isinstance(res[i],tuple)) self.assertEqual(2,len(res[i])) pass expected2=[1.,3.,-0.9,3.] - for i in xrange(4): + for i in range(4): self.assertAlmostEqual(expected2[i],res[i/2][i%2],14) pass # @@ -780,19 +780,19 @@ class MEDCouplingBasicsTest4(unittest.TestCase): res=d1.getMinMaxPerComponent(); self.assertTrue(isinstance(res,list)) self.assertEqual(1,len(res)) - for i in xrange(1): + for i in range(1): self.assertTrue(isinstance(res[i],tuple)) self.assertEqual(2,len(res[i])) pass expected3=[-0.9,3.] - for i in xrange(2): + for i in range(2): self.assertAlmostEqual(expected3[i],res[i/2][i%2],14) pass pass def testDataArrayIntGetHashCode1(self): - d1=DataArrayInt.New(range(3545)) - d2=DataArrayInt.New(range(3545)) + d1=DataArrayInt.New(list(range(3545))) + d2=DataArrayInt.New(list(range(3545))) self.assertEqual(d2.getHashCode(),d1.getHashCode()) self.assertEqual(232341068,d1.getHashCode()) d1[886]=6 @@ -950,7 +950,7 @@ class MEDCouplingBasicsTest4(unittest.TestCase): # m=MEDCouplingUMesh.New("convexhull",2); m.allocateCells(331); - for i in xrange(331): + for i in range(331): m.insertNextCell(NORM_POLYGON,conn[connI[i]:connI[i+1]]); pass m.finishInsertingCells(); @@ -1028,14 +1028,14 @@ class MEDCouplingBasicsTest4(unittest.TestCase): expected3=[1.,2.,4.,5.,6.,7.] self.assertEqual(6,ard1.getNumberOfTuples()); self.assertEqual(1,ard1.getNumberOfComponents()); - for i in xrange(6): + for i in range(6): self.assertAlmostEqual(expected3[i],ard1.getIJ(i,0),12) pass ard2.sort(False); expected4=[7.,6.,5.,4.,2.,1.] self.assertEqual(6,ard2.getNumberOfTuples()); self.assertEqual(1,ard2.getNumberOfComponents()); - for i in xrange(6): + for i in range(6): self.assertAlmostEqual(expected4[i],ard2.getIJ(i,0),12) pass pass @@ -1165,7 +1165,7 @@ class MEDCouplingBasicsTest4(unittest.TestCase): pass def testSwigBugNonRegressionZipDA(self): - angles=map(lambda x:pi/3*x,xrange(6)) + angles=[pi/3*x for x in range(6)] radius=3 # dad=DataArrayDouble.New(6, 2) @@ -1348,7 +1348,7 @@ class MEDCouplingBasicsTest4(unittest.TestCase): valuesToTest=f.getValueOnMulti(targetPointCoordsX); self.assertEqual(40,valuesToTest.getNumberOfTuples()); self.assertEqual(1,valuesToTest.getNumberOfComponents()); - for i in xrange(40): + for i in range(40): self.assertAlmostEqual(targetFieldValsExpected[i],valuesToTest.getIJ(i,0),10) pass fd=f.getDiscretization() @@ -1467,7 +1467,7 @@ class MEDCouplingBasicsTest4(unittest.TestCase): expected1=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,16,16,17,18,19,19,20,20,20,20,20,21,21,22,23,23,24,24,24,24,24,25,25,26,27,27,28,28,28,28,28,29,29,30,31,31,32,32,32,32,32,32,32,32,32,33,33,33,34,35,35,35,36,36,36,36,36,37,37,38,39,39,40,40,40,40,40,41,41,42,43,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59] expected2=[-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,2,-1,-1,-1,0,-1,0,2,4,5,-1,4,-1,-1,0,-1,0,2,4,5,-1,4,-1,-1,0,-1,0,2,4,5,-1,4,-1,-1,0,-1,0,1,2,3,4,5,6,7,-1,4,6,-1,-1,0,1,-1,1,3,6,7,-1,6,-1,-1,1,-1,1,3,6,7,-1,6,-1,-1,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1] f3=m3.getMeasureField(False).getArray().getValues(); - for i in xrange(105): + for i in range(105): self.assertAlmostEqual(areaExpected[i],f3[i],10) pass self.assertEqual(expected1,d1.getValues()) @@ -1529,7 +1529,7 @@ class MEDCouplingBasicsTest4(unittest.TestCase): def testIntersect2DMeshesTmp7(self): eps = 1.0e-8 coords = [-0.5,-0.5, -0.5, 0.5, 0.5, 0.5, 0.5,-0.5] - connec = range(4) + connec = list(range(4)) m1 = MEDCouplingUMesh.New("box", 2) m1.allocateCells(1) meshCoords = DataArrayDouble.New(coords, len(coords)/2, 2) @@ -1549,7 +1549,7 @@ class MEDCouplingBasicsTest4(unittest.TestCase): connI_tgt = [0, 9, 22] res1_tgt = [0, 0] res2_tgt = [0, -1] - self.assert_(coo_tgt.isEqualWithoutConsideringStr(m_intersec.getCoords(), 1e-12)) + self.assertTrue(coo_tgt.isEqualWithoutConsideringStr(m_intersec.getCoords(), 1e-12)) self.assertEqual(conn_tgt, m_intersec.getNodalConnectivity().getValues()) self.assertEqual(connI_tgt, m_intersec.getNodalConnectivityIndex().getValues()) self.assertEqual(res1_tgt, resToM1.getValues()) @@ -1574,15 +1574,15 @@ class MEDCouplingBasicsTest4(unittest.TestCase): coords=DataArrayDouble([0.,0.,0.,1.,1.,1.,1.,0.,0.,0.5,0.5,1.,1.,0.5,0.5,0.],8,2) mQ8=MEDCouplingUMesh("",2) ; mQ8.setCoords(coords) mQ8.allocateCells(1) - mQ8.insertNextCell(NORM_QUAD8,range(8)) + mQ8.insertNextCell(NORM_QUAD8,list(range(8))) mQ8.finishInsertingCells() mQ4=MEDCouplingUMesh("",2) ; mQ4.setCoords(coords) mQ4.allocateCells(1) - mQ4.insertNextCell(NORM_QUAD4,range(4)) + mQ4.insertNextCell(NORM_QUAD4,list(range(4))) mQ4.finishInsertingCells() mT3=MEDCouplingUMesh("",2) ; mT3.setCoords(coords) mT3.allocateCells(1) - mT3.insertNextCell(NORM_TRI3,range(3)) + mT3.insertNextCell(NORM_TRI3,list(range(3))) mT3.finishInsertingCells() tr=[[0.,0.],[2.,0.], [0.,2.],[2.,2.],[4.,2.],[6.,2.],[8.,2.],[10.,2.],[12.,2.],[0.,4.],[2.,4.],[4.,4.],[6.,4.],[8.,4.],[10.,4.],[12.,4.],[14.,4.],[16.,4.],[18.,4.],[20.,4.],[22.,4.]] @@ -1749,7 +1749,7 @@ class MEDCouplingBasicsTest4(unittest.TestCase): def testDAPushBack(self): d=DataArrayDouble(0,1) - for i in xrange(8): + for i in range(8): d.pushBackSilent(i) pass self.assertEqual(d.getNumberOfTuples(),8) @@ -1783,7 +1783,7 @@ class MEDCouplingBasicsTest4(unittest.TestCase): self.assertTrue(d.isEqual(DataArrayDouble([4.44,5.55,6.66]),1e-12)) # d=DataArrayInt(0,1) - for i in xrange(8): + for i in range(8): d.pushBackSilent(i) pass self.assertEqual(d.getNumberOfTuples(),8) @@ -1986,7 +1986,7 @@ class MEDCouplingBasicsTest4(unittest.TestCase): m=MEDCouplingMesh.MergeMeshes([m0,m1,m2,m3,m4]) expected1=DataArrayDouble([0.16666666666666666,0.3333333333333333,0.5,1.,1.]) for v in vects: - for i in xrange(nbOfDisc): + for i in range(nbOfDisc): mm=m.deepCopy() mm.rotate([0.,0.,0.],[0.3,0.7,0.2],float(i)/float(nbOfDisc)*2*pi) mm2=mm.deepCopy() @@ -2009,7 +2009,7 @@ class MEDCouplingBasicsTest4(unittest.TestCase): m=MEDCouplingMesh.MergeMeshes([m0,m1,m2,m3,m4]) expected2=DataArrayDouble([-0.16666666666666666,0.3333333333333333,0.5,-1.,-1.]) for v in vects: - for i in xrange(nbOfDisc): + for i in range(nbOfDisc): mm=m.deepCopy() mm.rotate([0.,0.,0.],[0.3,0.7,0.2],float(i)/float(nbOfDisc)*2*pi) mm2=mm.deepCopy() ; mm3=mm.deepCopy() ; mm3.convertAllToPoly() @@ -2030,12 +2030,12 @@ class MEDCouplingBasicsTest4(unittest.TestCase): m1=MEDCouplingUMesh("m",3) ; m1.allocateCells(0); m1.insertNextCell(NORM_PYRA5,[0,3,2,1,4]); #Not well oriented m2=MEDCouplingUMesh("m",3) ; m2.allocateCells(0); m2.insertNextCell(NORM_PENTA6,[0,2,1,3,5,4]); #Not well oriented m3=MEDCouplingUMesh("m",3) ; m3.allocateCells(0); m3.insertNextCell(NORM_HEXA8,[0,1,2,3,4,5,6,7]); #Well oriented - m4=MEDCouplingUMesh("m",3) ; m4.allocateCells(0); m4.insertNextCell(NORM_HEXGP12,range(12)); #Well oriented + m4=MEDCouplingUMesh("m",3) ; m4.allocateCells(0); m4.insertNextCell(NORM_HEXGP12,list(range(12))); #Well oriented m0.setCoords(c0) ; m1.setCoords(c1) ; m2.setCoords(c2) ; m3.setCoords(c3) ; m4.setCoords(c4) m=MEDCouplingMesh.MergeMeshes([m0,m1,m2,m3,m4]) expected3=DataArrayDouble([0.16666666666666666,-0.3333333333333333,-0.5,1.,1.]) for v in vects: - for i in xrange(nbOfDisc): + for i in range(nbOfDisc): mm=m.deepCopy() mm.rotate([0.,0.,0.],[0.3,0.7,0.2],float(i)/float(nbOfDisc)*2*pi) mm2=mm.deepCopy() ; mm3=mm.deepCopy() ; mm3.convertAllToPoly() @@ -2056,7 +2056,7 @@ class MEDCouplingBasicsTest4(unittest.TestCase): def testSwig2CellOrientation1(self): coords=DataArrayDouble([-0.21606,-0.10803,0.29999999999999999,-0.21606,-0.10803,0.37700000000000006,0,-0.10803,0.29999999999999999,0,-0.10803,0.37700000000000006,0,0.10803,0.29999999999999999,0,0.10803,0.37700000000000006,-0.21606,0.10803,0.29999999999999999,-0.21606,0.10803,0.37700000000000006,0,0.03601,0.29999999999999999,0,0.03601,0.37700000000000006,0,-0.03601,0.29999999999999999,0,-0.03601,0.37700000000000006],12,3) conn=[[0,2,10,8,4,6],[1,3,11,9,5,7],[0,1,3,2],[2,3,11,10],[10,11,9,8],[8,9,5,4],[4,5,7,6],[6,7,1,0]] - for i in xrange(256): + for i in range(256): mesh=MEDCouplingUMesh("FluidMesh_1",3); mesh.allocateCells(0) conn2=[elt[:] for elt in conn] @@ -2187,7 +2187,7 @@ class MEDCouplingBasicsTest4(unittest.TestCase): coords=DataArrayDouble([0.,0.,1.,1.,1.,0.]) ; m.setCoords(coords) da=DataArrayInt([0,1,2]) m.allocateCells(0) - for i in xrange(5): + for i in range(5): m.insertNextCell(NORM_TRI3,da) pass self.assertTrue(m.getNodalConnectivity().isEqual(DataArrayInt([3,0,1,2,3,0,1,2,3,0,1,2,3,0,1,2,3,0,1,2]))) @@ -2195,7 +2195,7 @@ class MEDCouplingBasicsTest4(unittest.TestCase): # da=DataArrayInt([0,1,2,3]) m.allocateCells(0) - for i in xrange(5): + for i in range(5): m.insertNextCell(NORM_TRI3,3,da) pass self.assertTrue(m.getNodalConnectivity().isEqual(DataArrayInt([3,0,1,2,3,0,1,2,3,0,1,2,3,0,1,2,3,0,1,2]))) @@ -2511,8 +2511,8 @@ class MEDCouplingBasicsTest4(unittest.TestCase): m3D.convertLinearCellsToQuadratic(0) m3D.checkConsistency() # check of new m3D content - coordsExp2=[coordsExp.changeNbOfComponents(3,i) for i in xrange(4)] - coordsExp3=[DataArrayDouble.Meld(cooTmp[:,[0,1]],cooTmp[:,2]+(0.5+float(i))) for i in xrange(3)] + coordsExp2=[coordsExp.changeNbOfComponents(3,i) for i in range(4)] + coordsExp3=[DataArrayDouble.Meld(cooTmp[:,[0,1]],cooTmp[:,2]+(0.5+float(i))) for i in range(3)] coordsExp4=DataArrayDouble.Aggregate([coordsExp2[0],coordsExp3[0],coordsExp2[1],coordsExp3[1],coordsExp2[2],coordsExp3[2],coordsExp2[3]]) c=DataArrayDouble.Aggregate(m3D.getCoords(),coordsExp4) self.assertEqual(len(coordsExp4),115) @@ -2718,7 +2718,7 @@ class MEDCouplingBasicsTest4(unittest.TestCase): def testSwig2DataArrayAsciiChar1(self): alpha=DataArrayInt(26) ; alpha.iota(ord("A")) d=DataArrayAsciiChar(alpha.getValues(),2,13) - d.setInfoOnComponents(["c%i"%(v) for v in xrange(13)]) + d.setInfoOnComponents(["c%i"%(v) for v in range(13)]) self.assertEqual('ABCDEFGHIJKLM',d.getTuple(0)) self.assertEqual('NOPQRSTUVWXYZ',d.getTuple(1)) self.assertEqual(2,d.getNumberOfTuples()) @@ -2851,8 +2851,8 @@ class MEDCouplingBasicsTest4(unittest.TestCase): self.assertTrue(mea.getArray().isEqual(DataArrayDouble([-0.08504076274779823,-0.06378057206084897,-0.08504076274779869,-0.10630095343474463,-0.12756114412169625,-0.10630095343474734,-0.0637805720608491,-0.0850407627477968,-0.1063009534347449,-0.0850407627477994,-0.10630095343474809,-0.1275611441216954,-0.037205333702161475,-0.037205333702161475,-0.037205333702161475,-0.037205333702161475,-0.047835429045636084,-0.047835429045636084,-0.047835429045636084,-0.047835429045636084,-0.05846552438911087,-0.05846552438911087,-0.05846552438911087,-0.05846552438911087,-0.037205333702161725,-0.037205333702161725,-0.037205333702161725,-0.037205333702161725,-0.047835429045635834,-0.047835429045635834,-0.047835429045635834,-0.047835429045635834,-0.05846552438911058,-0.05846552438911058,-0.05846552438911058,-0.05846552438911058,-0.03879154890291829,-0.03879154890291829,-0.03879154890291829,-0.04120270848015563,-0.04120270848015563,-0.04120270848015563,-0.03393028948486933,-0.03393028948486933,-0.03393028948486933,-0.03151955746491709,-0.03151955746491709,-0.03151955746491709,-0.02424752187358276,-0.02424752187358276,-0.02424752187358276,-0.026657914642918758,-0.026657914642918758,-0.026657914642918758,-0.04120270848015456,-0.04120270848015456,-0.04120270848015456,-0.03879154890291757,-0.03879154890291757,-0.03879154890291757,-0.031519557464916595,-0.031519557464916595,-0.031519557464916595,-0.03393028948487046,-0.03393028948487046,-0.03393028948487046,-0.0266579146429191,-0.0266579146429191,-0.0266579146429191,-0.024247521873582645,-0.024247521873582645,-0.024247521873582645,-0.01851718920904466,-0.01851718920904466,-0.01851718920904466,-0.01851718920904466,-0.029627502734471456,-0.029627502734471456,-0.029627502734471456,-0.029627502734471456,-0.04740400437515433,-0.015150427534672922,-0.015150427534672922,-0.015150427534672922,-0.015150427534672922,-0.024240684055476674,-0.024240684055476674,-0.024240684055476674,-0.024240684055476674,-0.038785094488762675,-0.011783665860301345,-0.011783665860301345,-0.011783665860301345,-0.011783665860301345,-0.018853865376482152,-0.018853865376482152,-0.018853865376482152,-0.018853865376482152,-0.030166184602371443,-0.018517189209044892,-0.018517189209044892,-0.018517189209044892,-0.018517189209044892,-0.029627502734471827,-0.029627502734471827,-0.029627502734471827,-0.029627502734471827,-0.04740400437515492,-0.015150427534672776,-0.015150427534672776,-0.015150427534672776,-0.015150427534672776,-0.02424068405547644,-0.02424068405547644,-0.02424068405547644,-0.02424068405547644,-0.03878509448876231,-0.011783665860301277,-0.011783665860301277,-0.011783665860301277,-0.011783665860301277,-0.01885386537648204,-0.01885386537648204,-0.01885386537648204,-0.01885386537648204,-0.030166184602371266]),1e-14)) f=MEDCouplingFieldDouble(ft) arr=DataArrayDouble(126,2) - arr[:,0]=range(126) - arr[:,1]=range(126) + arr[:,0]=list(range(126)) + arr[:,1]=list(range(126)) arr[:,1]+=1000 f.setArray(arr) f.checkConsistencyLight() @@ -2913,24 +2913,24 @@ class MEDCouplingBasicsTest4(unittest.TestCase): def testSwig2DAReverseMultiCompo1(self): d=DataArrayDouble(6,2) - d[:,0]=range(6) - d[:,1]=range(10,16) + d[:,0]=list(range(6)) + d[:,1]=list(range(10,16)) d.reverse() self.assertTrue(d.isEqual(DataArrayDouble([5.,15.,4.,14.,3.,13.,2.,12.,1.,11.,0.,10.],6,2),1e-14)) d=DataArrayDouble(7,2) - d[:,0]=range(7) - d[:,1]=range(10,17) + d[:,0]=list(range(7)) + d[:,1]=list(range(10,17)) d.reverse() self.assertTrue(d.isEqual(DataArrayDouble([6.,16.,5.,15.,4.,14.,3.,13.,2.,12.,1.,11.,0.,10.],7,2),1e-14)) # d=DataArrayInt(6,2) - d[:,0]=range(6) - d[:,1]=range(10,16) + d[:,0]=list(range(6)) + d[:,1]=list(range(10,16)) d.reverse() self.assertTrue(d.isEqual(DataArrayInt([5,15,4,14,3,13,2,12,1,11,0,10],6,2))) d=DataArrayInt(7,2) - d[:,0]=range(7) - d[:,1]=range(10,17) + d[:,0]=list(range(7)) + d[:,1]=list(range(10,17)) d.reverse() self.assertTrue(d.isEqual(DataArrayInt([6,16,5,15,4,14,3,13,2,12,1,11,0,10],7,2))) pass @@ -3007,16 +3007,16 @@ class MEDCouplingBasicsTest4(unittest.TestCase): d=DataArrayDouble() self.assertTrue(len(d.__repr__())<120) d.alloc(1000,0) ; self.assertTrue(len(d.__repr__())<100) - for i in xrange(100): + for i in range(100): d.alloc(i,1) ; d.iota(1.1234567890123456) ; d*=1e123 self.assertTrue(len(d.__repr__())<500) pass - for i in xrange(50): + for i in range(50): d.alloc(i,2) ; d.rearrange(1) ; d.iota(1.1234567890123456) ; d.rearrange(2) ; d*=1e123 self.assertTrue(len(d.__repr__())<500) pass d.alloc(4000,1) ; d.iota() ; self.assertTrue(len(d.__repr__())<500) - for i in xrange(2,4): + for i in range(2,4): d.alloc(362880,1) ; d.iota() ; d.rearrange(i) ; self.assertTrue(len(d.__repr__())<500) pass d.alloc(0,9) @@ -3025,16 +3025,16 @@ class MEDCouplingBasicsTest4(unittest.TestCase): d=DataArrayInt() self.assertTrue(len(d.__repr__())<100) d.alloc(1000,0) ; self.assertTrue(len(d.__repr__())<100) - for i in xrange(100): + for i in range(100): d.alloc(i,1) ; d.iota(123456789) self.assertTrue(len(d.__repr__())<500) pass - for i in xrange(50): + for i in range(50): d.alloc(i,2) ; d.rearrange(1) ; d.iota(123456789) ; d.rearrange(2) self.assertTrue(len(d.__repr__())<500) pass d.alloc(4000,1) ; d.iota() ; self.assertTrue(len(d.__repr__())<500) - for i in xrange(2,10): + for i in range(2,10): d.alloc(362880,1) ; d.iota() ; d.rearrange(i) ; self.assertTrue(len(d.__repr__())<500) pass d.alloc(0,9) @@ -3100,7 +3100,7 @@ class MEDCouplingBasicsTest4(unittest.TestCase): m2.allocateCells(0) m2.setCoords(coo) conn2=[[0,3,5,1,7,4,6,2],[12,14,16,18,13,15,17,19],[0,12,18,3,8,19,11,7],[3,18,16,5,11,17,10,4],[5,16,14,1,10,15,9,6],[1,14,12,0,9,13,8,2]] - for i in xrange(6): + for i in range(6): m2.insertNextCell(NORM_QUAD8,conn2[i]) pass self.assertTrue(m2.isEqual(a,1e-12)) @@ -3123,7 +3123,7 @@ class MEDCouplingBasicsTest4(unittest.TestCase): conn4=[[0,2,3,1,8,9,10,11,20],[4,5,6,7,15,14,13,12,25],[0,4,7,2,16,12,17,8,21],[2,7,6,3,17,13,18,9,22],[3,6,5,1,18,14,19,10,23],[1,5,4,0,19,15,16,11,24]] m4=MEDCouplingUMesh("mesh",2) m4.allocateCells(0) - for i in xrange(6): + for i in range(6): m4.insertNextCell(NORM_QUAD9,conn4[i]) pass m4.setCoords(coo2) @@ -3200,20 +3200,20 @@ class MEDCouplingBasicsTest4(unittest.TestCase): f=MEDCouplingFieldDouble(ON_CELLS) f.setMesh(m) arr=DataArrayDouble(5,2) - arr[:,0]=range(5) ; arr[:,1]=2*arr[:,0] + arr[:,0]=list(range(5)) ; arr[:,1]=2*arr[:,0] f2=f.clone(True) self.assertRaises(InterpKernelException,f.__add__,2) - self.assertRaises(InterpKernelException,f.__add__,range(5)) + self.assertRaises(InterpKernelException,f.__add__,list(range(5))) self.assertRaises(InterpKernelException,f.__add__,arr) self.assertRaises(InterpKernelException,f.__add__,f2) f.setArray(DataArrayDouble()) self.assertRaises(InterpKernelException,f.__add__,2) - self.assertRaises(InterpKernelException,f.__add__,range(5)) + self.assertRaises(InterpKernelException,f.__add__,list(range(5))) self.assertRaises(InterpKernelException,f.__add__,arr) self.assertRaises(InterpKernelException,f.__add__,f2) self.assertRaises(InterpKernelException,f.__getitem__,(slice(None),0)) f.getArray().alloc(5,2) - f.getArray()[:,0]=range(5) ; f.getArray()[:,1]=f.getArray()[:,0]+7 + f.getArray()[:,0]=list(range(5)) ; f.getArray()[:,1]=f.getArray()[:,0]+7 ff=f+2 ff.checkConsistencyLight() self.assertTrue(ff.getArray().isEqual(DataArrayDouble([(2,9),(3,10),(4,11),(5,12),(6,13)]),1e-12)) @@ -3232,20 +3232,20 @@ class MEDCouplingBasicsTest4(unittest.TestCase): f=MEDCouplingFieldDouble(ON_CELLS) f.setMesh(m) arr=DataArrayDouble(5,2) - arr[:,0]=range(5) ; arr[:,1]=2*arr[:,0] + arr[:,0]=list(range(5)) ; arr[:,1]=2*arr[:,0] f2=f.clone(True) self.assertRaises(InterpKernelException,f.__sub__,2) - self.assertRaises(InterpKernelException,f.__sub__,range(5)) + self.assertRaises(InterpKernelException,f.__sub__,list(range(5))) self.assertRaises(InterpKernelException,f.__sub__,arr) self.assertRaises(InterpKernelException,f.__sub__,f2) f.setArray(DataArrayDouble()) self.assertRaises(InterpKernelException,f.__sub__,2) - self.assertRaises(InterpKernelException,f.__sub__,range(5)) + self.assertRaises(InterpKernelException,f.__sub__,list(range(5))) self.assertRaises(InterpKernelException,f.__sub__,arr) self.assertRaises(InterpKernelException,f.__sub__,f2) self.assertRaises(InterpKernelException,f.__getitem__,(slice(None),0)) f.getArray().alloc(5,2) - f.getArray()[:,0]=range(5) ; f.getArray()[:,1]=f.getArray()[:,0]+7 + f.getArray()[:,0]=list(range(5)) ; f.getArray()[:,1]=f.getArray()[:,0]+7 ff=f-2 ff.checkConsistencyLight() self.assertTrue(ff.getArray().isEqual(DataArrayDouble([(-2,5),(-1,6),(0,7),(1,8),(2,9)]),1e-12)) @@ -3264,20 +3264,20 @@ class MEDCouplingBasicsTest4(unittest.TestCase): f=MEDCouplingFieldDouble(ON_CELLS) f.setMesh(m) arr=DataArrayDouble(5,2) - arr[:,0]=range(5) ; arr[:,1]=2*arr[:,0] + arr[:,0]=list(range(5)) ; arr[:,1]=2*arr[:,0] f2=f.clone(True) self.assertRaises(InterpKernelException,f.__mul__,2) - self.assertRaises(InterpKernelException,f.__mul__,range(5)) + self.assertRaises(InterpKernelException,f.__mul__,list(range(5))) self.assertRaises(InterpKernelException,f.__mul__,arr) self.assertRaises(InterpKernelException,f.__mul__,f2) f.setArray(DataArrayDouble()) self.assertRaises(InterpKernelException,f.__mul__,2) - self.assertRaises(InterpKernelException,f.__mul__,range(5)) + self.assertRaises(InterpKernelException,f.__mul__,list(range(5))) self.assertRaises(InterpKernelException,f.__mul__,arr) self.assertRaises(InterpKernelException,f.__mul__,f2) self.assertRaises(InterpKernelException,f.__getitem__,(slice(None),0)) f.getArray().alloc(5,2) - f.getArray()[:,0]=range(5) ; f.getArray()[:,1]=f.getArray()[:,0]+7 + f.getArray()[:,0]=list(range(5)) ; f.getArray()[:,1]=f.getArray()[:,0]+7 ff=f*2 ff.checkConsistencyLight() self.assertTrue(ff.getArray().isEqual(DataArrayDouble([(0,14),(2,16),(4,18),(6,20),(8,22)]),1e-12)) @@ -3296,20 +3296,20 @@ class MEDCouplingBasicsTest4(unittest.TestCase): f=MEDCouplingFieldDouble(ON_CELLS) f.setMesh(m) arr=DataArrayDouble(5,2) - arr[:,0]=range(1,6) ; arr[:,1]=2*arr[:,0] + arr[:,0]=list(range(1,6)) ; arr[:,1]=2*arr[:,0] f2=f.clone(True) self.assertRaises(InterpKernelException,f.__div__,2) - self.assertRaises(InterpKernelException,f.__div__,range(5)) + self.assertRaises(InterpKernelException,f.__div__,list(range(5))) self.assertRaises(InterpKernelException,f.__div__,arr) self.assertRaises(InterpKernelException,f.__div__,f2) f.setArray(DataArrayDouble()) self.assertRaises(InterpKernelException,f.__div__,2) - self.assertRaises(InterpKernelException,f.__div__,range(5)) + self.assertRaises(InterpKernelException,f.__div__,list(range(5))) self.assertRaises(InterpKernelException,f.__div__,arr) self.assertRaises(InterpKernelException,f.__div__,f2) self.assertRaises(InterpKernelException,f.__getitem__,(slice(None),0)) f.getArray().alloc(5,2) - f.getArray()[:,0]=range(5) ; f.getArray()[:,1]=f.getArray()[:,0]+7 + f.getArray()[:,0]=list(range(5)) ; f.getArray()[:,1]=f.getArray()[:,0]+7 self.assertRaises(InterpKernelException,f.__div__,0) ff=f/2 ff.checkConsistencyLight() @@ -3332,17 +3332,17 @@ class MEDCouplingBasicsTest4(unittest.TestCase): arr[:]=[1,1,3,2,0] f2=f.clone(True) self.assertRaises(InterpKernelException,f.__div__,2) - self.assertRaises(InterpKernelException,f.__div__,range(5)) + self.assertRaises(InterpKernelException,f.__div__,list(range(5))) self.assertRaises(InterpKernelException,f.__div__,arr) self.assertRaises(InterpKernelException,f.__div__,f2) f.setArray(DataArrayDouble()) self.assertRaises(InterpKernelException,f.__div__,2) - self.assertRaises(InterpKernelException,f.__div__,range(5)) + self.assertRaises(InterpKernelException,f.__div__,list(range(5))) self.assertRaises(InterpKernelException,f.__div__,arr) self.assertRaises(InterpKernelException,f.__div__,f2) self.assertRaises(InterpKernelException,f.__getitem__,(slice(None),0)) f.getArray().alloc(5,1) - f.getArray()[:]=range(2,7) + f.getArray()[:]=list(range(2,7)) ff=f**2 ff.checkConsistencyLight() self.assertTrue(ff.getArray().isEqual(DataArrayDouble([4,9,16,25,36]),1e-12)) @@ -3358,19 +3358,19 @@ class MEDCouplingBasicsTest4(unittest.TestCase): f=MEDCouplingFieldDouble(ON_CELLS) f.setMesh(m) arr=DataArrayDouble(5,2) - arr[:,0]=range(5) ; arr[:,1]=2*arr[:,0] + arr[:,0]=list(range(5)) ; arr[:,1]=2*arr[:,0] f2=f.clone(True) self.assertRaises(InterpKernelException,f.__iadd__,2) - self.assertRaises(InterpKernelException,f.__iadd__,range(5)) + self.assertRaises(InterpKernelException,f.__iadd__,list(range(5))) self.assertRaises(InterpKernelException,f.__iadd__,arr) self.assertRaises(InterpKernelException,f.__iadd__,f2) f.setArray(DataArrayDouble()) self.assertRaises(InterpKernelException,f.__iadd__,2) - self.assertRaises(InterpKernelException,f.__iadd__,range(5)) + self.assertRaises(InterpKernelException,f.__iadd__,list(range(5))) self.assertRaises(InterpKernelException,f.__iadd__,arr) self.assertRaises(InterpKernelException,f.__iadd__,f2) f.getArray().alloc(5,2) - f.getArray()[:,0]=range(5) ; f.getArray()[:,1]=f.getArray()[:,0]+7 + f.getArray()[:,0]=list(range(5)) ; f.getArray()[:,1]=f.getArray()[:,0]+7 f.checkConsistencyLight() f+=2 f.checkConsistencyLight() @@ -3390,19 +3390,19 @@ class MEDCouplingBasicsTest4(unittest.TestCase): f=MEDCouplingFieldDouble(ON_CELLS) f.setMesh(m) arr=DataArrayDouble(5,2) - arr[:,0]=range(5) ; arr[:,1]=2*arr[:,0] + arr[:,0]=list(range(5)) ; arr[:,1]=2*arr[:,0] f2=f.clone(True) self.assertRaises(InterpKernelException,f.__isub__,2) - self.assertRaises(InterpKernelException,f.__isub__,range(5)) + self.assertRaises(InterpKernelException,f.__isub__,list(range(5))) self.assertRaises(InterpKernelException,f.__isub__,arr) self.assertRaises(InterpKernelException,f.__isub__,f2) f.setArray(DataArrayDouble()) self.assertRaises(InterpKernelException,f.__isub__,2) - self.assertRaises(InterpKernelException,f.__isub__,range(5)) + self.assertRaises(InterpKernelException,f.__isub__,list(range(5))) self.assertRaises(InterpKernelException,f.__isub__,arr) self.assertRaises(InterpKernelException,f.__isub__,f2) f.getArray().alloc(5,2) - f.getArray()[:,0]=range(5) ; f.getArray()[:,1]=f.getArray()[:,0]+7 + f.getArray()[:,0]=list(range(5)) ; f.getArray()[:,1]=f.getArray()[:,0]+7 f.checkConsistencyLight() f-=2 f.checkConsistencyLight() @@ -3422,19 +3422,19 @@ class MEDCouplingBasicsTest4(unittest.TestCase): f=MEDCouplingFieldDouble(ON_CELLS) f.setMesh(m) arr=DataArrayDouble(5,2) - arr[:,0]=range(5) ; arr[:,1]=2*arr[:,0] + arr[:,0]=list(range(5)) ; arr[:,1]=2*arr[:,0] f2=f.clone(True) self.assertRaises(InterpKernelException,f.__imul__,2) - self.assertRaises(InterpKernelException,f.__imul__,range(5)) + self.assertRaises(InterpKernelException,f.__imul__,list(range(5))) self.assertRaises(InterpKernelException,f.__imul__,arr) self.assertRaises(InterpKernelException,f.__imul__,f2) f.setArray(DataArrayDouble()) self.assertRaises(InterpKernelException,f.__imul__,2) - self.assertRaises(InterpKernelException,f.__imul__,range(5)) + self.assertRaises(InterpKernelException,f.__imul__,list(range(5))) self.assertRaises(InterpKernelException,f.__imul__,arr) self.assertRaises(InterpKernelException,f.__imul__,f2) f.getArray().alloc(5,2) - f.getArray()[:,0]=range(5) ; f.getArray()[:,1]=f.getArray()[:,0]+7 + f.getArray()[:,0]=list(range(5)) ; f.getArray()[:,1]=f.getArray()[:,0]+7 f.checkConsistencyLight() f*=2 f.checkConsistencyLight() @@ -3454,19 +3454,19 @@ class MEDCouplingBasicsTest4(unittest.TestCase): f=MEDCouplingFieldDouble(ON_CELLS) f.setMesh(m) arr=DataArrayDouble(5,2) - arr[:,0]=range(1,6) ; arr[:,1]=2*arr[:,0] + arr[:,0]=list(range(1,6)) ; arr[:,1]=2*arr[:,0] f2=f.clone(True) self.assertRaises(InterpKernelException,f.__idiv__,2) - self.assertRaises(InterpKernelException,f.__idiv__,range(5)) + self.assertRaises(InterpKernelException,f.__idiv__,list(range(5))) self.assertRaises(InterpKernelException,f.__idiv__,arr) self.assertRaises(InterpKernelException,f.__idiv__,f2) f.setArray(DataArrayDouble()) self.assertRaises(InterpKernelException,f.__idiv__,2) - self.assertRaises(InterpKernelException,f.__idiv__,range(5)) + self.assertRaises(InterpKernelException,f.__idiv__,list(range(5))) self.assertRaises(InterpKernelException,f.__idiv__,arr) self.assertRaises(InterpKernelException,f.__idiv__,f2) f.getArray().alloc(5,2) - f.getArray()[:,0]=range(5) ; f.getArray()[:,1]=f.getArray()[:,0]+7 + f.getArray()[:,0]=list(range(5)) ; f.getArray()[:,1]=f.getArray()[:,0]+7 f.checkConsistencyLight() f/=2 f.checkConsistencyLight() @@ -3486,19 +3486,19 @@ class MEDCouplingBasicsTest4(unittest.TestCase): f=MEDCouplingFieldDouble(ON_CELLS) f.setMesh(m) arr=DataArrayDouble(5,2) - arr[:,0]=range(1,6) ; arr[:,1]=2*arr[:,0] + arr[:,0]=list(range(1,6)) ; arr[:,1]=2*arr[:,0] f2=f.clone(True) self.assertRaises(InterpKernelException,f.__ipow__,2) - self.assertRaises(InterpKernelException,f.__ipow__,range(5)) + self.assertRaises(InterpKernelException,f.__ipow__,list(range(5))) self.assertRaises(InterpKernelException,f.__ipow__,arr) self.assertRaises(InterpKernelException,f.__ipow__,f2) f.setArray(DataArrayDouble()) self.assertRaises(InterpKernelException,f.__ipow__,2) - self.assertRaises(InterpKernelException,f.__ipow__,range(5)) + self.assertRaises(InterpKernelException,f.__ipow__,list(range(5))) self.assertRaises(InterpKernelException,f.__ipow__,arr) self.assertRaises(InterpKernelException,f.__ipow__,f2) f.getArray().alloc(5,2) - f.getArray()[:,0]=range(5) ; f.getArray()[:,1]=f.getArray()[:,0]+7 + f.getArray()[:,0]=list(range(5)) ; f.getArray()[:,1]=f.getArray()[:,0]+7 f.checkConsistencyLight() f**=2 f.checkConsistencyLight() @@ -3508,20 +3508,20 @@ class MEDCouplingBasicsTest4(unittest.TestCase): f=MEDCouplingFieldDouble(ON_CELLS) f.setMesh(m) arr=DataArrayDouble(5,2) - arr[:,0]=range(5) ; arr[:,1]=2*arr[:,0] + arr[:,0]=list(range(5)) ; arr[:,1]=2*arr[:,0] f2=f.clone(True) self.assertRaises(InterpKernelException,f.__radd__,2) - self.assertRaises(InterpKernelException,f.__radd__,range(5)) + self.assertRaises(InterpKernelException,f.__radd__,list(range(5))) self.assertRaises(InterpKernelException,f.__radd__,arr) self.assertRaises(InterpKernelException,f.__radd__,f2) f.setArray(DataArrayDouble()) self.assertRaises(InterpKernelException,f.__radd__,2) - self.assertRaises(InterpKernelException,f.__radd__,range(5)) + self.assertRaises(InterpKernelException,f.__radd__,list(range(5))) self.assertRaises(InterpKernelException,f.__radd__,arr) self.assertRaises(InterpKernelException,f.__radd__,f2) self.assertRaises(InterpKernelException,f.__getitem__,(slice(None),0)) f.getArray().alloc(5,2) - f.getArray()[:,0]=range(5) ; f.getArray()[:,1]=f.getArray()[:,0]+7 + f.getArray()[:,0]=list(range(5)) ; f.getArray()[:,1]=f.getArray()[:,0]+7 ff=2+f ff.checkConsistencyLight() self.assertTrue(ff.getArray().isEqual(DataArrayDouble([(2,9),(3,10),(4,11),(5,12),(6,13)]),1e-12)) @@ -3536,20 +3536,20 @@ class MEDCouplingBasicsTest4(unittest.TestCase): f=MEDCouplingFieldDouble(ON_CELLS) f.setMesh(m) arr=DataArrayDouble(5,2) - arr[:,0]=range(5) ; arr[:,1]=2*arr[:,0] + arr[:,0]=list(range(5)) ; arr[:,1]=2*arr[:,0] f2=f.clone(True) self.assertRaises(InterpKernelException,f.__rsub__,2) - self.assertRaises(InterpKernelException,f.__rsub__,range(5)) + self.assertRaises(InterpKernelException,f.__rsub__,list(range(5))) self.assertRaises(InterpKernelException,f.__rsub__,arr) self.assertRaises(InterpKernelException,f.__rsub__,f2) f.setArray(DataArrayDouble()) self.assertRaises(InterpKernelException,f.__rsub__,2) - self.assertRaises(InterpKernelException,f.__rsub__,range(5)) + self.assertRaises(InterpKernelException,f.__rsub__,list(range(5))) self.assertRaises(InterpKernelException,f.__rsub__,arr) self.assertRaises(InterpKernelException,f.__rsub__,f2) self.assertRaises(InterpKernelException,f.__getitem__,(slice(None),0)) f.getArray().alloc(5,2) - f.getArray()[:,0]=range(5) ; f.getArray()[:,1]=f.getArray()[:,0]+7 + f.getArray()[:,0]=list(range(5)) ; f.getArray()[:,1]=f.getArray()[:,0]+7 ff=2-f ff.checkConsistencyLight() self.assertTrue(ff.getArray().isEqual(DataArrayDouble([(2,-5),(1,-6),(0,-7),(-1,-8),(-2,-9)]),1e-12)) @@ -3562,20 +3562,20 @@ class MEDCouplingBasicsTest4(unittest.TestCase): f=MEDCouplingFieldDouble(ON_CELLS) f.setMesh(m) arr=DataArrayDouble(5,2) - arr[:,0]=range(5) ; arr[:,1]=2*arr[:,0] + arr[:,0]=list(range(5)) ; arr[:,1]=2*arr[:,0] f2=f.clone(True) self.assertRaises(InterpKernelException,f.__rmul__,2) - self.assertRaises(InterpKernelException,f.__rmul__,range(5)) + self.assertRaises(InterpKernelException,f.__rmul__,list(range(5))) self.assertRaises(InterpKernelException,f.__rmul__,arr) self.assertRaises(InterpKernelException,f.__rmul__,f2) f.setArray(DataArrayDouble()) self.assertRaises(InterpKernelException,f.__rmul__,2) - self.assertRaises(InterpKernelException,f.__rmul__,range(5)) + self.assertRaises(InterpKernelException,f.__rmul__,list(range(5))) self.assertRaises(InterpKernelException,f.__rmul__,arr) self.assertRaises(InterpKernelException,f.__rmul__,f2) self.assertRaises(InterpKernelException,f.__getitem__,(slice(None),0)) f.getArray().alloc(5,2) - f.getArray()[:,0]=range(5) ; f.getArray()[:,1]=f.getArray()[:,0]+7 + f.getArray()[:,0]=list(range(5)) ; f.getArray()[:,1]=f.getArray()[:,0]+7 ff=2*f ff.checkConsistencyLight() self.assertTrue(ff.getArray().isEqual(DataArrayDouble([(0,14),(2,16),(4,18),(6,20),(8,22)]),1e-12)) @@ -3590,20 +3590,20 @@ class MEDCouplingBasicsTest4(unittest.TestCase): f=MEDCouplingFieldDouble(ON_CELLS) f.setMesh(m) arr=DataArrayDouble(5,2) - arr[:,0]=range(1,6) ; arr[:,1]=2*arr[:,0] + arr[:,0]=list(range(1,6)) ; arr[:,1]=2*arr[:,0] f2=f.clone(True) self.assertRaises(InterpKernelException,f.__rdiv__,2) - self.assertRaises(InterpKernelException,f.__rdiv__,range(5)) + self.assertRaises(InterpKernelException,f.__rdiv__,list(range(5))) self.assertRaises(InterpKernelException,f.__rdiv__,arr) self.assertRaises(InterpKernelException,f.__rdiv__,f2) f.setArray(DataArrayDouble()) self.assertRaises(InterpKernelException,f.__rdiv__,2) - self.assertRaises(InterpKernelException,f.__rdiv__,range(5)) + self.assertRaises(InterpKernelException,f.__rdiv__,list(range(5))) self.assertRaises(InterpKernelException,f.__rdiv__,arr) self.assertRaises(InterpKernelException,f.__rdiv__,f2) self.assertRaises(InterpKernelException,f.__getitem__,(slice(None),0)) f.getArray().alloc(5,2) - f.getArray()[:,0]=range(1,6) ; f.getArray()[:,1]=f.getArray()[:,0]+7 + f.getArray()[:,0]=list(range(1,6)) ; f.getArray()[:,1]=f.getArray()[:,0]+7 ff=2/f ff.checkConsistencyLight() self.assertTrue(ff.getArray().isEqual(DataArrayDouble([(2,0.25),(1,0.22222222222222221),(0.66666666666666663,0.20000000000000001),(0.5,0.18181818181818182),(0.40000000000000002,0.16666666666666666)]),1e-12)) diff --git a/src/MEDCoupling_Swig/MEDCouplingBasicsTest5.py b/src/MEDCoupling_Swig/MEDCouplingBasicsTest5.py index b0684f46d..4bb720eef 100644 --- a/src/MEDCoupling_Swig/MEDCouplingBasicsTest5.py +++ b/src/MEDCoupling_Swig/MEDCouplingBasicsTest5.py @@ -31,7 +31,7 @@ class MEDCouplingBasicsTest5(unittest.TestCase): m=MEDCouplingDataForTest.build2DTargetMesh_1() f=MEDCouplingFieldDouble(ON_CELLS) f.setMesh(m) - arr=DataArrayDouble(5,2) ; arr[:,0]=range(7,12) ; arr[:,1]=100+arr[:,0] + arr=DataArrayDouble(5,2) ; arr[:,0]=list(range(7,12)) ; arr[:,1]=100+arr[:,0] f.setArray(arr) f.checkConsistencyLight() ff=f[1:-1:2] @@ -61,7 +61,7 @@ class MEDCouplingBasicsTest5(unittest.TestCase): #ON_NODES f=MEDCouplingFieldDouble(ON_NODES) f.setMesh(m) - arr=DataArrayDouble(9,2) ; arr[:,0]=range(7,16) ; arr[:,1]=100+arr[:,0] + arr=DataArrayDouble(9,2) ; arr[:,0]=list(range(7,16)) ; arr[:,1]=100+arr[:,0] f.setArray(arr) f.checkConsistencyLight() ff=f[1:-1:2] @@ -96,7 +96,7 @@ class MEDCouplingBasicsTest5(unittest.TestCase): #ON_GAUSS_NE f=MEDCouplingFieldDouble(ON_GAUSS_NE) f.setMesh(m) - arr=DataArrayDouble(18,2) ; arr[:,0]=range(7,25) ; arr[:,1]=100+arr[:,0] + arr=DataArrayDouble(18,2) ; arr[:,0]=list(range(7,25)) ; arr[:,1]=100+arr[:,0] f.setArray(arr) f.checkConsistencyLight() ff=f[1:-1:2] @@ -130,7 +130,7 @@ class MEDCouplingBasicsTest5(unittest.TestCase): f.setGaussLocalizationOnCells([3],[0,0,1,0,1,1,1,0],[1.1,1.1,2.2,2.2,3.,3.],[0.2,0.4,0.4]); f.setGaussLocalizationOnCells([1],[0,0,1,0,1,0],[1.1,1.1,2.2,2.2,3.,3.,4.,4.],[0.1,0.1,0.4,0.4]); f.setGaussLocalizationOnCells([2],[0,0,1,0,1,0],[1.1,1.1,2.2,2.2,3.,3.,4.,4.,5.,5.],[0.1,0.1,0.4,0.3,0.1]); - arr=DataArrayDouble(16,2) ; arr[:,0]=range(7,23) ; arr[:,1]=100+arr[:,0] + arr=DataArrayDouble(16,2) ; arr[:,0]=list(range(7,23)) ; arr[:,1]=100+arr[:,0] f.setArray(arr) f.checkConsistencyLight() ff=f[1:-1:2] @@ -230,7 +230,7 @@ class MEDCouplingBasicsTest5(unittest.TestCase): time_deb = datetime.now() a1=DataArrayDouble(len(d)) b1=DataArrayInt(len(d)) - m1s=[m1[i] for i in xrange(m1.getNumberOfCells())] + m1s=[m1[i] for i in range(m1.getNumberOfCells())] for j,pt in enumerate(d): eter=1e308 fter=-1 @@ -258,7 +258,7 @@ class MEDCouplingBasicsTest5(unittest.TestCase): m=MEDCouplingUMesh("mesh",2) m.setCoords(coo) m.allocateCells() - for i in xrange(24): + for i in range(24): m.insertNextCell(NORM_QUAD4,conn[4*i:4*i+4]) pass m.checkConsistency() @@ -288,7 +288,7 @@ class MEDCouplingBasicsTest5(unittest.TestCase): d[:,1]*=pi/180. # angle in radian d=d.fromPolarToCart() d+=zeBary - m=MEDCouplingUMesh("quad8",2) ; m.allocateCells() ; m.insertNextCell(NORM_QUAD8,range(8)) ; m.setCoords(d) + m=MEDCouplingUMesh("quad8",2) ; m.allocateCells() ; m.insertNextCell(NORM_QUAD8,list(range(8))) ; m.setCoords(d) self.assertTrue(m.computeCellCenterOfMass().isEqual(DataArrayDouble(zeBary,1,2),1e-13)) self.assertAlmostEqual(float(m.getMeasureField(False).getArray()),pi*zeRadius*zeRadius,12) tri32D=m.buildDescendingConnectivity()[0][0] ; tri32D.zipCoords() @@ -307,7 +307,7 @@ class MEDCouplingBasicsTest5(unittest.TestCase): d[:,1]*=pi/180. # angle in radian d=d.fromPolarToCart() d+=zeBary - m=MEDCouplingUMesh("tri6",2) ; m.allocateCells() ; m.insertNextCell(NORM_TRI6,range(6)) ; m.setCoords(d) + m=MEDCouplingUMesh("tri6",2) ; m.allocateCells() ; m.insertNextCell(NORM_TRI6,list(range(6))) ; m.setCoords(d) self.assertTrue(m.computeCellCenterOfMass().isEqual(DataArrayDouble(zeBary,1,2),1e-13)) self.assertAlmostEqual(float(m.getMeasureField(False).getArray()),pi*zeRadius*zeRadius,12) # spaceDim=3 TRI6 becomes TRI3 ... for the moment @@ -325,7 +325,7 @@ class MEDCouplingBasicsTest5(unittest.TestCase): d[:,1]*=pi/180. # angle in radian d=d.fromPolarToCart() d+=zeBary - m=MEDCouplingUMesh("qpolyg",2) ; m.allocateCells() ; m.insertNextCell(NORM_QPOLYG,range(10)) ; m.setCoords(d) + m=MEDCouplingUMesh("qpolyg",2) ; m.allocateCells() ; m.insertNextCell(NORM_QPOLYG,list(range(10))) ; m.setCoords(d) self.assertTrue(m.computeCellCenterOfMass().isEqual(DataArrayDouble(zeBary,1,2),1e-13)) self.assertAlmostEqual(float(m.getMeasureField(False).getArray()),pi*zeRadius*zeRadius,12) # spaceDim=3 QPOLYG becomes POLYG ... for the moment @@ -469,7 +469,7 @@ class MEDCouplingBasicsTest5(unittest.TestCase): s=slice(18,1,-2) self.assertEqual(DataArray.GetNumberOfItemGivenBESRelative(s),9) self.assertRaises(InterpKernelException,DataArray.GetNumberOfItemGivenBES,s) - self.assertEqual(sum([DataArray.GetNumberOfItemGivenBESRelative(DataArray.GetSlice(s,i,4)) for i in xrange(4)]),DataArray.GetNumberOfItemGivenBESRelative(s)) + self.assertEqual(sum([DataArray.GetNumberOfItemGivenBESRelative(DataArray.GetSlice(s,i,4)) for i in range(4)]),DataArray.GetNumberOfItemGivenBESRelative(s)) self.assertEqual(DataArray.GetSlice(s,0,4),slice(18,14,-2)) self.assertEqual(DataArray.GetSlice(s,1,4),slice(14,10,-2)) self.assertEqual(DataArray.GetSlice(s,2,4),slice(10,6,-2)) @@ -537,7 +537,7 @@ class MEDCouplingBasicsTest5(unittest.TestCase): # maxNbCSN=nbOfCellsSharingNodes.getMaxValue()[0] arr3=DataArrayDouble(f.getMesh().getNumberOfNodes(),f.getArray().getNumberOfComponents()) ; arr3[:]=0. - for i in xrange(1,maxNbCSN+1): + for i in range(1,maxNbCSN+1): ids=nbOfCellsSharingNodes.findIdsEqual(i) if len(ids)==0: continue @@ -601,7 +601,7 @@ class MEDCouplingBasicsTest5(unittest.TestCase): m=MEDCoupling1SGTUMesh("m",NORM_QUAD4) mem_m=m.getHeapMemorySize() m.allocateCells(5) - self.assertIn(m.getHeapMemorySize()-mem_m,xrange(5*4*4,5*4*4+32)) + self.assertIn(m.getHeapMemorySize()-mem_m,range(5*4*4,5*4*4+32)) self.assertEqual(m.getNodalConnectivity().getNbOfElemAllocated(),20) m.setCoords(um.getCoords()) m.insertNextCell([1,0,6,7]) @@ -1405,7 +1405,7 @@ class MEDCouplingBasicsTest5(unittest.TestCase): valuesToTest=f.getValueOnMulti(targetPointCoordsXY); self.assertEqual(196,valuesToTest.getNumberOfTuples()); self.assertEqual(1,valuesToTest.getNumberOfComponents()); - for i in xrange(40): + for i in range(40): self.assertAlmostEqual(targetFieldValsExpected[i],valuesToTest.getIJ(i,0),10) pass fd=f.getDiscretization() @@ -1572,7 +1572,7 @@ class MEDCouplingBasicsTest5(unittest.TestCase): # trs=[[0.,0.,-1.],[0.,0.,1.],[1.,0.,0.],[0.,-1.,0.],[-1.,0.,0.],[0.,1.,0.]] for i,t in enumerate(trs): - for j in xrange(64): + for j in range(64): j2=(j//16) ; j1=((j%16)//4) ; j0=(j%4) m11=m1.deepCopy() m11.rotate([0.,0.,0.],[0.,0.,1.],float(j0)*pi/2) @@ -2015,7 +2015,7 @@ class MEDCouplingBasicsTest5(unittest.TestCase): m=MEDCouplingUMesh("mesh",2) ; m.setCoords(coo) m.allocateCells() # the cell description is exactly those described in the description of TRI7 in MED file 3.0.7 documentation - m.insertNextCell(NORM_TRI7,range(7)) + m.insertNextCell(NORM_TRI7,list(range(7))) refCoords=[0.,0.,1.,0.,0.,1.,0.5,0.,0.5,0.5,0.,0.5,0.3333333333333333,0.3333333333333333] gaussCoords=[0.3333333333333333,0.3333333333333333,0.470142064105115,0.470142064105115,0.05971587178977,0.470142064105115,0.470142064105115,0.05971587178977,0.101286507323456,0.101286507323456,0.797426985353088,0.101286507323456,0.101286507323456,0.797426985353088] weights=[0.062969590272413,0.062969590272413,0.062969590272413,0.066197076394253,0.066197076394253,0.066197076394253,0.1125] @@ -2320,34 +2320,34 @@ class MEDCouplingBasicsTest5(unittest.TestCase): def testSwigBugOnUnpackingTuplesInDataArray1(self): inp=DataArrayDouble([(1,2,3),(4,5,6),(7,8,9),(10,11,12)]) it=inp.__iter__() - r=it.next() + r=next(it) self.assertRaises(StopIteration,r.__getitem__,4) self.assertEqual(len(r),3) a,b,c=r - r=it.next() + r=next(it) self.assertEqual(len(r),3) d,e,f=r - r=it.next() + r=next(it) self.assertEqual(len(r),3) g,h,i=r - r=it.next() + r=next(it) self.assertEqual(len(r),3) j,k,l=r self.assertTrue(inp.isEqual(DataArrayDouble([a,b,c,d,e,f,g,h,i,j,k,l],4,3),1e-12)) ######## inp=DataArrayInt([(1,2,3),(4,5,6),(7,8,9),(10,11,12)]) it=inp.__iter__() - r=it.next() + r=next(it) self.assertRaises(StopIteration,r.__getitem__,4) self.assertEqual(len(r),3) a,b,c=r - r=it.next() + r=next(it) self.assertEqual(len(r),3) d,e,f=r - r=it.next() + r=next(it) self.assertEqual(len(r),3) g,h,i=r - r=it.next() + r=next(it) self.assertEqual(len(r),3) j,k,l=r self.assertTrue(inp.isEqual(DataArrayInt([a,b,c,d,e,f,g,h,i,j,k,l],4,3))) @@ -2783,7 +2783,7 @@ class MEDCouplingBasicsTest5(unittest.TestCase): self.assertTrue(isinstance(g0[0],MEDCouplingCartesianAMRPatchGF)) g1=amr.retrieveGridsAt(1) self.assertEqual(5,len(g1)) - for i in xrange(5): + for i in range(5): self.assertTrue(isinstance(g1[i],MEDCouplingCartesianAMRPatch)) pass pass @@ -3218,7 +3218,7 @@ class MEDCouplingBasicsTest5(unittest.TestCase): i=MEDCouplingIMesh("mesh",2,[5,5],[0.,0.],[1.,1.]) m1=i.buildUnstructured() m2=MEDCouplingUMesh("mesh",1) ; m2.setCoords(DataArrayDouble([0.5,2.,2.25,2.,2.5,2.,2.75,2.,3.,2.,4.,2.,5.,2.],7,2)) ; m2.allocateCells() - for i in xrange(6): + for i in range(6): m2.insertNextCell(NORM_SEG2,[i,i+1]) pass a,b,c,d=MEDCouplingUMesh.Intersect2DMeshWith1DLine(m1,m2,1e-12) @@ -3238,7 +3238,7 @@ class MEDCouplingBasicsTest5(unittest.TestCase): i=MEDCouplingIMesh("mesh",2,[5,5],[0.,0.],[1.,1.]) m1=i.buildUnstructured() m2=MEDCouplingUMesh("mesh",1) ; m2.setCoords(DataArrayDouble([(0.75,3.25),(0.5,3.5),(0.25,3.25)])) ; m2.allocateCells() - for i in xrange(2): + for i in range(2): m2.insertNextCell(NORM_SEG2,[i,i+1]) pass a,b,c,d=MEDCouplingUMesh.Intersect2DMeshWith1DLine(m1,m2,1e-12) @@ -3281,7 +3281,7 @@ class MEDCouplingBasicsTest5(unittest.TestCase): i=MEDCouplingIMesh("mesh",2,[5,5],[0.,0.],[1.,1.]) m1=i.buildUnstructured() m2=MEDCouplingUMesh("mesh",1) ; m2.setCoords(DataArrayDouble([(1.,0.),(3.,2.),(1.,4.)])) ; m2.allocateCells() - for i in xrange(2): + for i in range(2): m2.insertNextCell(NORM_SEG2,[i,i+1]) pass a,b,c,d=MEDCouplingUMesh.Intersect2DMeshWith1DLine(m1,m2,1e-12) @@ -3851,7 +3851,7 @@ class MEDCouplingBasicsTest5(unittest.TestCase): li=[] liExp3D=[(0,0,0),(1,0,0),(2,0,0),(3,0,0),(0,1,0),(1,1,0),(2,1,0),(3,1,0),(0,2,0),(1,2,0),(2,2,0),(3,2,0),(0,0,1),(1,0,1),(2,0,1),(3,0,1),(0,1,1),(1,1,1),(2,1,1),(3,1,1),(0,2,1),(1,2,1),(2,2,1),(3,2,1)] self.assertEqual(24,m.getNumberOfCells()) - for i in xrange(m.getNumberOfCells()): + for i in range(m.getNumberOfCells()): li.append(m.getLocationFromCellId(i)) pass self.assertEqual(liExp3D,li) @@ -3864,7 +3864,7 @@ class MEDCouplingBasicsTest5(unittest.TestCase): li=[] liExp2D=[(0,0),(1,0),(2,0),(3,0),(0,1),(1,1),(2,1),(3,1),(0,2),(1,2),(2,2),(3,2)] self.assertEqual(12,m.getNumberOfCells()) - for i in xrange(m.getNumberOfCells()): + for i in range(m.getNumberOfCells()): li.append(m.getLocationFromCellId(i)) pass self.assertEqual(liExp2D,li) @@ -3874,7 +3874,7 @@ class MEDCouplingBasicsTest5(unittest.TestCase): arrX=DataArrayDouble(5) ; arrX.iota() m=MEDCouplingCMesh() ; m.setCoords(arrX) self.assertEqual(4,m.getNumberOfCells()) - for i in xrange(m.getNumberOfCells()): + for i in range(m.getNumberOfCells()): self.assertEqual((i,),m.getLocationFromCellId(i)) pass self.assertRaises(InterpKernelException,m.getLocationFromCellId,4) @@ -3890,7 +3890,7 @@ class MEDCouplingBasicsTest5(unittest.TestCase): li=[] liExp3D=[(0,0,0),(1,0,0),(2,0,0),(3,0,0),(4,0,0),(0,1,0),(1,1,0),(2,1,0),(3,1,0),(4,1,0),(0,2,0),(1,2,0),(2,2,0),(3,2,0),(4,2,0),(0,3,0),(1,3,0),(2,3,0),(3,3,0),(4,3,0),(0,0,1),(1,0,1),(2,0,1),(3,0,1),(4,0,1),(0,1,1),(1,1,1),(2,1,1),(3,1,1),(4,1,1),(0,2,1),(1,2,1),(2,2,1),(3,2,1),(4,2,1),(0,3,1),(1,3,1),(2,3,1),(3,3,1),(4,3,1),(0,0,2),(1,0,2),(2,0,2),(3,0,2),(4,0,2),(0,1,2),(1,1,2),(2,1,2),(3,1,2),(4,1,2),(0,2,2),(1,2,2),(2,2,2),(3,2,2),(4,2,2),(0,3,2),(1,3,2),(2,3,2),(3,3,2),(4,3,2)] self.assertEqual(60,m.getNumberOfNodes()) - for i in xrange(m.getNumberOfNodes()): + for i in range(m.getNumberOfNodes()): li.append(m.getLocationFromNodeId(i)) pass self.assertEqual(liExp3D,li) @@ -3903,7 +3903,7 @@ class MEDCouplingBasicsTest5(unittest.TestCase): li=[] liExp2D=[(0,0),(1,0),(2,0),(3,0),(4,0),(0,1),(1,1),(2,1),(3,1),(4,1),(0,2),(1,2),(2,2),(3,2),(4,2),(0,3),(1,3),(2,3),(3,3),(4,3)] self.assertEqual(20,m.getNumberOfNodes()) - for i in xrange(m.getNumberOfNodes()): + for i in range(m.getNumberOfNodes()): li.append(m.getLocationFromNodeId(i)) pass self.assertEqual(liExp2D,li) @@ -3913,7 +3913,7 @@ class MEDCouplingBasicsTest5(unittest.TestCase): arrX=DataArrayDouble(5) ; arrX.iota() m=MEDCouplingCMesh() ; m.setCoords(arrX) self.assertEqual(5,m.getNumberOfNodes()) - for i in xrange(m.getNumberOfNodes()): + for i in range(m.getNumberOfNodes()): self.assertEqual((i,),m.getLocationFromNodeId(i)) pass self.assertRaises(InterpKernelException,m.getLocationFromCellId,5) @@ -3931,7 +3931,7 @@ class MEDCouplingBasicsTest5(unittest.TestCase): st0=d.repr() ; st1=str(d) ; st2=d.reprNotTooLong() self.assertNotEqual(st0,st1) # 1001 tuples ( > 1000) -> str(d)==d.reprNotTooLong() self.assertEqual(st1,st2) - self.assertIn(len(st2),xrange(0,1000)) # no more than 1000 characters + self.assertIn(len(st2),range(0,1000)) # no more than 1000 characters ## Now for DataArrayInt d=DataArrayInt(2000) ; d.iota() ; d.rearrange(2) st0=d.repr() ; st1=str(d) ; st2=d.reprNotTooLong() @@ -3942,7 +3942,7 @@ class MEDCouplingBasicsTest5(unittest.TestCase): st0=d.repr() ; st1=str(d) ; st2=d.reprNotTooLong() self.assertNotEqual(st0,st1) # 1001 tuples ( > 1000) -> str(d)==d.reprNotTooLong() self.assertEqual(st1,st2) - self.assertIn(len(st2),xrange(0,1000)) # no more than 1000 characters + self.assertIn(len(st2),range(0,1000)) # no more than 1000 characters pass def testExtrudedMeshWithoutZipCoords1(self): @@ -4016,8 +4016,8 @@ class MEDCouplingBasicsTest5(unittest.TestCase): coo=DataArrayDouble([(0,2),(2,0),(6,4),(4,9)]) m=MEDCoupling1SGTUMesh("mesh",NORM_QUAD4) ; m.setCoords(coo) exp3=sqrt(85.) - for delta in xrange(4): - c=[(elt+delta)%4 for elt in xrange(4)] + for delta in range(4): + c=[(elt+delta)%4 for elt in range(4)] m.setNodalConnectivity(DataArrayInt(c)) self.assertAlmostEqual(m.computeDiameterField().getArray()[0],exp3,12) m2=m.buildUnstructured() ; m2.convertLinearCellsToQuadratic(0) @@ -4034,8 +4034,8 @@ class MEDCouplingBasicsTest5(unittest.TestCase): # QUAD4 - spacedim = 3 coo=DataArrayDouble([(0.26570992384234871,2.0405889913271817,-0.079134238105786903),(2.3739976619218064,0.15779148692781009,0.021842842914139737),(6.1207841448393197,4.3755532938679655,0.43666375769970678),(3.8363255342943359,9.2521096041694229,0.41551170895942313)]) m=MEDCoupling1SGTUMesh("mesh",NORM_QUAD4) ; m.setCoords(coo) - for delta in xrange(4): - c=[(elt+delta)%4 for elt in xrange(4)] + for delta in range(4): + c=[(elt+delta)%4 for elt in range(4)] m.setNodalConnectivity(DataArrayInt(c)) self.assertAlmostEqual(m.computeDiameterField().getArray()[0],exp3,12) m2=m.buildUnstructured() ; m2.convertLinearCellsToQuadratic(0) @@ -4055,8 +4055,8 @@ class MEDCouplingBasicsTest5(unittest.TestCase): m=MEDCoupling1SGTUMesh("mesh",NORM_PENTA6) ; m.setCoords(coo) exp4=2.5041256256889888 self.assertAlmostEqual(exp4,coo.buildEuclidianDistanceDenseMatrix().getMaxValue()[0],12)# <- the definition of diameter - for delta in xrange(3): - c=[(elt+delta)%3 for elt in xrange(3)] + for delta in range(3): + c=[(elt+delta)%3 for elt in range(3)] c+=[elt+3 for elt in c] m.setNodalConnectivity(DataArrayInt(c)) self.assertAlmostEqual(m.computeDiameterField().getArray()[0],exp4,12) @@ -4073,8 +4073,8 @@ class MEDCouplingBasicsTest5(unittest.TestCase): m=MEDCoupling1SGTUMesh("mesh",NORM_HEXA8) ; m.setCoords(coo) exp5=2.5366409441884215 self.assertAlmostEqual(exp5,coo.buildEuclidianDistanceDenseMatrix().getMaxValue()[0],12)# <- the definition of diameter - for delta in xrange(4): - c=[(elt+delta)%4 for elt in xrange(4)] + for delta in range(4): + c=[(elt+delta)%4 for elt in range(4)] c+=[elt+4 for elt in c] m.setNodalConnectivity(DataArrayInt(c)) self.assertAlmostEqual(m.computeDiameterField().getArray()[0],exp5,12) @@ -4091,8 +4091,8 @@ class MEDCouplingBasicsTest5(unittest.TestCase): m=MEDCoupling1SGTUMesh("mesh",NORM_PYRA5) ; m.setCoords(coo) exp6=2.1558368027391386 self.assertAlmostEqual(exp6,coo.buildEuclidianDistanceDenseMatrix().getMaxValue()[0],12)# <- the definition of diameter - for delta in xrange(4): - c=[(elt+delta)%4 for elt in xrange(4)] + for delta in range(4): + c=[(elt+delta)%4 for elt in range(4)] c+=[4] m.setNodalConnectivity(DataArrayInt(c)) self.assertAlmostEqual(m.computeDiameterField().getArray()[0],exp6,12) @@ -4105,8 +4105,8 @@ class MEDCouplingBasicsTest5(unittest.TestCase): m=MEDCoupling1SGTUMesh("mesh",NORM_PYRA5) ; m.setCoords(coo) exp7=1.4413563787228953 self.assertAlmostEqual(exp7,coo.buildEuclidianDistanceDenseMatrix().getMaxValue()[0],12)# <- the definition of diameter - for delta in xrange(4): - c=[(elt+delta)%4 for elt in xrange(4)] + for delta in range(4): + c=[(elt+delta)%4 for elt in range(4)] c+=[4] m.setNodalConnectivity(DataArrayInt(c)) self.assertAlmostEqual(m.computeDiameterField().getArray()[0],exp7,12) @@ -4120,7 +4120,7 @@ class MEDCouplingBasicsTest5(unittest.TestCase): exp8=1.7131322579364157 self.assertAlmostEqual(exp8,coo.buildEuclidianDistanceDenseMatrix().getMaxValue()[0],12)# <- the definition of diameter for c in [[0,1,2,3],[0,3,2,1],[0,1,3,2],[0,2,3,1],[0,3,1,2],[0,2,1,3]]: - for i in xrange(4): + for i in range(4): m.setNodalConnectivity(DataArrayInt([(elt+i)%4 for elt in c])) self.assertAlmostEqual(m.computeDiameterField().getArray()[0],exp8,12) m2=m.buildUnstructured() ; m2.convertLinearCellsToQuadratic(0) diff --git a/src/MEDCoupling_Swig/MEDCouplingDataForTest.py b/src/MEDCoupling_Swig/MEDCouplingDataForTest.py index 9d68678e4..a79956a12 100644 --- a/src/MEDCoupling_Swig/MEDCouplingDataForTest.py +++ b/src/MEDCoupling_Swig/MEDCouplingDataForTest.py @@ -60,7 +60,7 @@ class MEDCouplingDataForTest: targetMesh=MEDCouplingUMesh.New(); targetMesh.setMeshDimension(3); targetMesh.allocateCells(12); - for i in xrange(8): + for i in range(8): targetMesh.insertNextCell(NORM_HEXA8,8,targetConn[8*i:8*i+8]); pass targetMesh.finishInsertingCells(); @@ -225,7 +225,7 @@ class MEDCouplingDataForTest: targetMesh=MEDCouplingUMesh.New(); targetMesh.setMeshDimension(3); targetMesh.allocateCells(12); - for i in xrange(8): + for i in range(8): targetMesh.insertNextCell(NORM_HEXA8,8,targetConn[8*i:8*(i+1)]); pass targetMesh.finishInsertingCells(); @@ -284,7 +284,7 @@ class MEDCouplingDataForTest: ret=MEDCouplingUMesh.New("1DSourceMesh",1); ret.allocateCells(4); conn=[0,1,2,3,1,2,3,4] - for i in xrange(4): + for i in range(4): ret.insertNextCell(NORM_SEG2,2,conn[2*i:2*i+2]); pass ret.finishInsertingCells(); @@ -541,7 +541,7 @@ class MEDCouplingDataForTest: 15,24,25,16,12,21,22,13, 16,25,26,17,13,22,23,14]; mesh.allocateCells(8); - for i in xrange(8): + for i in range(8): mesh.insertNextCell(NORM_HEXA8,8,conn[8*i:8*(i+1)]) pass mesh.finishInsertingCells(); @@ -558,7 +558,7 @@ class MEDCouplingDataForTest: mesh.setCoords(coo); mesh2.setCoords(coo); mesh.allocateCells(16); - for i in xrange(12): + for i in range(12): mesh.insertNextCell(NORM_TETRA4,4,conn[4*i:4*i+4]) pass mesh.insertNextCell(NORM_PYRA5,5,conn[48:53]) @@ -569,7 +569,7 @@ class MEDCouplingDataForTest: #[1,34,29,23,41,32] conn2=[0,5,1,14,18,17,8,7,4,9,5,2, 12,8,9,13,6,7,8,9] mesh2.allocateCells(6); - for i in xrange(4): + for i in range(4): mesh2.insertNextCell(NORM_TRI3,3,conn2[3*i:3*i+3]) pass mesh2.insertNextCell(NORM_QUAD4,4,conn2[12:16]) @@ -586,24 +586,24 @@ class MEDCouplingDataForTest: m.setCoords(coo) m.allocateCells() conn=[[11,8,13],[11,13,12],[8,9,13],[9,14,13],[9,10,15],[9,15,14],[12,13,19],[13,16,19],[13,14,17],[13,17,16],[14,15,17],[15,18,17],[0,1,4,3],[1,2,5,4],[2,6,7,5],[3,4,8,11],[4,5,9,8],[5,7,10,9],[20,22,21,28,41,51],[21,25,20,29,42,51],[22,23,21,30,43,41],[23,27,21,31,35,43],[23,38,24,32,44,52],[24,27,23,33,31,52],[25,21,50,29,45,53],[21,39,50,34,46,45],[21,27,26,35,47,54],[26,39,21,36,34,54],[27,24,26,33,48,47],[24,40,26,37,49,48],[50,39,56,55,46,62,58,71],[39,26,57,56,36,63,59,62],[26,40,61,57,49,64,60,63],[55,56,17,18,58,65,68,72],[56,57,16,17,59,66,69,65],[57,61,19,16,60,67,70,66]] - for i in xrange(0,12): + for i in range(0,12): m.insertNextCell(NORM_TRI3,conn[i]) pass - for i in xrange(12,18): + for i in range(12,18): m.insertNextCell(NORM_QUAD4,conn[i]) pass - for i in xrange(18,30): + for i in range(18,30): m.insertNextCell(NORM_TRI6,conn[i]) pass - for i in xrange(30,36): + for i in range(30,36): m.insertNextCell(NORM_QUAD8,conn[i]) pass fff=MEDCouplingFieldDouble.New(ON_GAUSS_PT) ; fff.setName("CH1RB") ; fff.setNature(IntensiveMaximum) fff.setMesh(m) - fff.setGaussLocalizationOnCells(range(0,12),[0.,0.,1.,0.,0.,1.],[0.3333333333333333,0.3333333333333333],[0.5]) - fff.setGaussLocalizationOnCells(range(12,18),[-1.,-1.,1.,-1.,1.,1.,-1.,1.],[-0.577350269189626,-0.577350269189626,0.577350269189626,-0.577350269189626,0.577350269189626,0.577350269189626,-0.577350269189626,0.577350269189626],[1.,1.,1.,1.]) - fff.setGaussLocalizationOnCells(range(18,30),[0.,0.,1.,0.,0.,1.,0.5, 0.,0.5, 0.5, 0.,0.5],[0.16666666666666666,0.16666666666666666,0.6666666666666666,0.16666666666666666,0.16666666666666666,0.6666666666666666],[0.16666666666666666,0.16666666666666666,0.16666666666666666]) - fff.setGaussLocalizationOnCells(range(30,36),[-1.,-1.,1.,-1.,1.,1.,-1.,1.,0.,-1.,1.,0.,0.,1.,-1.,0.],[-0.774596669241483,-0.774596669241483,0.774596669241483,-0.774596669241483,0.774596669241483,0.774596669241483,-0.774596669241483,0.774596669241483,0.0,-0.774596669241483,0.774596669241483,0.0,0.0,0.774596669241483,-0.774596669241483,0.0,0.0,0.0],[0.30864197530864196,0.30864197530864196,0.30864197530864196,0.30864197530864196,0.49382716049382713,0.49382716049382713,0.49382716049382713,0.49382716049382713,0.7901234567901234]) + fff.setGaussLocalizationOnCells(list(range(0,12)),[0.,0.,1.,0.,0.,1.],[0.3333333333333333,0.3333333333333333],[0.5]) + fff.setGaussLocalizationOnCells(list(range(12,18)),[-1.,-1.,1.,-1.,1.,1.,-1.,1.],[-0.577350269189626,-0.577350269189626,0.577350269189626,-0.577350269189626,0.577350269189626,0.577350269189626,-0.577350269189626,0.577350269189626],[1.,1.,1.,1.]) + fff.setGaussLocalizationOnCells(list(range(18,30)),[0.,0.,1.,0.,0.,1.,0.5, 0.,0.5, 0.5, 0.,0.5],[0.16666666666666666,0.16666666666666666,0.6666666666666666,0.16666666666666666,0.16666666666666666,0.6666666666666666],[0.16666666666666666,0.16666666666666666,0.16666666666666666]) + fff.setGaussLocalizationOnCells(list(range(30,36)),[-1.,-1.,1.,-1.,1.,1.,-1.,1.,0.,-1.,1.,0.,0.,1.,-1.,0.],[-0.774596669241483,-0.774596669241483,0.774596669241483,-0.774596669241483,0.774596669241483,0.774596669241483,-0.774596669241483,0.774596669241483,0.0,-0.774596669241483,0.774596669241483,0.0,0.0,0.774596669241483,-0.774596669241483,0.0,0.0,0.0],[0.30864197530864196,0.30864197530864196,0.30864197530864196,0.30864197530864196,0.49382716049382713,0.49382716049382713,0.49382716049382713,0.49382716049382713,0.7901234567901234]) return MEDCouplingFieldTemplate(fff) # 2D usecase2 for interpolation Gauss Pt-> Gauss Pt. Coming from ASTER : Please, do not touch @@ -615,24 +615,24 @@ class MEDCouplingDataForTest: m.setCoords(coo) m.allocateCells(0) conn=[[198,194,200],[198,200,199],[194,195,200],[195,201,200],[195,196,202],[195,202,201],[196,197,202],[197,203,202],[199,200,205],[199,205,204],[200,201,205],[201,206,205],[201,202,207],[201,207,206],[202,203,207],[203,208,207],[204,205,210],[204,210,209],[205,206,210],[206,211,210],[206,207,212],[206,212,211],[207,208,212],[208,213,212],[209,210,215],[209,215,214],[210,211,215],[211,216,215],[211,212,217],[211,217,216],[212,213,217],[213,218,217],[214,215,157],[214,157,158],[215,216,157],[216,156,157],[216,217,155],[216,155,156],[217,218,155],[218,163,155],[169,170,174,173],[170,171,175,174],[171,172,176,175],[172,189,190,176],[173,174,178,177],[174,175,179,178],[175,176,180,179],[176,190,191,180],[177,178,182,181],[178,179,183,182],[179,180,184,183],[180,191,192,184],[181,182,186,185],[182,183,187,186],[183,184,188,187],[184,192,193,188],[185,186,194,198],[186,187,195,194],[187,188,196,195],[188,193,197,196],[0,2,1,27,62,89],[1,7,0,28,63,89],[2,3,1,29,64,62],[3,9,1,30,36,64],[3,5,4,31,65,90],[4,9,3,32,30,90],[5,6,4,33,66,65],[6,11,4,34,39,66],[7,1,8,28,67,91],[8,12,7,35,68,91],[1,9,8,36,69,67],[9,14,8,37,42,69],[9,4,10,32,70,92],[10,14,9,38,37,92],[4,11,10,39,71,70],[11,16,10,40,45,71],[12,8,13,35,72,93],[13,17,12,41,73,93],[8,14,13,42,74,72],[14,19,13,43,48,74],[14,10,15,38,75,94],[15,19,14,44,43,94],[10,16,15,45,76,75],[16,21,15,46,51,76],[17,13,18,41,77,95],[18,22,17,47,78,95],[13,19,18,48,79,77],[19,24,18,49,54,79],[19,15,20,44,80,96],[20,24,19,50,49,96],[15,21,20,51,81,80],[21,26,20,52,57,81],[22,18,23,47,82,97],[23,59,22,53,83,97],[18,24,23,54,84,82],[24,60,23,55,85,84],[24,20,25,50,86,98],[25,60,24,56,55,98],[20,26,25,57,87,86],[26,61,25,58,88,87],[59,23,100,99,53,135,115,164],[23,60,101,100,85,136,116,135],[60,25,102,101,56,137,117,136],[25,61,131,102,88,138,118,137],[99,100,104,103,115,139,119,165],[100,101,105,104,116,140,120,139],[101,102,106,105,117,141,121,140],[102,131,132,106,118,142,122,141],[103,104,108,107,119,143,123,166],[104,105,109,108,120,144,124,143],[105,106,110,109,121,145,125,144],[106,132,133,110,122,146,126,145],[107,108,112,111,123,147,127,167],[108,109,113,112,124,148,128,147],[109,110,114,113,125,149,129,148],[110,133,134,114,126,150,130,149],[111,112,155,163,127,151,159,168],[112,113,156,155,128,152,160,151],[113,114,157,156,129,153,161,152],[114,134,158,157,130,154,162,153]] - for i in xrange(0,40): + for i in range(0,40): m.insertNextCell(NORM_TRI3,conn[i]) pass - for i in xrange(40,60): + for i in range(40,60): m.insertNextCell(NORM_QUAD4,conn[i]) pass - for i in xrange(60,100): + for i in range(60,100): m.insertNextCell(NORM_TRI6,conn[i]) pass - for i in xrange(100,120): + for i in range(100,120): m.insertNextCell(NORM_QUAD8,conn[i]) pass fff=MEDCouplingFieldDouble.New(ON_GAUSS_PT) ; fff.setName("CH2RB") ; fff.setNature(IntensiveMaximum) fff.setMesh(m) - fff.setGaussLocalizationOnCells(range(0,40),[0.,0.,1.,0.,0.,1.],[0.3333333333333333,0.3333333333333333],[0.5]) - fff.setGaussLocalizationOnCells(range(40,60),[-1.,-1.,1.,-1.,1.,1.,-1.,1.],[-0.577350269189626,-0.577350269189626,0.577350269189626,-0.577350269189626,0.577350269189626,0.577350269189626,-0.577350269189626,0.577350269189626],[1.,1.,1.,1.]) - fff.setGaussLocalizationOnCells(range(60,100),[0.,0.,1.,0.,0.,1.,0.5, 0.,0.5, 0.5, 0.,0.5],[0.16666666666666666,0.16666666666666666,0.6666666666666666,0.16666666666666666,0.16666666666666666,0.6666666666666666],[0.16666666666666666,0.16666666666666666,0.16666666666666666]) - fff.setGaussLocalizationOnCells(range(100,120),[-1.,-1.,1.,-1.,1.,1.,-1.,1.,0.,-1.,1.,0.,0.,1.,-1.,0.],[-0.774596669241483,-0.774596669241483,0.774596669241483,-0.774596669241483,0.774596669241483,0.774596669241483,-0.774596669241483,0.774596669241483,0.0,-0.774596669241483,0.774596669241483,0.0,0.0,0.774596669241483,-0.774596669241483,0.0,0.0,0.0],[0.30864197530864196,0.30864197530864196,0.30864197530864196,0.30864197530864196,0.49382716049382713,0.49382716049382713,0.49382716049382713,0.49382716049382713,0.7901234567901234]) + fff.setGaussLocalizationOnCells(list(range(0,40)),[0.,0.,1.,0.,0.,1.],[0.3333333333333333,0.3333333333333333],[0.5]) + fff.setGaussLocalizationOnCells(list(range(40,60)),[-1.,-1.,1.,-1.,1.,1.,-1.,1.],[-0.577350269189626,-0.577350269189626,0.577350269189626,-0.577350269189626,0.577350269189626,0.577350269189626,-0.577350269189626,0.577350269189626],[1.,1.,1.,1.]) + fff.setGaussLocalizationOnCells(list(range(60,100)),[0.,0.,1.,0.,0.,1.,0.5, 0.,0.5, 0.5, 0.,0.5],[0.16666666666666666,0.16666666666666666,0.6666666666666666,0.16666666666666666,0.16666666666666666,0.6666666666666666],[0.16666666666666666,0.16666666666666666,0.16666666666666666]) + fff.setGaussLocalizationOnCells(list(range(100,120)),[-1.,-1.,1.,-1.,1.,1.,-1.,1.,0.,-1.,1.,0.,0.,1.,-1.,0.],[-0.774596669241483,-0.774596669241483,0.774596669241483,-0.774596669241483,0.774596669241483,0.774596669241483,-0.774596669241483,0.774596669241483,0.0,-0.774596669241483,0.774596669241483,0.0,0.0,0.774596669241483,-0.774596669241483,0.0,0.0,0.0],[0.30864197530864196,0.30864197530864196,0.30864197530864196,0.30864197530864196,0.49382716049382713,0.49382716049382713,0.49382716049382713,0.49382716049382713,0.7901234567901234]) return MEDCouplingFieldTemplate(fff) # 3D usecase1 for interpolation Gauss Pt-> Gauss Pt. Coming from ASTER : Please, do not touch @@ -646,7 +646,7 @@ class MEDCouplingDataForTest: conn=[[3,10,8,4],[19,22,23,20,14],[0,6,1,3,8,4],[4,8,10,5,9,11],[12,16,17,14,19,20],[14,20,23,15,21,24],[1,2,5,4,6,7,9,8],[12,13,15,14,17,18,21,20]] m.insertNextCell(NORM_TETRA4,conn[0]) m.insertNextCell(NORM_PYRA5,conn[1]) - for i in xrange(2,6): + for i in range(2,6): m.insertNextCell(NORM_PENTA6,conn[i]) pass m.insertNextCell(NORM_HEXA8,conn[6]) @@ -670,7 +670,7 @@ class MEDCouplingDataForTest: conn=[[3,10,8,4],[19,22,23,20,14],[0,6,1,3,8,4],[4,8,10,5,9,11],[12,16,17,14,19,20],[14,20,23,15,21,24],[1,2,5,4,6,7,9,8],[12,13,15,14,17,18,21,20]] m.insertNextCell(NORM_TETRA4,conn[0]) m.insertNextCell(NORM_PYRA5,conn[1]) - for i in xrange(2,6): + for i in range(2,6): m.insertNextCell(NORM_PENTA6,conn[i]) pass m.insertNextCell(NORM_HEXA8,conn[6]) @@ -690,7 +690,7 @@ class MEDCouplingDataForTest: c = [rect(radius, i*pi/4.0) for i in range(8)] coords = [c[-1].real,c[-1].imag, c[3].real,c[3].imag, c[5].real,c[5].imag, c[1].real,c[1].imag] - connec = range(4) + connec = list(range(4)) baseMesh = MEDCouplingUMesh.New("circle", 2) baseMesh.allocateCells(1) meshCoords = DataArrayDouble.New(coords, len(coords)/2, 2) diff --git a/src/MEDCoupling_Swig/MEDCouplingExamplesTest.py b/src/MEDCoupling_Swig/MEDCouplingExamplesTest.py index b174ff256..1ce1f2cce 100644 --- a/src/MEDCoupling_Swig/MEDCouplingExamplesTest.py +++ b/src/MEDCoupling_Swig/MEDCouplingExamplesTest.py @@ -43,7 +43,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): fileName = "testExample_MEDCouplingFieldDouble_WriteVTK" fs = [ field1, field2, field3 ] # field series writtenFileName=MEDCouplingFieldDouble.WriteVTK( fileName, fs ) - print "The file name with correct extension is : %s"%(writtenFileName) + print("The file name with correct extension is : %s"%(writtenFileName)) #! [PySnippet_MEDCouplingFieldDouble_WriteVTK_1] import os os.remove( writtenFileName ) @@ -1478,7 +1478,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): #! [Snippet_DataArrayInt_getTuple_1] #! [Snippet_DataArrayInt_getTuple_2] for tpl in dv: - print tpl + print(tpl) #! [Snippet_DataArrayInt_getTuple_2] return @@ -1500,7 +1500,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): da.setValues(arr1,6,1) da2=da.invertArrayO2N2N2O(6) expected1=[1,3,0,5,2,4] - for i in xrange(6): + for i in range(6): self.assertEqual(expected1[i],da2.getIJ(i,0)) pass #! [PySnippet_DataArrayInt_invertArrayO2N2N2O_1] @@ -1513,7 +1513,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): da.setValues(arr1,6,1) da2=da.invertArrayN2O2O2N(7) expected1=[1,3,0,5,2,4,-1] - for i in xrange(6): + for i in range(6): self.assertEqual(expected1[i],da2.getIJ(i,0)) pass #! [PySnippet_DataArrayInt_invertArrayN2O2O2N_1] @@ -1524,7 +1524,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): #! [PySnippet_DataArrayDouble_getIdsInRange_1] da=DataArrayDouble() da.alloc( 10, 1 ) - da[ :, :] = range(10) + da[ :, :] = list(range(10)) da2 = da.findIdsInRange( 2.5, 6 ) #! [PySnippet_DataArrayDouble_getIdsInRange_1] return @@ -1890,7 +1890,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): dv=da.getDifferentValues(2e-1) expected2=[2.301,1.3,0.8] self.assertEqual(3,dv.getNbOfElems()) - for i in xrange(3): + for i in range(3): self.assertAlmostEqual(expected2[i],dv.getIJ(i,0),14) pass #! [Snippet_DataArrayDouble_getDifferentValues1] @@ -2009,7 +2009,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): self.assertEqual(3,f2.getNumberOfTuples()) self.assertEqual(2,f2.getNumberOfComponents()) expected1=[5.,105.,4.,104.,7.,107.] - for i in xrange(6): + for i in range(6): self.assertAlmostEqual(f2.getIJ(0,i),expected1[i],12) pass self.assertEqual(3,f2.getMesh().getNumberOfCells()) @@ -2019,7 +2019,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): m2C=f2.getMesh() self.assertEqual(13,m2C.getNodalConnectivityArrayLen()) expected2=[0.2, -0.3, 0.7, -0.3, 0.2, 0.2, 0.7, 0.2, 0.2, 0.7, 0.7, 0.7] - for i in xrange(12): + for i in range(12): self.assertAlmostEqual(expected2[i],m2C.getCoords().getIJ(0,i),12) pass expected3=[3,2,3,1,3,0,2,1,4,4,5,3,2] @@ -2042,7 +2042,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): self.assertEqual(4,f2.getNumberOfTuples()) self.assertEqual(2,f2.getNumberOfComponents()) expected5=[4.,104.,5.,105.,7.,107.,8.,108.] - for i in xrange(8): + for i in range(8): self.assertAlmostEqual(f2.getIJ(0,i),expected5[i],12) pass self.assertEqual(2,f2.getMesh().getNumberOfCells()) @@ -2051,7 +2051,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): self.assertEqual(2,f2.getMesh().getMeshDimension()) m2C=f2.getMesh() self.assertEqual(8,m2C.getNodalConnectivityArrayLen()) - for i in xrange(8):#8 is not an error + for i in range(8):#8 is not an error self.assertAlmostEqual(expected2[i],m2C.getCoords().getIJ(0,i),12) pass self.assertEqual(expected3[:4],[int(i) for i in m2C.getNodalConnectivity()][4:]) @@ -2064,7 +2064,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): f2=f1.buildSubPart(arrr) self.assertEqual(4,f2.getNumberOfTuples()) self.assertEqual(2,f2.getNumberOfComponents()) - for i in xrange(8): + for i in range(8): self.assertAlmostEqual(f2.getIJ(0,i),expected5[i],12) pass self.assertEqual(2,f2.getMesh().getNumberOfCells()) @@ -2073,7 +2073,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): self.assertEqual(2,f2.getMesh().getMeshDimension()) m2C=f2.getMesh() self.assertEqual(8,m2C.getNodalConnectivityArrayLen()) - for i in xrange(8):#8 is not an error + for i in range(8):#8 is not an error self.assertAlmostEqual(expected2[i],m2C.getCoords().getIJ(0,i),12) pass self.assertEqual(expected3[:4],[int(i) for i in m2C.getNodalConnectivity()][4:8]) @@ -2084,7 +2084,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): self.assertEqual(6,f2.getNumberOfTuples()) self.assertEqual(2,f2.getNumberOfComponents()) expected6=[4.,104.,5.,105.,7.,107.,8.,108.,10.,110.,11.,111.] - for i in xrange(12): + for i in range(12): self.assertAlmostEqual(f2.getIJ(0,i),expected6[i],12) pass self.assertEqual(3,f2.getMesh().getNumberOfCells()) @@ -2093,7 +2093,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): self.assertEqual(2,f2.getMesh().getMeshDimension()) m2C=f2.getMesh() self.assertEqual(13,m2C.getNodalConnectivityArrayLen()) - for i in xrange(12): + for i in range(12): self.assertAlmostEqual(expected2[i],m2C.getCoords().getIJ(0,i),12) pass self.assertEqual(expected3[0:4],m2C.getNodalConnectivity().getValues()[4:8]) diff --git a/src/MEDCoupling_Swig/MEDCouplingNumPyTest.py b/src/MEDCoupling_Swig/MEDCouplingNumPyTest.py index 7b2036343..1837fbd94 100644 --- a/src/MEDCoupling_Swig/MEDCouplingNumPyTest.py +++ b/src/MEDCoupling_Swig/MEDCouplingNumPyTest.py @@ -668,11 +668,11 @@ class MEDCouplingNumPyTest(unittest.TestCase): """Test on DataArrayBytes""" # use case 1 d=DataArrayByte(256) - for i in xrange(len(d)): + for i in range(len(d)): d[i]=-128+i pass arr=d.toNumPyArray() - for i in xrange(len(d)): + for i in range(len(d)): self.assertEqual(int(arr[i]),-128+i) pass d[0]=7 @@ -685,11 +685,11 @@ class MEDCouplingNumPyTest(unittest.TestCase): gc.collect() # use case 2 d=DataArrayByte(256) - for i in xrange(len(d)): + for i in range(len(d)): d[i]=-128+i pass arr=d.toNumPyArray() - for i in xrange(len(d)): + for i in range(len(d)): self.assertEqual(int(arr[i]),-128+i) pass del d @@ -698,7 +698,7 @@ class MEDCouplingNumPyTest(unittest.TestCase): gc.collect() # use case 3 d=DataArrayByte(256) - for i in xrange(len(d)): + for i in range(len(d)): d[i]=-128+i pass arr1=d.toNumPyArray() @@ -708,20 +708,20 @@ class MEDCouplingNumPyTest(unittest.TestCase): self.assertEqual(int(arr1[0]),10) ; self.assertEqual(int(arr2[0]),10) ; self.assertEqual(int(arr3[0]),10) arr2[0]=15 ; self.assertEqual(int(d.getIJ(0,0)),15) ; self.assertEqual(int(arr1[0]),15) ; self.assertEqual(int(arr3[0]),15) arr1[0]=-128 - for i in xrange(len(d)): + for i in range(len(d)): self.assertEqual(int(arr1[i]),-128+i) self.assertEqual(int(arr2[i]),-128+i) self.assertEqual(int(arr3[i]),-128+i) pass del arr2 gc.collect() - for i in xrange(len(d)): + for i in range(len(d)): self.assertEqual(int(arr1[i]),-128+i) self.assertEqual(int(arr3[i]),-128+i) pass del arr1 gc.collect() - for i in xrange(len(d)): + for i in range(len(d)): self.assertEqual(int(arr3[i]),-128+i) pass del arr3 @@ -729,11 +729,11 @@ class MEDCouplingNumPyTest(unittest.TestCase): # use case 4 arr=array(0,dtype=int8) arr.resize(256) - for i in xrange(256): + for i in range(256): arr[i]=-128+i pass d=DataArrayByte(arr) - for i in xrange(256): + for i in range(256): self.assertEqual(int(d.getIJ(i,0)),-128+i) pass del arr @@ -743,11 +743,11 @@ class MEDCouplingNumPyTest(unittest.TestCase): # use case 5 arr=array(0,dtype=int8) arr.resize(256) - for i in xrange(256): + for i in range(256): arr[i]=-128+i pass d=DataArrayByte(arr) - for i in xrange(256): + for i in range(256): self.assertEqual(int(d.getIJ(i,0)),-128+i) pass del d diff --git a/src/MEDCoupling_Swig/MEDCouplingPickleTest.py b/src/MEDCoupling_Swig/MEDCouplingPickleTest.py index a34420d8a..51ef2ab6e 100644 --- a/src/MEDCoupling_Swig/MEDCouplingPickleTest.py +++ b/src/MEDCoupling_Swig/MEDCouplingPickleTest.py @@ -28,7 +28,7 @@ if MEDCouplingHasNumPyBindings(): from platform import architecture from sys import getrefcount -import os,gc,weakref,cPickle,unittest +import os,gc,weakref,pickle,unittest class MEDCouplingPickleTest(unittest.TestCase): @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy") @@ -36,14 +36,14 @@ class MEDCouplingPickleTest(unittest.TestCase): """ Test of a simple DataArrayDouble.""" x=DataArrayDouble(10,1) ; x.iota() ; x.rearrange(2) ; x.setInfoOnComponents(["aa","bbb"]) x.setName("toto") - pickled=cPickle.dumps(x,cPickle.HIGHEST_PROTOCOL) - xx=cPickle.loads(pickled) + pickled=pickle.dumps(x,pickle.HIGHEST_PROTOCOL) + xx=pickle.loads(pickled) self.assertTrue(xx.isEqual(x,1e-16)) # Bigger to check that the behavior is OK for large strings. x=DataArrayDouble(1200) ; x.iota() ; x.setInfoOnComponents(["aa"]) x.setName("titi") - pickled=cPickle.dumps(x,cPickle.HIGHEST_PROTOCOL) - xx=cPickle.loads(pickled) + pickled=pickle.dumps(x,pickle.HIGHEST_PROTOCOL) + xx=pickle.loads(pickled) self.assertTrue(xx.isEqual(x,1e-16)) pass @@ -52,14 +52,14 @@ class MEDCouplingPickleTest(unittest.TestCase): """ Test of a simple DataArrayInt.""" x=DataArrayInt(10) ; x.iota() ; x.rearrange(2) ; x.setInfoOnComponents(["aa","bbb"]) x.setName("toto") - pickled=cPickle.dumps(x,cPickle.HIGHEST_PROTOCOL) - xx=cPickle.loads(pickled) + pickled=pickle.dumps(x,pickle.HIGHEST_PROTOCOL) + xx=pickle.loads(pickled) self.assertTrue(xx.isEqual(x)) # Bigger to check that the behavior is OK for large strings. x=DataArrayInt(1200) ; x.iota() ; x.setInfoOnComponents(["aa"]) x.setName("titi") - pickled=cPickle.dumps(x,cPickle.HIGHEST_PROTOCOL) - xx=cPickle.loads(pickled) + pickled=pickle.dumps(x,pickle.HIGHEST_PROTOCOL) + xx=pickle.loads(pickled) self.assertTrue(xx.isEqual(x)) pass @@ -72,8 +72,8 @@ class MEDCouplingPickleTest(unittest.TestCase): m.setName("mesh") m.getCoords().setInfoOnComponents(["aa","bbb","ddddd"]) m.checkConsistencyLight() - st=cPickle.dumps(m,cPickle.HIGHEST_PROTOCOL) - m2=cPickle.loads(st) + st=pickle.dumps(m,pickle.HIGHEST_PROTOCOL) + m2=pickle.loads(st) self.assertTrue(m2.isEqual(m,1e-16)) pass @@ -104,8 +104,8 @@ class MEDCouplingPickleTest(unittest.TestCase): m=MEDCouplingCMesh() ; m.setCoords(arrX,arrY,arrZ) m.setName("mesh") m.checkConsistencyLight() - st=cPickle.dumps(m,cPickle.HIGHEST_PROTOCOL) - m2=cPickle.loads(st) + st=pickle.dumps(m,pickle.HIGHEST_PROTOCOL) + m2=pickle.loads(st) self.assertTrue(m2.isEqual(m,1e-16)) self.assertTrue(m2.getCoordsAt(0).isEqual(arrX,1e-16)) pass @@ -117,8 +117,8 @@ class MEDCouplingPickleTest(unittest.TestCase): m=MEDCouplingCMesh() ; m.setCoords(arr,arr) m=m.build1SGTUnstructured() self.assertTrue(isinstance(m,MEDCoupling1SGTUMesh)) - st=cPickle.dumps(m,cPickle.HIGHEST_PROTOCOL) - m2=cPickle.loads(st) + st=pickle.dumps(m,pickle.HIGHEST_PROTOCOL) + m2=pickle.loads(st) self.assertTrue(m2.isEqual(m,1e-16)) pass @@ -130,8 +130,8 @@ class MEDCouplingPickleTest(unittest.TestCase): m=m.buildUnstructured() ; m.convertAllToPoly() m=MEDCoupling1DGTUMesh(m) self.assertTrue(isinstance(m,MEDCoupling1DGTUMesh)) - st=cPickle.dumps(m,cPickle.HIGHEST_PROTOCOL) - m2=cPickle.loads(st) + st=pickle.dumps(m,pickle.HIGHEST_PROTOCOL) + m2=pickle.loads(st) self.assertTrue(m2.isEqual(m,1e-16)) pass @@ -150,8 +150,8 @@ class MEDCouplingPickleTest(unittest.TestCase): mesh2D.setCoords(mesh3D.getCoords()) mesh=MEDCouplingMappedExtrudedMesh(mesh3D,mesh2D,0) ; del mesh3D,mesh2D self.assertTrue(isinstance(mesh,MEDCouplingMappedExtrudedMesh)) - st=cPickle.dumps(mesh,cPickle.HIGHEST_PROTOCOL) - m2=cPickle.loads(st) + st=pickle.dumps(mesh,pickle.HIGHEST_PROTOCOL) + m2=pickle.loads(st) self.assertTrue(m2.isEqual(mesh,1e-16)) pass @@ -165,8 +165,8 @@ class MEDCouplingPickleTest(unittest.TestCase): # mesh=MEDCouplingCurveLinearMesh() ; mesh.setCoords(m.getCoords()) ; del m mesh.setNodeGridStructure([10,5]) - st=cPickle.dumps(mesh,cPickle.HIGHEST_PROTOCOL) - m2=cPickle.loads(st) + st=pickle.dumps(mesh,pickle.HIGHEST_PROTOCOL) + m2=pickle.loads(st) self.assertTrue(m2.isEqual(mesh,1e-16)) pass @@ -175,8 +175,8 @@ class MEDCouplingPickleTest(unittest.TestCase): """ Test of a MEDCouplingIMesh pickeling.""" m=MEDCouplingIMesh("mesh",3,DataArrayInt([3,1,4]),DataArrayDouble([1.5,2.5,3.5]),DataArrayDouble((0.5,1.,0.25))) ; m.setAxisUnit("km") m.checkConsistencyLight() - st=cPickle.dumps(m,cPickle.HIGHEST_PROTOCOL) - m2=cPickle.loads(st) + st=pickle.dumps(m,pickle.HIGHEST_PROTOCOL) + m2=pickle.loads(st) self.assertTrue(m2.isEqual(m,1e-16)) self.assertEqual(m2.getName(),m.getName()) pass @@ -195,8 +195,8 @@ class MEDCouplingPickleTest(unittest.TestCase): f.getArray().setInfoOnComponents(["u1","vv2"]) f.checkConsistencyLight(); # - st=cPickle.dumps(f,cPickle.HIGHEST_PROTOCOL) - f2=cPickle.loads(st) + st=pickle.dumps(f,pickle.HIGHEST_PROTOCOL) + f2=pickle.loads(st) self.assertTrue(f2.isEqual(f,1e-16,1e-16)) self.assertTrue(f2.getMesh().isEqual(f.getMesh(),1e-16)) pass @@ -233,7 +233,7 @@ class MEDCouplingPickleTest(unittest.TestCase): self.assertEqual(2,f.getNbOfGaussLocalization()); array=DataArrayDouble.New(); ptr=18*2*[None] - for i in xrange(18*2): + for i in range(18*2): ptr[i]=float(i+1) array.setValues(ptr,18,2); ptr=array.getPointer(); @@ -275,8 +275,8 @@ class MEDCouplingPickleTest(unittest.TestCase): f.setArray(array2); f.checkConsistencyLight(); #### - st=cPickle.dumps(f,cPickle.HIGHEST_PROTOCOL) - f2=cPickle.loads(st) + st=pickle.dumps(f,pickle.HIGHEST_PROTOCOL) + f2=pickle.loads(st) self.assertTrue(f2.isEqual(f,1e-16,1e-16)) self.assertTrue(f2.getMesh().isEqual(f.getMesh(),1e-16)) pass @@ -285,8 +285,8 @@ class MEDCouplingPickleTest(unittest.TestCase): eStr="This is an exception." e=InterpKernelException(eStr) self.assertEqual(e.what(),eStr) - st=cPickle.dumps(e,cPickle.HIGHEST_PROTOCOL) - e2=cPickle.loads(st) + st=pickle.dumps(e,pickle.HIGHEST_PROTOCOL) + e2=pickle.loads(st) self.assertTrue(e is not e2) self.assertTrue(isinstance(e2,InterpKernelException)) self.assertEqual(e2.what(),eStr) @@ -296,13 +296,13 @@ class MEDCouplingPickleTest(unittest.TestCase): def test14(self): """Pickelization of DataArrayBytes""" x=DataArrayByte(256,1) - for i in xrange(256): + for i in range(256): x[i]=-128+i pass x.rearrange(2) ; x.setInfoOnComponents(["aa","bbb"]) x.setName("toto") - st=cPickle.dumps(x,cPickle.HIGHEST_PROTOCOL) - x2=cPickle.loads(st) + st=pickle.dumps(x,pickle.HIGHEST_PROTOCOL) + x2=pickle.loads(st) self.assertTrue(x2.isEqual(x)) pass diff --git a/src/MEDCoupling_Swig/MEDCouplingRemapperTest.py b/src/MEDCoupling_Swig/MEDCouplingRemapperTest.py index 5ff24cd86..77a332abc 100644 --- a/src/MEDCoupling_Swig/MEDCouplingRemapperTest.py +++ b/src/MEDCoupling_Swig/MEDCouplingRemapperTest.py @@ -30,13 +30,13 @@ class MEDCouplingBasicsTest(unittest.TestCase): remapper=MEDCouplingRemapper() remapper.setPrecision(1e-12); remapper.setIntersectionType(Triangulation); - self.failUnless(remapper.prepare(sourceMesh,targetMesh,"P0P0")==1); + self.assertTrue(remapper.prepare(sourceMesh,targetMesh,"P0P0")==1); srcField=MEDCouplingFieldDouble.New(ON_CELLS); srcField.setNature(IntensiveMaximum); srcField.setMesh(sourceMesh); array=DataArrayDouble.New(); ptr=sourceMesh.getNumberOfCells()*[None] - for i in xrange(sourceMesh.getNumberOfCells()): + for i in range(sourceMesh.getNumberOfCells()): ptr[i]=float(i+7) pass array.setValues(ptr,sourceMesh.getNumberOfCells(),1); @@ -52,10 +52,10 @@ class MEDCouplingBasicsTest(unittest.TestCase): self.assertEqual(c,10) values=trgfield.getArray().getValues(); valuesExpected=[7.5 ,7. ,7.,8.,7.5]; - for i in xrange(targetMesh.getNumberOfCells()): - self.failUnless(abs(values[i]-valuesExpected[i])<1e-12); + for i in range(targetMesh.getNumberOfCells()): + self.assertTrue(abs(values[i]-valuesExpected[i])<1e-12); pass - self.failUnless(1==trgfield.getArray().getNumberOfComponents()); + self.assertTrue(1==trgfield.getArray().getNumberOfComponents()); pass def testPrepareEx1(self): @@ -75,7 +75,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): srcField.setMesh(sourceMesh); array=DataArrayDouble.New(); ptr=sourceMesh.getNumberOfCells()*[None] - for i in xrange(sourceMesh.getNumberOfCells()): + for i in range(sourceMesh.getNumberOfCells()): ptr[i]=float(i+7); pass array.setValues(ptr,sourceMesh.getNumberOfCells(),1); @@ -85,7 +85,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): valuesExpected=[7.75, 7.0625, 4.220173,8.0] self.assertEqual(4,trgfield.getArray().getNumberOfTuples()); self.assertEqual(1,trgfield.getArray().getNumberOfComponents()); - for i0 in xrange(4): + for i0 in range(4): self.assertAlmostEqual(valuesExpected[i0],values[i0],12); pass pass @@ -107,7 +107,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): srcField.setMesh(sourceMesh); array=DataArrayDouble.New(); ptr=sourceMesh.getNumberOfCells()*[None] - for i in xrange(sourceMesh.getNumberOfCells()): + for i in range(sourceMesh.getNumberOfCells()): ptr[i]=float(i+7); pass array.setValues(ptr,sourceMesh.getNumberOfCells(),1); @@ -117,7 +117,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): trgfield.setMesh(targetMesh); array=DataArrayDouble.New(); ptr=targetMesh.getNumberOfCells()*[None] - for i in xrange(targetMesh.getNumberOfCells()): + for i in range(targetMesh.getNumberOfCells()): ptr[i]=4.220173; pass array.setValues(ptr,targetMesh.getNumberOfCells(),1); @@ -127,7 +127,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): valuesExpected=[7.75, 7.0625, 4.220173,8.0] self.assertEqual(4,trgfield.getArray().getNumberOfTuples()); self.assertEqual(1,trgfield.getArray().getNumberOfComponents()); - for i0 in xrange(4): + for i0 in range(4): self.assertAlmostEqual(valuesExpected[i0],values[i0],12); pass pass @@ -308,7 +308,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): rem2=MEDCouplingRemapper() ; rem2.setSplittingPolicy(PLANAR_FACE_5) ; rem2.prepare(src1,trg,"P0P0") mat1=rem1.getCrudeMatrix() ; mat2=rem2.getCrudeMatrix() self.assertEqual(1,len(mat1)) ; self.assertEqual(1,len(mat2)) - self.assertEqual(mat1[0].keys(),mat2[0].keys()) ; self.assertEqual([0,1],mat1[0].keys()) + self.assertEqual(list(mat1[0].keys()),list(mat2[0].keys())) ; self.assertEqual([0,1],list(mat1[0].keys())) self.assertAlmostEqual(1.25884108122e-06,mat1[0][0],16) ; self.assertAlmostEqual(1.25884108122e-06,mat2[0][0],16) self.assertAlmostEqual(1.25884086663e-06,mat1[0][1],16) ; self.assertAlmostEqual(1.25884086663e-06,mat2[0][1],16) # @@ -570,7 +570,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): self.assertEqual(aRemapper.prepare(s,t,'P1P1'),1) m=aRemapper.getCrudeMatrix() self.assertEqual(len(m),28) - for i in xrange(28): + for i in range(28): if i not in [5,6]: self.assertEqual(len(m[i]),0) pass @@ -727,7 +727,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): rem=MEDCouplingRemapper() rem.prepare(src,trg,"P0P0") # Internal crude sparse matrix computed. Let's manipulate it using CSR matrix in scipy. - for i in xrange(10): + for i in range(10): m=rem.getCrudeCSRMatrix() pass m2=rem.getCrudeCSRMatrix() @@ -776,7 +776,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): a.allocateCells() conna=[0,1,3,2,1,4,5,3,4,6,7,5,6,8,9,7,8,10,11,9,10,12,13,11,12,14,15,13,14,16,17,15,16,18,19,17,18,20,21,19,20,22,23,21,22,24,25,23,24,26,27,25] a.setCoords(DataArrayDouble([1.54,0,-0.01,1.54,0.02,-0.01,1.54,0,0.01,1.54,0.02,0.01,1.54,0.04,-0.01,1.54,0.04,0.01,1.54,0.06,-0.01,1.54,0.06,0.01,1.54,0.08,-0.01,1.54,0.08,0.01,1.54,0.1,-0.01,1.54,0.1,0.01,1.54,0.12,-0.01,1.54,0.12,0.01,1.54,0.14,-0.01,1.54,0.14,0.01,1.54,0.16,-0.01,1.54,0.16,0.01,1.54,0.18,-0.01,1.54,0.18,0.01,1.54,0.2,-0.01,1.54,0.2,0.01,1.54,0.22,-0.01,1.54,0.22,0.01,1.54,0.24,-0.01,1.54,0.24,0.01,1.54,0.26,-0.01,1.54,0.26,0.01],28,3)) - for i in xrange(13): + for i in range(13): a.insertNextCell(NORM_QUAD4,conna[4*i:4*(i+1)]) pass a.finishInsertingCells() ; a.simplexize(0) @@ -784,7 +784,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): connb=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,0,2,39,3,5,40,6,8,41,9,11,42,12,14,43,15,17,44,18,20,45,21,23,46,24,26,47,27,29,48,30,32,49,33,35,50,36,38,51,52,2,39,53,5,40,54,8,41,55,11,42,56,14,43,57,17,44,58,20,45,59,23,46,60,26,47,61,29,48,62,32,49,63,35,50,64,38,51,52,2,65,53,5,66,54,8,67,55,11,68,56,14,69,57,17,70,58,20,71,59,23,72,60,26,73,61,29,74,62,32,75,63,35,76,64,38,77,53,2,65,54,5,66,55,8,67,56,11,68,57,14,69,58,17,70,59,20,71,60,23,72,61,26,73,62,29,74,63,32,75,64,35,76,78,38,77,53,2,40,54,5,41,55,8,42,56,11,43,57,14,44,58,17,45,59,20,46,60,23,47,61,26,48,62,29,49,63,32,50,64,35,51,78,38,79,3,2,40,6,5,41,9,8,42,12,11,43,15,14,44,18,17,45,21,20,46,24,23,47,27,26,48,30,29,49,33,32,50,36,35,51,80,38,79,3,2,1,6,5,4,9,8,7,12,11,10,15,14,13,18,17,16,21,20,19,24,23,22,27,26,25,30,29,28,33,32,31,36,35,34,80,38,37] b=MEDCouplingUMesh("b",2) b.allocateCells() - for i in xrange(104): + for i in range(104): b.insertNextCell(NORM_TRI3,connb[3*i:3*(i+1)]) pass b.setCoords(DataArrayDouble([1.54,0,-0.01,1.54,0.01,-0.01,1.54,0.01,0,1.54,0.02,-0.01,1.54,0.03,-0.01,1.54,0.03,0,1.54,0.04,-0.01,1.54,0.05,-0.01,1.54,0.05,0,1.54,0.06,-0.01,1.54,0.07,-0.01,1.54,0.07,0,1.54,0.08,-0.01,1.54,0.09,-0.01,1.54,0.09,0,1.54,0.1,-0.01,1.54,0.11,-0.01,1.54,0.11,0,1.54,0.12,-0.01,1.54,0.13,-0.01,1.54,0.13,0,1.54,0.14,-0.01,1.54,0.15,-0.01,1.54,0.15,0,1.54,0.16,-0.01,1.54,0.17,-0.01,1.54,0.17,0,1.54,0.18,-0.01,1.54,0.19,-0.01,1.54,0.19,0,1.54,0.2,-0.01,1.54,0.21,-0.01,1.54,0.21,0,1.54,0.22,-0.01,1.54,0.23,-0.01,1.54,0.23,0,1.54,0.24,-0.01,1.54,0.25,-0.01,1.54,0.25,0,1.54,0,0,1.54,0.02,0,1.54,0.04,0,1.54,0.06,0,1.54,0.08,0,1.54,0.1,0,1.54,0.12,0,1.54,0.14,0,1.54,0.16,0,1.54,0.18,0,1.54,0.2,0,1.54,0.22,0,1.54,0.24,0,1.54,0,0.01,1.54,0.02,0.01,1.54,0.04,0.01,1.54,0.06,0.01,1.54,0.08,0.01,1.54,0.1,0.01,1.54,0.12,0.01,1.54,0.14,0.01,1.54,0.16,0.01,1.54,0.18,0.01,1.54,0.2,0.01,1.54,0.22,0.01,1.54,0.24,0.01,1.54,0.01,0.01,1.54,0.03,0.01,1.54,0.05,0.01,1.54,0.07,0.01,1.54,0.09,0.01,1.54,0.11,0.01,1.54,0.13,0.01,1.54,0.15,0.01,1.54,0.17,0.01,1.54,0.19,0.01,1.54,0.21,0.01,1.54,0.23,0.01,1.54,0.25,0.01,1.54,0.26,0.01,1.54,0.26,0,1.54,0.26,-0.01],81,3)) @@ -860,7 +860,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): source=MEDCoupling1SGTUMesh("SourcePrimaire",NORM_SEG2) source.setCoords(sourceCoo) source.allocateCells() - for i in xrange(len(sourceCoo)-1): + for i in range(len(sourceCoo)-1): source.insertNextCell([i,i+1]) pass source=source.buildUnstructured() @@ -1157,7 +1157,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): def checkMatrix(self,mat1,mat2,nbCols,eps): self.assertEqual(len(mat1),len(mat2)) - for i in xrange(len(mat1)): + for i in range(len(mat1)): self.assertTrue(max(mat2[i].keys())=0) @@ -1211,7 +1211,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): targetMesh=MEDCouplingUMesh.New(); targetMesh.setMeshDimension(2); targetMesh.allocateCells(4); - for i in xrange(4): + for i in range(4): targetMesh.insertNextCell(NORM_QUAD4,4,targetConn[4*i:4*(i+1)]) pass targetMesh.finishInsertingCells(); diff --git a/src/MEDLoader/Swig/CaseIO.py b/src/MEDLoader/Swig/CaseIO.py index 1b71cc54f..9c0467f2a 100644 --- a/src/MEDLoader/Swig/CaseIO.py +++ b/src/MEDLoader/Swig/CaseIO.py @@ -25,7 +25,7 @@ class CaseIO: dictMCTyp={NORM_HEXA8:"hexa8",NORM_POLYHED:"nfaced",NORM_QUAD4:"quad4",NORM_POLYGON:"nsided",NORM_POINT1:"point",NORM_SEG2:"bar2",NORM_SEG3:"bar3",NORM_TRI3:"tria3",NORM_TRI6:"tria6",NORM_QUAD8:"quad8",NORM_TETRA4:"tetra4",NORM_TETRA10:"tetra10",NORM_PYRA5:"pyramid5",NORM_PYRA13:"pyramid13",NORM_PENTA6:"penta6",NORM_PENTA15:"penta15",NORM_HEXA20:"hexa20"} discSpatial={ON_CELLS:"element",ON_NODES:"node"} dictCompo={1:"scalar",3:"vector",6:"tensor",9:"tensor9"} - dictMCTyp2=dict((v,k) for k,v in dictMCTyp.iteritems()) - discSpatial2=dict((v,k) for k,v in discSpatial.iteritems()) - dictCompo2=dict((v,k) for k,v in dictCompo.iteritems()) + dictMCTyp2=dict((v,k) for k,v in dictMCTyp.items()) + discSpatial2=dict((v,k) for k,v in discSpatial.items()) + dictCompo2=dict((v,k) for k,v in dictCompo.items()) pass diff --git a/src/MEDLoader/Swig/CaseReader.py b/src/MEDLoader/Swig/CaseReader.py index ea266d3fc..f70ec1704 100644 --- a/src/MEDLoader/Swig/CaseReader.py +++ b/src/MEDLoader/Swig/CaseReader.py @@ -166,7 +166,7 @@ class CaseReader(CaseIO): pos+=nbNodes*3*4 ; fd.seek(pos)#np.array(0,dtype='float%i'%(typeOfCoo)).nbytes typ=fd.read(80).strip() ; pos=fd.tell() zeK="" - for k in self.dictMCTyp2.keys(): + for k in list(self.dictMCTyp2.keys()): if k in typ: zeK=k break @@ -327,7 +327,7 @@ class CaseReader(CaseIO): nbOfValsOfTyp=np.memmap(fd,dtype='>i4',mode='r',offset=pos,shape=(1)).tolist()[0]/4 pos+=4 vals=np.zeros(dtype=">f4",shape=(nbOfValsOfTyp*nbCompo)) - for iii in xrange(nbCompo): + for iii in range(nbCompo): valsTmp=np.memmap(fd,dtype='>f4',mode='r',offset=int(pos),shape=(nbOfValsOfTyp)) vals[iii*nbOfValsOfTyp:(iii+1)*nbOfValsOfTyp]=valsTmp pos+=nbOfValsOfTyp*4 @@ -368,7 +368,7 @@ class CaseReader(CaseIO): if "TIME\n" in lines: end=lines.index("TIME\n") pass - for i in xrange(ind+1,end): + for i in range(ind+1,end): m=re.match("^([\w]+)[\s]+\per[\s]+([\w]+)[\s]*\:[\s]*([\w]+)[\s]+([\S]+)$",lines[i]) if m: if m.groups()[0]=="constant": @@ -379,7 +379,7 @@ class CaseReader(CaseIO): pass expr=re.compile("number[\s]+of[\s]+steps[\s]*\:[\s]*([\d]+)") - tmp=filter(expr.search,lines) + tmp=list(filter(expr.search,lines)) if len(tmp)!=0: nbOfTimeSteps=int(expr.search(filter(expr.search,lines)[0]).group(1)) expr=re.compile("filename[\s]+start[\s]+number[\s]*\:[\s]*([\d]+)") @@ -402,7 +402,7 @@ class CaseReader(CaseIO): i+=1 pass pass - for ts in xrange(nbOfTimeSteps): + for ts in range(nbOfTimeSteps): i=0 for field in fieldsInfo: if typeOfFile: @@ -416,7 +416,7 @@ class CaseReader(CaseIO): pass ret=MEDFileData() ret.setMeshes(m2) - del mlfields[filter(lambda x: len(mlfields[x])==0,range(len(mlfields)))] + del mlfields[[x for x in range(len(mlfields)) if len(mlfields[x])==0]] ret.setFields(mlfields) return ret diff --git a/src/MEDLoader/Swig/CaseWriter.py b/src/MEDLoader/Swig/CaseWriter.py index 7d23153ad..ad3b23056 100644 --- a/src/MEDLoader/Swig/CaseWriter.py +++ b/src/MEDLoader/Swig/CaseWriter.py @@ -201,7 +201,7 @@ time values: self._ze_top_dict={} its,areForgottenTS=mdfs.getCommonIterations() if areForgottenTS: - print "WARNING : some iterations are NOT present in all fields ! Kept iterations are : %s !"%(str(its)) + print("WARNING : some iterations are NOT present in all fields ! Kept iterations are : %s !"%(str(its))) pass TimeValues="" for it in its: @@ -211,12 +211,12 @@ time values: for mdf in mdfs: nbCompo=mdf.getNumberOfComponents() if nbCompo not in self.dictCompo: - l=filter(lambda x:x-nbCompo>0,self.dictCompo.keys()) + l=[x for x in list(self.dictCompo.keys()) if x-nbCompo>0] if len(l)==0: - print "Field \"%s\" will be ignored because number of components (%i) is too big to be %s supported by case files !"%(mdf.getName(),nbCompo,str(self.dictCompo.keys())) + print("Field \"%s\" will be ignored because number of components (%i) is too big to be %s supported by case files !"%(mdf.getName(),nbCompo,str(list(self.dictCompo.keys())))) continue pass - print "WARNING : Field \"%s\" will have its number of components (%i) set to %i, in order to be supported by case files (must be in %s) !"%(mdf.getName(),nbCompo,l[0],str(self.dictCompo.keys())) + print("WARNING : Field \"%s\" will have its number of components (%i) set to %i, in order to be supported by case files (must be in %s) !"%(mdf.getName(),nbCompo,l[0],str(list(self.dictCompo.keys())))) nbCompo=l[0] pass if nbCompo in dictVars: @@ -229,7 +229,7 @@ time values: for mdf in mdfs: nbCompo=mdf.getNumberOfComponents() if nbCompo not in self.dictCompo: - l=filter(lambda x:x-nbCompo>0,self.dictCompo.keys()) + l=[x for x in list(self.dictCompo.keys()) if x-nbCompo>0] if len(l)==0: continue; nbCompo=l[0] @@ -276,7 +276,7 @@ time values: mm.write(self.__str80("coordinates")) pass else: - print "UnManaged type of field for field \"%s\" !"%(mdf.getName()) + print("UnManaged type of field for field \"%s\" !"%(mdf.getName())) pass a=np.memmap(f,dtype='float32',mode='w+',offset=mm.tell(),shape=(nbCompo,end-bg)) b=arr.toNumPyArray() ; b=b.reshape(nbCompo,end-bg) diff --git a/src/MEDLoader/Swig/ConvertMEDFileTo30.py b/src/MEDLoader/Swig/ConvertMEDFileTo30.py index 88f523354..3501af902 100644 --- a/src/MEDLoader/Swig/ConvertMEDFileTo30.py +++ b/src/MEDLoader/Swig/ConvertMEDFileTo30.py @@ -35,12 +35,12 @@ def ConvertTo30(nameOfMEDFile): # finalVersion=ml.MEDFileVersionOfFileStr(realFnOut) # - print("File \"%s\" has been converted to 3.0 successfuly ( %s -> %s ) !\nOutput file is here : \"%s\" !"%(fn,initalVersion,finalVersion,realFnOut)) + print(("File \"%s\" has been converted to 3.0 successfuly ( %s -> %s ) !\nOutput file is here : \"%s\" !"%(fn,initalVersion,finalVersion,realFnOut))) pass if __name__=="__main__": import argparse - parser=argparse.ArgumentParser(description=u'Convert a MED file into a MED file with 3.0 version (3.0.8)') + parser=argparse.ArgumentParser(description='Convert a MED file into a MED file with 3.0 version (3.0.8)') parser.add_argument('nameOfMEDFile', type=str, nargs=1,help='File name of the MED file to be converted into 3.0.') args=parser.parse_args() nameOfMEDFile=args.nameOfMEDFile[0] diff --git a/src/MEDLoader/Swig/MEDLoaderCouplingTrainingSession.py b/src/MEDLoader/Swig/MEDLoaderCouplingTrainingSession.py index e301dd71a..135c1b9cd 100644 --- a/src/MEDLoader/Swig/MEDLoaderCouplingTrainingSession.py +++ b/src/MEDLoader/Swig/MEDLoaderCouplingTrainingSession.py @@ -25,13 +25,13 @@ import math, os d=DataArrayDouble.New(6,2) d[:,0]=3. -d[:,1]=range(6) +d[:,1]=list(range(6)) d[:,1]*=math.pi/3. d=d.fromPolarToCart() d.setInfoOnComponents(["X [m]","Y [m]"]) -print d.getValues() -print d -print d.magnitude().isUniform(3.,1e-12) +print(d.getValues()) +print(d) +print(d.magnitude().isUniform(3.,1e-12)) # radius=3. translationToPerform=[[0.,0.],[3./2.*radius,-radius*math.sqrt(3.)/2],[3./2.*radius,radius*math.sqrt(3.)/2],[0.,radius*math.sqrt(3.)],[-3./2.*radius,radius*math.sqrt(3.)/2],[-3./2.*radius,-radius*math.sqrt(3.)/2],[0.,-radius*math.sqrt(3.)]] @@ -45,24 +45,24 @@ d2=DataArrayDouble.Aggregate(ds) oldNbOfTuples=d2.getNumberOfTuples() c,cI=d2.findCommonTuples(1e-12) tmp=c[cI[0]:cI[0+1]] -print tmp +print(tmp) a=cI.deltaShiftIndex() b=a-1 myNewNbOfTuples=oldNbOfTuples-sum(b.getValues()) o2n,newNbOfTuples=DataArrayInt.ConvertIndexArrayToO2N(oldNbOfTuples,c,cI) -print "Ai je trouve le bon resultat ? %s"%(str(myNewNbOfTuples==newNbOfTuples)) ; assert myNewNbOfTuples==newNbOfTuples +print("Ai je trouve le bon resultat ? %s"%(str(myNewNbOfTuples==newNbOfTuples))) ; assert myNewNbOfTuples==newNbOfTuples # d3=d2.renumberAndReduce(o2n,newNbOfTuples) n2o=o2n.invertArrayO2N2N2O(newNbOfTuples) d3_bis=d2[n2o] -print "Ai je trouve le bon resultat (2) ? %s"%(str(d3.isEqual(d3_bis,1e-12))) ; assert d3.isEqual(d3_bis,1e-12) +print("Ai je trouve le bon resultat (2) ? %s"%(str(d3.isEqual(d3_bis,1e-12)))) ; assert d3.isEqual(d3_bis,1e-12) # d3+=[3.3,4.4] # d3 contains coordinates m=MEDCouplingUMesh.New("My7hexagons",2) m.setCoords(d3) m.allocateCells(7) -for i in xrange(7): +for i in range(7): m.insertNextCell(NORM_POLYGON,o2n[6*i:6*(i+1)].getValues()) pass m.finishInsertingCells() @@ -99,7 +99,7 @@ mesh3D.setCoords(myCoords); mesh3D.orientCorrectlyPolyhedrons() mesh3D.sortCellsInMEDFileFrmt() mesh3D.checkConsistencyLight() -renum=DataArrayInt.New(60) ; renum[:15]=range(15,30) ; renum[15:30]=range(15) ; renum[30:45]=range(45,60) ; renum[45:]=range(30,45) +renum=DataArrayInt.New(60) ; renum[:15]=list(range(15,30)) ; renum[15:30]=list(range(15)) ; renum[30:45]=list(range(45,60)) ; renum[45:]=list(range(30,45)) mesh3D.renumberNodes(renum,60) # mesh3D.getCoords()[:]*=100. @@ -117,13 +117,13 @@ nodeIds=mesh3D.findNodesOnPlane([0.,0.,zLev[0]],[0.,0.,1.],1e-10) mesh2D=mesh3D.buildFacePartOfMySelfNode(nodeIds,True) extMesh=MEDCouplingMappedExtrudedMesh.New(mesh3D,mesh2D,0) cellIdsSol3=extMesh.getMesh3DIds()[mesh2D.getNumberOfCells():2*mesh2D.getNumberOfCells()] -for i in xrange(3): +for i in range(3): exec("print cellIdsSol%s.getValues()"%(i+1)) # mesh3DPart=mesh3D[cellIdsSol2] # equivalent to mesh3DPart=mesh3D.buildPartOfMySelf(cellIdsSol2,True) mesh3DPart.zipCoords() -print mesh3DPart.checkConsecutiveCellTypesAndOrder([NORM_HEXA8,NORM_POLYHED]) ; assert mesh3DPart.checkConsecutiveCellTypesAndOrder([NORM_HEXA8,NORM_POLYHED]) -print mesh3DPart.checkConsecutiveCellTypes() ; assert mesh3DPart.checkConsecutiveCellTypes() +print(mesh3DPart.checkConsecutiveCellTypesAndOrder([NORM_HEXA8,NORM_POLYHED])) ; assert mesh3DPart.checkConsecutiveCellTypesAndOrder([NORM_HEXA8,NORM_POLYHED]) +print(mesh3DPart.checkConsecutiveCellTypes()) ; assert mesh3DPart.checkConsecutiveCellTypes() #print mesh3DPart.advancedRepr() # baryXY=bary[:,[0,1]] @@ -136,7 +136,7 @@ bary2-=[250.,150.] magn=bary2.magnitude() ids=magn.findIdsInRange(0.,1e-12) idStart=int(ids) # ids is assumed to contain only one value, if not an exception is thrown -cellIds2Sol2=extMesh.getMesh3DIds()[range(idStart,mesh3D.getNumberOfCells(),mesh2D.getNumberOfCells())] +cellIds2Sol2=extMesh.getMesh3DIds()[list(range(idStart,mesh3D.getNumberOfCells(),mesh2D.getNumberOfCells()))] # mesh3DSlice2=mesh3D[cellIds2Sol1] mesh3DSlice2.zipCoords() @@ -169,7 +169,7 @@ f2=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME) f2.setMesh(mesh) f2.setName("MyField2") f2.fillFromAnalytic(1,"(x-5.)*(x-5.)+(y-5.)*(y-5.)+(z-5.)*(z-5.)") -print "f and f2 are equal : %s"%(f.isEqualWithoutConsideringStr(f2,1e-13,1e-12)) ; assert f.isEqualWithoutConsideringStr(f2,1e-13,1e-12) +print("f and f2 are equal : %s"%(f.isEqualWithoutConsideringStr(f2,1e-13,1e-12))) ; assert f.isEqualWithoutConsideringStr(f2,1e-13,1e-12) # ids1=f.getArray().findIdsInRange(0.,5.) fPart1=f.buildSubPart(ids1) @@ -182,7 +182,7 @@ fPart1Cpy.getArray().renumberInPlace(o2n) #Check that fPart1Cpy and fPart1 are the same fPart1Cpy.substractInPlaceDM(fPart1,12,1e-12) fPart1Cpy.getArray().abs() -print "Fields are the same ? %s"%(fPart1Cpy.getArray().accumulate()[0]<1e-12) ; assert fPart1Cpy.getArray().accumulate()[0]<1e-12 +print("Fields are the same ? %s"%(fPart1Cpy.getArray().accumulate()[0]<1e-12)) ; assert fPart1Cpy.getArray().accumulate()[0]<1e-12 # fPart12=MEDCouplingFieldDouble.MergeFields([fPart1,fPart2]) # evaluation on points @@ -191,11 +191,11 @@ arr1=fPart12.getValueOnMulti(bary) arr2=f.getValueOnMulti(bary) delta=arr1-arr2 delta.abs() -print "Check OK : %s"%(delta.accumulate()[0]<1e-12) ; assert delta.accumulate()[0]<1e-12 +print("Check OK : %s"%(delta.accumulate()[0]<1e-12)) ; assert delta.accumulate()[0]<1e-12 # -print abs(fPart12.integral(0,True)-fPart12.getArray().accumulate()[0])<1e-10 ; assert abs(fPart12.integral(0,True)-fPart12.getArray().accumulate()[0])<1e-10 +print(abs(fPart12.integral(0,True)-fPart12.getArray().accumulate()[0])<1e-10) ; assert abs(fPart12.integral(0,True)-fPart12.getArray().accumulate()[0])<1e-10 fPart12.getMesh().scale([0.,0.,0.],1.2) -print abs(fPart12.integral(0,True)-fPart12.getArray().accumulate()[0]*1.2*1.2*1.2)<1e-8 ; assert abs(fPart12.integral(0,True)-fPart12.getArray().accumulate()[0]*1.2*1.2*1.2)<1e-8 +print(abs(fPart12.integral(0,True)-fPart12.getArray().accumulate()[0]*1.2*1.2*1.2)<1e-8) ; assert abs(fPart12.integral(0,True)-fPart12.getArray().accumulate()[0]*1.2*1.2*1.2)<1e-8 # Explosion of field fVec=mesh.fillFromAnalytic(ON_CELLS,3,"(x-5.)*IVec+(y-5.)*JVec+(z-5.)*KVec") fVecPart1=fVec.buildSubPart(ids1) @@ -229,7 +229,7 @@ targetMesh.setCoords(myCoords); WriteUMesh("TargetMesh.med",targetMesh,True) # meshRead=ReadUMeshFromFile("TargetMesh.med",targetMesh.getName(),0) -print "Is the mesh read in file equals targetMesh ? %s"%(meshRead.isEqual(targetMesh,1e-12)) ; assert meshRead.isEqual(targetMesh,1e-12) +print("Is the mesh read in file equals targetMesh ? %s"%(meshRead.isEqual(targetMesh,1e-12))) ; assert meshRead.isEqual(targetMesh,1e-12) # f=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME) f.setTime(5.6,7,8) @@ -239,7 +239,7 @@ f.setName("AFieldName") WriteField("MyFirstField.med",f,True) # f2=ReadFieldCell("MyFirstField.med",f.getMesh().getName(),0,f.getName(),7,8) -print "Is the field read in file equals f ? %s"%(f2.isEqual(f,1e-12,1e-12)) ; assert f2.isEqual(f,1e-12,1e-12) +print("Is the field read in file equals f ? %s"%(f2.isEqual(f,1e-12,1e-12))) ; assert f2.isEqual(f,1e-12,1e-12) # WriteUMesh("MySecondField.med",f.getMesh(),True) WriteFieldUsingAlreadyWrittenMesh("MySecondField.med",f) @@ -250,9 +250,9 @@ f2.setTime(7.8,9,10) WriteFieldUsingAlreadyWrittenMesh("MySecondField.med",f2) # f3=ReadFieldCell("MySecondField.med",f.getMesh().getName(),0,f.getName(),7,8) -print "Is the field read in file equals f ? %s"%(f.isEqual(f3,1e-12,1e-12)) ; assert f.isEqual(f3,1e-12,1e-12) +print("Is the field read in file equals f ? %s"%(f.isEqual(f3,1e-12,1e-12))) ; assert f.isEqual(f3,1e-12,1e-12) f4=ReadFieldCell("MySecondField.med",f.getMesh().getName(),0,f.getName(),9,10) -print "Is the field read in file equals f ? %s"%(f2.isEqual(f4,1e-12,1e-12)) ; assert f2.isEqual(f4,1e-12,1e-12) +print("Is the field read in file equals f ? %s"%(f2.isEqual(f4,1e-12,1e-12))) ; assert f2.isEqual(f4,1e-12,1e-12) ##### @@ -292,12 +292,12 @@ meshMEDFile.write("TargetMesh2.med",2) # 2 stands for write from scratch meshMEDFileRead=MEDFileMesh.New("TargetMesh2.med") meshRead0=meshMEDFileRead.getMeshAtLevel(0) meshRead1=meshMEDFileRead.getMeshAtLevel(-1) -print "Is the mesh at level 0 read in file equals targetMesh ? %s"%(meshRead0.isEqual(targetMesh,1e-12)) ; assert meshRead0.isEqual(targetMesh,1e-12) -print "Is the mesh at level -1 read in file equals targetMesh ? %s"%(meshRead1.isEqual(targetMesh1,1e-12)) ; assert meshRead1.isEqual(targetMesh1,1e-12) +print("Is the mesh at level 0 read in file equals targetMesh ? %s"%(meshRead0.isEqual(targetMesh,1e-12))) ; assert meshRead0.isEqual(targetMesh,1e-12) +print("Is the mesh at level -1 read in file equals targetMesh ? %s"%(meshRead1.isEqual(targetMesh1,1e-12))) ; assert meshRead1.isEqual(targetMesh1,1e-12) # -print meshMEDFileRead.getGrpNonEmptyLevels("grp0_Lev0") +print(meshMEDFileRead.getGrpNonEmptyLevels("grp0_Lev0")) grp0_0_read=meshMEDFileRead.getGroupArr(0,"grp0_Lev0") -print "Is group \"grp0_Lev0\" are the same ? %s"%(grp0_0_read.isEqual(grp0_0)) ; assert grp0_0_read.isEqual(grp0_0) +print("Is group \"grp0_Lev0\" are the same ? %s"%(grp0_0_read.isEqual(grp0_0))) ; assert grp0_0_read.isEqual(grp0_0) # # Fields # @@ -315,8 +315,8 @@ fMEDFile.write("TargetMesh2.med",0) # 0 is very important here because we want t fMEDFileRead=MEDFileField1TS.New("TargetMesh2.med",f.getName(),7,8) fRead1=fMEDFileRead.getFieldOnMeshAtLevel(ON_CELLS,0,meshMEDFileRead) # fastest method. No read in file. fRead2=fMEDFileRead.getFieldAtLevel(ON_CELLS,0) # basic method like, mesh is reread in file... -print "Does the field f remains the same using fast method ? %s"%(fRead1.isEqual(f,1e-12,1e-12)) ; assert fRead1.isEqual(f,1e-12,1e-12) -print "Does the field f remains the same using slow method ? %s"%(fRead2.isEqual(f,1e-12,1e-12)) ; assert fRead2.isEqual(f,1e-12,1e-12) +print("Does the field f remains the same using fast method ? %s"%(fRead1.isEqual(f,1e-12,1e-12))) ; assert fRead1.isEqual(f,1e-12,1e-12) +print("Does the field f remains the same using slow method ? %s"%(fRead2.isEqual(f,1e-12,1e-12))) ; assert fRead2.isEqual(f,1e-12,1e-12) # # Writing and Reading fields on profile using MEDLoader advanced API # @@ -330,8 +330,8 @@ fMEDFile2.write("TargetMesh2.med",0) # 0 is very important here because we want # fMEDFileRead2=MEDFileField1TS.New("TargetMesh2.med",fPart.getName(),7,8) fPartRead,pflRead=fMEDFileRead2.getFieldWithProfile(ON_CELLS,0,meshMEDFileRead) -print fPartRead.isEqualWithoutConsideringStr(fPart.getArray(),1e-12) ; assert fPartRead.isEqualWithoutConsideringStr(fPart.getArray(),1e-12) -print pflRead.isEqualWithoutConsideringStr(pfl) ; assert pflRead.isEqualWithoutConsideringStr(pfl) +print(fPartRead.isEqualWithoutConsideringStr(fPart.getArray(),1e-12)) ; assert fPartRead.isEqualWithoutConsideringStr(fPart.getArray(),1e-12) +print(pflRead.isEqualWithoutConsideringStr(pfl)) ; assert pflRead.isEqualWithoutConsideringStr(pfl) ##### @@ -370,7 +370,7 @@ CellField_read=MEDCouplingFieldDouble.MergeFields([CellField0_read,CellField1_re CellFieldCpy=CellField.deepCopy() CellFieldCpy.substractInPlaceDM(CellField_read,10,1e-12) CellFieldCpy.getArray().abs() -print CellFieldCpy.getArray().isUniform(0.,1e-12) +print(CellFieldCpy.getArray().isUniform(0.,1e-12)) # NodeField0_read=ReadFieldNode("proc0.med","mesh",0,"NodeField",5,6) NodeField1_read=ReadFieldNode("proc1.med","mesh",0,"NodeField",5,6) @@ -379,7 +379,7 @@ NodeField_read.mergeNodes(1e-10) NodeFieldCpy=NodeField.deepCopy() NodeFieldCpy.mergeNodes(1e-10) NodeFieldCpy.substractInPlaceDM(NodeField_read,10,1e-12) -print NodeFieldCpy.getArray().isUniform(0.,1e-12) ; assert NodeFieldCpy.getArray().isUniform(0.,1e-12) +print(NodeFieldCpy.getArray().isUniform(0.,1e-12)) ; assert NodeFieldCpy.getArray().isUniform(0.,1e-12) # fileNames=["proc0.med","proc1.med"] msML=[MEDFileMesh.New(fname) for fname in fileNames] @@ -408,7 +408,7 @@ for fieldName in fsML[0].getFieldsNames(): for ft in fts: for geoTyp,smth in ft.getFieldSplitedByType(): if geoTyp!=NORM_ERROR: - smth1=filter(lambda x:x[0]==ON_CELLS,smth) + smth1=[x for x in smth if x[0]==ON_CELLS] arr2s=[ft.getUndergroundDataArray()[elt[1][0]:elt[1][1]] for elt in smth1] arr1s.append(DataArrayDouble.Aggregate(arr2s)) pass @@ -417,7 +417,7 @@ for fieldName in fsML[0].getFieldsNames(): pass else: for ft in fts: - smth=filter(lambda x:x[0]==NORM_ERROR,ft.getFieldSplitedByType()) + smth=[x for x in ft.getFieldSplitedByType() if x[0]==NORM_ERROR] arr2=DataArrayDouble.Aggregate([ft.getUndergroundDataArray()[elt[1][0][1][0]:elt[1][0][1][1]] for elt in smth]) arr1s.append(arr2) pass @@ -450,14 +450,14 @@ remap=MEDCouplingRemapper() remap.prepare(srcMesh,trgMesh,"P0P0") # myMatrix=remap.getCrudeMatrix() -print myMatrix # pour voir a quoi elle ressemble +print(myMatrix) # pour voir a quoi elle ressemble sumByRows=DataArrayDouble(len(myMatrix)) for i,wIt in enumerate(sumByRows): su=0. for it in myMatrix[i]: su+=myMatrix[i][it] wIt[0]=su -print "Does interpolation look OK ? %s"%(str(sumByRows.isUniform(1.,1e-12))) ; assert sumByRows.isUniform(1.,1e-12) +print("Does interpolation look OK ? %s"%(str(sumByRows.isUniform(1.,1e-12)))) ; assert sumByRows.isUniform(1.,1e-12) # srcField=MEDCouplingFieldDouble(ON_CELLS,ONE_TIME) ; srcField.setMesh(srcMesh) srcField.fillFromAnalytic(1,"7-sqrt((x-5.)*(x-5.)+(y-5.)*(y-5.))") ; CellField.getArray().setInfoOnComponent(0,"powercell [W]") @@ -466,14 +466,14 @@ srcField.fillFromAnalytic(1,"7-sqrt((x-5.)*(x-5.)+(y-5.)*(y-5.))") ; CellField.g srcField.setNature(IntensiveMaximum) trgFieldCV=remap.transferField(srcField,1e300) # -print "IntensiveMaximum %lf == %lf"%(srcField.integral(True)[0],trgFieldCV.integral(True)[0]) ; assert abs(srcField.integral(True)[0]-trgFieldCV.integral(True)[0])<1e-6 -print "IntensiveMaximum %lf != %lf"%(srcField.getArray().accumulate()[0],trgFieldCV.getArray().accumulate()[0]) ; assert abs(srcField.getArray().accumulate()[0]-trgFieldCV.getArray().accumulate()[0])>1e-6 +print("IntensiveMaximum %lf == %lf"%(srcField.integral(True)[0],trgFieldCV.integral(True)[0])) ; assert abs(srcField.integral(True)[0]-trgFieldCV.integral(True)[0])<1e-6 +print("IntensiveMaximum %lf != %lf"%(srcField.getArray().accumulate()[0],trgFieldCV.getArray().accumulate()[0])) ; assert abs(srcField.getArray().accumulate()[0]-trgFieldCV.getArray().accumulate()[0])>1e-6 # srcField.setNature(ExtensiveMaximum) trgFieldI=remap.transferField(srcField,1e300) # -print "ExtensiveConservation %lf != %lf"%(srcField.integral(True)[0],trgFieldI.integral(True)[0]) ; assert abs(srcField.integral(True)[0]-trgFieldI.integral(True)[0])>1e-6 -print "ExtensiveConservation %lf == %lf"%(srcField.getArray().accumulate()[0],trgFieldI.getArray().accumulate()[0]) ; assert abs(srcField.getArray().accumulate()[0]-trgFieldI.getArray().accumulate()[0])<1e-6 +print("ExtensiveConservation %lf != %lf"%(srcField.integral(True)[0],trgFieldI.integral(True)[0])) ; assert abs(srcField.integral(True)[0]-trgFieldI.integral(True)[0])>1e-6 +print("ExtensiveConservation %lf == %lf"%(srcField.getArray().accumulate()[0],trgFieldI.getArray().accumulate()[0])) ; assert abs(srcField.getArray().accumulate()[0]-trgFieldI.getArray().accumulate()[0])<1e-6 ###### @@ -490,7 +490,7 @@ if not os.path.exists(agitateur_file): pass data=MEDFileData(agitateur_file) ts=data.getFields()[0].getTimeSteps() -print ts +print(ts) # fMts=data.getFields()["DISTANCE_INTERFACE_ELEM_BODY_ELEM_DOM"] f1ts=fMts[(2,-1)] @@ -534,7 +534,7 @@ posSkin=barySkin-centerOfMass torquePerCellOnSkin=DataArrayDouble.CrossProduct(posSkin,forceVectSkin) zeTorque=torquePerCellOnSkin.accumulate() -print "couple = %r N.m"%(zeTorque[2]) ; assert abs(zeTorque[2]-0.37)<1e-2 +print("couple = %r N.m"%(zeTorque[2])) ; assert abs(zeTorque[2]-0.37)<1e-2 speedMts=data.getFields()["VITESSE_ELEM_DOM"] speed1ts=speedMts[(2,-1)] @@ -542,7 +542,7 @@ speedMc=speed1ts.getFieldAtLevel(ON_CELLS,0) speedOnSkin=speedMc.getArray()[tupleIdsInField] powerSkin=DataArrayDouble.Dot(forceVectSkin,speedOnSkin) power=powerSkin.accumulate()[0] -print "power = %r W"%(power) ; assert abs(power-4.22)<1e-2 +print("power = %r W"%(power)) ; assert abs(power-4.22)<1e-2 x2=posSkin[:,0]*posSkin[:,0] ; x2=x2.accumulate()[0] y2=posSkin[:,1]*posSkin[:,1] ; y2=y2.accumulate()[0] @@ -551,7 +551,7 @@ inertiaSkin=matrix([[x2,xy],[xy,y2]]) inertiaSkinValues,inertiaSkinVects=linalg.eig(inertiaSkin) pos=max(enumerate(inertiaSkinValues),key=lambda x: x[1])[0] vect0=inertiaSkinVects[pos].tolist()[0] -print vect0 +print(vect0) def computeAngle(locAgitateur1ts): fMc=locAgitateur1ts.getFieldAtLevel(ON_CELLS,0) @@ -584,7 +584,7 @@ for itts,locAgitateur1ts in zip(ts,data.getFields()["DISTANCE_INTERFACE_ELEM_BOD pass angle2=len(ts)*[0.] -for pos in xrange(2,len(vects)): +for pos in range(2,len(vects)): norm1=sqrt(vects[pos-1][0]*vects[pos-1][0]+vects[pos-1][1]*vects[pos-1][1]) norm2=sqrt(vects[pos][0]*vects[pos][0]+vects[pos][1]*vects[pos][1]) crs=vects[pos-1][0]*vects[pos][0]+vects[pos-1][1]*vects[pos][1] @@ -593,6 +593,6 @@ for pos in xrange(2,len(vects)): pass omega=sum(angle2)/(ts[-1][2]-ts[0][2]) -print sum(angle2) ; assert abs(sum(angle2)-1.12)<1e-2 -print "Au pdt (%d,%d) a %r s le couple est de : %r N.m, power/omega=%r N.m"%(ts[2][0],ts[2][1],ts[2][2],zeTorque[2],power/omega) +print(sum(angle2)) ; assert abs(sum(angle2)-1.12)<1e-2 +print("Au pdt (%d,%d) a %r s le couple est de : %r N.m, power/omega=%r N.m"%(ts[2][0],ts[2][1],ts[2][2],zeTorque[2],power/omega)) assert abs(power/omega-0.37)<1e-2 diff --git a/src/MEDLoader/Swig/MEDLoaderDataForTest.py b/src/MEDLoader/Swig/MEDLoaderDataForTest.py index 369ccb266..653b271eb 100644 --- a/src/MEDLoader/Swig/MEDLoaderDataForTest.py +++ b/src/MEDLoader/Swig/MEDLoaderDataForTest.py @@ -243,11 +243,11 @@ class MEDLoaderDataForTest: m2.setCoords(coo2) m2.allocateCells(128) nbTri=len(c2tri)/3 - for i in xrange(nbTri): + for i in range(nbTri): m2.insertNextCell(NORM_TRI3,3,c2tri[3*i:3*i+3]) pass nbQua=len(c2quad4)/4 - for i in xrange(nbQua): + for i in range(nbQua): m2.insertNextCell(NORM_QUAD4,4,c2quad4[4*i:4*i+4]) pass m2.finishInsertingCells() @@ -256,7 +256,7 @@ class MEDLoaderDataForTest: m1.setCoords(coo2) c1seg=[0,1,1,2,2,3,3,4,4,9,9,14,14,19,19,24,24,29,29,34,34,39,39,43,43,42,42,41,41,40,40,44,44,35,35,30,30,25,25,20,20,15,15,10,10,5,5,0,43,39,39,34,34,29,29,24,24,19,19,14,14,9,9,4,45,53,53,54,54,55,55,56,56,57,57,58,58,59,59,49,49,60,60,61,61,62,62,52,52,63,63,64,64,65,65,66,66,67,67,68,68,69,69,47,47,70,70,71,71,72,72,45,50,94,94,95,95,96,96,97,97,98,98,99,99,100,100,46,46,101,101,102,102,103,103,48,48,104,104,105,105,106,106,107,107,108,108,109,109,110,110,51,51,111,111,112,112,113,113,50] m1.allocateCells(80) - for i in xrange(80): + for i in range(80): m1.insertNextCell(NORM_SEG2,2,c1seg[2*i:2*i+2]) pass m1.finishInsertingCells() @@ -265,7 +265,7 @@ class MEDLoaderDataForTest: m0.setCoords(coo2) c0pt=[44,0,47,48] m0.allocateCells(4) - for i in xrange(4): + for i in range(4): m0.insertNextCell(NORM_POINT1,1,[c0pt[i]]) pass m0.finishInsertingCells() @@ -437,7 +437,7 @@ class MEDLoaderDataForTest: array=DataArrayDouble.New(); array.alloc(19,2); ptr=array.getPointer(); - for i in xrange(19*2): + for i in range(19*2): array.setIJ(0,i,float(i+7)); pass f.setArray(array); @@ -486,7 +486,7 @@ class MEDLoaderDataForTest: array=DataArrayDouble.New(); array.alloc(53,2); ptr=array.getPointer(); - for i in xrange(53*2): + for i in range(53*2): array.setIJ(0,i,float(i+7)); pass f.setArray(array); @@ -536,7 +536,7 @@ class MEDLoaderDataForTest: array=DataArrayDouble.New(); array.alloc(53,2); ptr=array.getPointer(); - for i in xrange(53*2): + for i in range(53*2): array.setIJ(0,i,float(i+7)); pass f.setArray(array); @@ -553,7 +553,7 @@ class MEDLoaderDataForTest: f.setMesh(m); array=DataArrayDouble.New(); array.alloc(20,2); - for i in xrange(2*20): + for i in range(2*20): array.setIJ(0,i,float(i+8)); f.setArray(array); array.setInfoOnComponent(0,"power [W]"); diff --git a/src/MEDLoader/Swig/MEDLoaderExamplesTest.py b/src/MEDLoader/Swig/MEDLoaderExamplesTest.py index cdb17921c..575f7a0e9 100644 --- a/src/MEDLoader/Swig/MEDLoaderExamplesTest.py +++ b/src/MEDLoader/Swig/MEDLoaderExamplesTest.py @@ -232,7 +232,7 @@ class MEDLoaderBasicsTest(unittest.TestCase): #! [PySnippetMeshAdvAPI1_6] m0D=ReadUMeshFromFile("file2.med","Example2",-3) #! [PySnippetMeshAdvAPI1_6] - for i in xrange(4): + for i in range(4): mm.removeMeshAtLevel(-i) pass mm.setMeshAtLevel(0,myMesh1) diff --git a/src/MEDLoader/Swig/MEDLoaderSplitter.py b/src/MEDLoader/Swig/MEDLoaderSplitter.py index 62319a571..dcd4523ce 100644 --- a/src/MEDLoader/Swig/MEDLoaderSplitter.py +++ b/src/MEDLoader/Swig/MEDLoaderSplitter.py @@ -38,7 +38,7 @@ class MEDLoaderSplitter: mfflds=mfflds.partOfThisLyingOnSpecifiedMeshName(mfmsh[0].getName()) retf=self.__splitFields(mfmsh[0],mfflds,idsLst) retm=self.__splitMesh(mfmsh[0],idsLst) - self._mfd_splitted=[MEDFileData() for i in xrange(len(idsLst))] + self._mfd_splitted=[MEDFileData() for i in range(len(idsLst))] for a,b,c in zip(self._mfd_splitted,retf,retm): a.setFields(b) ; a.setMeshes(c) pass @@ -62,7 +62,7 @@ class MEDLoaderSplitter: pass def __splitMEDFileField1TS(self,mm,f1ts,idsLst): - ret=[MEDFileField1TS() for i in xrange(len(idsLst))] + ret=[MEDFileField1TS() for i in range(len(idsLst))] dico={ON_CELLS:self.__splitMEDFileField1TSCell, ON_NODES:self.__splitMEDFileField1TSNode, ON_GAUSS_PT:self.__splitMEDFileField1TSCell, @@ -76,13 +76,13 @@ class MEDLoaderSplitter: return ret def __splitFields(self,mm,mfflds,idsLst): - ret0=[MEDFileFields() for i in xrange(len(idsLst))] + ret0=[MEDFileFields() for i in range(len(idsLst))] for fmts in mfflds: if len(fmts.getPflsReallyUsed())!=0: - print "Field \"%s\" contains profiles ! Not supported yet ! This field will be ignored !"%(fmts.getName()) + print("Field \"%s\" contains profiles ! Not supported yet ! This field will be ignored !"%(fmts.getName())) continue pass - ret1=[MEDFileFieldMultiTS() for i in xrange(len(idsLst))] + ret1=[MEDFileFieldMultiTS() for i in range(len(idsLst))] for f1ts in fmts: for fmtsPart,f1tsPart in zip(ret1,self.__splitMEDFileField1TS(mm,f1ts,idsLst)): fmtsPart.pushBackTimeStep(f1tsPart) @@ -95,7 +95,7 @@ class MEDLoaderSplitter: return ret0 def __splitMesh(self,mfm,idsLst): - ret0=[MEDFileMeshes() for i in xrange(len(idsLst))] + ret0=[MEDFileMeshes() for i in range(len(idsLst))] m=mfm.getMeshAtLevel(0) for ret,ids in zip(ret0,idsLst): mlPart=mfm.createNewEmpty() diff --git a/src/MEDLoader/Swig/MEDLoaderTest1.py b/src/MEDLoader/Swig/MEDLoaderTest1.py index 94f21b14e..a2adaa485 100644 --- a/src/MEDLoader/Swig/MEDLoaderTest1.py +++ b/src/MEDLoader/Swig/MEDLoaderTest1.py @@ -556,7 +556,7 @@ class MEDLoaderTest1(unittest.TestCase): nbOfCompo=4100 arr=MEDLoader.DataArrayDouble(nbOfCompo*3) ; arr.iota() arr.rearrange(nbOfCompo) - arr.setInfoOnComponents(["c%i"%(i) for i in xrange(nbOfCompo)]) + arr.setInfoOnComponents(["c%i"%(i) for i in range(nbOfCompo)]) f.setArray(arr) f.setName("FieldBigCompo") MEDLoader.WriteField(fileName,f,True) @@ -570,7 +570,7 @@ class MEDLoaderTest1(unittest.TestCase): m.insertNextCell([0,2,1,3]) m.setCoords(MEDLoader.DataArrayDouble([0.,0.,1.,1.,1.,0.,0.,1.],4,2)) # - 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 @@ -619,7 +619,7 @@ class MEDLoaderTest1(unittest.TestCase): m.insertNextCell([0,2,1,3]) m.setCoords(MEDLoader.DataArrayDouble([0.,0.,1.,1.,1.,0.,0.,1.],4,2)) # - 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 @@ -811,7 +811,7 @@ class MEDLoaderTest1(unittest.TestCase): mm[0]=m mm.write(fname,2) # - pfl=MEDLoader.DataArrayInt(range(8)) + pfl=MEDLoader.DataArrayInt(list(range(8))) pfl.setName("PFL") # f=MEDLoader.MEDCouplingFieldDouble(MEDLoader.ON_CELLS) diff --git a/src/MEDLoader/Swig/MEDLoaderTest3.py b/src/MEDLoader/Swig/MEDLoaderTest3.py index 6738da924..d9957a823 100644 --- a/src/MEDLoader/Swig/MEDLoaderTest3.py +++ b/src/MEDLoader/Swig/MEDLoaderTest3.py @@ -145,10 +145,10 @@ class MEDLoaderTest3(unittest.TestCase): g2_1.setName("G2") mm.setGroupsAtLevel(-1,[g1_1,g2_1],False) g1_N=DataArrayInt.New() - 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(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") @@ -167,7 +167,7 @@ class MEDLoaderTest3(unittest.TestCase): self.assertTrue(g2_N.isEqual(t)); self.assertTrue(mm.existsGroup("GrpOnAllCell")); t=mm.getGroupArr(0,"GrpOnAllCell") - self.assertTrue(t.getValues()==range(5)) + self.assertTrue(t.getValues()==list(range(5))) # mmCpy=mm.deepCopy() self.assertTrue(mm.isEqual(mmCpy,1e-12)[0]) ; del mm @@ -302,7 +302,7 @@ class MEDLoaderTest3(unittest.TestCase): self.assertTrue(not mm2.existsFamily("Family_-8")) mm2.createGroupOnAll(-1,"GrpOnAllFace") self.assertTrue(mm2.existsFamily("Family_-8")) - self.assertEqual(range(3),mm2.getGroupArr(-1,"GrpOnAllFace").getValues()) + self.assertEqual(list(range(3)),mm2.getGroupArr(-1,"GrpOnAllFace").getValues()) pass #testing persistence of retrieved arrays @@ -382,11 +382,11 @@ class MEDLoaderTest3(unittest.TestCase): m.setRenumFieldArr(-1,n1) m.setRenumFieldArr(-2,n0) nbOfFams=len(fns) - for i in xrange(nbOfFams): + for i in range(nbOfFams): m.addFamily(fns[i],fids[i]) pass nbOfGrps=len(grpns) - for i in xrange(nbOfGrps): + for i in range(nbOfGrps): m.setFamiliesIdsOnGroup(grpns[i],famIdsPerGrp[i]) pass m.setName(m2.getName()) @@ -813,7 +813,7 @@ class MEDLoaderTest3(unittest.TestCase): m1=MEDLoaderDataForTest.build2DMesh_1() m1.renumberCells([0,1,4,2,3,5],False) tmp=m1.getName(); - m1=m1.buildPartOfMySelf(range(5),True) ; m1.setName(tmp) # suppression of last cell that is a polygon + m1=m1.buildPartOfMySelf(list(range(5)),True) ; m1.setName(tmp) # suppression of last cell that is a polygon mm1=MEDFileUMesh.New() ; mm1.setCoords(m1.getCoords()) ; mm1.setMeshAtLevel(0,m1) ; mm1.write(fname,2) ff1=MEDFileField1TS.New() @@ -840,7 +840,7 @@ class MEDLoaderTest3(unittest.TestCase): m1=MEDLoaderDataForTest.build2DMesh_1() m1.renumberCells([0,1,4,2,3,5],False) tmp=m1.getName(); - m1=m1.buildPartOfMySelf(range(5),True) ; m1.setName(tmp) # suppression of last cell that is a polygon + m1=m1.buildPartOfMySelf(list(range(5)),True) ; m1.setName(tmp) # suppression of last cell that is a polygon mm1=MEDFileUMesh.New() ; mm1.setCoords(m1.getCoords()) ; mm1.setMeshAtLevel(0,m1) ; mm1.write(fname,2) ff1=MEDFileFieldMultiTS.New() @@ -887,7 +887,7 @@ class MEDLoaderTest3(unittest.TestCase): da=DataArrayInt.New(); da.setValues([0,1,3,4,6],5,1) ; da.setName("sup1NodeElt") # ff1.setFieldProfile(f1,mm1,0,da) - m1=m0.buildPartOfMySelf(range(5),True) ; m1.setName(tmp) ; mm1.setMeshAtLevel(0,m1) ; + m1=m0.buildPartOfMySelf(list(range(5)),True) ; m1.setName(tmp) ; mm1.setMeshAtLevel(0,m1) ; mm1.write(fname,2) ff1.write(fname,0) f1=ff1.getFieldOnMeshAtLevel(ON_GAUSS_NE,m1,0) @@ -1173,11 +1173,11 @@ class MEDLoaderTest3(unittest.TestCase): expected1=[1.,10.,100.,2.,20.,200.] nodeCoordsWithValue1=[10.,2.5,0.] nodeCoordsWithValue2=[10.,3.75,0.] - for i in xrange(3): + for i in range(3): self.assertAlmostEqual(nodeCoordsWithValue1[i],tes0.getMesh().getCoordinatesOfNode(0)[i],13); self.assertAlmostEqual(nodeCoordsWithValue2[i],tes0.getMesh().getCoordinatesOfNode(1)[i],13); pass - for i in xrange(6): + for i in range(6): self.assertAlmostEqual(expected1[i],tes0.getArray().getIJ(0,i),13); pass del tes0 @@ -1191,7 +1191,7 @@ class MEDLoaderTest3(unittest.TestCase): self.assertEqual([0,2,4],tes1.getMesh().getNodalConnectivityIndex().getValues()) self.assertEqual(2,tes1.getArray().getNumberOfTuples()) self.assertEqual(3,tes1.getArray().getNumberOfComponents()) - for i in xrange(6): + for i in range(6): self.assertAlmostEqual(expected1[i],tes1.getArray().getIJ(0,i),13); pass m.write(fname,2) @@ -1210,11 +1210,11 @@ class MEDLoaderTest3(unittest.TestCase): self.assertEqual(2,tes2.getArray().getNumberOfTuples()) self.assertEqual(3,tes2.getArray().getNumberOfComponents()) expected2=[2.,20.,200.,1.,10.,100.] - for i in xrange(3): + for i in range(3): self.assertAlmostEqual(nodeCoordsWithValue1[i],tes2.getMesh().getCoordinatesOfNode(0)[i],13); self.assertAlmostEqual(nodeCoordsWithValue2[i],tes2.getMesh().getCoordinatesOfNode(1)[i],13); pass - for i in xrange(6): + for i in range(6): self.assertAlmostEqual(expected2[i],tes2.getArray().getIJ(0,i),13);#compare tes2 and tes3 pass # @@ -1227,7 +1227,7 @@ class MEDLoaderTest3(unittest.TestCase): self.assertEqual([0,2,4],tes3.getMesh().getNodalConnectivityIndex().getValues()) self.assertEqual(2,tes3.getArray().getNumberOfTuples()) self.assertEqual(3,tes3.getArray().getNumberOfComponents()) - for i in xrange(6): + for i in range(6): self.assertAlmostEqual(expected1[i],tes3.getArray().getIJ(0,i),13); pass pass @@ -1644,15 +1644,15 @@ class MEDLoaderTest3(unittest.TestCase): coords=DataArrayDouble([0.,0.,0.,1.,1.,1.,1.,0.,0.,0.5,0.5,1.,1.,0.5,0.5,0.],8,2) mQ8=MEDCouplingUMesh("",2) ; mQ8.setCoords(coords) mQ8.allocateCells(1) - mQ8.insertNextCell(NORM_QUAD8,range(8)) + mQ8.insertNextCell(NORM_QUAD8,list(range(8))) mQ8.finishInsertingCells() mQ4=MEDCouplingUMesh("",2) ; mQ4.setCoords(coords) mQ4.allocateCells(1) - mQ4.insertNextCell(NORM_QUAD4,range(4)) + mQ4.insertNextCell(NORM_QUAD4,list(range(4))) mQ4.finishInsertingCells() mT3=MEDCouplingUMesh("",2) ; mT3.setCoords(coords) mT3.allocateCells(1) - mT3.insertNextCell(NORM_TRI3,range(3)) + mT3.insertNextCell(NORM_TRI3,list(range(3))) mT3.finishInsertingCells() tr=[[0.,4.],[2.,4.],[4.,4.],[6.,4.],[8.,4.],[10.,4.],[12.,4.],[14.,4.],[16.,4.],[18.,4.],[20.,4.],[0.,0.],[2.,0.], [0.,2.],[2.,2.],[4.,2.],[6.,2.],[8.,2.],[10.,2.],[12.,2.]] @@ -1685,7 +1685,7 @@ class MEDLoaderTest3(unittest.TestCase): mm.write(fname,2) # f1ts=MEDFileField1TS.New() - pfl=DataArrayInt(range(13)) ; pfl.setName("pfl") + pfl=DataArrayInt(list(range(13))) ; pfl.setName("pfl") self.assertRaises(InterpKernelException,f1ts.setFieldProfile,fInvalid,mm,0,pfl) # fails because no Gauss localization per cell set ! self.assertRaises(InterpKernelException,f1ts.setFieldProfile,fInvalid2,mm,0,pfl) # fails because no Gauss localization set whereas gauss locid per cell given ! f1ts.setFieldProfile(f,mm,0,pfl) @@ -1809,7 +1809,7 @@ class MEDLoaderTest3(unittest.TestCase): m1=MEDCouplingUMesh(m0.getName(),1) m1.allocateCells(9) conn1=[0,1,0,3,3,4,4,1,5,4,2,4,1,2,3,6,5,8] - for i in xrange(9): + for i in range(9): m1.insertNextCell(NORM_SEG2,conn1[2*i:2*i+2]) pass m1.finishInsertingCells() @@ -1899,7 +1899,7 @@ class MEDLoaderTest3(unittest.TestCase): m1=MEDCouplingUMesh(m0.getName(),1) m1.allocateCells(9) conn1=[0,1,0,3,3,4,4,1,5,4,2,4,1,2,3,6,5,8] - for i in xrange(9): + for i in range(9): m1.insertNextCell(NORM_SEG2,conn1[2*i:2*i+2]) pass m1.finishInsertingCells() @@ -2066,13 +2066,13 @@ class MEDLoaderTest3(unittest.TestCase): m=MEDFileUMesh() coo=DataArrayDouble(9) ; coo.iota(1.) ; coo.rearrange(3) ; coo.setInfoOnComponents(["aaa [b]","cc [dd]", "e [fff]"]) m0=MEDCouplingUMesh("toto",2) ; m0.allocateCells(0) - for i in xrange(7): + for i in range(7): m0.insertNextCell(NORM_TRI3,[1,2,1]) pass - for i in xrange(4): + for i in range(4): m0.insertNextCell(NORM_QUAD4,[1,1,2,0]) pass - for i in xrange(2): + for i in range(2): m0.insertNextCell(NORM_POLYGON,[0,0,1,1,2,2]) pass m1=MEDCouplingUMesh("toto",1) ; m1.allocateCells(0) ; m1.insertNextCell(NORM_SEG2,[1,6]) ; m1.insertNextCell(NORM_SEG2,[7,3]) @@ -2143,30 +2143,30 @@ class MEDLoaderTest3(unittest.TestCase): m=m.buildUnstructured() m.setName("mm") f=m.getMeasureField(False) - 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(),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(),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(),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(),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(),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): @@ -2274,20 +2274,20 @@ class MEDLoaderTest3(unittest.TestCase): mm.setMeshAtLevel(0,m) mm.setMeshAtLevel(-1,m1) namesCellL0=DataArrayAsciiChar(6,16) - 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 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 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 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]) @@ -2304,7 +2304,7 @@ class MEDLoaderTest3(unittest.TestCase): 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 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() @@ -2313,12 +2313,12 @@ class MEDLoaderTest3(unittest.TestCase): c.setName("cmesh") cc=MEDFileCMesh() cc.setMesh(c) - 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 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]) @@ -2545,11 +2545,11 @@ class MEDLoaderTest3(unittest.TestCase): m.setFamilyFieldArr(-2,f0) m.setFamilyFieldArr(1,p) nbOfFams=len(fns) - for i in xrange(nbOfFams): + for i in range(nbOfFams): m.addFamily(fns[i],fids[i]) pass nbOfGrps=len(grpns) - for i in xrange(nbOfGrps): + for i in range(nbOfGrps): m.setFamiliesIdsOnGroup(grpns[i],famIdsPerGrp[i]) pass m.setName(m2.getName()) @@ -2610,7 +2610,7 @@ class MEDLoaderTest3(unittest.TestCase): 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__() ; 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 @@ -2624,7 +2624,7 @@ class MEDLoaderTest3(unittest.TestCase): 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]=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) @@ -2635,7 +2635,7 @@ class MEDLoaderTest3(unittest.TestCase): 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]=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") @@ -2694,7 +2694,7 @@ class MEDLoaderTest3(unittest.TestCase): 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]=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() @@ -2728,13 +2728,13 @@ class MEDLoaderTest3(unittest.TestCase): 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 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 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) @@ -2743,7 +2743,7 @@ class MEDLoaderTest3(unittest.TestCase): fmts0_0=MEDFileFieldMultiTS() fmts0_1=MEDFileFieldMultiTS() # time steps - for i in xrange(10): + for i in range(10): infos1=["aa [bb]","ccc [ddd]"] ; name1="1stField" d=DataArrayDouble(18) ; d.iota(i*10) ; d.rearrange(2) ; d.setInfoOnComponents(infos1) f=MEDCouplingFieldDouble(ON_CELLS) ; f.setName(name1) ; f.setArray(d) ; f.setMesh(m) @@ -2806,13 +2806,13 @@ class MEDLoaderTest3(unittest.TestCase): 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 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 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) @@ -2825,7 +2825,7 @@ class MEDLoaderTest3(unittest.TestCase): fmts0_0=MEDFileFieldMultiTS() fmts0_1=MEDFileFieldMultiTS() # time steps - for i in xrange(10): + for i in range(10): infos1=["aa [bb]","ccc [ddd]"] ; name1="1stField" d=DataArrayDouble(14) ; d.iota(i*10) ; d.rearrange(2) ; d.setInfoOnComponents(infos1) f=MEDCouplingFieldDouble(ON_CELLS) ; f.setName(name1) ; f.setArray(d) ; f.setMesh(m) @@ -2852,7 +2852,7 @@ class MEDLoaderTest3(unittest.TestCase): self.assertEqual(fs0.getPfls(),('pfl_NORM_QUAD4',)) # fmts0_5=MEDFileFieldMultiTS() - for i in xrange(7): + for i in range(7): infos1=["aa [bb]","ccc [ddd]"] ; name1="1stField" d=DataArrayDouble(16) ; d.iota(i*10) ; d.rearrange(2) ; d.setInfoOnComponents(infos1) f=MEDCouplingFieldDouble(ON_CELLS) ; f.setName(name1) ; f.setArray(d) ; f.setMesh(m) @@ -2871,13 +2871,13 @@ class MEDLoaderTest3(unittest.TestCase): 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 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 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) @@ -2891,7 +2891,7 @@ class MEDLoaderTest3(unittest.TestCase): fmts0_1=MEDFileFieldMultiTS() # time steps infos1=['aa [bb]','ccc [ddd]',"ZZZZ [MW*s]"] - for i in xrange(10): + for i in range(10): name1="1stField" d=DataArrayDouble(21) ; d.iota(i*10) ; d.rearrange(3) ; d.setInfoOnComponents(infos1) f=MEDCouplingFieldDouble(ON_CELLS) ; f.setName(name1) ; f.setArray(d) ; f.setMesh(m) @@ -2920,7 +2920,7 @@ class MEDLoaderTest3(unittest.TestCase): self.assertEqual(fs1.getPfls(),('pfl_NORM_QUAD4',)) self.assertEqual(fs1.getPflsReallyUsed(),('pfl_NORM_QUAD4',)) self.assertEqual(4,len(fs1)) - for i in xrange(10): + for i in range(10): for j,fieldName in enumerate(['1stField_aa','1stField_ccc','1stField_ZZZZ']): f1ts=fs1[fieldName][i] f=f1ts.getFieldOnMeshAtLevel(ON_CELLS,0,mm) @@ -2940,13 +2940,13 @@ class MEDLoaderTest3(unittest.TestCase): 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 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 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) @@ -3042,13 +3042,13 @@ class MEDLoaderTest3(unittest.TestCase): 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 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 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) @@ -3078,7 +3078,7 @@ class MEDLoaderTest3(unittest.TestCase): 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,xrange(182,465+2*strMulFac)) + self.assertIn(heap_memory_ref,range(182,465+2*strMulFac)) ff0.loadArrays() ## arr=DataArrayDouble(140) ; arr.iota() ; arr.rearrange(2) self.assertTrue(ff0.getUndergroundDataArray().isEqualWithoutConsideringStr(arr,1e-14)) @@ -3087,7 +3087,7 @@ class MEDLoaderTest3(unittest.TestCase): ff0=MEDFileField1TS(fname,"FieldCellPfl",False) self.assertEqual(ff0.getUndergroundDataArray().getInfoOnComponents(),["XX [pm]","YYY [hm]"]) heap_memory_ref=ff0.getHeapMemorySize() - self.assertIn(heap_memory_ref,xrange(350,520+6*strMulFac)) + self.assertIn(heap_memory_ref,range(350,520+6*strMulFac)) ff0.loadArrays() ## arr=DataArrayDouble(100) ; arr.iota() ; arr.rearrange(2) self.assertTrue(ff0.getUndergroundDataArray().isEqualWithoutConsideringStr(arr,1e-14)) @@ -3105,7 +3105,7 @@ class MEDLoaderTest3(unittest.TestCase): 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,xrange(1100,1384+2*strMulFac)) + self.assertIn(heap_memory_ref,range(1100,1384+2*strMulFac)) ff0.unloadArrays() hmd=ff0.getHeapMemorySize()-heap_memory_ref self.assertEqual(hmd,-800) # -50*8*2 @@ -3114,14 +3114,14 @@ class MEDLoaderTest3(unittest.TestCase): # ff0=MEDFileField1TS(fname,"FieldCellPfl",-1,-1,False) heap_memory_ref=ff0.getHeapMemorySize() - self.assertIn(heap_memory_ref,xrange(299,520+6*strMulFac)) + self.assertIn(heap_memory_ref,range(299,520+6*strMulFac)) ff0.loadArrays() ## self.assertTrue(ff0.getUndergroundDataArray().isEqualWithoutConsideringStr(arr,1e-14)) self.assertEqual(ff0.getHeapMemorySize()-heap_memory_ref,50*8*2) # fieldName="FieldCellMultiTS" ff0=MEDFileFieldMultiTS() - for t in xrange(20): + for t in range(20): f0=MEDCouplingFieldDouble(ON_CELLS,ONE_TIME) ; f0.setMesh(m) ; arr=DataArrayDouble(m.getNumberOfCells()*2) ; arr.iota(float(t+1000)) ; arr.rearrange(2) ; arr.setInfoOnComponents(["X [km]","YY [mm]"]) ; f0.setArray(arr) ; f0.setName(fieldName) f0.setTime(float(t)+0.1,t,100+t) f0.checkConsistencyLight() @@ -3131,14 +3131,14 @@ class MEDLoaderTest3(unittest.TestCase): # ff0=MEDFileAnyTypeFieldMultiTS.New(fname,fieldName,False) heap_memory_ref=ff0.getHeapMemorySize() - self.assertIn(heap_memory_ref,xrange(5536,8212+(80+26+1)*strMulFac)) + self.assertIn(heap_memory_ref,range(5536,8212+(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,xrange(5335,9031+(80+50+len(ffs))*strMulFac)) + self.assertIn(heap_memory_ref,range(5335,9031+(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 @@ -3310,13 +3310,13 @@ class MEDLoaderTest3(unittest.TestCase): 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 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 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) @@ -3425,13 +3425,13 @@ class MEDLoaderTest3(unittest.TestCase): 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 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 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) @@ -3509,7 +3509,7 @@ class MEDLoaderTest3(unittest.TestCase): m00=MEDCouplingUMesh("mesh",1) ; m00.setCoords(m0.getCoords()) ; m00.allocateCells(0) m=MEDFileUMesh() m.setMeshAtLevel(0,m00) - 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 @@ -3517,7 +3517,7 @@ class MEDLoaderTest3(unittest.TestCase): 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(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 @@ -3527,14 +3527,14 @@ class MEDLoaderTest3(unittest.TestCase): 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 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 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 @@ -3752,7 +3752,7 @@ class MEDLoaderTest3(unittest.TestCase): # fmts=MEDFileFieldMultiTS() # - for i in xrange(nbCells): + for i in range(nbCells): t=(float(i)+0.1,i+1,-i-2) f.setTime(*t) arr2=DataArrayDouble(nbCells) @@ -3821,7 +3821,7 @@ class MEDLoaderTest3(unittest.TestCase): 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 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) @@ -3832,7 +3832,7 @@ class MEDLoaderTest3(unittest.TestCase): 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 xrange(36)] + namesNodes[:]=["Node#%.3d "%(i) for i in range(36)] mm.setRenumFieldArr(1,renum1) mm.setFamilyFieldArr(1,famField1) mm.setNameFieldAtLevel(1,namesNodes) @@ -3900,15 +3900,15 @@ class MEDLoaderTest3(unittest.TestCase): f=MEDCouplingFieldDouble(ON_CELLS,ONE_TIME) ; f.setMesh(m) f.setName("Field") arr=DataArrayDouble(25,2) ; arr.setInfoOnComponents(compos) - 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]=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) @@ -3925,11 +3925,11 @@ class MEDLoaderTest3(unittest.TestCase): fs=MEDFileFields.LoadPartOf(fileName,False,ms) fs=fs.deepCopy() fs[0][0].loadArrays() - arr=DataArrayDouble(12,2) ; arr[:,0]=range(3,15) ; arr[:,1]=range(103,115) + arr=DataArrayDouble(12,2) ; arr[:,0]=list(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]=range(203,224) ; arr[:,1]=range(303,324) + arr=DataArrayDouble(21,2) ; arr[:,0]=list(range(203,224)) ; arr[:,1]=list(range(303,324)) arr.setInfoOnComponents(compos) self.assertTrue(fs[1][0].getUndergroundDataArray().isEqual(arr,1e-12)) pass @@ -3965,15 +3965,15 @@ class MEDLoaderTest3(unittest.TestCase): f=MEDCouplingFieldDouble(ON_CELLS,ONE_TIME) ; f.setMesh(m) f.setName("Field") arr=DataArrayDouble(25,2) ; arr.setInfoOnComponents(compos) - 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]=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) @@ -4097,7 +4097,7 @@ class MEDLoaderTest3(unittest.TestCase): @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy") def testMEDFileUMeshPickeling1(self): - import cPickle + import pickle outFileName="Pyfile86.med" c=DataArrayDouble([-0.3,-0.3, 0.2,-0.3, 0.7,-0.3, -0.3,0.2, 0.2,0.2, 0.7,0.2, -0.3,0.7, 0.2,0.7, 0.7,0.7 ],9,2) c.setInfoOnComponents(["aa","bbb"]) @@ -4159,10 +4159,10 @@ class MEDLoaderTest3(unittest.TestCase): g2_1.setName("G2") mm.setGroupsAtLevel(-1,[g1_1,g2_1],False) g1_N=DataArrayInt.New() - 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(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") @@ -4182,14 +4182,14 @@ class MEDLoaderTest3(unittest.TestCase): self.assertTrue(mm.existsGroup("GrpOnAllCell")); t=mm.getGroupArr(0,"GrpOnAllCell") # - st=cPickle.dumps(mm,cPickle.HIGHEST_PROTOCOL) - mm2=cPickle.loads(st) + st=pickle.dumps(mm,pickle.HIGHEST_PROTOCOL) + mm2=pickle.loads(st) self.assertTrue(mm.isEqual(mm2,1e-12)[0]) self.assertEqual(mm.getAxisType(),AX_CART) # mm.setAxisType(AX_CYL) - st=cPickle.dumps(mm,cPickle.HIGHEST_PROTOCOL) - mm2=cPickle.loads(st) + st=pickle.dumps(mm,pickle.HIGHEST_PROTOCOL) + mm2=pickle.loads(st) self.assertTrue(mm.isEqual(mm2,1e-12)[0]) self.assertEqual(mm2.getAxisType(),AX_CYL) pass @@ -4208,7 +4208,7 @@ class MEDLoaderTest3(unittest.TestCase): m.setName(meshName) # fmts=MEDFileFieldMultiTS() - for i in xrange(nbPdt): + for i in range(nbPdt): f=MEDCouplingFieldDouble(ON_NODES) f.setMesh(m) arr=DataArrayDouble(nbNodes) ; arr.iota() ; arr*=i @@ -4226,14 +4226,14 @@ class MEDLoaderTest3(unittest.TestCase): fs2=MEDFileFields.LoadSpecificEntities(fileName,[(ON_NODES,NORM_ERROR)],False) fs.loadArraysIfNecessary() fs2.loadArraysIfNecessary() - for i in xrange(nbPdt): + for i in range(nbPdt): self.assertTrue(fs[fieldName][i].getUndergroundDataArray().isEqual(fs2[fieldName][i].getUndergroundDataArray(),1e-12)) pass m1=MEDCouplingCMesh() ; m1.setCoords(DataArrayDouble([0,1,2,3]),DataArrayDouble([0,1])) ; m1=m1.buildUnstructured() ; m1.simplexize(0) m2=MEDCouplingCMesh() ; m2.setCoords(DataArrayDouble([3,4,5]),DataArrayDouble([0,1])) ; m2=m2.buildUnstructured() m3=MEDCouplingUMesh.MergeUMeshes(m1,m2) ; m3.setName(meshName) fmts=MEDFileFieldMultiTS() - for i in xrange(nbPdt): + for i in range(nbPdt): f=MEDCouplingFieldDouble(ON_CELLS) f.setMesh(m3) arr=DataArrayDouble(8) ; arr.iota() ; arr*=i @@ -4256,7 +4256,7 @@ class MEDLoaderTest3(unittest.TestCase): fs2.loadArraysIfNecessary() fs3.loadArraysIfNecessary() fs4.loadArraysIfNecessary() - for i in xrange(nbPdt): + for i in range(nbPdt): self.assertTrue(fs[fieldName][i].getUndergroundDataArray()[:6].isEqual(fs2[fieldName][i].getUndergroundDataArray(),1e-12)) self.assertTrue(fs[fieldName][i].getUndergroundDataArray()[6:8].isEqual(fs3[i].getUndergroundDataArray(),1e-12)) self.assertTrue(fs[fieldName][i].getUndergroundDataArray().isEqual(fs4[fieldName][i].getUndergroundDataArray(),1e-12)) @@ -4279,10 +4279,10 @@ class MEDLoaderTest3(unittest.TestCase): # 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 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 @@ -4330,13 +4330,13 @@ class MEDLoaderTest3(unittest.TestCase): fmts2.reverse() zeResu=fmts2.pop() nbIter=len(fmts2) - for ii in xrange(nbIter): + for ii in range(nbIter): zeResu.pushBackTimeSteps(fmts2.pop()) pass zeResu.setName(k) fs2.pushField(zeResu) pass - 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): @@ -4691,7 +4691,7 @@ class MEDLoaderTest3(unittest.TestCase): mm.setName("mesh") mm.write(fname,2) # third : change permissions to remove write access on created file - os.chmod(fname,0444) + os.chmod(fname,0o444) # four : try to append data on file -> check that it raises Exception f=MEDCouplingFieldDouble(ON_CELLS) f.setName("field") @@ -4760,11 +4760,11 @@ class MEDLoaderTest3(unittest.TestCase): grp2=bary1.findIdsInRange(0.-1e-12,0.+1e-12) ; grp2.setName(grpName2) mesh.setGroupsAtLevel(-1,[grp1,grp2]) - import cPickle - st=cPickle.dumps(mesh,2) - mm=cPickle.loads(st) - st2=cPickle.dumps(mm,2) - mm2=cPickle.loads(st2) + import pickle + st=pickle.dumps(mesh,2) + mm=pickle.loads(st) + st2=pickle.dumps(mm,2) + mm2=pickle.loads(st2) self.assertTrue(mesh.isEqual(mm2,1e-12)[0]) pass @@ -5792,7 +5792,7 @@ class MEDLoaderTest3(unittest.TestCase): m1=MEDCouplingUMesh(m0.getName(),1) m1.allocateCells(9) conn1=[0,1,0,3,3,4,4,1,5,4,2,4,1,2,3,6,5,8] - for i in xrange(9): + for i in range(9): m1.insertNextCell(NORM_SEG2,conn1[2*i:2*i+2]) pass m1.finishInsertingCells() @@ -5835,9 +5835,9 @@ class MEDLoaderTest3(unittest.TestCase): ff =mfd.getFields()[0][0].field(mfd.getMeshes()[0]) self.assertTrue(ff2.isEqual(ff,1e-12,1e-12)) # OK now end of joke -> serialization of MEDFileData - import cPickle - st=cPickle.dumps(mfd,cPickle.HIGHEST_PROTOCOL) - mfd3=cPickle.loads(st) + import pickle + st=pickle.dumps(mfd,pickle.HIGHEST_PROTOCOL) + mfd3=pickle.loads(st) # check of object self.assertEqual(len(mfd3.getMeshes()),1) self.assertEqual(len(mfd3.getFields()),1) @@ -5846,23 +5846,23 @@ class MEDLoaderTest3(unittest.TestCase): ff3=mfd3.getFields()[0][0].field(mfd3.getMeshes()[0]) self.assertTrue(ff3.isEqual(ff,1e-12,1e-12)) # serialization of MEDFileFields - st=cPickle.dumps(mfd.getFields(),cPickle.HIGHEST_PROTOCOL) - fs4=cPickle.loads(st) + st=pickle.dumps(mfd.getFields(),pickle.HIGHEST_PROTOCOL) + fs4=pickle.loads(st) ff4=fs4[0][0].field(mfd3.getMeshes()[0]) self.assertTrue(ff4.isEqual(ff,1e-12,1e-12)) # serialization of MEDFileFieldMulitTS - st=cPickle.dumps(mfd.getFields()[0],cPickle.HIGHEST_PROTOCOL) - fmts5=cPickle.loads(st) + st=pickle.dumps(mfd.getFields()[0],pickle.HIGHEST_PROTOCOL) + fmts5=pickle.loads(st) ff5=fmts5[0].field(mfd3.getMeshes()[0]) self.assertTrue(ff5.isEqual(ff,1e-12,1e-12)) # serialization of MEDFileField1TS - st=cPickle.dumps(mfd.getFields()[0][0],cPickle.HIGHEST_PROTOCOL) - f1ts6=cPickle.loads(st) + st=pickle.dumps(mfd.getFields()[0][0],pickle.HIGHEST_PROTOCOL) + f1ts6=pickle.loads(st) ff6=f1ts6.field(mfd3.getMeshes()[0]) self.assertTrue(ff6.isEqual(ff,1e-12,1e-12)) # serialization of MEDFileMeshes - st=cPickle.dumps(mfd.getMeshes(),cPickle.HIGHEST_PROTOCOL) - ms7=cPickle.loads(st) + st=pickle.dumps(mfd.getMeshes(),pickle.HIGHEST_PROTOCOL) + ms7=pickle.loads(st) self.assertEqual(len(ms7),1) self.assertTrue(ms7[0].isEqual(mfd.getMeshes()[0],1e-12)) pass @@ -5873,17 +5873,17 @@ class MEDLoaderTest3(unittest.TestCase): self.testMEDMesh6() # generates MEDFileMesh5.med file mm=MEDFileMesh.New("MEDFileMesh5.med") self.assertTrue(isinstance(mm,MEDFileCMesh)) - import cPickle - st=cPickle.dumps(mm,cPickle.HIGHEST_PROTOCOL) - mm2=cPickle.loads(st) + import pickle + st=pickle.dumps(mm,pickle.HIGHEST_PROTOCOL) + mm2=pickle.loads(st) self.assertTrue(isinstance(mm2,MEDFileCMesh)) self.assertTrue(mm.getMesh().isEqual(mm2.getMesh(),1e-12)) # CurveLinear self.testCurveLinearMesh1() # generates Pyfile55.med mm=MEDFileMesh.New("Pyfile55.med") self.assertTrue(isinstance(mm,MEDFileCurveLinearMesh)) - st=cPickle.dumps(mm,cPickle.HIGHEST_PROTOCOL) - mm3=cPickle.loads(st) + st=pickle.dumps(mm,pickle.HIGHEST_PROTOCOL) + mm3=pickle.loads(st) self.assertTrue(isinstance(mm3,MEDFileCurveLinearMesh)) self.assertTrue(mm.getMesh().isEqual(mm3.getMesh(),1e-12)) self.testInt32InMEDFileFieldStar1()# generates Pyfile63.med @@ -5891,23 +5891,23 @@ class MEDLoaderTest3(unittest.TestCase): fs4=MEDFileFields("Pyfile63.med") ms4=MEDFileMeshes("Pyfile63.med") self.assertTrue(isinstance(fs4[0],MEDFileIntFieldMultiTS)) - st=cPickle.dumps(fs4[0],cPickle.HIGHEST_PROTOCOL) - fmts5=cPickle.loads(st) + st=pickle.dumps(fs4[0],pickle.HIGHEST_PROTOCOL) + fmts5=pickle.loads(st) self.assertEqual(len(fs4[0]),len(fmts5)) self.assertTrue(isinstance(fmts5,MEDFileIntFieldMultiTS)) self.assertTrue(fmts5[0].field(ms4[0]).isEqual((fs4[0][0]).field(ms4[0]),1e-12,1e-12)) # MEDFileIntField1TS - st=cPickle.dumps(fs4[0][0],cPickle.HIGHEST_PROTOCOL) - f1ts6=cPickle.loads(st) + st=pickle.dumps(fs4[0][0],pickle.HIGHEST_PROTOCOL) + f1ts6=pickle.loads(st) self.assertTrue(isinstance(f1ts6,MEDFileIntField1TS)) self.assertTrue(f1ts6.field(ms4[0]).isEqual((fs4[0][0]).field(ms4[0]),1e-12,1e-12)) # MEDFileParameters self.testParameters1()# generates Pyfile56.med params=MEDFileParameters("Pyfile56.med") - st=cPickle.dumps(params,cPickle.HIGHEST_PROTOCOL) - params7=cPickle.loads(st) + st=pickle.dumps(params,pickle.HIGHEST_PROTOCOL) + params7=pickle.loads(st) self.assertEqual(len(params),len(params7)) - for i in xrange(len(params)): + for i in range(len(params)): self.assertTrue(params[i].isEqual(params7[i],1e-12)[0]) pass pass diff --git a/src/MEDLoader/Swig/MEDLoaderTest4.py b/src/MEDLoader/Swig/MEDLoaderTest4.py index 669c71c90..6052445a7 100644 --- a/src/MEDLoader/Swig/MEDLoaderTest4.py +++ b/src/MEDLoader/Swig/MEDLoaderTest4.py @@ -37,13 +37,13 @@ class MEDLoaderTest4(unittest.TestCase): 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 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 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) @@ -181,7 +181,7 @@ class MEDLoaderTest4(unittest.TestCase): mml=fcscp.buildFromScratchDataSetSupport(0,fields) mml2=mml.prepare() self.assertTrue(isinstance(mml2,MEDUMeshMultiLev)) - for i in xrange(1,5): + for i in range(1,5): self.assertTrue(fcscp.isDataSetSupportEqualToThePreviousOne(i,fields)) pass ncc,a0,a1,a2,a3,a4,a5=mml2.buildVTUArrays() @@ -199,7 +199,7 @@ class MEDLoaderTest4(unittest.TestCase): self.assertTrue(a8.isEqual(DataArrayInt([120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,100,101,102,103,104,105,106,107,108]))) self.assertTrue(not a9) self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None) - for i in xrange(5): + for i in range(5): fsst=MEDFileField1TSStructItem.BuildItemFrom(fields[0][i],mst) fields[0][i].loadArraysIfNecessary() tmpMem=fields.getHeapMemorySize() @@ -222,13 +222,13 @@ class MEDLoaderTest4(unittest.TestCase): 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 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 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) @@ -399,7 +399,7 @@ class MEDLoaderTest4(unittest.TestCase): mml=fcscp.buildFromScratchDataSetSupport(0,fields) mml2=mml.prepare() assert isinstance(mml2,MEDUMeshMultiLev) - for i in xrange(1,5): + for i in range(1,5): self.assertTrue(fcscp.isDataSetSupportEqualToThePreviousOne(i,fields)) pass ncc,a0,a1,a2,a3,a4,a5=mml2.buildVTUArrays() @@ -412,7 +412,7 @@ class MEDLoaderTest4(unittest.TestCase): self.assertTrue(a5 is None) self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None) # for cells - for i in xrange(5): + for i in range(5): f=allFMTSLeavesPerCommonSupport[0][0][0][i] fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst)# Second 0 is for cells f.loadArraysIfNecessary() @@ -421,7 +421,7 @@ class MEDLoaderTest4(unittest.TestCase): vExp=DataArrayDouble([200.,201.,202.,203.,204.,205.,206.,207.,208.,209.,210.,211.,212.,213.,214.,215.,216.,217.,218.,219.,220.,221.,222.,223.,224.,225.,226.,227.,228.,229.,230.,231.,232.,233.,234.,235.,236.,237.,238.,239.,240.,241.,242.,243.,244.,245.,246.,247.,248.,249.,250.,251.,252.,253.,254.,255.,256.,257.,258.,259.,260.,261.,262.,263.,100.,101.,102.,103.,104.,105.,106.,107.,108.,109.,110.,111.,112.,113.,114.,115.,116.,117.],41,2) ; vExp.setInfoOnComponents(['Comp1 [m]','Com2 [s^2]']) ; vExp+=i*1000 self.assertTrue(v.isEqual(vExp,1e-12)) pass - for i in xrange(5): + for i in range(5): f=allFMTSLeavesPerCommonSupport[0][0][1][i] fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst)# Second 0 is for cells f.loadArraysIfNecessary() @@ -441,13 +441,13 @@ class MEDLoaderTest4(unittest.TestCase): 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 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 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) @@ -564,7 +564,7 @@ class MEDLoaderTest4(unittest.TestCase): mml=fcscp.buildFromScratchDataSetSupport(0,fields) mml2=mml.prepare() self.assertTrue(isinstance(mml2,MEDUMeshMultiLev)) - for i in xrange(1,3): + for i in range(1,3): self.assertTrue(fcscp.isDataSetSupportEqualToThePreviousOne(i,fields)) pass ncc,a0,a1,a2,a3,a4,a5=mml2.buildVTUArrays() @@ -577,7 +577,7 @@ class MEDLoaderTest4(unittest.TestCase): assert a5 is None self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None) # for cells - for i in xrange(3): + for i in range(3): f=allFMTSLeavesPerCommonSupport[0][0][0][i] fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst)# Second 0 is for cells f.loadArraysIfNecessary() @@ -595,7 +595,7 @@ class MEDLoaderTest4(unittest.TestCase): mml=fcscp.buildFromScratchDataSetSupport(0,fields) mml2=mml.prepare() self.assertTrue(isinstance(mml2,MEDUMeshMultiLev)) - for i in xrange(1,2): + for i in range(1,2): self.assertTrue(fcscp.isDataSetSupportEqualToThePreviousOne(i,fields)) pass ncc,a0,a1,a2,a3,a4,a5=mml2.buildVTUArrays() @@ -607,7 +607,7 @@ class MEDLoaderTest4(unittest.TestCase): self.assertTrue(a4 is None) self.assertTrue(a5 is None) self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None) - for i in xrange(2): + for i in range(2): f=allFMTSLeavesPerCommonSupport[0][0][0][i] fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst)# Second 0 is for cells f.loadArraysIfNecessary() @@ -627,13 +627,13 @@ class MEDLoaderTest4(unittest.TestCase): 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 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 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) @@ -823,7 +823,7 @@ class MEDLoaderTest4(unittest.TestCase): mml=fcscp.buildFromScratchDataSetSupport(0,fields) mml2=mml.prepare() self.assertTrue(isinstance(mml2,MEDUMeshMultiLev)) - for i in xrange(1,5): + for i in range(1,5): self.assertTrue(fcscp.isDataSetSupportEqualToThePreviousOne(i,fields)) pass ncc,a0,a1,a2,a3,a4,a5=mml2.buildVTUArrays() @@ -836,7 +836,7 @@ class MEDLoaderTest4(unittest.TestCase): self.assertTrue(a5 is None) self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None) # test all the time steps of the 1/1 time step serie, on field 1 - for i in xrange(5): + for i in range(5): f=allFMTSLeavesPerCommonSupport[0][0][0][i] fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst) f.loadArraysIfNecessary() @@ -847,7 +847,7 @@ class MEDLoaderTest4(unittest.TestCase): self.assertTrue(v.isEqual(vExp,1e-12)) pass # test all the time steps of the 1/1 time step serie, on field 2 - for i in xrange(5): + for i in range(5): f=allFMTSLeavesPerCommonSupport[0][0][1][i] fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst) f.loadArraysIfNecessary() @@ -858,7 +858,7 @@ class MEDLoaderTest4(unittest.TestCase): self.assertTrue(v.isEqual(vExp,1e-12)) pass # test all the time steps of the 1/1 time step serie, on field 3 - for i in xrange(5): + for i in range(5): f=allFMTSLeavesPerCommonSupport[0][0][2][i] fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst) f.loadArraysIfNecessary() @@ -893,7 +893,7 @@ class MEDLoaderTest4(unittest.TestCase): fieldName3="zeField3" ; pfl3=DataArrayInt([0,1,2,3,4,5,9,10]) ; pfl3.setName("pfl3") # on cells but different support fs1=MEDFileFieldMultiTS() ; fs2=MEDFileFieldMultiTS() ; fs3=MEDFileFieldMultiTS() # - for i in xrange(5): + for i in range(5): f=MEDFileField1TS() fNode=MEDCouplingFieldDouble(ON_CELLS) ; fNode.setTime(float(i),i,0) fNode.setName(fieldName1) @@ -955,7 +955,7 @@ class MEDLoaderTest4(unittest.TestCase): mml=fcscp.buildFromScratchDataSetSupport(0,fields) mml2=mml.prepare() self.assertTrue(isinstance(mml2,MEDUMeshMultiLev)) - for i in xrange(1,5): + for i in range(1,5): self.assertTrue((fcscp.isDataSetSupportEqualToThePreviousOne(i,fields))) pass ncc,a0,a1,a2,a3,a4,a5=mml2.buildVTUArrays() @@ -973,10 +973,10 @@ class MEDLoaderTest4(unittest.TestCase): self.assertTrue(a8.isEqual(DataArrayInt([100,101,102,103,104,105]))) self.assertTrue(not a9) self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None) - for i in xrange(5): + for i in range(5): nbOfT=[6,8] fieldNames=[fieldName1,fieldName2] - for j in xrange(2): + for j in range(2): m={"i":j} f=allFMTSLeavesPerCommonSupport[0][0][j][i] fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst) @@ -993,7 +993,7 @@ class MEDLoaderTest4(unittest.TestCase): mml=fcscp.buildFromScratchDataSetSupport(0,fields) mml2=mml.prepare() self.assertTrue(isinstance(mml2,MEDUMeshMultiLev)) - for i in xrange(1,5): + for i in range(1,5): self.assertTrue(fcscp.isDataSetSupportEqualToThePreviousOne(i,fields)) pass ncc,a0,a1,a2,a3,a4,a5=mml2.buildVTUArrays() @@ -1011,7 +1011,7 @@ class MEDLoaderTest4(unittest.TestCase): self.assertTrue(a8.isEqual(DataArrayInt([100,101,102,103,104,105,109,110]))) self.assertTrue(not a9) self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None) - for i in xrange(5): + for i in range(5): f=allFMTSLeavesPerCommonSupport[1][0][0][i] fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst) f.loadArraysIfNecessary() @@ -1043,7 +1043,7 @@ class MEDLoaderTest4(unittest.TestCase): fieldName4="zeField4" ;# on nodes fs0=MEDFileFieldMultiTS() ; fs1=MEDFileFieldMultiTS() ; fs2=MEDFileFieldMultiTS() ; fs3=MEDFileFieldMultiTS() ; fs4=MEDFileFieldMultiTS() # - for i in xrange(5): + for i in range(5): f=MEDFileField1TS() fNode=MEDCouplingFieldDouble(ON_CELLS) ; fNode.setTime(float(i),i,0) fNode.setName(fieldName0) ; fNode.setMesh(m) @@ -1128,7 +1128,7 @@ class MEDLoaderTest4(unittest.TestCase): self.assertTrue(a.isEqual(coordsX,1e-12)) self.assertTrue(b.isEqual(coordsY,1e-12)) self.assertTrue(isinstance(mml2,MEDCMeshMultiLev)) - for i in xrange(1,5): + for i in range(1,5): self.assertTrue((fcscp.isDataSetSupportEqualToThePreviousOne(i,fields))) pass a6,a7=mml2.retrieveFamilyIdsOnCells() @@ -1141,7 +1141,7 @@ class MEDLoaderTest4(unittest.TestCase): self.assertTrue(a10.isEqual(DataArrayInt([200,201,202,203,204,205,206,207,208,209,210,211,212,213,214]))) self.assertTrue(a11) # True because no copy self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None) - for i in xrange(5): + for i in range(5): f=allFMTSLeavesPerCommonSupport[0][0][0][i] fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst) f.loadArraysIfNecessary() @@ -1179,10 +1179,10 @@ class MEDLoaderTest4(unittest.TestCase): self.assertTrue(a10.isEqual(DataArrayInt([202,203,204,207,208,209,212,213,214]))) self.assertTrue(not a11) # False because copy self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None) - for i in xrange(1,5): + for i in range(1,5): self.assertTrue((fcscp.isDataSetSupportEqualToThePreviousOne(i,fields))) pass - for i in xrange(5): + for i in range(5): f=allFMTSLeavesPerCommonSupport[1][0][0][i] fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst) f.loadArraysIfNecessary() @@ -1223,7 +1223,7 @@ class MEDLoaderTest4(unittest.TestCase): self.assertTrue(a8.isEqual(DataArrayInt([102,103,105,107]))) self.assertTrue(not a9) # False because copy self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None) - for i in xrange(5): + for i in range(5): f=allFMTSLeavesPerCommonSupport[2][0][0][i] fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst) f.loadArraysIfNecessary() @@ -1255,7 +1255,7 @@ class MEDLoaderTest4(unittest.TestCase): fieldName4="zeField4" ;# on nodes fs0=MEDFileFieldMultiTS() ; fs1=MEDFileFieldMultiTS() ; fs2=MEDFileFieldMultiTS() ; fs3=MEDFileFieldMultiTS() ; fs4=MEDFileFieldMultiTS() # - for i in xrange(5): + for i in range(5): f=MEDFileField1TS() fNode=MEDCouplingFieldDouble(ON_CELLS) ; fNode.setTime(float(i),i,0) fNode.setName(fieldName0) ; fNode.setMesh(m) @@ -1347,10 +1347,10 @@ class MEDLoaderTest4(unittest.TestCase): self.assertTrue(a8.isEqual(DataArrayInt([100,101,102,103,104,105,106,107]))) self.assertTrue(a9) # True because no copy self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None) - for i in xrange(1,5): + for i in range(1,5): self.assertTrue((fcscp.isDataSetSupportEqualToThePreviousOne(i,fields))) pass - for i in xrange(5): + for i in range(5): f=allFMTSLeavesPerCommonSupport[0][0][0][i] fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst) f.loadArraysIfNecessary() @@ -1385,10 +1385,10 @@ class MEDLoaderTest4(unittest.TestCase): self.assertTrue(a8.isEqual(DataArrayInt([102,103,106,107]))) self.assertTrue(not a9) # False because copy self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None) - for i in xrange(1,5): + for i in range(1,5): self.assertTrue((fcscp.isDataSetSupportEqualToThePreviousOne(i,fields))) pass - for i in xrange(5): + for i in range(5): f=allFMTSLeavesPerCommonSupport[1][0][0][i] fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst) f.loadArraysIfNecessary() @@ -1429,7 +1429,7 @@ class MEDLoaderTest4(unittest.TestCase): self.assertTrue(a8.isEqual(DataArrayInt([102,103,105,107]))) self.assertTrue(not a9) # False because copy self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None) - for i in xrange(5): + for i in range(5): f=allFMTSLeavesPerCommonSupport[2][0][0][i] fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst) f.loadArraysIfNecessary() @@ -1461,7 +1461,7 @@ class MEDLoaderTest4(unittest.TestCase): fieldName2="zeField2" fieldName3="zeField3" fs0=MEDFileFieldMultiTS() ; fs1=MEDFileFieldMultiTS() ; fs2=MEDFileFieldMultiTS() ; fs3=MEDFileFieldMultiTS() - for i in xrange(5): + for i in range(5): f=MEDFileField1TS() fNode=MEDCouplingFieldDouble(ON_GAUSS_NE) ; fNode.setTime(float(i),i,0) fNode.setName(fieldName0) ; fNode.setMesh(m) @@ -1545,10 +1545,10 @@ class MEDLoaderTest4(unittest.TestCase): self.assertTrue(a4 is None) self.assertTrue(a5 is None) self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None) - for i in xrange(1,5): + for i in range(1,5): self.assertTrue((fcscp.isDataSetSupportEqualToThePreviousOne(i,fields))) pass - for i in xrange(5): + for i in range(5): f=allFMTSLeavesPerCommonSupport[0][0][0][i] fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst) f.loadArraysIfNecessary() @@ -1610,7 +1610,7 @@ class MEDLoaderTest4(unittest.TestCase): pfl1=DataArrayInt([0,1,7,9,10]) ; pfl1.setName("pfl1") # on cells pfl2=DataArrayInt([1,2,3,6,7,8,11,12,13]) ; pfl2.setName("pfl2") # on nodes fs0=MEDFileFieldMultiTS() ; fs1=MEDFileFieldMultiTS() ; fs2=MEDFileFieldMultiTS() ; fs3=MEDFileFieldMultiTS() - for i in xrange(5): + for i in range(5): f=MEDFileField1TS() fNode=MEDCouplingFieldDouble(ON_GAUSS_NE) ; fNode.setTime(float(i),i,0) fNode.setName(fieldName0) @@ -1694,10 +1694,10 @@ class MEDLoaderTest4(unittest.TestCase): self.assertTrue(a4 is None) self.assertTrue(a5 is None) self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None) - for i in xrange(1,5): + for i in range(1,5): self.assertTrue((fcscp.isDataSetSupportEqualToThePreviousOne(i,fields))) pass - for i in xrange(5): + for i in range(5): f=allFMTSLeavesPerCommonSupport[0][0][0][i] fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst) f.loadArraysIfNecessary() @@ -1756,7 +1756,7 @@ class MEDLoaderTest4(unittest.TestCase): fieldName2="zeField2" pfl1=DataArrayInt([1,2,3,6,7,8,11,12,13]) ; pfl1.setName("pfl1") # on nodes fs0=MEDFileFieldMultiTS() ; fs1=MEDFileFieldMultiTS() ; fs2=MEDFileFieldMultiTS() - for i in xrange(5): + for i in range(5): f=MEDFileField1TS() fNode=MEDCouplingFieldDouble(ON_NODES) ; fNode.setTime(float(i),i,0) fNode.setName(fieldName0) @@ -1828,10 +1828,10 @@ class MEDLoaderTest4(unittest.TestCase): self.assertTrue(a4 is None) self.assertTrue(a5 is None) self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None) - for i in xrange(1,5): + for i in range(1,5): self.assertTrue((fcscp.isDataSetSupportEqualToThePreviousOne(i,fields))) pass - for i in xrange(5): + for i in range(5): f=allFMTSLeavesPerCommonSupport[0][0][0][i] fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst) f.loadArraysIfNecessary() @@ -1874,7 +1874,7 @@ class MEDLoaderTest4(unittest.TestCase): # fieldName0="zeField0" fs0=MEDFileFieldMultiTS() - for i in xrange(5): + for i in range(5): f=MEDFileField1TS() fNode=MEDCouplingFieldDouble(ON_GAUSS_PT) ; fNode.setTime(float(i),i,0) fNode.setName(fieldName0) ; fNode.setMesh(m) @@ -1932,10 +1932,10 @@ class MEDLoaderTest4(unittest.TestCase): self.assertTrue(a4 is None) self.assertTrue(a5 is None) self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None) - for i in xrange(1,5): + for i in range(1,5): self.assertTrue((fcscp.isDataSetSupportEqualToThePreviousOne(i,fields))) pass - for i in xrange(5): + for i in range(5): f=allFMTSLeavesPerCommonSupport[0][0][0][i] fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst) f.loadArraysIfNecessary() @@ -1962,7 +1962,7 @@ class MEDLoaderTest4(unittest.TestCase): fieldName0="zeField0" fieldName1="zeField1" fs0=MEDFileFieldMultiTS() ; fs1=MEDFileFieldMultiTS() - for i in xrange(5): + for i in range(5): f=MEDFileField1TS() fNode=MEDCouplingFieldDouble(ON_GAUSS_PT) ; fNode.setTime(float(i),i,0) fNode.setName(fieldName0) ; fNode.setMesh(m) @@ -2028,10 +2028,10 @@ class MEDLoaderTest4(unittest.TestCase): self.assertTrue(a4 is None) self.assertTrue(a5 is None) self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None) - for i in xrange(1,5): + for i in range(1,5): self.assertTrue((fcscp.isDataSetSupportEqualToThePreviousOne(i,fields))) pass - for i in xrange(5): + for i in range(5): f=allFMTSLeavesPerCommonSupport[0][0][0][i] fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst) f.loadArraysIfNecessary() @@ -2068,7 +2068,7 @@ class MEDLoaderTest4(unittest.TestCase): fieldName1="zeField1" fieldName2="zeField2" ; pfl1=DataArrayInt([2,3]) ; pfl1.setName("pfl1") fieldName3="zefield3" ; pfl2=DataArrayInt([2,3,4]) ; pfl2.setName("pfl2") - for i in xrange(5): + for i in range(5): f=MEDFileField1TS() fNode=MEDCouplingFieldDouble(ON_CELLS) ; fNode.setTime(float(i),i,0) fNode.setName(fieldName0) ; fNode.setMesh(m) @@ -2148,11 +2148,11 @@ class MEDLoaderTest4(unittest.TestCase): self.assertTrue(a4.isEqual(DataArrayInt([-1,-1,0,31,62]))) self.assertTrue(a5.isEqual(DataArrayInt([6,4,3,2,8,9,4,15,21,20,14,4,3,15,14,2,4,2,14,20,8,4,8,20,21,9,4,9,21,15,3,6,4,4,3,9,10,4,16,22,21,15,4,4,16,15,3,4,3,15,21,9,4,9,21,22,10,4,10,22,16,4,6,4,5,4,10,11,4,17,23,22,16,4,5,17,16,4,4,4,16,22,10,4,10,22,23,11,4,11,23,17,5]))) self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None) - for i in xrange(1,5): + for i in range(1,5): self.assertTrue((fcscp.isDataSetSupportEqualToThePreviousOne(i,fields))) pass pass - for i in xrange(5): + for i in range(5): f=allFMTSLeavesPerCommonSupport[0][0][0][i] fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst) f.loadArraysIfNecessary() @@ -2185,11 +2185,11 @@ class MEDLoaderTest4(unittest.TestCase): self.assertTrue(a4.isEqual(DataArrayInt([0,31]))) self.assertTrue(a5.isEqual(DataArrayInt([6,4,3,2,8,9,4,15,21,20,14,4,3,15,14,2,4,2,14,20,8,4,8,20,21,9,4,9,21,15,3,6,4,4,3,9,10,4,16,22,21,15,4,4,16,15,3,4,3,15,21,9,4,9,21,22,10,4,10,22,16,4]))) self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None) - for i in xrange(1,5): + for i in range(1,5): self.assertTrue((fcscp.isDataSetSupportEqualToThePreviousOne(i,fields))) pass pass - for i in xrange(5): + for i in range(5): f=allFMTSLeavesPerCommonSupport[1][0][0][i] fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst) f.loadArraysIfNecessary() @@ -2212,11 +2212,11 @@ class MEDLoaderTest4(unittest.TestCase): self.assertTrue(a3.isEqual(DataArrayInt([8,2,3,8,9,14,15,20,21,8,3,4,9,10,15,16,21,22,8,4,5,10,11,16,17,22,23]))) self.assertTrue(a4.isEqual(DataArrayInt([0,31,62]))) self.assertTrue(a5.isEqual(DataArrayInt([6,4,3,2,8,9,4,15,21,20,14,4,3,15,14,2,4,2,14,20,8,4,8,20,21,9,4,9,21,15,3,6,4,4,3,9,10,4,16,22,21,15,4,4,16,15,3,4,3,15,21,9,4,9,21,22,10,4,10,22,16,4,6,4,5,4,10,11,4,17,23,22,16,4,5,17,16,4,4,4,16,22,10,4,10,22,23,11,4,11,23,17,5]))) - for i in xrange(1,5): + for i in range(1,5): self.assertTrue((fcscp.isDataSetSupportEqualToThePreviousOne(i,fields))) pass pass - for i in xrange(5): + for i in range(5): f=allFMTSLeavesPerCommonSupport[2][0][0][i] fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst) f.loadArraysIfNecessary() @@ -2242,7 +2242,7 @@ class MEDLoaderTest4(unittest.TestCase): fs0=MEDFileFieldMultiTS() ; fs1=MEDFileFieldMultiTS() fieldName0="zeField0" fieldName1="zeField1" - for i in xrange(5): + for i in range(5): f=MEDFileField1TS() fNode=MEDCouplingFieldDouble(ON_CELLS) ; fNode.setTime(float(i),i,0) fNode.setName(fieldName0) ; fNode.setMesh(m) @@ -2304,7 +2304,7 @@ class MEDLoaderTest4(unittest.TestCase): self.assertTrue(a4.isEqual(DataArrayInt([0,31,62]))) self.assertTrue(a5.isEqual(DataArrayInt([6,4,3,2,8,9,4,15,21,20,14,4,3,15,14,2,4,2,14,20,8,4,8,20,21,9,4,9,21,15,3,6,4,4,3,9,10,4,16,22,21,15,4,4,16,15,3,4,3,15,21,9,4,9,21,22,10,4,10,22,16,4,6,4,5,4,10,11,4,17,23,22,16,4,5,17,16,4,4,4,16,22,10,4,10,22,23,11,4,11,23,17,5]))) self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None) - for i in xrange(1,5): + for i in range(1,5): self.assertTrue((fcscp.isDataSetSupportEqualToThePreviousOne(i,fields))) pass a6,a7=mml2.retrieveFamilyIdsOnCells() @@ -2313,7 +2313,7 @@ class MEDLoaderTest4(unittest.TestCase): a8,a9=mml2.retrieveNumberIdsOnCells() self.assertTrue(a8 is None) self.assertTrue(a9) - for i in xrange(5): + for i in range(5): f=allFMTSLeavesPerCommonSupport[0][0][0][i] fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst) f.loadArraysIfNecessary() @@ -2742,12 +2742,12 @@ class MEDLoaderTest4(unittest.TestCase): self.assertTrue(a8.isEqual(DataArrayInt([0,1]))) self.assertTrue(a9) # no copy here self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None) - for i in xrange(1,2): + for i in range(1,2): self.assertTrue((fcscp.isDataSetSupportEqualToThePreviousOne(i,fields))) pass vExp0=[DataArrayDouble([7.,11.]),DataArrayDouble([11.,7.])] vExp1=[DataArrayDouble([3.,5.,7.,6.,2.,3.,11.,8.]),DataArrayDouble([7.,6.,3.,5.,11.,8.,2.,3.])] - for i in xrange(2): + for i in range(2): f=allFMTSLeavesPerCommonSupport1[0][0][0][i] fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst) f.loadArraysIfNecessary() @@ -2860,12 +2860,12 @@ class MEDLoaderTest4(unittest.TestCase): self.assertTrue(a8.isEqual(DataArrayInt([0,1]))) self.assertTrue(a9) # no copy here self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None) - for i in xrange(1,2): + for i in range(1,2): self.assertTrue((fcscp.isDataSetSupportEqualToThePreviousOne(i,fields))) pass vExp0=[DataArrayDouble([7.,11.]),DataArrayDouble([11.,7.])] vExp1=[DataArrayDouble([3.,5.,4.,6.]),DataArrayDouble([5.,3.,6.,4.])] - for i in xrange(2): + for i in range(2): f=allFMTSLeavesPerCommonSupport1[0][0][0][i] fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst) f.loadArraysIfNecessary() @@ -2929,12 +2929,12 @@ class MEDLoaderTest4(unittest.TestCase): self.assertTrue(a8.isEqual(DataArrayInt([0,1]))) self.assertTrue(a9) # no copy here self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None) - for i in xrange(1,2): + for i in range(1,2): self.assertTrue((fcscp.isDataSetSupportEqualToThePreviousOne(i,fields))) pass vExp0=[DataArrayDouble([7.,11.]),DataArrayDouble([11.,7.])] vExp1=[DataArrayDouble([3.,5.,4.,6.]),DataArrayDouble([5.,3.,6.,4.])] - for i in xrange(2): + for i in range(2): f=allFMTSLeavesPerCommonSupport1[0][0][0][i] fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst) # no load needed here v=mml.buildDataArray(fsst,fields,f.getUndergroundDataArray()) @@ -3041,10 +3041,10 @@ class MEDLoaderTest4(unittest.TestCase): self.assertTrue(not a12) self.assertTrue(a13) # no copy here self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None) - for i in xrange(1,2): + for i in range(1,2): self.assertTrue((fcscp.isDataSetSupportEqualToThePreviousOne(i,fields))) pass - for i in xrange(2): + for i in range(2): f=allFMTSLeavesPerCommonSupport1[0][0][0][i] fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst) f.loadArraysIfNecessary() @@ -3227,10 +3227,10 @@ class MEDLoaderTest4(unittest.TestCase): self.assertTrue(a12.isEqual(DataArrayInt([0,10,20,30,40,50,60,70,80,90,100,110,120,130,140,150,160,170,180,190,200,210,220,230,240]))) self.assertTrue(a13) # no copy here self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None) - for i in xrange(1,2): + for i in range(1,2): self.assertTrue((fcscp.isDataSetSupportEqualToThePreviousOne(i,fields))) pass - for i in xrange(2): + for i in range(2): f=allFMTSLeavesPerCommonSupport1[0][0][0][i] fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst) f.loadArraysIfNecessary() @@ -3280,7 +3280,7 @@ class MEDLoaderTest4(unittest.TestCase): self.assertTrue(a12.isEqual(DataArrayInt([50,60,70,100,110,120,150,160,170,200,210,220]))) self.assertTrue(not a13) # copy here self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None) - for i in xrange(2): + for i in range(2): f=allFMTSLeavesPerCommonSupport1[1][0][0][i] fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst) f.loadArraysIfNecessary() @@ -3633,7 +3633,7 @@ class MEDLoaderTest4(unittest.TestCase): self.assertTrue(b.isEqual(arr1,1e-12)) self.assertTrue(c.isEqual(arr2,1e-12)) self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None) - for i in xrange(2): + for i in range(2): f=allFMTSLeavesPerCommonSupport[0][0][0][i] fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst) f.loadArraysIfNecessary() @@ -4388,7 +4388,7 @@ class MEDLoaderTest4(unittest.TestCase): self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None) self.assertEqual(v.getHiddenCppPointer(),ffGauss.getUndergroundDataArray().getHiddenCppPointer()) self.assertEqual(ffGauss.getName(),"fGauss") - self.assertTrue(v.isEqual(arrGauss,1e-12)) ; self.assertTrue(v.isEqualWithoutConsideringStr(DataArrayDouble(range(27)),1e-12)) ; self.assertEqual(v.getInfoOnComponents(),["gaussc"]) + self.assertTrue(v.isEqual(arrGauss,1e-12)) ; self.assertTrue(v.isEqualWithoutConsideringStr(DataArrayDouble(list(range(27))),1e-12)) ; self.assertEqual(v.getInfoOnComponents(),["gaussc"]) ffGauss=allFMTSLeavesPerCommonSupport1[0][0][1][0] pass @@ -4417,7 +4417,7 @@ class MEDLoaderTest4(unittest.TestCase): # fmts0=MEDFileFieldMultiTS() fmts1=MEDFileFieldMultiTS() - for i in xrange(30): + for i in range(30): f1ts=MEDFileField1TS() fFaces=MEDCouplingFieldDouble(ON_CELLS) ; fFaces.setName("FieldOnFaces") arr=DataArrayDouble(98) ; arr.iota() ; arr[i]=100. @@ -4480,7 +4480,7 @@ class MEDLoaderTest4(unittest.TestCase): self.assertTrue(b.isEqual(arrY,1e-12)) self.assertTrue(c.isEqual(arrZ,1e-12)) self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None) - for i in xrange(30): + for i in range(30): ffCell=allFMTSLeavesPerCommonSupport1[0][0][0][i] fsst=MEDFileField1TSStructItem.BuildItemFrom(ffCell,mst) ffCell.loadArraysIfNecessary() @@ -4504,7 +4504,7 @@ class MEDLoaderTest4(unittest.TestCase): self.assertTrue(a3.isEqual(DataArrayInt([4,0,12,15,3,4,12,24,27,15,4,24,36,39,27,4,36,48,51,39,4,3,15,18,6,4,15,27,30,18,4,27,39,42,30,4,39,51,54,42,4,6,18,21,9,4,18,30,33,21,4,30,42,45,33,4,42,54,57,45,4,1,13,16,4,4,13,25,28,16,4,25,37,40,28,4,37,49,52,40,4,4,16,19,7,4,16,28,31,19,4,28,40,43,31,4,40,52,55,43,4,7,19,22,10,4,19,31,34,22,4,31,43,46,34,4,43,55,58,46,4,2,14,17,5,4,14,26,29,17,4,26,38,41,29,4,38,50,53,41,4,5,17,20,8,4,17,29,32,20,4,29,41,44,32,4,41,53,56,44,4,8,20,23,11,4,20,32,35,23,4,32,44,47,35,4,44,56,59,47,4,0,12,13,1,4,12,24,25,13,4,24,36,37,25,4,36,48,49,37,4,1,13,14,2,4,13,25,26,14,4,25,37,38,26,4,37,49,50,38,4,3,15,16,4,4,15,27,28,16,4,27,39,40,28,4,39,51,52,40,4,4,16,17,5,4,16,28,29,17,4,28,40,41,29,4,40,52,53,41,4,6,18,19,7,4,18,30,31,19,4,30,42,43,31,4,42,54,55,43,4,7,19,20,8,4,19,31,32,20,4,31,43,44,32,4,43,55,56,44,4,9,21,22,10,4,21,33,34,22,4,33,45,46,34,4,45,57,58,46,4,10,22,23,11,4,22,34,35,23,4,34,46,47,35,4,46,58,59,47,4,0,1,4,3,4,3,4,7,6,4,6,7,10,9,4,1,2,5,4,4,4,5,8,7,4,7,8,11,10,4,12,13,16,15,4,15,16,19,18,4,18,19,22,21,4,13,14,17,16,4,16,17,20,19,4,19,20,23,22,4,24,25,28,27,4,27,28,31,30,4,30,31,34,33,4,25,26,29,28,4,28,29,32,31,4,31,32,35,34,4,36,37,40,39,4,39,40,43,42,4,42,43,46,45,4,37,38,41,40,4,40,41,44,43,4,43,44,47,46,4,48,49,52,51,4,51,52,55,54,4,54,55,58,57,4,49,50,53,52,4,52,53,56,55,4,55,56,59,58]))) self.assertTrue(a4 is None) self.assertTrue(a5 is None) - for i in xrange(30): + for i in range(30): ffCell=allFMTSLeavesPerCommonSupport1[1][0][0][i] fsst=MEDFileField1TSStructItem.BuildItemFrom(ffCell,mst) ffCell.loadArraysIfNecessary() @@ -4537,7 +4537,7 @@ class MEDLoaderTest4(unittest.TestCase): fmts0=MEDFileFieldMultiTS() fmts1=MEDFileFieldMultiTS() pfl=DataArrayInt(11) ; pfl.iota() ; pfl.setName("PflOnHECA8") - for i in xrange(30): + for i in range(30): f1ts=MEDFileField1TS() fFaces=MEDCouplingFieldDouble(ON_CELLS) ; fFaces.setName("FieldOnCells") arr=DataArrayDouble(11) ; arr.iota() ; arr[i%11]=100. @@ -4593,7 +4593,7 @@ class MEDLoaderTest4(unittest.TestCase): self.assertTrue(a3.isEqual(DataArrayInt([8,1,0,3,4,13,12,15,16,8,2,1,4,5,14,13,16,17,8,4,3,6,7,16,15,18,19,8,5,4,7,8,17,16,19,20,8,7,6,9,10,19,18,21,22,8,8,7,10,11,20,19,22,23,8,13,12,15,16,25,24,27,28,8,14,13,16,17,26,25,28,29,8,16,15,18,19,28,27,30,31,8,17,16,19,20,29,28,31,32,8,19,18,21,22,31,30,33,34]))) self.assertTrue(a4 is None) self.assertTrue(a5 is None) - for i in xrange(30): + for i in range(30): ffCell=allFMTSLeavesPerCommonSupport1[0][0][0][i] fsst=MEDFileField1TSStructItem.BuildItemFrom(ffCell,mst) ffCell.loadArraysIfNecessary() @@ -4628,7 +4628,7 @@ class MEDLoaderTest4(unittest.TestCase): fmts0=MEDFileFieldMultiTS() fmts1=MEDFileFieldMultiTS() pfl=DataArrayInt(31) ; pfl.iota() ; pfl.setName("PflOnQUAD4") - for i in xrange(30): + for i in range(30): f1ts=MEDFileField1TS() fFaces=MEDCouplingFieldDouble(ON_CELLS) ; fFaces.setName("FieldOnFaces") arr=DataArrayDouble(31) ; arr.iota() ; arr[i]=100. @@ -4692,7 +4692,7 @@ class MEDLoaderTest4(unittest.TestCase): self.assertTrue(b.isEqual(arrY,1e-12)) self.assertTrue(c.isEqual(arrZ,1e-12)) self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None) - for i in xrange(30): + for i in range(30): ffCell=allFMTSLeavesPerCommonSupport1[0][0][0][i] fsst=MEDFileField1TSStructItem.BuildItemFrom(ffCell,mst) ffCell.loadArraysIfNecessary() @@ -4719,7 +4719,7 @@ class MEDLoaderTest4(unittest.TestCase): a6,a7=mml2.retrieveFamilyIdsOnCells() self.assertTrue(a6 is None) self.assertTrue(a7) - for i in xrange(30): + for i in range(30): ffCell=allFMTSLeavesPerCommonSupport1[1][0][0][i] fsst=MEDFileField1TSStructItem.BuildItemFrom(ffCell,mst) ffCell.loadArraysIfNecessary() @@ -4751,7 +4751,7 @@ class MEDLoaderTest4(unittest.TestCase): mm=MEDFileUMesh() mm.setMeshAtLevel(0,m) mm.write(fname,2) - for i in xrange(15): + for i in range(15): fCell0=MEDCouplingFieldDouble(ON_CELLS) ; fCell0.setTime(float(i)+0.1,i,0) fCell0.setName(fieldName) ; fCell0.setMesh(m) arr=DataArrayDouble(m.getNumberOfCells()) ; arr.iota(0) ; arr[i%10]=100. @@ -4800,7 +4800,7 @@ class MEDLoaderTest4(unittest.TestCase): self.assertTrue(a4 is None) self.assertTrue(a5 is None) self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None) - for i in xrange(15): + for i in range(15): ffCell=allFMTSLeavesPerCommonSupport1[0][0][0][i] fsst=MEDFileField1TSStructItem.BuildItemFrom(ffCell,mst) ffCell.loadArraysIfNecessary() @@ -4827,7 +4827,7 @@ class MEDLoaderTest4(unittest.TestCase): fieldName0="zeField0" fieldName1="zeField1" fs0=MEDFileFieldMultiTS() ; fs1=MEDFileFieldMultiTS() - for i in xrange(5): + for i in range(5): f=MEDFileField1TS() fNode=MEDCouplingFieldDouble(ON_GAUSS_PT) ; fNode.setTime(float(i),i,0) fNode.setName(fieldName0) ; fNode.setMesh(m) @@ -4885,7 +4885,7 @@ class MEDLoaderTest4(unittest.TestCase): self.assertEqual(len(allFMTSLeavesPerTimeSeries[0]),5) allFMTSLeavesPerCommonSupport=MEDFileAnyTypeFieldMultiTS.SplitPerCommonSupport(allFMTSLeavesPerTimeSeries[0],ms[ms.getMeshesNames()[0]]) self.assertEqual(len(allFMTSLeavesPerCommonSupport),5) - for i in xrange(5): + for i in range(5): self.assertEqual(len(allFMTSLeavesPerCommonSupport[i][0]),1) # mst=MEDFileMeshStruct.New(ms[0]) @@ -4903,10 +4903,10 @@ class MEDLoaderTest4(unittest.TestCase): self.assertTrue(a4 is None) self.assertTrue(a5 is None) self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None) - for i in xrange(1,5): + for i in range(1,5): self.assertTrue((fcscp.isDataSetSupportEqualToThePreviousOne(i,fields))) pass - for i in xrange(5): + for i in range(5): f=allFMTSLeavesPerCommonSupport[0][0][0][i] fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst) f.loadArraysIfNecessary() @@ -5133,7 +5133,7 @@ class MEDLoaderTest4(unittest.TestCase): self.assertTrue(a4 is None) self.assertTrue(a5 is None) self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None) - for i in xrange(1): + for i in range(1): ffCell=allFMTSLeavesPerCommonSupport1[0][0][0][i] fsst=MEDFileField1TSStructItem.BuildItemFrom(ffCell,mst) ffCell.loadArraysIfNecessary() @@ -5161,7 +5161,7 @@ class MEDLoaderTest4(unittest.TestCase): self.assertTrue(a4 is None) self.assertTrue(a5 is None) self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None) - for i in xrange(1): + for i in range(1): ffCell=allFMTSLeavesPerCommonSupport1[1][0][0][i] fsst=MEDFileField1TSStructItem.BuildItemFrom(ffCell,mst) ffCell.loadArraysIfNecessary() @@ -5231,7 +5231,7 @@ class MEDLoaderTest4(unittest.TestCase): self.assertTrue(a.isEqual(ref_a,1e-14)) self.assertEqual(b,[3,4,5]) self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None) - for i in xrange(1): + for i in range(1): ffCell=allFMTSLeavesPerCommonSupport1[0][0][0][i] fsst=MEDFileField1TSStructItem.BuildItemFrom(ffCell,mst) ffCell.loadArraysIfNecessary() @@ -5301,7 +5301,7 @@ class MEDLoaderTest4(unittest.TestCase): self.assertTrue(a.isEqual(ref_a,1e-14)) self.assertEqual(b,[3,4,5]) self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None) - for i in xrange(1): + for i in range(1): ffCell=allFMTSLeavesPerCommonSupport1[0][0][0][i] fsst=MEDFileField1TSStructItem.BuildItemFrom(ffCell,mst) ffCell.loadArraysIfNecessary() @@ -5371,7 +5371,7 @@ class MEDLoaderTest4(unittest.TestCase): ref_a.setInfoOnComponents(comps) self.assertTrue(a0.isEqual(ref_a,1e-14))#<- Test is here self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None) - for i in xrange(1): + for i in range(1): ffCell=allFMTSLeavesPerCommonSupport1[0][0][0][i] fsst=MEDFileField1TSStructItem.BuildItemFrom(ffCell,mst) ffCell.loadArraysIfNecessary() @@ -5437,7 +5437,7 @@ class MEDLoaderTest4(unittest.TestCase): self.assertTrue(a.isEqual(ref_a,1e-14))#<- Test is here self.assertEqual(b,[3,4,5]) self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None) - for i in xrange(1): + for i in range(1): ffCell=allFMTSLeavesPerCommonSupport1[0][0][0][i] fsst=MEDFileField1TSStructItem.BuildItemFrom(ffCell,mst) ffCell.loadArraysIfNecessary() diff --git a/src/MEDLoader/Swig/VTKReader.py b/src/MEDLoader/Swig/VTKReader.py index 48368bd7c..012ccb575 100644 --- a/src/MEDLoader/Swig/VTKReader.py +++ b/src/MEDLoader/Swig/VTKReader.py @@ -105,7 +105,7 @@ class PVTUReader: self._tmp=3 return if name=="PDataArray": - if self._tmp in self._data_array.keys(): + if self._tmp in list(self._data_array.keys()): self._data_array[self._tmp](attrs) pass return @@ -270,7 +270,7 @@ class VTURawReader: except self.NormalException as e: isOK=True fd.seek(0) - for i in xrange(e.getLineNb()): fd.readline() + for i in range(e.getLineNb()): fd.readline() ref=fd.tell()+5 pass if not isOK: diff --git a/src/MEDLoader/Swig/medutilities.py b/src/MEDLoader/Swig/medutilities.py index 84eccadb6..e0a3d3fb6 100644 --- a/src/MEDLoader/Swig/medutilities.py +++ b/src/MEDLoader/Swig/medutilities.py @@ -33,7 +33,7 @@ def my_remove(f): def convert(file_in, driver_in, driver_out, format=1, file_out=None): # - print file_in + print(file_in) # if file_out is None: file_out = file_in @@ -45,7 +45,7 @@ def convert(file_in, driver_in, driver_out, format=1, file_out=None): msg = "Driver out %s is unknown"%(driver_out) raise NotImplementedError(msg) pass - print file_out + print(file_out) # if driver_in == "GIBI": sr = SauvReader.New(file_in) diff --git a/src/MEDPartitioner_Swig/MEDPartitionerTest.py b/src/MEDPartitioner_Swig/MEDPartitionerTest.py index 030759f2d..93657cabf 100644 --- a/src/MEDPartitioner_Swig/MEDPartitionerTest.py +++ b/src/MEDPartitioner_Swig/MEDPartitionerTest.py @@ -78,7 +78,7 @@ class MEDPartitionerTest(unittest.TestCase): self.assertEqual( 2, joints.getJointAtPos(1).getStepAtPos(0).getNumberOfCorrespondences()) self.assertEqual( 1, joints.getJointAtPos(2).getStepAtPos(0).getNumberOfCorrespondences()) found=0 - for ii in xrange(joints.getJointAtPos(0).getStepAtPos(0).getNumberOfCorrespondences()): + for ii in range(joints.getJointAtPos(0).getStepAtPos(0).getNumberOfCorrespondences()): correspond=joints.getJointAtPos(0).getStepAtPos(0).getCorrespondenceAtPos(ii) #VSR (10/05/2016): changed to work with metis 5.1... to be confirmed! #if correspond.getCorrespondence().isEqual(DataArrayInt([1,3,2,4])): diff --git a/src/ParaMEDMEM_Swig/test_InterpKernelDEC.py b/src/ParaMEDMEM_Swig/test_InterpKernelDEC.py index abf8c9589..380044f13 100755 --- a/src/ParaMEDMEM_Swig/test_InterpKernelDEC.py +++ b/src/ParaMEDMEM_Swig/test_InterpKernelDEC.py @@ -30,11 +30,11 @@ class ParaMEDMEMBasicsTest(unittest.TestCase): size = MPI_Comm_size(MPI_COMM_WORLD) rank = MPI_Comm_rank(MPI_COMM_WORLD) if size != 5: - raise RuntimeError, "Expect MPI_COMM_WORLD size == 5" - print rank + raise RuntimeError("Expect MPI_COMM_WORLD size == 5") + print(rank) nproc_source = 3 - procs_source = range( nproc_source ) - procs_target = range( size - nproc_source + 1, size) + procs_source = list(range( nproc_source)) + procs_target = list(range( size - nproc_source + 1, size)) interface = CommInterface() target_group = MPIProcessorGroup(interface, procs_target) @@ -95,7 +95,7 @@ class ParaMEDMEMBasicsTest(unittest.TestCase): dec.sendData() dec.recvData() field_after_int=parafield.getVolumeIntegral(0,True); - self.failUnless(math.fabs(field_after_int-field_before_int)<1e-8) + self.assertTrue(math.fabs(field_after_int-field_before_int)<1e-8) pass else: dec.synchronize() diff --git a/src/ParaMEDMEM_Swig/test_NonCoincidentDEC.py b/src/ParaMEDMEM_Swig/test_NonCoincidentDEC.py index 3d78a496b..b98820dac 100755 --- a/src/ParaMEDMEM_Swig/test_NonCoincidentDEC.py +++ b/src/ParaMEDMEM_Swig/test_NonCoincidentDEC.py @@ -27,11 +27,11 @@ MPI_Init(sys.argv) size = MPI_Comm_size(MPI_COMM_WORLD) rank = MPI_Comm_rank(MPI_COMM_WORLD) if size != 5: - raise RuntimeError, "Expect MPI_COMM_WORLD size == 5" + raise RuntimeError("Expect MPI_COMM_WORLD size == 5") nproc_source = 3 -procs_source = range( nproc_source ) -procs_target = range( size - nproc_source + 1, size) +procs_source = list(range( nproc_source)) +procs_target = list(range( size - nproc_source + 1, size)) interface = CommInterface() @@ -114,7 +114,7 @@ if source_group.containsMyRank(): field_before_int = [parafield.getVolumeIntegral(1)] MPI_Bcast(field_before_int, 1, MPI_DOUBLE, 0, MPI_COMM_WORLD); dec.synchronize() - print "DEC usage" + print("DEC usage") dec.setForcedRenormalization(False) dec.sendData() @@ -134,11 +134,11 @@ MPI_Bcast(field_after_int , 1, MPI_DOUBLE, size-1, MPI_COMM_WORLD) epsilon = 1e-6 if abs(field_before_int[0] - field_after_int[0]) > epsilon: - print "Field before is not equal field after: %s != %s"%\ - (field_before_int[0],field_after_int[0]) + print("Field before is not equal field after: %s != %s"%\ + (field_before_int[0],field_after_int[0])) pass MPI_Barrier(MPI_COMM_WORLD) MPI_Finalize() -print "# End of testNonCoincidentDEC" +print("# End of testNonCoincidentDEC") diff --git a/src/ParaMEDMEM_Swig/test_StructuredCoincidentDEC.py b/src/ParaMEDMEM_Swig/test_StructuredCoincidentDEC.py index e577ef8a8..48cfb7c21 100755 --- a/src/ParaMEDMEM_Swig/test_StructuredCoincidentDEC.py +++ b/src/ParaMEDMEM_Swig/test_StructuredCoincidentDEC.py @@ -32,7 +32,7 @@ class ParaMEDMEMBasicsTest2(unittest.TestCase): rank = MPI_Comm_rank(MPI_COMM_WORLD) # if size < 4: - raise RuntimeError, "Expect MPI_COMM_WORLD size >= 4" + raise RuntimeError("Expect MPI_COMM_WORLD size >= 4") # interface = CommInterface() # @@ -103,7 +103,7 @@ class ParaMEDMEMBasicsTest2(unittest.TestCase): for i in range(nb_local): first=comptopo.firstLocalComponent() for icomp in range(comptopo.nbLocalComponents()): - self.failUnless(math.fabs(recv_value[i*comptopo.nbLocalComponents()+icomp]- + self.assertTrue(math.fabs(recv_value[i*comptopo.nbLocalComponents()+icomp]- (float)(i*6+icomp+first))<1e-12) pass pass @@ -121,7 +121,7 @@ class ParaMEDMEMBasicsTest2(unittest.TestCase): source_group = 0 MPI_Barrier(MPI_COMM_WORLD) MPI_Finalize() - print "End of test StructuredCoincidentDEC" + print("End of test StructuredCoincidentDEC") pass diff --git a/v8_work/ModifyNamespace.py b/v8_work/ModifyNamespace.py index a5f738e44..b387e5303 100644 --- a/v8_work/ModifyNamespace.py +++ b/v8_work/ModifyNamespace.py @@ -30,7 +30,7 @@ def rep1(dirname,rep): dirs=["MEDCoupling","MEDCoupling/Test","MEDLoader","MEDLoader/Swig","MEDLoader/Test","MEDPartitioner","MEDPartitioner/Test","MEDPartitioner_Swig","RENUMBER","RENUMBER_Swig","INTERP_KERNELTest","ParaMEDMEM","ParaMEDLoader","ParaMEDMEMTest","ParaMEDMEM_Swig","doc/user/doxygen/fakesources","doc/user/doxygen/doxy2swig","doc/user/doxygen/doxfiles","/home/H87074/salome/DEV/modules/src/MED/src/MEDCouplingCorba","/home/H87074/salome/DEV/modules/src/MED/src/MEDCouplingCorba/Client","/home/H87074/salome/DEV/modules/src/MED/src/MEDCouplingCorba/Test","/home/H87074/salome/DEV/modules/src/MED/src/MEDCalc/cmp","/home/H87074/salome/DEV/modules/src/MED/src/MEDCalculator","/home/H87074/salome/DEV/modules/src/MED/src/MEDCalculator/Swig","/home/H87074/salome/DEV/modules/src/MED/src/MEDCalculator/Test","/home/H87074/salome/DEV/modules/src/PARAVIS/src/Plugins/MEDReader/IO"] dirname=dirs[-1] i=0 -print rep1(dirname,rep) +print(rep1(dirname,rep)) """for r,dirs,fis in os.walk(dirname): for fi in fis: if os.path.splitext(fi)[1] not in [".dox",".doxy"]: diff --git a/v8_work/medcoup7to8.py b/v8_work/medcoup7to8.py index e577a546e..f3044a3b6 100755 --- a/v8_work/medcoup7to8.py +++ b/v8_work/medcoup7to8.py @@ -108,7 +108,7 @@ def convert(root_dir, ext, quiet): # Skip this script! if fileName == __myName: if not quiet: - print "!!! Skipping script %s !!!" % __myName + print("!!! Skipping script %s !!!" % __myName) continue ok = False if fileName[-28:] != "MEDCouplingNatureOfFieldEnum": @@ -119,7 +119,7 @@ def convert(root_dir, ext, quiet): else: ok = True if not ok: continue # skip file - if not quiet: print "Handling %s ..." % fileName + if not quiet: print("Handling %s ..." % fileName) for line in fileinput.input(fileName, inplace=1, backup='.bak'): for before, after in REPLACEMENTS: line = re.sub("(\W|^)(%s)(\W|$)" % before, r"\1%s\3" % after, line.rstrip('\r\n'))