From fb4a9461b33217e3348ab4c54c42a2995ac09f00 Mon Sep 17 00:00:00 2001 From: Gilles DAVID Date: Wed, 19 Apr 2017 10:38:45 +0200 Subject: [PATCH] =?utf8?q?Ajout=20d=C3=A9pendance=20=C3=A0=20six?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- doc/user/doxygen/doxy2swig/doxy2swig.py | 8 +- src/INTERP_KERNEL/GaussPoints/CleanUpGauss.py | 3 +- .../MEDCouplingBasicsTest1.py | 15 +- .../MEDCouplingBasicsTest2.py | 5 +- .../MEDCouplingBasicsTest3.py | 16 +- .../MEDCouplingBasicsTest4.py | 183 +++++++++--------- .../MEDCouplingBasicsTest5.py | 60 +++--- .../MEDCouplingDataForTest.py | 43 ++-- .../MEDCouplingExamplesTest.py | 5 +- src/MEDCoupling_Swig/MEDCouplingNumPyTest.py | 1 + src/MEDCoupling_Swig/MEDCouplingPickleTest.py | 3 +- .../MEDCouplingRemapperTest.py | 3 +- src/MEDLoader/Swig/CaseIO.py | 7 +- src/MEDLoader/Swig/CaseReader.py | 16 +- src/MEDLoader/Swig/CaseWriter.py | 4 +- .../Swig/MEDLoaderCouplingTrainingSession.py | 9 +- src/MEDLoader/Swig/MEDLoaderDataForTest.py | 9 +- src/MEDLoader/Swig/MEDLoaderExamplesTest.py | 1 + src/MEDLoader/Swig/MEDLoaderSplitter.py | 11 +- src/MEDLoader/Swig/MEDLoaderTest1.py | 9 +- src/MEDLoader/Swig/MEDLoaderTest3.py | 158 +++++++-------- src/MEDLoader/Swig/MEDLoaderTest4.py | 71 +++---- src/MEDLoader/Swig/SauvLoaderTest.py | 7 +- src/MEDLoader/Swig/VTKReader.py | 3 +- src/MEDPartitioner_Swig/MEDPartitionerTest.py | 1 + src/ParaMEDMEM_Swig/test_InterpKernelDEC.py | 5 +- src/ParaMEDMEM_Swig/test_NonCoincidentDEC.py | 5 +- .../test_StructuredCoincidentDEC.py | 1 + 28 files changed, 346 insertions(+), 316 deletions(-) diff --git a/doc/user/doxygen/doxy2swig/doxy2swig.py b/doc/user/doxygen/doxy2swig/doxy2swig.py index ede076a9a..f8499b449 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 (list, tuple): + if isinstance(value, (list, tuple)): self.pieces.extend(value) else: self.pieces.append(value) @@ -220,7 +220,7 @@ class Doxy2SWIG: self.parse(first[n]) self.add_text(['";','\n']) for n in node.childNodes: - if n not in list(first.values()): + if n not in 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 list(node.attributes.items()): + for key, val in node.attributes.items(): if key == 'kind': if val == 'param': text = 'Parameters' elif val == 'exception': text = 'Exceptions' @@ -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 list(first.values()): + if n not in first.values(): self.parse(n) self.add_text(['";', '\n']) diff --git a/src/INTERP_KERNEL/GaussPoints/CleanUpGauss.py b/src/INTERP_KERNEL/GaussPoints/CleanUpGauss.py index d8b9f9b98..60738c9b9 100644 --- a/src/INTERP_KERNEL/GaussPoints/CleanUpGauss.py +++ b/src/INTERP_KERNEL/GaussPoints/CleanUpGauss.py @@ -18,6 +18,7 @@ # Author : Anthony Geay (EDF R&D) import re +from six.moves import range s1=2709 s2=2848 @@ -48,7 +49,7 @@ dim=nbLines/nbPts-2 if dim<1 or dim>3: raise Exception("Ooops invalid dim !") entries=[(i,int(casePat.match(elt).group(1))) for i,elt in entries] -assert({elt[1] for elt in entries}==set(range(nbPts))) +assert({elt[1] for elt in entries} == set(range(nbPts))) # partEndEntries=re.compile("[\s]*break[\s]*\;[\s]*$") zePat=re.compile("[\s]+coords\[([\d]+)\][\s]*=[\s]*([\-]?[\d]+[\.]?[\d]*)[\s]*\;[\s]*$") diff --git a/src/MEDCoupling_Swig/MEDCouplingBasicsTest1.py b/src/MEDCoupling_Swig/MEDCouplingBasicsTest1.py index 324dce52c..d32171834 100644 --- a/src/MEDCoupling_Swig/MEDCouplingBasicsTest1.py +++ b/src/MEDCoupling_Swig/MEDCouplingBasicsTest1.py @@ -24,6 +24,7 @@ from math import pi,e,sqrt,cos,sin from datetime import datetime from MEDCouplingDataForTest import MEDCouplingDataForTest import rlcompleter,readline # this line has to be here, to ensure a usability of MEDCoupling/MEDLoader. B4 removing it please notify to anthony.geay@cea.fr +from six.moves import range class MEDCouplingBasicsTest1(unittest.TestCase): def testArray2(self): @@ -133,7 +134,7 @@ class MEDCouplingBasicsTest1(unittest.TestCase): field.setNature(ExtensiveMaximum) myCoords=DataArrayDouble.New() sampleTab=[] - for i in range(nbOfCells*9): + for i in range(nbOfCells * 9): sampleTab.append(float(i)) myCoords.setValues(sampleTab,nbOfCells,9); field.setArray(myCoords) @@ -797,7 +798,7 @@ class MEDCouplingBasicsTest1(unittest.TestCase): self.assertEqual(5,m4.getMesh2D().getNumberOfCells()); self.assertEqual(3,m4.getMesh1D().getNumberOfCells()); m3DIds=m4.getMesh3DIds().getValues(); - self.assertEqual(list(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); @@ -877,7 +878,7 @@ class MEDCouplingBasicsTest1(unittest.TestCase): o2n,newNbOfNodes=targetMesh.buildNewNumberingFromCommonNodesFormat(comm,commI); self.assertEqual(27,newNbOfNodes); self.assertEqual(27,o2n.getNumberOfTuples()); - o2nExp1=list(range(27)) + o2nExp1 = list(range(27)) self.assertEqual(o2nExp1,list(o2n.getValues())); # targetMesh=MEDCouplingDataForTest.build3DTargetMeshMergeNode_1(); @@ -992,7 +993,7 @@ class MEDCouplingBasicsTest1(unittest.TestCase): def testMergeMeshOnSameCoords1(self): m1=MEDCouplingDataForTest.build2DTargetMesh_1(); m2=MEDCouplingDataForTest.build2DTargetMesh_1(); - cells=list(range(5)); + cells = list(range(5)); m2.convertToPolyTypes(cells); m1.tryToShareSameCoords(m2,1e-12); m3=MEDCouplingDataForTest.build2DTargetMesh_1(); @@ -2084,7 +2085,7 @@ class MEDCouplingBasicsTest1(unittest.TestCase): self.assertEqual(2,f.getNbOfGaussLocalization()); array=DataArrayDouble.New(); ptr=18*2*[None] - for i in range(18*2): + for i in range(18 * 2): ptr[i]=float(i+1) array.setValues(ptr,18,2); ptr=array.getPointer(); @@ -2146,7 +2147,7 @@ class MEDCouplingBasicsTest1(unittest.TestCase): f.setDescription("MyDescriptionNE"); array=DataArrayDouble.New(); tmp=18*2*[None] - for i in range(18*2): + for i in range(18 * 2): tmp[i]=float(i+7) pass array.setValues(tmp,18,2); @@ -2244,7 +2245,7 @@ class MEDCouplingBasicsTest1(unittest.TestCase): def testCellOrientation3(self): from cmath import rect - c = [rect(1.0, i*pi/4.0) for i in range(8)] + c = [rect(1.0, 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 = [0,1,2,3] diff --git a/src/MEDCoupling_Swig/MEDCouplingBasicsTest2.py b/src/MEDCoupling_Swig/MEDCouplingBasicsTest2.py index de19d6a4f..a261817e6 100644 --- a/src/MEDCoupling_Swig/MEDCouplingBasicsTest2.py +++ b/src/MEDCoupling_Swig/MEDCouplingBasicsTest2.py @@ -24,6 +24,7 @@ from math import pi,e,sqrt,cos,sin from datetime import datetime from MEDCouplingDataForTest import MEDCouplingDataForTest import rlcompleter,readline # this line has to be here, to ensure a usability of MEDCoupling/MEDLoader. B4 removing it please notify to anthony.geay@cea.fr +from six.moves import range class MEDCouplingBasicsTest2(unittest.TestCase): def testMinMaxFields1(self): @@ -167,7 +168,7 @@ class MEDCouplingBasicsTest2(unittest.TestCase): self.assertEqual(2,f2.getMesh().getMeshDimension()); m2C=f2.getMesh(); self.assertEqual(8,m2C.getNodalConnectivityArrayLen()); - for i in range(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],list(m2C.getNodalConnectivity().getValues())[4:]); @@ -189,7 +190,7 @@ class MEDCouplingBasicsTest2(unittest.TestCase): self.assertEqual(2,f2.getMesh().getMeshDimension()); m2C=f2.getMesh(); self.assertEqual(8,m2C.getNodalConnectivityArrayLen()); - for i in range(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],list(m2C.getNodalConnectivity().getValues())[4:8]); diff --git a/src/MEDCoupling_Swig/MEDCouplingBasicsTest3.py b/src/MEDCoupling_Swig/MEDCouplingBasicsTest3.py index ea8b1257d..10ed467b4 100644 --- a/src/MEDCoupling_Swig/MEDCouplingBasicsTest3.py +++ b/src/MEDCoupling_Swig/MEDCouplingBasicsTest3.py @@ -24,6 +24,8 @@ from math import pi,e,sqrt,cos,sin from datetime import datetime from MEDCouplingDataForTest import MEDCouplingDataForTest import rlcompleter,readline # this line has to be here, to ensure a usability of MEDCoupling/MEDLoader. B4 removing it please notify to anthony.geay@cea.fr +import six +from six.moves import range class MEDCouplingBasicsTest3(unittest.TestCase): def testSwigGetItem1(self): @@ -271,7 +273,7 @@ class MEDCouplingBasicsTest3(unittest.TestCase): da-=8 st2=da.getHiddenCppPointer() self.assertEqual(st1,st2) - self.assertEqual(list(range(12)),da.getValues()) + self.assertEqual(list(range(12)), da.getValues()) da+=da1 st2=da.getHiddenCppPointer() self.assertEqual(st1,st2) @@ -347,7 +349,7 @@ class MEDCouplingBasicsTest3(unittest.TestCase): da-=8 st2=da.getHiddenCppPointer() self.assertEqual(st1,st2) - self.assertEqual(list(range(12)),da.getValues()) + self.assertEqual(list(range(12)), da.getValues()) da+=da1 st2=da.getHiddenCppPointer() self.assertEqual(st1,st2) @@ -492,7 +494,7 @@ class MEDCouplingBasicsTest3(unittest.TestCase): it2=da2.__iter__() i=0 for it in da: - pt=next(it2) + pt = six.next(it2) it[:]=pt pass self.assertTrue(da.isEqual(da2)) @@ -550,7 +552,7 @@ class MEDCouplingBasicsTest3(unittest.TestCase): it2=da2.__iter__() i=0 for it in da: - pt=next(it2) + pt = six.next(it2) it[:]=pt pass self.assertTrue(da.isEqual(da2,1e-12)) @@ -616,12 +618,12 @@ class MEDCouplingBasicsTest3(unittest.TestCase): def testDAIAggregateMulti1(self): a=DataArrayInt.New() - a.setValues(list(range(4)),2,2) + a.setValues(list(range(4)), 2, 2) a.setName("aa") b=DataArrayInt.New() - b.setValues(list(range(6)),3,2) + b.setValues(list(range(6)), 3, 2) c=DataArrayInt.Aggregate([a,b]) - self.assertEqual(list(range(4))+list(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()) diff --git a/src/MEDCoupling_Swig/MEDCouplingBasicsTest4.py b/src/MEDCoupling_Swig/MEDCouplingBasicsTest4.py index 108d4c6b9..f0586d109 100644 --- a/src/MEDCoupling_Swig/MEDCouplingBasicsTest4.py +++ b/src/MEDCoupling_Swig/MEDCouplingBasicsTest4.py @@ -25,6 +25,7 @@ from datetime import datetime from MEDCouplingDataForTest import MEDCouplingDataForTest import rlcompleter,readline # this line has to be here, to ensure a usability of MEDCoupling/MEDLoader. B4 removing it please notify to anthony.geay@cea.fr from sys import platform +from six.moves import range def checkFreeMemory(size): """ @@ -50,7 +51,7 @@ def checkFreeMemory(size): class MEDCouplingBasicsTest4(unittest.TestCase): def testSwigDADOp4(self): - da=DataArrayDouble.New(list(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 range(24): @@ -95,8 +96,8 @@ class MEDCouplingBasicsTest4(unittest.TestCase): self.assertAlmostEqual(li[0],100.,13) ; self.assertAlmostEqual(li[1],101.,13) pass # operator-= - da=DataArrayDouble.New(list(range(6,30)),12,2) - da2=DataArrayDouble.New(list(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.] @@ -121,8 +122,8 @@ class MEDCouplingBasicsTest4(unittest.TestCase): self.assertAlmostEqual(da.getIJ(0,i),expected3[i],13) pass # operator*= - da=DataArrayDouble.New(list(range(6,30)),12,2) - da2=DataArrayDouble.New(list(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.] @@ -147,8 +148,8 @@ class MEDCouplingBasicsTest4(unittest.TestCase): self.assertAlmostEqual(da.getIJ(0,i),expected3[i],13) pass # operator/= - da=DataArrayDouble.New(list(range(6,30)),12,2) - da2=DataArrayDouble.New(list(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] @@ -175,7 +176,7 @@ class MEDCouplingBasicsTest4(unittest.TestCase): pass def testSwigDAIOp4(self): - da=DataArrayInt.New(list(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 range(24): @@ -220,8 +221,8 @@ class MEDCouplingBasicsTest4(unittest.TestCase): self.assertEqual(li[0],100) ; self.assertEqual(li[1],101) pass # operator-= - da=DataArrayInt.New(list(range(6,30)),12,2) - da2=DataArrayInt.New(list(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] @@ -246,8 +247,8 @@ class MEDCouplingBasicsTest4(unittest.TestCase): self.assertEqual(da.getIJ(0,i),expected3[i]) pass # operator*= - da=DataArrayInt.New(list(range(6,30)),12,2) - da2=DataArrayInt.New(list(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] @@ -272,8 +273,8 @@ class MEDCouplingBasicsTest4(unittest.TestCase): self.assertEqual(da.getIJ(0,i),expected3[i]) pass # operator/= - da=DataArrayInt.New(list(range(6,30)),12,2) - da2=DataArrayInt.New(list(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] @@ -791,8 +792,8 @@ class MEDCouplingBasicsTest4(unittest.TestCase): pass def testDataArrayIntGetHashCode1(self): - d1=DataArrayInt.New(list(range(3545))) - d2=DataArrayInt.New(list(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 @@ -1165,7 +1166,7 @@ class MEDCouplingBasicsTest4(unittest.TestCase): pass def testSwigBugNonRegressionZipDA(self): - angles=[pi/3*x for x in range(6)] + angles = [pi / 3 * x for x in range(6)] radius=3 # dad=DataArrayDouble.New(6, 2) @@ -1574,15 +1575,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,list(range(8))) + mQ8.insertNextCell(NORM_QUAD8, list(range(8))) mQ8.finishInsertingCells() mQ4=MEDCouplingUMesh("",2) ; mQ4.setCoords(coords) mQ4.allocateCells(1) - mQ4.insertNextCell(NORM_QUAD4,list(range(4))) + mQ4.insertNextCell(NORM_QUAD4, list(range(4))) mQ4.finishInsertingCells() mT3=MEDCouplingUMesh("",2) ; mT3.setCoords(coords) mT3.allocateCells(1) - mT3.insertNextCell(NORM_TRI3,list(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.]] @@ -2030,7 +2031,7 @@ 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,list(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.]) @@ -2511,8 +2512,8 @@ class MEDCouplingBasicsTest4(unittest.TestCase): m3D.convertLinearCellsToQuadratic(0) m3D.checkConsistency() # check of new m3D content - 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)] + 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 +2719,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 range(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 +2852,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]=list(range(126)) - arr[:,1]=list(range(126)) + arr[:, 0] = list(range(126)) + arr[:, 1] = list(range(126)) arr[:,1]+=1000 f.setArray(arr) f.checkConsistencyLight() @@ -2913,24 +2914,24 @@ class MEDCouplingBasicsTest4(unittest.TestCase): def testSwig2DAReverseMultiCompo1(self): d=DataArrayDouble(6,2) - d[:,0]=list(range(6)) - d[:,1]=list(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]=list(range(7)) - d[:,1]=list(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]=list(range(6)) - d[:,1]=list(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]=list(range(7)) - d[:,1]=list(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 @@ -3016,7 +3017,7 @@ class MEDCouplingBasicsTest4(unittest.TestCase): self.assertTrue(len(d.__repr__())<500) pass d.alloc(4000,1) ; d.iota() ; self.assertTrue(len(d.__repr__())<500) - for i in range(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) @@ -3034,7 +3035,7 @@ class MEDCouplingBasicsTest4(unittest.TestCase): self.assertTrue(len(d.__repr__())<500) pass d.alloc(4000,1) ; d.iota() ; self.assertTrue(len(d.__repr__())<500) - for i in range(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) @@ -3200,20 +3201,20 @@ class MEDCouplingBasicsTest4(unittest.TestCase): f=MEDCouplingFieldDouble(ON_CELLS) f.setMesh(m) arr=DataArrayDouble(5,2) - arr[:,0]=list(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__,list(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__,list(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]=list(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 +3233,20 @@ class MEDCouplingBasicsTest4(unittest.TestCase): f=MEDCouplingFieldDouble(ON_CELLS) f.setMesh(m) arr=DataArrayDouble(5,2) - arr[:,0]=list(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__,list(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__,list(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]=list(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 +3265,20 @@ class MEDCouplingBasicsTest4(unittest.TestCase): f=MEDCouplingFieldDouble(ON_CELLS) f.setMesh(m) arr=DataArrayDouble(5,2) - arr[:,0]=list(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__,list(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__,list(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]=list(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 +3297,20 @@ class MEDCouplingBasicsTest4(unittest.TestCase): f=MEDCouplingFieldDouble(ON_CELLS) f.setMesh(m) arr=DataArrayDouble(5,2) - arr[:,0]=list(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__,list(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__,list(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]=list(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 +3333,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__,list(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__,list(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()[:]=list(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 +3359,19 @@ class MEDCouplingBasicsTest4(unittest.TestCase): f=MEDCouplingFieldDouble(ON_CELLS) f.setMesh(m) arr=DataArrayDouble(5,2) - arr[:,0]=list(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__,list(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__,list(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]=list(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 +3391,19 @@ class MEDCouplingBasicsTest4(unittest.TestCase): f=MEDCouplingFieldDouble(ON_CELLS) f.setMesh(m) arr=DataArrayDouble(5,2) - arr[:,0]=list(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__,list(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__,list(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]=list(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 +3423,19 @@ class MEDCouplingBasicsTest4(unittest.TestCase): f=MEDCouplingFieldDouble(ON_CELLS) f.setMesh(m) arr=DataArrayDouble(5,2) - arr[:,0]=list(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__,list(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__,list(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]=list(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 +3455,19 @@ class MEDCouplingBasicsTest4(unittest.TestCase): f=MEDCouplingFieldDouble(ON_CELLS) f.setMesh(m) arr=DataArrayDouble(5,2) - arr[:,0]=list(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__,list(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__,list(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]=list(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 +3487,19 @@ class MEDCouplingBasicsTest4(unittest.TestCase): f=MEDCouplingFieldDouble(ON_CELLS) f.setMesh(m) arr=DataArrayDouble(5,2) - arr[:,0]=list(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__,list(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__,list(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]=list(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 +3509,20 @@ class MEDCouplingBasicsTest4(unittest.TestCase): f=MEDCouplingFieldDouble(ON_CELLS) f.setMesh(m) arr=DataArrayDouble(5,2) - arr[:,0]=list(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__,list(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__,list(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]=list(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 +3537,20 @@ class MEDCouplingBasicsTest4(unittest.TestCase): f=MEDCouplingFieldDouble(ON_CELLS) f.setMesh(m) arr=DataArrayDouble(5,2) - arr[:,0]=list(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__,list(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__,list(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]=list(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 +3563,20 @@ class MEDCouplingBasicsTest4(unittest.TestCase): f=MEDCouplingFieldDouble(ON_CELLS) f.setMesh(m) arr=DataArrayDouble(5,2) - arr[:,0]=list(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__,list(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__,list(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]=list(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 +3591,20 @@ class MEDCouplingBasicsTest4(unittest.TestCase): f=MEDCouplingFieldDouble(ON_CELLS) f.setMesh(m) arr=DataArrayDouble(5,2) - arr[:,0]=list(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__,list(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__,list(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]=list(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 6e6183379..08fa757b9 100644 --- a/src/MEDCoupling_Swig/MEDCouplingBasicsTest5.py +++ b/src/MEDCoupling_Swig/MEDCouplingBasicsTest5.py @@ -24,6 +24,8 @@ from math import pi,e,sqrt,cos,sin from datetime import datetime from MEDCouplingDataForTest import MEDCouplingDataForTest import rlcompleter,readline # this line has to be here, to ensure a usability of MEDCoupling/MEDLoader. B4 removing it please notify to anthony.geay@cea.fr +import six +from six.moves import range class MEDCouplingBasicsTest5(unittest.TestCase): def testSwig2FieldDoubleBuildSubPartRange1(self): @@ -31,7 +33,7 @@ class MEDCouplingBasicsTest5(unittest.TestCase): m=MEDCouplingDataForTest.build2DTargetMesh_1() f=MEDCouplingFieldDouble(ON_CELLS) f.setMesh(m) - arr=DataArrayDouble(5,2) ; arr[:,0]=list(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 +63,7 @@ class MEDCouplingBasicsTest5(unittest.TestCase): #ON_NODES f=MEDCouplingFieldDouble(ON_NODES) f.setMesh(m) - arr=DataArrayDouble(9,2) ; arr[:,0]=list(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 +98,7 @@ class MEDCouplingBasicsTest5(unittest.TestCase): #ON_GAUSS_NE f=MEDCouplingFieldDouble(ON_GAUSS_NE) f.setMesh(m) - arr=DataArrayDouble(18,2) ; arr[:,0]=list(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 +132,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]=list(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 +232,7 @@ class MEDCouplingBasicsTest5(unittest.TestCase): time_deb = datetime.now() a1=DataArrayDouble(len(d)) b1=DataArrayInt(len(d)) - m1s=[m1[i] for i in range(m1.getNumberOfCells())] + m1s = [m1[i] for i in range(m1.getNumberOfCells())] for j,pt in enumerate(d): eter=1e308 fter=-1 @@ -288,7 +290,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,list(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 +309,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,list(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 +327,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,list(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 +471,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 range(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 +539,7 @@ class MEDCouplingBasicsTest5(unittest.TestCase): # maxNbCSN=nbOfCellsSharingNodes.getMaxValue()[0] arr3=DataArrayDouble(f.getMesh().getNumberOfNodes(),f.getArray().getNumberOfComponents()) ; arr3[:]=0. - for i in range(1,maxNbCSN+1): + for i in range(1, maxNbCSN + 1): ids=nbOfCellsSharingNodes.findIdsEqual(i) if len(ids)==0: continue @@ -601,7 +603,7 @@ class MEDCouplingBasicsTest5(unittest.TestCase): m=MEDCoupling1SGTUMesh("m",NORM_QUAD4) mem_m=m.getHeapMemorySize() m.allocateCells(5) - self.assertIn(m.getHeapMemorySize()-mem_m,list(range(5*4*4,5*4*4+32))) + self.assertIn(m.getHeapMemorySize() - mem_m, list(range(5 * 4 * 4, 5 * 4 * 4 + 32))) self.assertEqual(m.getNodalConnectivity().getNbOfElemAllocated(),20) m.setCoords(um.getCoords()) m.insertNextCell([1,0,6,7]) @@ -2015,7 +2017,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,list(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 +2322,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=next(it) + r = six.next(it) self.assertRaises(StopIteration,r.__getitem__,4) self.assertEqual(len(r),3) a,b,c=r - r=next(it) + r = six.next(it) self.assertEqual(len(r),3) d,e,f=r - r=next(it) + r = six.next(it) self.assertEqual(len(r),3) g,h,i=r - r=next(it) + r = six.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=next(it) + r = six.next(it) self.assertRaises(StopIteration,r.__getitem__,4) self.assertEqual(len(r),3) a,b,c=r - r=next(it) + r = six.next(it) self.assertEqual(len(r),3) d,e,f=r - r=next(it) + r = six.next(it) self.assertEqual(len(r),3) g,h,i=r - r=next(it) + r = six.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))) @@ -3628,7 +3630,7 @@ class MEDCouplingBasicsTest5(unittest.TestCase): NORM_SEG2,11,12,NORM_SEG2,12,13, NORM_SEG2,14,15]) cI = DataArrayInt([0,3,7,10,14,18,21,24,27,30]) - coords2 = DataArrayDouble([float(i) for i in range(32)], 16,2) + coords2 = DataArrayDouble([float(i) for i in range(32)], 16, 2) m2.setCoords(coords2); m2.setConnectivity(c, cI); m2.checkConsistency(1.0e-8); @@ -3931,7 +3933,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),list(range(0,1000))) # no more than 1000 characters + self.assertIn(len(st2), list(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 +3944,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),list(range(0,1000))) # no more than 1000 characters + self.assertIn(len(st2), list(range(0, 1000))) # no more than 1000 characters pass def testExtrudedMeshWithoutZipCoords1(self): @@ -4017,7 +4019,7 @@ class MEDCouplingBasicsTest5(unittest.TestCase): m=MEDCoupling1SGTUMesh("mesh",NORM_QUAD4) ; m.setCoords(coo) exp3=sqrt(85.) for delta in range(4): - c=[(elt+delta)%4 for elt 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) @@ -4035,7 +4037,7 @@ class MEDCouplingBasicsTest5(unittest.TestCase): 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 range(4): - c=[(elt+delta)%4 for elt 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) @@ -4056,7 +4058,7 @@ class MEDCouplingBasicsTest5(unittest.TestCase): exp4=2.5041256256889888 self.assertAlmostEqual(exp4,coo.buildEuclidianDistanceDenseMatrix().getMaxValue()[0],12)# <- the definition of diameter for delta in range(3): - c=[(elt+delta)%3 for elt 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) @@ -4074,7 +4076,7 @@ class MEDCouplingBasicsTest5(unittest.TestCase): exp5=2.5366409441884215 self.assertAlmostEqual(exp5,coo.buildEuclidianDistanceDenseMatrix().getMaxValue()[0],12)# <- the definition of diameter for delta in range(4): - c=[(elt+delta)%4 for elt 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) @@ -4092,7 +4094,7 @@ class MEDCouplingBasicsTest5(unittest.TestCase): exp6=2.1558368027391386 self.assertAlmostEqual(exp6,coo.buildEuclidianDistanceDenseMatrix().getMaxValue()[0],12)# <- the definition of diameter for delta in range(4): - c=[(elt+delta)%4 for elt 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) @@ -4106,7 +4108,7 @@ class MEDCouplingBasicsTest5(unittest.TestCase): exp7=1.4413563787228953 self.assertAlmostEqual(exp7,coo.buildEuclidianDistanceDenseMatrix().getMaxValue()[0],12)# <- the definition of diameter for delta in range(4): - c=[(elt+delta)%4 for elt 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) diff --git a/src/MEDCoupling_Swig/MEDCouplingDataForTest.py b/src/MEDCoupling_Swig/MEDCouplingDataForTest.py index a79956a12..485a4d98e 100644 --- a/src/MEDCoupling_Swig/MEDCouplingDataForTest.py +++ b/src/MEDCoupling_Swig/MEDCouplingDataForTest.py @@ -19,6 +19,7 @@ # from MEDCoupling import * +from six.moves import range class MEDCouplingDataForTest: def build2DTargetMesh_1(cls): @@ -586,24 +587,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 range(0,12): + for i in range(0, 12): m.insertNextCell(NORM_TRI3,conn[i]) pass - for i in range(12,18): + for i in range(12, 18): m.insertNextCell(NORM_QUAD4,conn[i]) pass - for i in range(18,30): + for i in range(18, 30): m.insertNextCell(NORM_TRI6,conn[i]) pass - for i in range(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(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]) + 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 +616,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 range(0,40): + for i in range(0, 40): m.insertNextCell(NORM_TRI3,conn[i]) pass - for i in range(40,60): + for i in range(40, 60): m.insertNextCell(NORM_QUAD4,conn[i]) pass - for i in range(60,100): + for i in range(60, 100): m.insertNextCell(NORM_TRI6,conn[i]) pass - for i in range(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(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]) + 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 +647,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 range(2,6): + for i in range(2, 6): m.insertNextCell(NORM_PENTA6,conn[i]) pass m.insertNextCell(NORM_HEXA8,conn[6]) @@ -670,7 +671,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 range(2,6): + for i in range(2, 6): m.insertNextCell(NORM_PENTA6,conn[i]) pass m.insertNextCell(NORM_HEXA8,conn[6]) @@ -687,10 +688,10 @@ class MEDCouplingDataForTest: from cmath import rect from math import pi - c = [rect(radius, i*pi/4.0) for i in range(8)] + 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 = list(range(4)) + connec = list(range(4)) baseMesh = MEDCouplingUMesh.New("circle", 2) baseMesh.allocateCells(1) meshCoords = DataArrayDouble.New(coords, len(coords)/2, 2) @@ -705,7 +706,7 @@ class MEDCouplingDataForTest: from cmath import rect from math import pi - c = [rect(radius, i*pi/4.0) for i in range(8)] + c = [rect(radius, i * pi / 4.0) for i in range(8)] coords = [] for i in range(8): coords.extend([c[i].real,c[i].imag]) diff --git a/src/MEDCoupling_Swig/MEDCouplingExamplesTest.py b/src/MEDCoupling_Swig/MEDCouplingExamplesTest.py index 1ce1f2cce..b811511ee 100644 --- a/src/MEDCoupling_Swig/MEDCouplingExamplesTest.py +++ b/src/MEDCoupling_Swig/MEDCouplingExamplesTest.py @@ -21,6 +21,7 @@ from MEDCoupling import * import unittest from math import pi, sqrt +from six.moves import range class MEDCouplingBasicsTest(unittest.TestCase): @@ -2051,7 +2052,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): self.assertEqual(2,f2.getMesh().getMeshDimension()) m2C=f2.getMesh() self.assertEqual(8,m2C.getNodalConnectivityArrayLen()) - for i in range(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:]) @@ -2073,7 +2074,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): self.assertEqual(2,f2.getMesh().getMeshDimension()) m2C=f2.getMesh() self.assertEqual(8,m2C.getNodalConnectivityArrayLen()) - for i in range(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]) diff --git a/src/MEDCoupling_Swig/MEDCouplingNumPyTest.py b/src/MEDCoupling_Swig/MEDCouplingNumPyTest.py index 1837fbd94..0f6735d65 100644 --- a/src/MEDCoupling_Swig/MEDCouplingNumPyTest.py +++ b/src/MEDCoupling_Swig/MEDCouplingNumPyTest.py @@ -28,6 +28,7 @@ from platform import architecture from sys import getrefcount import os,gc,weakref,unittest +from six.moves import range class MEDCouplingNumPyTest(unittest.TestCase): diff --git a/src/MEDCoupling_Swig/MEDCouplingPickleTest.py b/src/MEDCoupling_Swig/MEDCouplingPickleTest.py index 51ef2ab6e..5565c1b5e 100644 --- a/src/MEDCoupling_Swig/MEDCouplingPickleTest.py +++ b/src/MEDCoupling_Swig/MEDCouplingPickleTest.py @@ -29,6 +29,7 @@ from platform import architecture from sys import getrefcount import os,gc,weakref,pickle,unittest +from six.moves import range class MEDCouplingPickleTest(unittest.TestCase): @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy") @@ -233,7 +234,7 @@ class MEDCouplingPickleTest(unittest.TestCase): self.assertEqual(2,f.getNbOfGaussLocalization()); array=DataArrayDouble.New(); ptr=18*2*[None] - for i in range(18*2): + for i in range(18 * 2): ptr[i]=float(i+1) array.setValues(ptr,18,2); ptr=array.getPointer(); diff --git a/src/MEDCoupling_Swig/MEDCouplingRemapperTest.py b/src/MEDCoupling_Swig/MEDCouplingRemapperTest.py index 77a332abc..cde9b2ed6 100644 --- a/src/MEDCoupling_Swig/MEDCouplingRemapperTest.py +++ b/src/MEDCoupling_Swig/MEDCouplingRemapperTest.py @@ -22,6 +22,7 @@ from MEDCouplingDataForTest import MEDCouplingDataForTest from MEDCouplingRemapper import * from math import * import unittest +from six.moves import range class MEDCouplingBasicsTest(unittest.TestCase): def testRemapper1(self): @@ -860,7 +861,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): source=MEDCoupling1SGTUMesh("SourcePrimaire",NORM_SEG2) source.setCoords(sourceCoo) source.allocateCells() - for i in range(len(sourceCoo)-1): + for i in range(len(sourceCoo) - 1): source.insertNextCell([i,i+1]) pass source=source.buildUnstructured() diff --git a/src/MEDLoader/Swig/CaseIO.py b/src/MEDLoader/Swig/CaseIO.py index fa61441de..e4ec215f5 100644 --- a/src/MEDLoader/Swig/CaseIO.py +++ b/src/MEDLoader/Swig/CaseIO.py @@ -20,12 +20,13 @@ # Author : Anthony GEAY (CEA/DEN/DM2S/STMF/LGLS) from MEDLoader import * +import six 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 = {v:k for k, v in dictMCTyp.items()} - discSpatial2 = {v:k for k, v in discSpatial.items()} - dictCompo2 = {v:k for k, v in dictCompo.items()} + dictMCTyp2 = {v:k for k, v in six.iteritems(dictMCTyp)} + discSpatial2 = {v:k for k, v in six.iteritems(discSpatial)} + dictCompo2 = {v:k for k, v in six.iteritems(dictCompo)} pass diff --git a/src/MEDLoader/Swig/CaseReader.py b/src/MEDLoader/Swig/CaseReader.py index f70ec1704..1126da95b 100644 --- a/src/MEDLoader/Swig/CaseReader.py +++ b/src/MEDLoader/Swig/CaseReader.py @@ -24,6 +24,8 @@ import numpy as np from MEDLoader import * from CaseIO import CaseIO import sys,re +import six +from six.moves import range class CaseReader(CaseIO): """ Converting a file in the Case format (Ensight) to the MED format. @@ -166,7 +168,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 list(self.dictMCTyp2.keys()): + for k in self.dictMCTyp2: if k in typ: zeK=k break @@ -368,7 +370,7 @@ class CaseReader(CaseIO): if "TIME\n" in lines: end=lines.index("TIME\n") pass - for i in range(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,13 +381,13 @@ class CaseReader(CaseIO): pass expr=re.compile("number[\s]+of[\s]+steps[\s]*\:[\s]*([\d]+)") - tmp=list(filter(expr.search,lines)) + tmp = list(six.filter(expr.search, lines)) if len(tmp)!=0: - nbOfTimeSteps=int(expr.search(filter(expr.search,lines)[0]).group(1)) + nbOfTimeSteps = int(expr.search(six.filter(expr.search, lines)[0]).group(1)) expr=re.compile("filename[\s]+start[\s]+number[\s]*\:[\s]*([\d]+)") - startIt=int(expr.search(filter(expr.search,lines)[0]).group(1)) + startIt = int(expr.search(six.filter(expr.search, lines)[0]).group(1)) expr=re.compile("filename[\s]+increment[\s]*\:[\s]*([\d]+)") - incrIt=int(expr.search(filter(expr.search,lines)[0]).group(1)) + incrIt = int(expr.search(six.filter(expr.search, lines)[0]).group(1)) else: nbOfTimeSteps=1 startIt=0 @@ -416,7 +418,7 @@ class CaseReader(CaseIO): pass ret=MEDFileData() ret.setMeshes(m2) - del mlfields[[x for x in range(len(mlfields)) if len(mlfields[x])==0]] + 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 ad3b23056..557527738 100644 --- a/src/MEDLoader/Swig/CaseWriter.py +++ b/src/MEDLoader/Swig/CaseWriter.py @@ -211,7 +211,7 @@ time values: for mdf in mdfs: nbCompo=mdf.getNumberOfComponents() if nbCompo not in self.dictCompo: - l=[x for x in list(self.dictCompo.keys()) if x-nbCompo>0] + l = [x for x in self.dictCompo 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(list(self.dictCompo.keys())))) continue @@ -229,7 +229,7 @@ time values: for mdf in mdfs: nbCompo=mdf.getNumberOfComponents() if nbCompo not in self.dictCompo: - l=[x for x in list(self.dictCompo.keys()) if x-nbCompo>0] + l = [x for x in self.dictCompo if x - nbCompo > 0] if len(l)==0: continue; nbCompo=l[0] diff --git a/src/MEDLoader/Swig/MEDLoaderCouplingTrainingSession.py b/src/MEDLoader/Swig/MEDLoaderCouplingTrainingSession.py index c620a87f4..031143bd5 100644 --- a/src/MEDLoader/Swig/MEDLoaderCouplingTrainingSession.py +++ b/src/MEDLoader/Swig/MEDLoaderCouplingTrainingSession.py @@ -22,10 +22,11 @@ from MEDLoader import * from MEDCouplingRemapper import * import math, os +from six.moves import range d=DataArrayDouble.New(6,2) d[:,0]=3. -d[:,1]=list(range(6)) +d[:, 1] = list(range(6)) d[:,1]*=math.pi/3. d=d.fromPolarToCart() d.setInfoOnComponents(["X [m]","Y [m]"]) @@ -99,7 +100,7 @@ mesh3D.setCoords(myCoords); mesh3D.orientCorrectlyPolyhedrons() mesh3D.sortCellsInMEDFileFrmt() mesh3D.checkConsistencyLight() -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)) +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. @@ -135,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()[list(range(idStart,mesh3D.getNumberOfCells(),mesh2D.getNumberOfCells()))] +cellIds2Sol2 = extMesh.getMesh3DIds()[list(range(idStart, mesh3D.getNumberOfCells(), mesh2D.getNumberOfCells()))] # mesh3DSlice2=mesh3D[cellIds2Sol1] mesh3DSlice2.zipCoords() @@ -583,7 +584,7 @@ for itts,locAgitateur1ts in zip(ts,data.getFields()["DISTANCE_INTERFACE_ELEM_BOD pass angle2=len(ts)*[0.] -for pos in range(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] diff --git a/src/MEDLoader/Swig/MEDLoaderDataForTest.py b/src/MEDLoader/Swig/MEDLoaderDataForTest.py index 653b271eb..ce7e7b824 100644 --- a/src/MEDLoader/Swig/MEDLoaderDataForTest.py +++ b/src/MEDLoader/Swig/MEDLoaderDataForTest.py @@ -21,6 +21,7 @@ from MEDLoader import * from math import pi,e,sqrt +from six.moves import range class MEDLoaderDataForTest: def build1DMesh_1(cls): @@ -437,7 +438,7 @@ class MEDLoaderDataForTest: array=DataArrayDouble.New(); array.alloc(19,2); ptr=array.getPointer(); - for i in range(19*2): + for i in range(19 * 2): array.setIJ(0,i,float(i+7)); pass f.setArray(array); @@ -486,7 +487,7 @@ class MEDLoaderDataForTest: array=DataArrayDouble.New(); array.alloc(53,2); ptr=array.getPointer(); - for i in range(53*2): + for i in range(53 * 2): array.setIJ(0,i,float(i+7)); pass f.setArray(array); @@ -536,7 +537,7 @@ class MEDLoaderDataForTest: array=DataArrayDouble.New(); array.alloc(53,2); ptr=array.getPointer(); - for i in range(53*2): + for i in range(53 * 2): array.setIJ(0,i,float(i+7)); pass f.setArray(array); @@ -553,7 +554,7 @@ class MEDLoaderDataForTest: f.setMesh(m); array=DataArrayDouble.New(); array.alloc(20,2); - for i in range(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 575f7a0e9..b6feb441f 100644 --- a/src/MEDLoader/Swig/MEDLoaderExamplesTest.py +++ b/src/MEDLoader/Swig/MEDLoaderExamplesTest.py @@ -22,6 +22,7 @@ from MEDLoader import * import unittest import os +from six.moves import range class MEDLoaderBasicsTest(unittest.TestCase): def testExampleReadFieldOnAllEntity1(self): diff --git a/src/MEDLoader/Swig/MEDLoaderSplitter.py b/src/MEDLoader/Swig/MEDLoaderSplitter.py index dcd4523ce..3b1d5f83e 100644 --- a/src/MEDLoader/Swig/MEDLoaderSplitter.py +++ b/src/MEDLoader/Swig/MEDLoaderSplitter.py @@ -21,6 +21,7 @@ from MEDLoader import * import os +from six.moves import range class MEDLoaderSplitter: @classmethod @@ -38,7 +39,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 range(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 +63,7 @@ class MEDLoaderSplitter: pass def __splitMEDFileField1TS(self,mm,f1ts,idsLst): - ret=[MEDFileField1TS() for i in range(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 +77,13 @@ class MEDLoaderSplitter: return ret def __splitFields(self,mm,mfflds,idsLst): - ret0=[MEDFileFields() for i in range(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())) continue pass - ret1=[MEDFileFieldMultiTS() for i in range(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 +96,7 @@ class MEDLoaderSplitter: return ret0 def __splitMesh(self,mfm,idsLst): - ret0=[MEDFileMeshes() for i in range(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 a2adaa485..aadab88fc 100644 --- a/src/MEDLoader/Swig/MEDLoaderTest1.py +++ b/src/MEDLoader/Swig/MEDLoaderTest1.py @@ -23,6 +23,7 @@ import MEDLoader import unittest from math import pi,e,sqrt from MEDLoaderDataForTest import MEDLoaderDataForTest +from six.moves import range class MEDLoaderTest1(unittest.TestCase): def testMesh1DRW(self): @@ -556,7 +557,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 range(nbOfCompo)]) + arr.setInfoOnComponents(["c%i" % (i) for i in range(nbOfCompo)]) f.setArray(arr) f.setName("FieldBigCompo") MEDLoader.WriteField(fileName,f,True) @@ -570,7 +571,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 range(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 +620,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 range(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 +812,7 @@ class MEDLoaderTest1(unittest.TestCase): mm[0]=m mm.write(fname,2) # - pfl=MEDLoader.DataArrayInt(list(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 b5c71af77..1fc9b0ed8 100644 --- a/src/MEDLoader/Swig/MEDLoaderTest3.py +++ b/src/MEDLoader/Swig/MEDLoaderTest3.py @@ -20,8 +20,10 @@ # Author : Anthony Geay (CEA/DEN) from MEDLoader import * +import six import unittest import platform +from six.moves import range from math import pi,e,sqrt from MEDLoaderDataForTest import MEDLoaderDataForTest from distutils.version import LooseVersion @@ -145,10 +147,10 @@ class MEDLoaderTest3(unittest.TestCase): g2_1.setName("G2") mm.setGroupsAtLevel(-1,[g1_1,g2_1],False) g1_N=DataArrayInt.New() - g1_N.setValues(list(range(8)),8,1) + g1_N.setValues(list(range(8)), 8, 1) g1_N.setName("G1") g2_N=DataArrayInt.New() - g2_N.setValues(list(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 +169,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()==list(range(5))) + self.assertTrue(t.getValues() == list(range(5))) # mmCpy=mm.deepCopy() self.assertTrue(mm.isEqual(mmCpy,1e-12)[0]) ; del mm @@ -302,7 +304,7 @@ class MEDLoaderTest3(unittest.TestCase): self.assertTrue(not mm2.existsFamily("Family_-8")) mm2.createGroupOnAll(-1,"GrpOnAllFace") self.assertTrue(mm2.existsFamily("Family_-8")) - self.assertEqual(list(range(3)),mm2.getGroupArr(-1,"GrpOnAllFace").getValues()) + self.assertEqual(list(range(3)), mm2.getGroupArr(-1, "GrpOnAllFace").getValues()) pass #testing persistence of retrieved arrays @@ -813,7 +815,7 @@ class MEDLoaderTest3(unittest.TestCase): m1=MEDLoaderDataForTest.build2DMesh_1() m1.renumberCells([0,1,4,2,3,5],False) tmp=m1.getName(); - m1=m1.buildPartOfMySelf(list(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 +842,7 @@ class MEDLoaderTest3(unittest.TestCase): m1=MEDLoaderDataForTest.build2DMesh_1() m1.renumberCells([0,1,4,2,3,5],False) tmp=m1.getName(); - m1=m1.buildPartOfMySelf(list(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 +889,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(list(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) @@ -1644,15 +1646,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,list(range(8))) + mQ8.insertNextCell(NORM_QUAD8, list(range(8))) mQ8.finishInsertingCells() mQ4=MEDCouplingUMesh("",2) ; mQ4.setCoords(coords) mQ4.allocateCells(1) - mQ4.insertNextCell(NORM_QUAD4,list(range(4))) + mQ4.insertNextCell(NORM_QUAD4, list(range(4))) mQ4.finishInsertingCells() mT3=MEDCouplingUMesh("",2) ; mT3.setCoords(coords) mT3.allocateCells(1) - mT3.insertNextCell(NORM_TRI3,list(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 +1687,7 @@ class MEDLoaderTest3(unittest.TestCase): mm.write(fname,2) # f1ts=MEDFileField1TS.New() - pfl=DataArrayInt(list(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) @@ -2143,30 +2145,30 @@ class MEDLoaderTest3(unittest.TestCase): m=m.buildUnstructured() m.setName("mm") f=m.getMeasureField(False) - self.assertIn(m.getHeapMemorySize(),list(range(3552-100,3552+100+4*strMulFac))) - self.assertIn(f.getHeapMemorySize(),list(range(4215-100,4215+100+8*strMulFac))) + self.assertIn(m.getHeapMemorySize(), list(range(3552 - 100, 3552 + 100 + 4 * strMulFac))) + self.assertIn(f.getHeapMemorySize(), list(range(4215 - 100, 4215 + 100 + 8 * strMulFac))) # mm=MEDFileUMesh() mm.setMeshAtLevel(0,m) - self.assertIn(mm.getHeapMemorySize(),list(range(3889-100,4225+100+10*strMulFac))) + self.assertIn(mm.getHeapMemorySize(), list(range(3889 - 100, 4225 + 100 + 10 * strMulFac))) ff=MEDFileField1TS() ff.setFieldNoProfileSBT(f) - self.assertIn(ff.getHeapMemorySize(),list(range(771-40,871+21+(4+1)*strMulFac))) + self.assertIn(ff.getHeapMemorySize(), list(range(771 - 40, 871 + 21 + (4 + 1) * strMulFac))) # fff=MEDFileFieldMultiTS() fff.appendFieldNoProfileSBT(f) - self.assertIn(fff.getHeapMemorySize(),list(range(815-50,915+30+(6+2)*strMulFac))) + self.assertIn(fff.getHeapMemorySize(), list(range(815 - 50, 915 + 30 + (6 + 2) * strMulFac))) f.setTime(1.,0,-1) fff.appendFieldNoProfileSBT(f) - self.assertIn(fff.getHeapMemorySize(),list(range(1594-90,1794+50+(10+1)*strMulFac))) - self.assertIn(fff[0,-1].getHeapMemorySize(),list(range(771-40,871+20+(4+1)*strMulFac))) + self.assertIn(fff.getHeapMemorySize(), list(range(1594 - 90, 1794 + 50 + (10 + 1) * strMulFac))) + self.assertIn(fff[0, -1].getHeapMemorySize(), list(range(771 - 40, 871 + 20 + (4 + 1) * strMulFac))) f2=f[:50] f2.setTime(2.,1,-1) pfl=DataArrayInt.Range(0,50,1) ; pfl.setName("pfl") fff.appendFieldProfile(f2,mm,0,pfl) - self.assertIn(fff.getHeapMemorySize(),list(range(2348-130,2608+100+(10+2)*strMulFac))) - self.assertIn(fff.getProfile("pfl").getHeapMemorySize(),list(range(204-10,204+10+2*strMulFac))) - self.assertIn(fff[1,-1].getHeapMemorySize(),list(range(738-50,838+30+4*strMulFac))) + self.assertIn(fff.getHeapMemorySize(), list(range(2348 - 130, 2608 + 100 + (10 + 2) * strMulFac))) + self.assertIn(fff.getProfile("pfl").getHeapMemorySize(), list(range(204 - 10, 204 + 10 + 2 * strMulFac))) + self.assertIn(fff[1, -1].getHeapMemorySize(), list(range(738 - 50, 838 + 30 + 4 * strMulFac))) pass def testCurveLinearMesh1(self): @@ -2274,20 +2276,20 @@ class MEDLoaderTest3(unittest.TestCase): mm.setMeshAtLevel(0,m) mm.setMeshAtLevel(-1,m1) namesCellL0=DataArrayAsciiChar(6,16) - namesCellL0[:]=["CellL0#%.3d "%(i) for i in range(6)] + namesCellL0[:] = ["CellL0#%.3d " % (i) for i in range(6)] mm.setNameFieldAtLevel(0,namesCellL0) namesCellL1=DataArrayAsciiChar.Aggregate([namesCellL0,namesCellL0,namesCellL0.subArray(2)]) - namesCellL1[:]=["CellLM1#%.3d "%(i) for i in range(16)] + namesCellL1[:] = ["CellLM1#%.3d " % (i) for i in range(16)] mm.setNameFieldAtLevel(-1,namesCellL1) namesNodes=namesCellL1.subArray(4,16) - namesNodes[:]=["Node#%.3d "%(i) for i in range(12)] + namesNodes[:] = ["Node#%.3d " % (i) for i in range(12)] mm.setNameFieldAtLevel(1,namesNodes) mm.write(fname,2) # mmr=MEDFileMesh.New(fname) - self.assertTrue(mm.getNameFieldAtLevel(0).isEqual(DataArrayAsciiChar(["CellL0#%.3d "%(i) for i in range(6)]))) - self.assertTrue(mm.getNameFieldAtLevel(-1).isEqual(DataArrayAsciiChar(["CellLM1#%.3d "%(i) for i in range(16)]))) - self.assertTrue(mm.getNameFieldAtLevel(1).isEqual(DataArrayAsciiChar(["Node#%.3d "%(i) for i in range(12)]))) + self.assertTrue(mm.getNameFieldAtLevel(0).isEqual(DataArrayAsciiChar(["CellL0#%.3d " % (i) for i in 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 +2306,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 range(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 +2315,12 @@ class MEDLoaderTest3(unittest.TestCase): c.setName("cmesh") cc=MEDFileCMesh() cc.setMesh(c) - cc.setNameFieldAtLevel(0,DataArrayAsciiChar(["Cell#%.3d "%(i) for i in range(4)])) - cc.setNameFieldAtLevel(1,DataArrayAsciiChar(["Node#%.3d "%(i) for i in range(9)])) + cc.setNameFieldAtLevel(0, DataArrayAsciiChar(["Cell#%.3d " % (i) for i in range(4)])) + cc.setNameFieldAtLevel(1, DataArrayAsciiChar(["Node#%.3d " % (i) for i in range(9)])) cc.write(fname2,2) ccr=MEDFileMesh.New(fname2) - self.assertTrue(ccr.getNameFieldAtLevel(0).isEqual(DataArrayAsciiChar(["Cell#%.3d "%(i) for i in range(4)]))) - self.assertTrue(ccr.getNameFieldAtLevel(1).isEqual(DataArrayAsciiChar(["Node#%.3d "%(i) for i in range(9)]))) + self.assertTrue(ccr.getNameFieldAtLevel(0).isEqual(DataArrayAsciiChar(["Cell#%.3d " % (i) for i in 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]) @@ -2610,7 +2612,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__() ; next(it) ; ff2bis=next(it) + it = ffs1.__iter__() ; six.next(it) ; ff2bis = six.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 +2626,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]=list(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 +2637,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]=list(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 +2696,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]=list(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 +2730,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 range(4)] + tris = [tri.deepCopy() for i in range(4)] for i,elt in enumerate(tris): elt.translate([i,0]) tris=MEDCouplingUMesh.MergeUMeshes(tris) quad=MEDCouplingUMesh("quad",2) quad.allocateCells() ; quad.insertNextCell(NORM_QUAD4,[0,1,2,3]) quad.setCoords(DataArrayDouble([(0.,0.),(0.,1.),(1.,1.),(1.,0.)])) - quads=[quad.deepCopy() for i in range(5)] + quads = [quad.deepCopy() for i in range(5)] for i,elt in enumerate(quads): elt.translate([5+i,0]) quads=MEDCouplingUMesh.MergeUMeshes(quads) m=MEDCouplingUMesh.MergeUMeshes(tris,quads) @@ -2806,13 +2808,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 range(4)] + tris = [tri.deepCopy() for i in range(4)] for i,elt in enumerate(tris): elt.translate([i,0]) tris=MEDCouplingUMesh.MergeUMeshes(tris) quad=MEDCouplingUMesh("quad",2) quad.allocateCells() ; quad.insertNextCell(NORM_QUAD4,[0,1,2,3]) quad.setCoords(DataArrayDouble([(0.,0.),(0.,1.),(1.,1.),(1.,0.)])) - quads=[quad.deepCopy() for i in range(5)] + quads = [quad.deepCopy() for i in range(5)] for i,elt in enumerate(quads): elt.translate([5+i,0]) quads=MEDCouplingUMesh.MergeUMeshes(quads) m=MEDCouplingUMesh.MergeUMeshes(tris,quads) @@ -2871,13 +2873,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 range(4)] + tris = [tri.deepCopy() for i in range(4)] for i,elt in enumerate(tris): elt.translate([i,0]) tris=MEDCouplingUMesh.MergeUMeshes(tris) quad=MEDCouplingUMesh("quad",2) quad.allocateCells() ; quad.insertNextCell(NORM_QUAD4,[0,1,2,3]) quad.setCoords(DataArrayDouble([(0.,0.),(0.,1.),(1.,1.),(1.,0.)])) - quads=[quad.deepCopy() for i in range(5)] + quads = [quad.deepCopy() for i in range(5)] for i,elt in enumerate(quads): elt.translate([5+i,0]) quads=MEDCouplingUMesh.MergeUMeshes(quads) m=MEDCouplingUMesh.MergeUMeshes(tris,quads) @@ -2940,13 +2942,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 range(4)] + tris = [tri.deepCopy() for i in range(4)] for i,elt in enumerate(tris): elt.translate([i,0]) tris=MEDCouplingUMesh.MergeUMeshes(tris) quad=MEDCouplingUMesh("quad",2) quad.allocateCells() ; quad.insertNextCell(NORM_QUAD4,[0,1,2,3]) quad.setCoords(DataArrayDouble([(0.,0.),(0.,1.),(1.,1.),(1.,0.)])) - quads=[quad.deepCopy() for i in range(5)] + quads = [quad.deepCopy() for i in range(5)] for i,elt in enumerate(quads): elt.translate([5+i,0]) quads=MEDCouplingUMesh.MergeUMeshes(quads) m=MEDCouplingUMesh.MergeUMeshes(tris,quads) @@ -3042,13 +3044,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 range(30)] + tris = [tri.deepCopy() for i in range(30)] for i,elt in enumerate(tris): elt.translate([i,0]) tris=MEDCouplingUMesh.MergeUMeshes(tris) quad=MEDCouplingUMesh("quad",2) quad.allocateCells() ; quad.insertNextCell(NORM_QUAD4,[0,1,2,3]) quad.setCoords(DataArrayDouble([(0.,0.),(0.,1.),(1.,1.),(1.,0.)])) - quads=[quad.deepCopy() for i in range(40)] + quads = [quad.deepCopy() for i in range(40)] for i,elt in enumerate(quads): elt.translate([40+i,0]) quads=MEDCouplingUMesh.MergeUMeshes(quads) m=MEDCouplingUMesh.MergeUMeshes(tris,quads) @@ -3078,7 +3080,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,list(range(182,465+2*strMulFac))) + self.assertIn(heap_memory_ref, list(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 +3089,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,list(range(350,520+6*strMulFac))) + self.assertIn(heap_memory_ref, list(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 +3107,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,list(range(1100,1384+2*strMulFac))) + self.assertIn(heap_memory_ref, list(range(1100, 1384 + 2 * strMulFac))) ff0.unloadArrays() hmd=ff0.getHeapMemorySize()-heap_memory_ref self.assertEqual(hmd,-800) # -50*8*2 @@ -3114,7 +3116,7 @@ class MEDLoaderTest3(unittest.TestCase): # ff0=MEDFileField1TS(fname,"FieldCellPfl",-1,-1,False) heap_memory_ref=ff0.getHeapMemorySize() - self.assertIn(heap_memory_ref,list(range(299,520+6*strMulFac))) + self.assertIn(heap_memory_ref, list(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) @@ -3131,14 +3133,14 @@ class MEDLoaderTest3(unittest.TestCase): # ff0=MEDFileAnyTypeFieldMultiTS.New(fname,fieldName,False) heap_memory_ref=ff0.getHeapMemorySize() - self.assertIn(heap_memory_ref,list(range(5536,8212+(80+26+1)*strMulFac))) + self.assertIn(heap_memory_ref, list(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,list(range(5335,9031+(80+50+len(ffs))*strMulFac))) + self.assertIn(heap_memory_ref, list(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 +3312,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 range(4)] + tris = [tri.deepCopy() for i in range(4)] for i,elt in enumerate(tris): elt.translate([i,0]) tris=MEDCouplingUMesh.MergeUMeshes(tris) quad=MEDCouplingUMesh("quad",2) quad.allocateCells() ; quad.insertNextCell(NORM_QUAD4,[0,1,2,3]) quad.setCoords(DataArrayDouble([(0.,0.),(0.,1.),(1.,1.),(1.,0.)])) - quads=[quad.deepCopy() for i in range(5)] + quads = [quad.deepCopy() for i in range(5)] for i,elt in enumerate(quads): elt.translate([5+i,0]) quads=MEDCouplingUMesh.MergeUMeshes(quads) m=MEDCouplingUMesh.MergeUMeshes(tris,quads) @@ -3425,13 +3427,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 range(4)] + tris = [tri.deepCopy() for i in range(4)] for i,elt in enumerate(tris): elt.translate([i,0]) tris=MEDCouplingUMesh.MergeUMeshes(tris) quad=MEDCouplingUMesh("quad",2) quad.allocateCells() ; quad.insertNextCell(NORM_QUAD4,[0,1,2,3]) quad.setCoords(DataArrayDouble([(0.,0.),(0.,1.),(1.,1.),(1.,0.)])) - quads=[quad.deepCopy() for i in range(5)] + quads = [quad.deepCopy() for i in range(5)] for i,elt in enumerate(quads): elt.translate([5+i,0]) quads=MEDCouplingUMesh.MergeUMeshes(quads) m=MEDCouplingUMesh.MergeUMeshes(tris,quads) @@ -3509,7 +3511,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(list(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 +3519,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(list(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 +3529,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 range(4)] + ms = [m.deepCopy() for i in range(4)] for i,elt in enumerate(ms): elt.translate([float(i)*1.5,0.]) pass m0=MEDCoupling1SGTUMesh.Merge1SGTUMeshes(ms).buildUnstructured() m0.convertAllToPoly() # - ms=[m.deepCopy() for i in range(5)] + ms = [m.deepCopy() for i in range(5)] for i,elt in enumerate(ms): elt.translate([float(i)*1.5,1.5]) pass @@ -3821,7 +3823,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 range(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 +3834,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 range(36)] + namesNodes[:] = ["Node#%.3d " % (i) for i in range(36)] mm.setRenumFieldArr(1,renum1) mm.setFamilyFieldArr(1,famField1) mm.setNameFieldAtLevel(1,namesNodes) @@ -3900,15 +3902,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]=list(range(25)) - arr[:,1]=list(range(100,125)) + arr[:, 0] = list(range(25)) + arr[:, 1] = list(range(100, 125)) f.setArray(arr) WriteField(fileName,f,True) f=MEDCouplingFieldDouble(ON_NODES,ONE_TIME) ; f.setMesh(m) f.setName("FieldNode") arr=DataArrayDouble(36,2) ; arr.setInfoOnComponents(compos) - arr[:,0]=list(range(200,236)) - arr[:,1]=list(range(300,336)) + arr[:, 0] = list(range(200, 236)) + arr[:, 1] = list(range(300, 336)) f.setArray(arr) f.checkConsistencyLight() WriteFieldUsingAlreadyWrittenMesh(fileName,f) @@ -3925,11 +3927,11 @@ class MEDLoaderTest3(unittest.TestCase): fs=MEDFileFields.LoadPartOf(fileName,False,ms) fs=fs.deepCopy() fs[0][0].loadArrays() - arr=DataArrayDouble(12,2) ; arr[:,0]=list(range(3,15)) ; arr[:,1]=list(range(103,115)) + arr = DataArrayDouble(12, 2) ; arr[:, 0] = 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]=list(range(203,224)) ; arr[:,1]=list(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 +3967,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]=list(range(25)) - arr[:,1]=list(range(100,125)) + arr[:, 0] = list(range(25)) + arr[:, 1] = list(range(100, 125)) f.setArray(arr) WriteField(fileName,f,True) f=MEDCouplingFieldDouble(ON_NODES,ONE_TIME) ; f.setMesh(m) f.setName("FieldNode") arr=DataArrayDouble(36,2) ; arr.setInfoOnComponents(compos) - arr[:,0]=list(range(200,236)) - arr[:,1]=list(range(300,336)) + arr[:, 0] = list(range(200, 236)) + arr[:, 1] = list(range(300, 336)) f.setArray(arr) f.checkConsistencyLight() WriteFieldUsingAlreadyWrittenMesh(fileName,f) @@ -4159,10 +4161,10 @@ class MEDLoaderTest3(unittest.TestCase): g2_1.setName("G2") mm.setGroupsAtLevel(-1,[g1_1,g2_1],False) g1_N=DataArrayInt.New() - g1_N.setValues(list(range(8)),8,1) + g1_N.setValues(list(range(8)), 8, 1) g1_N.setName("G1") g2_N=DataArrayInt.New() - g2_N.setValues(list(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") @@ -4282,7 +4284,7 @@ class MEDLoaderTest3(unittest.TestCase): for j in range(nbOfField): fmts=MEDFileFieldMultiTS() s=DataArray.GetSlice(slice(0,nbPdt,1),j,nbOfField) - for i in range(s.start,s.stop,s.step): + for i in range(s.start, s.stop, s.step): f=MEDCouplingFieldDouble(ON_NODES) f.setMesh(m) arr=DataArrayDouble(nbNodes) ; arr.iota() ; arr*=i @@ -4336,7 +4338,7 @@ class MEDLoaderTest3(unittest.TestCase): zeResu.setName(k) fs2.pushField(zeResu) pass - self.assertEqual(fs2[0].getTimeSteps(),[(i,0,float(i)) for i in range(nbPdt)]) + self.assertEqual(fs2[0].getTimeSteps(), [(i, 0, float(i)) for i in range(nbPdt)]) pass def testMEDFileMeshRearrangeFamIds1(self): @@ -5560,7 +5562,7 @@ class MEDLoaderTest3(unittest.TestCase): mm1[-1]=mm1_1 mm1.setFamilyFieldArr(-1,DataArrayInt([6,7,8,9,10,11])) mm1.setRenumFieldArr(-1,DataArrayInt([16,17,18,19,20,21])) - for i in range(1,10): + for i in range(1, 10): mm1.setFamilyId("F%d"%i,i) mm1.setFamilyId("FAMILLE_ZERO",0) mm1.setFamilyId("H1",100) @@ -5595,7 +5597,7 @@ class MEDLoaderTest3(unittest.TestCase): mm2[-1]=mm2_1 mm2.setFamilyFieldArr(-1,DataArrayInt([200,201,202,203,204,205,206,207])) mm2.setRenumFieldArr(-1,DataArrayInt([300,301,302,303,304,305,306,307])) - for i in range(1,12): + for i in range(1, 12): mm2.setFamilyId("G%d"%i,i+30) mm2.setFamilyId("H1",100) mm2.setFamilyId("FAMILLE_ZERO",0) diff --git a/src/MEDLoader/Swig/MEDLoaderTest4.py b/src/MEDLoader/Swig/MEDLoaderTest4.py index 6052445a7..35540f596 100644 --- a/src/MEDLoader/Swig/MEDLoaderTest4.py +++ b/src/MEDLoader/Swig/MEDLoaderTest4.py @@ -22,6 +22,7 @@ from MEDLoader import * import unittest from math import pi,e,sqrt +from six.moves import range class MEDLoaderTest4(unittest.TestCase): """ @@ -37,13 +38,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 range(4)] + tris = [tri.deepCopy() for i in range(4)] for i,elt in enumerate(tris): elt.translate([i,0]) tris=MEDCouplingUMesh.MergeUMeshes(tris) quad=MEDCouplingUMesh("quad",2) quad.allocateCells() ; quad.insertNextCell(NORM_QUAD4,[0,1,2,3]) quad.setCoords(DataArrayDouble([(0.,0.),(0.,1.),(1.,1.),(1.,0.)])) - quads=[quad.deepCopy() for i in range(5)] + quads = [quad.deepCopy() for i in range(5)] for i,elt in enumerate(quads): elt.translate([5+i,0]) quads=MEDCouplingUMesh.MergeUMeshes(quads) m=MEDCouplingUMesh.MergeUMeshes(tris,quads) @@ -181,7 +182,7 @@ class MEDLoaderTest4(unittest.TestCase): mml=fcscp.buildFromScratchDataSetSupport(0,fields) mml2=mml.prepare() self.assertTrue(isinstance(mml2,MEDUMeshMultiLev)) - for i in range(1,5): + for i in range(1, 5): self.assertTrue(fcscp.isDataSetSupportEqualToThePreviousOne(i,fields)) pass ncc,a0,a1,a2,a3,a4,a5=mml2.buildVTUArrays() @@ -222,13 +223,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 range(4)] + tris = [tri.deepCopy() for i in range(4)] for i,elt in enumerate(tris): elt.translate([i,0]) tris=MEDCouplingUMesh.MergeUMeshes(tris) quad=MEDCouplingUMesh("quad",2) quad.allocateCells() ; quad.insertNextCell(NORM_QUAD4,[0,1,2,3]) quad.setCoords(DataArrayDouble([(0.,0.),(0.,1.),(1.,1.),(1.,0.)])) - quads=[quad.deepCopy() for i in range(5)] + quads = [quad.deepCopy() for i in range(5)] for i,elt in enumerate(quads): elt.translate([5+i,0]) quads=MEDCouplingUMesh.MergeUMeshes(quads) m=MEDCouplingUMesh.MergeUMeshes(tris,quads) @@ -399,7 +400,7 @@ class MEDLoaderTest4(unittest.TestCase): mml=fcscp.buildFromScratchDataSetSupport(0,fields) mml2=mml.prepare() assert isinstance(mml2,MEDUMeshMultiLev) - for i in range(1,5): + for i in range(1, 5): self.assertTrue(fcscp.isDataSetSupportEqualToThePreviousOne(i,fields)) pass ncc,a0,a1,a2,a3,a4,a5=mml2.buildVTUArrays() @@ -441,13 +442,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 range(4)] + tris = [tri.deepCopy() for i in range(4)] for i,elt in enumerate(tris): elt.translate([i,0]) tris=MEDCouplingUMesh.MergeUMeshes(tris) quad=MEDCouplingUMesh("quad",2) quad.allocateCells() ; quad.insertNextCell(NORM_QUAD4,[0,1,2,3]) quad.setCoords(DataArrayDouble([(0.,0.),(0.,1.),(1.,1.),(1.,0.)])) - quads=[quad.deepCopy() for i in range(5)] + quads = [quad.deepCopy() for i in range(5)] for i,elt in enumerate(quads): elt.translate([5+i,0]) quads=MEDCouplingUMesh.MergeUMeshes(quads) m=MEDCouplingUMesh.MergeUMeshes(tris,quads) @@ -564,7 +565,7 @@ class MEDLoaderTest4(unittest.TestCase): mml=fcscp.buildFromScratchDataSetSupport(0,fields) mml2=mml.prepare() self.assertTrue(isinstance(mml2,MEDUMeshMultiLev)) - for i in range(1,3): + for i in range(1, 3): self.assertTrue(fcscp.isDataSetSupportEqualToThePreviousOne(i,fields)) pass ncc,a0,a1,a2,a3,a4,a5=mml2.buildVTUArrays() @@ -595,7 +596,7 @@ class MEDLoaderTest4(unittest.TestCase): mml=fcscp.buildFromScratchDataSetSupport(0,fields) mml2=mml.prepare() self.assertTrue(isinstance(mml2,MEDUMeshMultiLev)) - for i in range(1,2): + for i in range(1, 2): self.assertTrue(fcscp.isDataSetSupportEqualToThePreviousOne(i,fields)) pass ncc,a0,a1,a2,a3,a4,a5=mml2.buildVTUArrays() @@ -627,13 +628,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 range(4)] + tris = [tri.deepCopy() for i in range(4)] for i,elt in enumerate(tris): elt.translate([i,0]) tris=MEDCouplingUMesh.MergeUMeshes(tris) quad=MEDCouplingUMesh("quad",2) quad.allocateCells() ; quad.insertNextCell(NORM_QUAD4,[0,1,2,3]) quad.setCoords(DataArrayDouble([(0.,0.),(0.,1.),(1.,1.),(1.,0.)])) - quads=[quad.deepCopy() for i in range(5)] + quads = [quad.deepCopy() for i in range(5)] for i,elt in enumerate(quads): elt.translate([5+i,0]) quads=MEDCouplingUMesh.MergeUMeshes(quads) m=MEDCouplingUMesh.MergeUMeshes(tris,quads) @@ -823,7 +824,7 @@ class MEDLoaderTest4(unittest.TestCase): mml=fcscp.buildFromScratchDataSetSupport(0,fields) mml2=mml.prepare() self.assertTrue(isinstance(mml2,MEDUMeshMultiLev)) - for i in range(1,5): + for i in range(1, 5): self.assertTrue(fcscp.isDataSetSupportEqualToThePreviousOne(i,fields)) pass ncc,a0,a1,a2,a3,a4,a5=mml2.buildVTUArrays() @@ -955,7 +956,7 @@ class MEDLoaderTest4(unittest.TestCase): mml=fcscp.buildFromScratchDataSetSupport(0,fields) mml2=mml.prepare() self.assertTrue(isinstance(mml2,MEDUMeshMultiLev)) - for i in range(1,5): + for i in range(1, 5): self.assertTrue((fcscp.isDataSetSupportEqualToThePreviousOne(i,fields))) pass ncc,a0,a1,a2,a3,a4,a5=mml2.buildVTUArrays() @@ -993,7 +994,7 @@ class MEDLoaderTest4(unittest.TestCase): mml=fcscp.buildFromScratchDataSetSupport(0,fields) mml2=mml.prepare() self.assertTrue(isinstance(mml2,MEDUMeshMultiLev)) - for i in range(1,5): + for i in range(1, 5): self.assertTrue(fcscp.isDataSetSupportEqualToThePreviousOne(i,fields)) pass ncc,a0,a1,a2,a3,a4,a5=mml2.buildVTUArrays() @@ -1128,7 +1129,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 range(1,5): + for i in range(1, 5): self.assertTrue((fcscp.isDataSetSupportEqualToThePreviousOne(i,fields))) pass a6,a7=mml2.retrieveFamilyIdsOnCells() @@ -1179,7 +1180,7 @@ 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 range(1,5): + for i in range(1, 5): self.assertTrue((fcscp.isDataSetSupportEqualToThePreviousOne(i,fields))) pass for i in range(5): @@ -1347,7 +1348,7 @@ 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 range(1,5): + for i in range(1, 5): self.assertTrue((fcscp.isDataSetSupportEqualToThePreviousOne(i,fields))) pass for i in range(5): @@ -1385,7 +1386,7 @@ 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 range(1,5): + for i in range(1, 5): self.assertTrue((fcscp.isDataSetSupportEqualToThePreviousOne(i,fields))) pass for i in range(5): @@ -1545,7 +1546,7 @@ class MEDLoaderTest4(unittest.TestCase): self.assertTrue(a4 is None) self.assertTrue(a5 is None) self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None) - for i in range(1,5): + for i in range(1, 5): self.assertTrue((fcscp.isDataSetSupportEqualToThePreviousOne(i,fields))) pass for i in range(5): @@ -1694,7 +1695,7 @@ class MEDLoaderTest4(unittest.TestCase): self.assertTrue(a4 is None) self.assertTrue(a5 is None) self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None) - for i in range(1,5): + for i in range(1, 5): self.assertTrue((fcscp.isDataSetSupportEqualToThePreviousOne(i,fields))) pass for i in range(5): @@ -1828,7 +1829,7 @@ class MEDLoaderTest4(unittest.TestCase): self.assertTrue(a4 is None) self.assertTrue(a5 is None) self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None) - for i in range(1,5): + for i in range(1, 5): self.assertTrue((fcscp.isDataSetSupportEqualToThePreviousOne(i,fields))) pass for i in range(5): @@ -1932,7 +1933,7 @@ class MEDLoaderTest4(unittest.TestCase): self.assertTrue(a4 is None) self.assertTrue(a5 is None) self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None) - for i in range(1,5): + for i in range(1, 5): self.assertTrue((fcscp.isDataSetSupportEqualToThePreviousOne(i,fields))) pass for i in range(5): @@ -2028,7 +2029,7 @@ class MEDLoaderTest4(unittest.TestCase): self.assertTrue(a4 is None) self.assertTrue(a5 is None) self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None) - for i in range(1,5): + for i in range(1, 5): self.assertTrue((fcscp.isDataSetSupportEqualToThePreviousOne(i,fields))) pass for i in range(5): @@ -2148,7 +2149,7 @@ 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 range(1,5): + for i in range(1, 5): self.assertTrue((fcscp.isDataSetSupportEqualToThePreviousOne(i,fields))) pass pass @@ -2185,7 +2186,7 @@ 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 range(1,5): + for i in range(1, 5): self.assertTrue((fcscp.isDataSetSupportEqualToThePreviousOne(i,fields))) pass pass @@ -2212,7 +2213,7 @@ 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 range(1,5): + for i in range(1, 5): self.assertTrue((fcscp.isDataSetSupportEqualToThePreviousOne(i,fields))) pass pass @@ -2304,7 +2305,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 range(1,5): + for i in range(1, 5): self.assertTrue((fcscp.isDataSetSupportEqualToThePreviousOne(i,fields))) pass a6,a7=mml2.retrieveFamilyIdsOnCells() @@ -2742,7 +2743,7 @@ 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 range(1,2): + for i in range(1, 2): self.assertTrue((fcscp.isDataSetSupportEqualToThePreviousOne(i,fields))) pass vExp0=[DataArrayDouble([7.,11.]),DataArrayDouble([11.,7.])] @@ -2860,7 +2861,7 @@ 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 range(1,2): + for i in range(1, 2): self.assertTrue((fcscp.isDataSetSupportEqualToThePreviousOne(i,fields))) pass vExp0=[DataArrayDouble([7.,11.]),DataArrayDouble([11.,7.])] @@ -2929,7 +2930,7 @@ 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 range(1,2): + for i in range(1, 2): self.assertTrue((fcscp.isDataSetSupportEqualToThePreviousOne(i,fields))) pass vExp0=[DataArrayDouble([7.,11.]),DataArrayDouble([11.,7.])] @@ -3041,7 +3042,7 @@ class MEDLoaderTest4(unittest.TestCase): self.assertTrue(not a12) self.assertTrue(a13) # no copy here self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None) - for i in range(1,2): + for i in range(1, 2): self.assertTrue((fcscp.isDataSetSupportEqualToThePreviousOne(i,fields))) pass for i in range(2): @@ -3227,7 +3228,7 @@ 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 range(1,2): + for i in range(1, 2): self.assertTrue((fcscp.isDataSetSupportEqualToThePreviousOne(i,fields))) pass for i in range(2): @@ -4388,7 +4389,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(list(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 @@ -4903,7 +4904,7 @@ class MEDLoaderTest4(unittest.TestCase): self.assertTrue(a4 is None) self.assertTrue(a5 is None) self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None) - for i in range(1,5): + for i in range(1, 5): self.assertTrue((fcscp.isDataSetSupportEqualToThePreviousOne(i,fields))) pass for i in range(5): diff --git a/src/MEDLoader/Swig/SauvLoaderTest.py b/src/MEDLoader/Swig/SauvLoaderTest.py index ffa9364e0..f6a81a7f1 100644 --- a/src/MEDLoader/Swig/SauvLoaderTest.py +++ b/src/MEDLoader/Swig/SauvLoaderTest.py @@ -22,6 +22,7 @@ from MEDLoader import * import unittest, os from MEDLoaderDataForTest import MEDLoaderDataForTest +from six.moves import range class SauvLoaderTest(unittest.TestCase): @@ -97,7 +98,7 @@ class SauvLoaderTest(unittest.TestCase): #remove fieldnodeint pointeFields = pointeMed.getFields() - for i in range( pointeFields.getNumberOfFields() ): + for i in range(pointeFields.getNumberOfFields()): if pointeFields.getFieldAtPos(i).getName() == "fieldnodeint": pointeFields.destroyFieldAtPos( i ) break @@ -144,7 +145,7 @@ class SauvLoaderTest(unittest.TestCase): self.assertEqual( fieldnodedoubleTS1.getNumberOfTS(), fieldnodedoubleTS2.getNumberOfTS()) io1 = fieldnodedoubleTS1.getIterations() io2 = fieldnodedoubleTS2.getIterations() - for i in range(fieldnodedoubleTS1.getNumberOfTS() ): + for i in range(fieldnodedoubleTS1.getNumberOfTS()): fnd1 = fieldnodedoubleTS1.getFieldOnMeshAtLevel(ON_NODES, io1[i][0],io1[i][1],pointeUM0) fnd2 = fieldnodedoubleTS2.getFieldOnMeshAtLevel(ON_NODES, io2[i][0],io2[i][1],um0) self.assertTrue( fnd1.getArray().isEqual( fnd2.getArray(), 1e-12 )) @@ -155,7 +156,7 @@ class SauvLoaderTest(unittest.TestCase): self.assertEqual( fieldnodedoubleTS1.getNumberOfTS(), fieldnodedoubleTS2.getNumberOfTS()) io1 = fieldnodedoubleTS1.getIterations() io2 = fieldnodedoubleTS2.getIterations() - for i in range(fieldnodedoubleTS1.getNumberOfTS() ): + for i in range(fieldnodedoubleTS1.getNumberOfTS()): fnd1 = fieldnodedoubleTS1.getFieldOnMeshAtLevel(ON_CELLS, io1[i][0],io1[i][1],pointeUM0) fnd2 = fieldnodedoubleTS2.getFieldOnMeshAtLevel(ON_CELLS, io2[i][0],io2[i][1],um0) self.assertAlmostEqual( fnd1.accumulate(0), fnd2.accumulate(0) ) diff --git a/src/MEDLoader/Swig/VTKReader.py b/src/MEDLoader/Swig/VTKReader.py index 7fc3c11f3..298726808 100644 --- a/src/MEDLoader/Swig/VTKReader.py +++ b/src/MEDLoader/Swig/VTKReader.py @@ -20,6 +20,7 @@ # Author : Anthony GEAY (CEA/DEN/DM2S/STMF) from MEDLoader import * +from six.moves import range class PVDReader: @classmethod @@ -105,7 +106,7 @@ class PVTUReader: self._tmp=3 return if name=="PDataArray": - if self._tmp in list(self._data_array.keys()): + if self._tmp in self._data_array: self._data_array[self._tmp](attrs) pass return diff --git a/src/MEDPartitioner_Swig/MEDPartitionerTest.py b/src/MEDPartitioner_Swig/MEDPartitionerTest.py index 93657cabf..714b5c953 100644 --- a/src/MEDPartitioner_Swig/MEDPartitionerTest.py +++ b/src/MEDPartitioner_Swig/MEDPartitionerTest.py @@ -21,6 +21,7 @@ from MEDPartitioner import * from MEDLoader import * import unittest from MEDLoaderDataForTest import MEDLoaderDataForTest +from six.moves import range class MEDPartitionerTest(unittest.TestCase): def testPartition(self): diff --git a/src/ParaMEDMEM_Swig/test_InterpKernelDEC.py b/src/ParaMEDMEM_Swig/test_InterpKernelDEC.py index 380044f13..e414c7aa8 100755 --- a/src/ParaMEDMEM_Swig/test_InterpKernelDEC.py +++ b/src/ParaMEDMEM_Swig/test_InterpKernelDEC.py @@ -23,6 +23,7 @@ from ParaMEDMEM import * import sys, os import unittest import math +from six.moves import range class ParaMEDMEMBasicsTest(unittest.TestCase): def testInterpKernelDEC_2D(self): @@ -33,8 +34,8 @@ class ParaMEDMEMBasicsTest(unittest.TestCase): raise RuntimeError("Expect MPI_COMM_WORLD size == 5") print(rank) nproc_source = 3 - procs_source = list(range( nproc_source)) - procs_target = list(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) diff --git a/src/ParaMEDMEM_Swig/test_NonCoincidentDEC.py b/src/ParaMEDMEM_Swig/test_NonCoincidentDEC.py index b98820dac..2f45af9f7 100755 --- a/src/ParaMEDMEM_Swig/test_NonCoincidentDEC.py +++ b/src/ParaMEDMEM_Swig/test_NonCoincidentDEC.py @@ -21,6 +21,7 @@ from ParaMEDMEM import * import sys, os +from six.moves import range MPI_Init(sys.argv) @@ -30,8 +31,8 @@ if size != 5: raise RuntimeError("Expect MPI_COMM_WORLD size == 5") nproc_source = 3 -procs_source = list(range( nproc_source)) -procs_target = list(range( size - nproc_source + 1, size)) +procs_source = list(range(nproc_source)) +procs_target = list(range(size - nproc_source + 1, size)) interface = CommInterface() diff --git a/src/ParaMEDMEM_Swig/test_StructuredCoincidentDEC.py b/src/ParaMEDMEM_Swig/test_StructuredCoincidentDEC.py index 48cfb7c21..edf163860 100755 --- a/src/ParaMEDMEM_Swig/test_StructuredCoincidentDEC.py +++ b/src/ParaMEDMEM_Swig/test_StructuredCoincidentDEC.py @@ -23,6 +23,7 @@ from ParaMEDMEM import * import sys, os import unittest import math +from six.moves import range class ParaMEDMEMBasicsTest2(unittest.TestCase): def testStructuredCoincidentDEC(self): -- 2.39.2