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)
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')
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'
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'])
# Author : Anthony Geay (EDF R&D)
import re
+from six.moves import range
s1=2709
s2=2848
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]*$")
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):
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)
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);
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();
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();
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();
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);
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]
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):
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:]);
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]);
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):
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)
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)
it2=da2.__iter__()
i=0
for it in da:
- pt=next(it2)
+ pt = six.next(it2)
it[:]=pt
pass
self.assertTrue(da.isEqual(da2))
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))
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())
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):
"""
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):
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.]
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.]
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]
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):
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]
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]
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]
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
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)
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.]]
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.])
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)
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())
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()
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
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)
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)
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))
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))
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))
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()
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))
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()
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()
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()
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()
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()
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))
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))
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))
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))
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):
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]
#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]
#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]
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]
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
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()
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
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
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))
#
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
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])
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]
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)))
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);
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()
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):
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)
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)
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)
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)
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)
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)
#
from MEDCoupling import *
+from six.moves import range
class MEDCouplingDataForTest:
def build2DTargetMesh_1(cls):
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
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
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])
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])
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)
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])
from MEDCoupling import *
import unittest
from math import pi, sqrt
+from six.moves import range
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:])
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])
from sys import getrefcount
import os,gc,weakref,unittest
+from six.moves import range
class MEDCouplingNumPyTest(unittest.TestCase):
from sys import getrefcount
import os,gc,weakref,pickle,unittest
+from six.moves import range
class MEDCouplingPickleTest(unittest.TestCase):
@unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
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();
from MEDCouplingRemapper import *
from math import *
import unittest
+from six.moves import range
class MEDCouplingBasicsTest(unittest.TestCase):
def testRemapper1(self):
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()
# 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
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.
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
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":
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
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
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
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]
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]"])
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.
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()
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]
from MEDLoader import *
from math import pi,e,sqrt
+from six.moves import range
class MEDLoaderDataForTest:
def build1DMesh_1(cls):
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);
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);
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);
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]");
from MEDLoader import *
import unittest
import os
+from six.moves import range
class MEDLoaderBasicsTest(unittest.TestCase):
def testExampleReadFieldOnAllEntity1(self):
from MEDLoader import *
import os
+from six.moves import range
class MEDLoaderSplitter:
@classmethod
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
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,
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)
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()
import unittest
from math import pi,e,sqrt
from MEDLoaderDataForTest import MEDLoaderDataForTest
+from six.moves import range
class MEDLoaderTest1(unittest.TestCase):
def testMesh1DRW(self):
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)
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
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
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)
# 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
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")
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
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
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()
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()
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)
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.]]
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)
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):
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])
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()
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])
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
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)
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")
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()
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)
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)
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)
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)
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)
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))
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))
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
#
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)
#
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
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)
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)
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
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
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
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)
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)
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)
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
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)
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")
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
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):
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)
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)
from MEDLoader import *
import unittest
from math import pi,e,sqrt
+from six.moves import range
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)
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()
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)
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()
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)
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()
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()
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)
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()
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()
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()
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()
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):
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):
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):
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):
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):
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):
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):
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):
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
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
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
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()
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.])]
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.])]
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.])]
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):
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):
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
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):
from MEDLoader import *
import unittest, os
from MEDLoaderDataForTest import MEDLoaderDataForTest
+from six.moves import range
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
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 ))
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) )
# Author : Anthony GEAY (CEA/DEN/DM2S/STMF)
from MEDLoader import *
+from six.moves import range
class PVDReader:
@classmethod
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
from MEDLoader import *
import unittest
from MEDLoaderDataForTest import MEDLoaderDataForTest
+from six.moves import range
class MEDPartitionerTest(unittest.TestCase):
def testPartition(self):
import sys, os
import unittest
import math
+from six.moves import range
class ParaMEDMEMBasicsTest(unittest.TestCase):
def testInterpKernelDEC_2D(self):
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)
from ParaMEDMEM import *
import sys, os
+from six.moves import range
MPI_Init(sys.argv)
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()
import sys, os
import unittest
import math
+from six.moves import range
class ParaMEDMEMBasicsTest2(unittest.TestCase):
def testStructuredCoincidentDEC(self):