SALOME_LOG_OPTIONAL_PACKAGE(PythonInterp MEDCOUPLING_ENABLE_PYTHON)
SALOME_LOG_OPTIONAL_PACKAGE(PythonLibs MEDCOUPLING_ENABLE_PYTHON)
SALOME_LOG_OPTIONAL_PACKAGE(SWIG MEDCOUPLING_ENABLE_PYTHON)
+ IF ("${PYTHON_VERSION_MAJOR}" STREQUAL "3")
+ MESSAGE(STATUS "Using Python 3")
+ ENDIF()
ENDIF(MEDCOUPLING_ENABLE_PYTHON)
IF(MEDCOUPLING_BUILD_DOC)
# Usage: BuildPyExamplesFromCPP.py <examples.in> <output directory>
-fCpp=file(sys.argv[1],"r")
-cppCont=fCpp.readlines() ; del fCpp
+with open(sys.argv[1], "r") as fCpp:
+ cppCont = fCpp.readlines()
pyCont=cppCont[:]
pyCont=[elt.replace("medcouplingcppexamples","medcouplingpyexamples") for elt in pyCont]
pyCont=Cpp2Python(pyCont)
# Save CPP and PY examples in two separate dox files
outFileName=os.path.join(sys.argv[2],os.path.basename(sys.argv[1]))
-f=file(os.path.splitext(outFileName)[0]+"CPP.dox","w")
-f.writelines(cppCont) ; del f
+with open(os.path.splitext(outFileName)[0] + "CPP.dox", "w") as f:
+ f.writelines(cppCont)
-f=file(os.path.splitext(outFileName)[0]+"PY.dox","w")
-f.writelines(pyCont) ; del f
+with open(os.path.splitext(outFileName)[0] + "PY.dox", "w") as f:
+ f.writelines(pyCont)
def add_text(self, value):
"""Adds text corresponding to `value` into `self.pieces`."""
- if type(value) in (types.ListType, types.TupleType):
+ if isinstance(value, (list, tuple)):
self.pieces.extend(value)
else:
self.pieces.append(value)
kind = node.attributes['kind'].value
if kind in ('class', 'struct'):
prot = node.attributes['prot'].value
- if prot <> 'public':
+ if prot != 'public':
return
names = ('compoundname', 'briefdescription',
'detaileddescription', 'includes')
first = self.get_specific_nodes(node, names)
for n in names:
- if first.has_key(n):
+ if n in first:
self.parse(first[n])
self.add_text(['";','\n'])
for n in node.childNodes:
if name[:8] == 'operator': # Don't handle operators yet.
return
- if not first.has_key('definition') or \
+ if 'definition' not in first or \
kind in ['variable', 'typedef']:
return
if not os.path.exists(fname):
fname = os.path.join(self.my_dir, fname)
if not self.quiet:
- print "parsing file: %s"%fname
+ print("parsing file: %s"%fname)
p = Doxy2SWIG(fname, self.include_function_definition, self.quiet)
p.generate()
self.pieces.extend(self.clean_pieces(p.pieces))
# Author : Anthony Geay (EDF R&D)
import re
+import sys
s1=2709
s2=2848
#
nbLines=len(lines)-4
casePat=re.compile("[\s]+case[\s]+([\d]+)\:[\s]*$")
-entries=filter(lambda (i,x): casePat.match(x),enumerate(lines[offsetLines:-1]))
+entries=[i_x for i_x in enumerate(lines[offsetLines:-1]) if casePat.match(i_x[1])]
#
nbPts=len(entries)
if nbLines%nbPts!=0:
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(set([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]*$")
for lineId,ptId in entries:
endLine=lines[offsetLines+lineId+1+dim]
assert(partEndEntries.match(endLine))
- for j in xrange(dim):
+ for j in range(dim):
curLine=lines[offsetLines+lineId+1+j]
m=zePat.match(curLine)
assert(m)
patInit="Init"
assert(m0.group(1)[-len(patInit):]==patInit)
varName="%s_REF"%((m0.group(1)[:-len(patInit)]).upper())
-print("const double %s[%d]={%s};"%(varName,len(zeTab),", ".join(zeTab)))
-for i in xrange(nbPts):
- print(" case %d:"%(i))
- for j in xrange(dim):
- print(" coords[%d] = %s[%d];"%(j,varName,i*dim+j))
+print(("const double %s[%d]={%s};"%(varName,len(zeTab),", ".join(zeTab))))
+for i in range(nbPts):
+ print((" case %d:"%(i)))
+ for j in range(dim):
+ print((" coords[%d] = %s[%d];"%(j,varName,i*dim+j)))
pass
print(" break;")
ADD_DEFINITIONS(${PYTHON_DEFINITIONS} ${NUMPY_DEFINITIONS} ${SCIPY_DEFINITIONS})
SET_SOURCE_FILES_PROPERTIES(MEDCoupling.i PROPERTIES CPLUSPLUS ON)
-SET_SOURCE_FILES_PROPERTIES(MEDCoupling.i PROPERTIES SWIG_DEFINITIONS "-shadow")
+IF ("${PYTHON_VERSION_MAJOR}" STREQUAL "3")
+ SET_SOURCE_FILES_PROPERTIES(MEDCoupling.i PROPERTIES SWIG_FLAGS "-py3")
+ELSE()
+ SET_SOURCE_FILES_PROPERTIES(MEDCoupling.i PROPERTIES SWIG_DEFINITIONS "-shadow")
+ENDIF()
SET(SWIG_MODULE_MEDCoupling_EXTRA_FLAGS "${NUMPY_DEFINITIONS};${SCIPY_DEFINITIONS}")
SET (MEDCoupling_SWIG_DPYS_FILES
SWIG_LINK_LIBRARIES(MEDCoupling ${PYTHON_LIBRARIES} ${PLATFORM_LIBS} medcoupling)
SET_SOURCE_FILES_PROPERTIES(MEDCouplingRemapper.i PROPERTIES CPLUSPLUS ON)
-SET_SOURCE_FILES_PROPERTIES(MEDCouplingRemapper.i PROPERTIES SWIG_DEFINITIONS "-shadow")
+IF ("${PYTHON_VERSION_MAJOR}" STREQUAL "3")
+ SET_SOURCE_FILES_PROPERTIES(MEDCouplingRemapper.i PROPERTIES SWIG_FLAGS "-py3")
+ELSE()
+ SET_SOURCE_FILES_PROPERTIES(MEDCouplingRemapper.i PROPERTIES SWIG_DEFINITIONS "-shadow")
+ENDIF()
SET(SWIG_MODULE_MEDCouplingRemapper_EXTRA_FLAGS "${NUMPY_DEFINITIONS};${SCIPY_DEFINITIONS}")
# _ABR_ Ensure dependency mechanism on all SWIG files and headers
from math import pi,e,sqrt,cos,sin
from datetime import datetime
from MEDCouplingDataForTest import MEDCouplingDataForTest
-import rlcompleter,readline # this line has to be here, to ensure a usability of MEDCoupling/MEDLoader. B4 removing it please notify to anthony.geay@cea.fr
+import rlcompleter,readline # this line has to be here, to ensure a usability of MEDCoupling/MEDLoader. B4 removing it please notify to anthony.geay@edf.fr
class MEDCouplingBasicsTest1(unittest.TestCase):
def testArray2(self):
self.assertEqual(7,arr4.getNumberOfTuples());
self.assertEqual(2,arr4.getNumberOfComponents());
tmp=arr4.getValues()
- for i in xrange(14):
+ for i in range(14):
self.assertTrue(abs(arr4Ref[i]-tmp[i])<1e-14);
pass
arr5=arr4.subArray(3);
self.assertEqual(4,arr5.getNumberOfTuples());
self.assertEqual(2,arr5.getNumberOfComponents());
tmp=arr5.getValues()
- for i in xrange(8):
+ for i in range(8):
self.assertTrue(abs(arr4Ref[6+i]-tmp[i])<1e-14);
pass
arr6=arr4.subArray(2,5);
self.assertEqual(3,arr6.getNumberOfTuples());
self.assertEqual(2,arr6.getNumberOfComponents());
tmp=arr6.getValues()
- for i in xrange(6):
+ for i in range(6):
self.assertTrue(abs(arr4Ref[4+i]-tmp[i])<1e-14);
pass
pass
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(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);
expected2=[0.075,0.0375,0.0375,0.075,0.075,
0.1125,0.05625,0.05625,0.1125,0.1125,
0.0625,0.03125,0.03125,0.0625,0.0625]
- for i in xrange(15):
+ for i in range(15):
self.assertAlmostEqual(expected2[rexpected1[i]],arrPtr[i],16);
pass
m5=m4.build3DUnstructuredMesh();
self.assertTrue(isinstance(f.getMesh(),MEDCouplingMappedExtrudedMesh))
arr=f.getArray();
arrPtr=arr.getValues();
- for i in xrange(15):
+ for i in range(15):
self.assertAlmostEqual(expected2[rexpected1[i]],arrPtr[i],15);
pass
pass
o2n,newNbOfNodes=targetMesh.buildNewNumberingFromCommonNodesFormat(comm,commI);
self.assertEqual(27,newNbOfNodes);
self.assertEqual(27,o2n.getNumberOfTuples());
- o2nExp1=range(27)
+ o2nExp1 = list(range(27))
self.assertEqual(o2nExp1,list(o2n.getValues()));
#
targetMesh=MEDCouplingDataForTest.build3DTargetMeshMergeNode_1();
def testMergeMeshOnSameCoords1(self):
m1=MEDCouplingDataForTest.build2DTargetMesh_1();
m2=MEDCouplingDataForTest.build2DTargetMesh_1();
- cells=range(5);
+ cells = list(range(5));
m2.convertToPolyTypes(cells);
m1.tryToShareSameCoords(m2,1e-12);
m3=MEDCouplingDataForTest.build2DTargetMesh_1();
values=[0.25,0.125,0.125,0.25,0.25,0.5,0.5]
tmp=f3.getArray().getValues();
self.assertEqual(len(values),len(tmp))
- for i in xrange(7):
+ for i in range(7):
self.assertTrue(abs(values[i]-tmp[i])<1e-12)
pass
pass
values1=[-0.1,0.23333333333333336,0.56666666666666665,0.4,0.9]
tmp=f1.getArray().getValues();
self.assertEqual(len(values1),len(tmp))
- for i in xrange(len(tmp)):
+ for i in range(len(tmp)):
self.assertTrue(abs(tmp[i]-values1[i])<1.e-12)
pass
#
values2=[-0.6,-0.1,0.4,-0.1,0.4,0.9,0.4,0.9,1.4]
tmp=f1.getArray().getValues();
self.assertEqual(len(values2),len(tmp))
- for i in xrange(len(tmp)):
+ for i in range(len(tmp)):
self.assertTrue(abs(tmp[i]-values2[i])<1.e-12)
pass
#
values3=[-0.6,-1.2,-0.1,-0.2,0.4,0.8,-0.1,-0.2,0.4,0.8,0.9,1.8,0.4,0.8,0.9,1.8,1.4,2.8]
tmp=f1.getArray().getValues();
self.assertEqual(len(values3),len(tmp))
- for i in xrange(len(tmp)):
+ for i in range(len(tmp)):
self.assertTrue(abs(tmp[i]-values3[i])<1.e-12)
pass
values4=f1.accumulate();
values1=[-0.1,0.23333333333333336,0.56666666666666665,0.4,0.9]
tmp=f1.getArray().getValues();
self.assertEqual(len(values1),len(tmp))
- for i in xrange(len(values1)):
+ for i in range(len(values1)):
self.assertTrue(abs(values1[i]-tmp[i])<1.e-12);
pass
#
values2=[-0.9,0.1,1.1,-0.4,0.6,1.6,0.1,1.1,2.1]
tmp=f1.getArray().getValues();
self.assertEqual(len(values2),len(tmp))
- for i in xrange(len(values2)):
+ for i in range(len(values2)):
self.assertTrue(abs(values2[i]-tmp[i])<1.e-12);
pass
f1=m.fillFromAnalytic(ON_NODES,1,"2.*x+y");
tmp=f1.getArray().getValues();
values2Bis=[-0.9,0.1,1.1,-0.4,0.6,1.6,0.1,1.1,2.1]
self.assertEqual(len(values2Bis),len(tmp))
- for i in xrange(len(values2Bis)):
+ for i in range(len(values2Bis)):
self.assertTrue(abs(values2Bis[i]-tmp[i])<1.e-12);
pass
#
values3=[-0.6,-1.2,-0.1,-0.2,0.4,0.8,-0.1,-0.2,0.4,0.8,0.9,1.8,0.4,0.8,0.9,1.8,1.4,2.8]
tmp=f1.getArray().getValues();
self.assertEqual(len(values3),len(tmp))
- for i in xrange(len(values3)):
+ for i in range(len(values3)):
self.assertTrue(abs(values3[i]-tmp[i])<1.e-12);
pass
values4=f1.accumulate();
values1=[-1.8,-0.3,1.2,-0.3,1.2,2.7,1.2,2.7,4.2]
tmp=f1.getArray().getValues();
self.assertEqual(len(values1),len(tmp))
- for i in xrange(len(tmp)):
+ for i in range(len(tmp)):
self.assertTrue(abs(tmp[i]-values1[i])<1.e-12)
pass
pass
5.0423700574830965, 17.435300118916864]
tmp=f2.getArray().getValues();
self.assertEqual(len(tmp),len(values2))
- for i in xrange(len(tmp)):
+ for i in range(len(tmp)):
self.assertTrue(abs(tmp[i]-values2[i])<1.e-12)
pass
#
values1=[-1.8,-0.3,1.2,-0.3,1.2,2.7,1.2,2.7,4.2]
tmp=f1.getArray().getValues();
self.assertEqual(len(tmp),len(values1))
- for i in xrange(len(tmp)):
+ for i in range(len(tmp)):
self.assertTrue(abs(tmp[i]-values1[i])<1.e-12)
pass
pass
values1=[-1.2,-0.2,0.8,-0.2,0.8,1.8,0.8,1.8,2.8]
tmp=f3.getArray().getValues();
self.assertEqual(len(values1),len(tmp))
- for i in xrange(len(tmp)):
+ for i in range(len(tmp)):
self.assertTrue(abs(tmp[i]-values1[i])<1.e-12)
pass
#
values2=[0.36,0.01,0.16,0.01,0.16,0.81,0.16,0.81,1.96]
tmp=f3.getArray().getValues();
self.assertEqual(len(values2),len(tmp))
- for i in xrange(len(tmp)):
+ for i in range(len(tmp)):
self.assertTrue(abs(tmp[i]-values2[i])<1.e-12)
pass
#
values3=[0.6,0.1,-0.4,0.1,-0.4,-0.9,-0.4,-0.9,-1.4]
tmp=f4.getArray().getValues();
self.assertEqual(len(values3),len(tmp))
- for i in xrange(len(tmp)):
+ for i in range(len(tmp)):
self.assertTrue(abs(tmp[i]-values3[i])<1.e-12)
pass
#
self.assertEqual(f4.getTypeOfField(),ON_NODES);
self.assertEqual(f4.getTimeDiscretization(),ONE_TIME);
tmp=f4.getArray().getValues();
- for i in xrange(len(tmp)):
+ for i in range(len(tmp)):
self.assertTrue(abs(tmp[i]-2.)<1.e-12)
pass
#
tmp=f3.getArray().getValues();
values4=[-1.2,-0.2,0.8,-0.2,0.8,1.8,0.8,1.8,2.8]
self.assertEqual(len(values3),len(tmp))
- for i in xrange(len(tmp)):
+ for i in range(len(tmp)):
self.assertTrue(abs(tmp[i]-values4[i])<1.e-12)
pass
#
tmp=f3.getArray().getValues();
values5=[-1.2,-0.2,0.8,-0.2,0.8,1.8,0.8,1.8,2.8]
self.assertEqual(len(values5),len(tmp))
- for i in xrange(len(tmp)):
+ for i in range(len(tmp)):
self.assertTrue(abs(tmp[i]-values5[i])<1.e-12)
pass
pass
self.assertEqual(1,f3.getNumberOfComponents());
self.assertEqual(9,f3.getNumberOfTuples());
val=f3.getArray().getValues();
- for i in xrange(9):
+ for i in range(9):
self.assertTrue(abs(expected1[i]-val[i])<1.e-12);
#
f1=m.buildOrthogonalField();
f3=f1*f2;
expected2=[-0.035355339059327376,0.,0.035355339059327376, 0.2592724864350674,0.,-0.2592724864350674, 0.37712361663282529,0.,-0.37712361663282529, -0.035355339059327376,0.,0.035355339059327376, 0.31819805153394637,0.,-0.31819805153394637]
val=f3.getArray().getValues();
- for i in xrange(15):
+ for i in range(15):
self.assertTrue(abs(expected2[i]-val[i])<1.e-12);
pass
#
f3=f2*f1;
val=f3.getArray().getValues();
- for i in xrange(15):
+ for i in range(15):
self.assertTrue(abs(expected2[i]-val[i])<1.e-12);
pass
pass
self.assertEqual(1,f1.getNumberOfComponents());
self.assertEqual(9,f1.getNumberOfTuples());
val=f1.getArray().getValues();
- for i in xrange(9):
+ for i in range(9):
self.assertTrue(abs(expected1[i]-val[i])<1.e-12);
pass
#
f1*=f2
expected2=[-0.035355339059327376,0.,0.035355339059327376, 0.2592724864350674,0.,-0.2592724864350674, 0.37712361663282529,0.,-0.37712361663282529, -0.035355339059327376,0.,0.035355339059327376, 0.31819805153394637,0.,-0.31819805153394637]
val=f1.getArray().getValues();
- for i in xrange(15):
+ for i in range(15):
self.assertTrue(abs(expected2[i]-val[i])<1.e-12);
pass
#
self.assertEqual(3,len(corr));
expectedVals1=[3,3,2]
expectedVals2=[[0,1,2],[3,0,2],[3,0]]
- for i in xrange(3):
+ for i in range(3):
arr=corr[i];
self.assertEqual(1,arr.getNumberOfComponents());
nbOfVals=expectedVals1[i];
self.assertEqual(1,arr2.getNumberOfComponents());
self.assertEqual(4,arr2.getNumberOfTuples());
self.assertEqual(fidExp,list(arr2.getValues()));
- for i in xrange(3):
+ for i in range(3):
nbOfVals=expectedVals1[i];
self.assertEqual(list(fidsOfGroups[i]),fidsGrp[i]);
pass
self.assertEqual(5,field.getNumberOfTuples());
self.assertEqual(3,field.getNumberOfComponents());
vals=field.getArray().getValues();
- for i in xrange(15):
+ for i in range(15):
self.assertTrue(abs(expected[i%3]-vals[i])<1e-12);
# testing
targetCoords=[0.,0.,0.,0.5,0.,0.5,1.,0.,1.,0.,1.,0.]
fieldOnCells.setMesh(targetMesh);
array=DataArrayDouble.New();
tmp=2*nbOfCells*[None]
- for i in xrange(nbOfCells):
+ for i in range(nbOfCells):
tmp[2*i]=7.+float(i);
tmp[2*i+1]=17.+float(i)
pass
fieldOnNodes.setMesh(targetMesh);
array=DataArrayDouble.New();
tmp=2*nbOfNodes*[None]
- for i in xrange(nbOfNodes):
+ for i in range(nbOfNodes):
tmp[2*i]=17.+float(i);
tmp[2*i+1]=27.+float(i)
pass
7., 4., 6., 7., 9., 5., 7., 8., 10., 7., 9., 10., 12.];
val=fieldOnNodes.getArray().getValues();
- for i in xrange(64):
+ for i in range(64):
self.assertAlmostEqual(expected1[i], val[i], 12)
res=fieldOnNodes.getValueOnPos(1, 3, 2);
self.assertAlmostEqual(7., res[0], 12);
val=fieldOnCells.getArray().getValues();
expected2=[0, 1.5, 3, 1.5, 3, 4.5, 3, 4.5, 6, 1.5, 3, 4.5, 3, 4.5,
6, 4.5, 6, 7.5, 3, 4.5, 6, 4.5, 6, 7.5, 6, 7.5, 9];
- for i in xrange(27):
+ for i in range(27):
self.assertAlmostEqual(expected2[i], val[i], 12);
#res=fieldOnCells.getValueOnPos(1,2,1);
#self.assertAlmostEqual(6.,res,12);
-0.05,0.45, 0.2,0.45, 0.45,0.45]
val=mesh.getCoords().getValues();
self.assertEqual(18,len(val))
- for i in xrange(18):
+ for i in range(18):
self.assertTrue(abs(expected1[i]-val[i])<1e-12);
pass
pass
self.assertEqual(3,m1.getSpaceDimension());
expected=[-0.3,-0.3,0., 0.2,-0.3,0., 0.7,-0.3,0., -0.3,0.2,0., 0.2,0.2,0., 0.7,0.2,0., -0.3,0.7,0., 0.2,0.7,0., 0.7,0.7,0.]
val=m1.getCoords().getValues();
- for i in xrange(27):
+ for i in range(27):
self.assertTrue(abs(expected[i]-val[i])<1e-14);
pass
pass
self.assertEqual(2,f.getNbOfGaussLocalization());
array=DataArrayDouble.New();
ptr=18*2*[None]
- for i in xrange(18*2):
+ for i in range(18 * 2):
ptr[i]=float(i+1)
array.setValues(ptr,18,2);
ptr=array.getPointer();
f.setDescription("MyDescriptionNE");
array=DataArrayDouble.New();
tmp=18*2*[None]
- for i in xrange(18*2):
+ for i in range(18 * 2):
tmp[i]=float(i+7)
pass
array.setValues(tmp,18,2);
self.assertEqual(1,f3.getNumberOfComponents());
f3Ptr=f3.getArray().getValues();
expected1=[0.075,0.0375,0.0375,0.075,0.075, 0.1125,0.05625,0.05625,0.1125,0.1125, 0.0625,0.03125,0.03125,0.0625,0.0625];
- for i in xrange(15):
+ for i in range(15):
self.assertTrue(abs(expected1[i]-f3Ptr[i])<1e-12);
pass
f4=m5.computeCellCenterOfMass();
self.assertEqual(3,f4.getNumberOfComponents());
f4Ptr=f4.getValues();
expected2=[-0.05,-0.05,0.15, 0.3666666666666667,-0.13333333333333333,0.15, 0.53333333333333333,0.033333333333333333,0.15, -0.05,0.45,0.15, 0.45,0.45,0.15,-0.05,-0.05,0.525, 0.3666666666666667,-0.13333333333333333,0.525, 0.53333333333333333,0.033333333333333333,0.525, -0.05,0.45,0.525, 0.45,0.45,0.525,-0.05,-0.05,0.875, 0.3666666666666667,-0.13333333333333333,0.875, 0.53333333333333333,0.033333333333333333,0.875, -0.05,0.45,0.875, 0.45,0.45,0.875];
- for i in xrange(45):
+ for i in range(45):
self.assertTrue(abs(expected2[i]-f4Ptr[i])<1e-12);
pass
pass
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]
self.assertEqual(3,da.getNumberOfComponents());
daPtr=da.getValues();
ref=meshN.getCoords().getValues()[24:];
- for i in xrange(3):
+ for i in range(3):
self.assertTrue(abs(ref[i]-daPtr[i])<1e-12);
pass
#
da=meshN.computeCellCenterOfMass();
daPtr=da.getValues();
ref=meshN.getCoords().getValues()[24:];
- for i in xrange(3):
+ for i in range(3):
self.assertTrue(abs(ref[i]-daPtr[i])<1e-12);
pass
#
da=meshN.computeCellCenterOfMass();
daPtr=da.getValues();
ref=meshN.getCoords().getValues()[24:];
- for i in xrange(3):
+ for i in range(3):
self.assertTrue(abs(ref[i]-daPtr[i])<1e-12);
pass
#
da=meshN.computeCellCenterOfMass();
daPtr=da.getValues();
ref=meshN.getCoords().getValues()[24:];
- for i in xrange(3):
+ for i in range(3):
self.assertTrue(abs(ref[i]-daPtr[i])<1e-10);
pass
pass
self.assertEqual(1,f3.getNumberOfComponents());
expected9=[0.75,5.105,0.8,5.155]
ptr=f3.getValues();
- for i in xrange(4):
+ for i in range(4):
self.assertTrue(abs(expected9[i]-ptr[i])<1e-12);
pass
#
self.assertEqual(1,f2.getNumberOfComponents());
expected1=[0.5,0.21,-0.6,-0.31]
ptr=f2.getArray().getValues();
- for i in xrange(4):
+ for i in range(4):
self.assertTrue(abs(expected1[i]-ptr[i])<1e-12);
pass
expected2=[0.5,0.21,0.6,0.31]
f2=m1.getMeasureField(True);
ptr=f2.getArray().getValues();
- for i in xrange(4):
+ for i in range(4):
self.assertTrue(abs(expected2[i]-ptr[i])<1e-12);
pass
#integral
res=f1.integral(False);
self.assertTrue(3,len(res))
expected3=[0.9866,-0.3615,0.4217]
- for i in xrange(3):
+ for i in range(3):
self.assertTrue(abs(expected3[i]-res[i])<1e-12);
pass
self.assertTrue(abs(expected3[0]-f1.integral(0,False))<1e-12);
self.assertTrue(abs(expected3[2]-f1.integral(2,False))<1e-12);
res=f1.integral(True);
expected4=[-3.4152,8.7639,-14.6879]
- for i in xrange(3):
+ for i in range(3):
self.assertTrue(abs(expected4[i]-res[i])<1e-12);
pass
#normL1
res=f1.normL1();
self.assertTrue(3,len(res))
expected5=[6.979506172839505, 16.89018518518518, 27.02969135802469]
- for i in xrange(3):
+ for i in range(3):
self.assertTrue(abs(expected5[i]-res[i])<1e-12);
pass
self.assertTrue(abs(expected5[0]-f1.normL1(0))<1e-12);
res=f1.normL2();
self.assertTrue(3,len(res))
expected7=[7.090910979452395, 16.9275542960123, 27.053271464160858]
- for i in xrange(3):
+ for i in range(3):
self.assertTrue(abs(expected7[i]-res[i])<1e-9);
pass
self.assertTrue(abs(expected7[0]-f1.normL2(0))<1e-9);
self.assertEqual(4,f2.getArray().getNumberOfTuples());
self.assertEqual(1,f2.getNumberOfComponents());
ptr=f2.getArray().getValues();
- for i in xrange(4):
+ for i in range(4):
self.assertTrue(abs(sqrt(2.)*expected2[i]-ptr[i])<1e-12);
pass
f2=m1.getMeasureField(True);
self.assertEqual(4,f2.getArray().getNumberOfTuples());
self.assertEqual(1,f2.getNumberOfComponents());
ptr=f2.getArray().getValues();
- for i in xrange(4):
+ for i in range(4):
self.assertTrue(abs(expected2[i]*sqrt(2.)-ptr[i])<1e-12);
pass
#bary
self.assertEqual(2,f3.getNumberOfComponents());
expected10=[0.75,0.75,5.105,5.105,0.8,0.8,5.155,5.155]
ptr=f3.getValues();
- for i in xrange(8):
+ for i in range(8):
self.assertTrue(abs(expected10[i]-ptr[i])<1e-12);
pass
#
array.setValues(arr,m1.getNumberOfCells(),3);
f1.setArray(array);
res=f1.integral(False);
- for i in xrange(3):
+ for i in range(3):
self.assertTrue(abs(sqrt(2.)*expected4[i]-res[i])<1e-12);
pass
res=f1.integral(True);
- for i in xrange(3):
+ for i in range(3):
self.assertTrue(abs(sqrt(2.)*expected4[i]-res[i])<1e-12);
pass
res=f1.normL1();
- for i in xrange(3):
+ for i in range(3):
self.assertTrue(abs(expected5[i]-res[i])<1e-12);
pass
res=f1.normL2();
- for i in xrange(3):
+ for i in range(3):
self.assertTrue(abs(expected7[i]-res[i])<1e-12);
pass
pass
self.assertEqual(1,f1.getNumberOfComponents());
expected1=[-0.5,-1,-1.5,-0.5,-1, 0.5,1,1.5,0.5,1]
ptr=f1.getArray().getValues();
- for i in xrange(10):
+ for i in range(10):
self.assertTrue(abs(expected1[i]-ptr[i])<1e-12);
pass
f1=m1.getMeasureField(True);
ptr=f1.getArray().getValues();
- for i in xrange(10):
+ for i in range(10):
self.assertTrue(abs(abs(expected1[i])-ptr[i])<1e-12);
pass
f2=m1.computeCellCenterOfMass();
self.assertEqual(2,f2.getNumberOfComponents());
expected2=[0.5,0.3333333333333333,0.5,0.5,0.5,0.77777777777777777,0.5,0.3333333333333333,0.5,0.5,0.5,0.3333333333333333,0.5,0.5,0.5,0.77777777777777777,0.5,0.3333333333333333,0.5,0.5]
ptr=f2.getValues();
- for i in xrange(20):
+ for i in range(20):
self.assertTrue(abs(expected2[i]-ptr[i])<1e-12);
pass
m1.changeSpaceDimension(3);
self.assertEqual(10,f1.getArray().getNumberOfTuples());
self.assertEqual(1,f1.getNumberOfComponents());
ptr=f1.getArray().getValues();
- for i in xrange(10):
+ for i in range(10):
self.assertTrue(abs(abs(expected1[i])-ptr[i])<1e-12);
pass
f2=m1.computeCellCenterOfMass();
self.assertEqual(3,f2.getNumberOfComponents());
ptr=f2.getValues();
expected3=[0.5,0.3333333333333333,0.,0.5,0.5,0.,0.5,0.77777777777777777,0.,0.5,0.3333333333333333,0.,0.5,0.5,0., 0.5,0.3333333333333333,0.,0.5,0.5,0.,0.5,0.77777777777777777,0.,0.5,0.3333333333333333,0.,0.5,0.5,0.]
- for i in xrange(30):
+ for i in range(30):
self.assertTrue(abs(expected3[i]-ptr[i])<1e-12);
pass
pass
self.assertEqual(4,da.getNumberOfTuples());
self.assertEqual(3,da.getNumberOfComponents());
daPtr=da.getValues();
- for i in xrange(12):
+ for i in range(12):
self.assertTrue(abs(barys[i]-daPtr[i])<1e-12);
pass
pass
f.setArray(arr);
renumber1=[3,1,0,4,2]
loc=[-0.05,-0.05, 0.55,-0.25, 0.55,0.15, -0.05,0.45, 0.45,0.45]
- for j in xrange(5):
+ for j in range(5):
res=f.getValueOn(loc[2*j:2*j+2]);
- for i in xrange(3):
+ for i in range(3):
self.assertTrue(abs(values1[i+3*j]-res[i])<1e-12);
pass
pass
f.renumberCells(renumber1,False);
ptr=f.getArray().getValues();
expected1=[9.,109.,10009.,8.,108.,10008.,11.,111.,10011.,7.,107.,10007.,10.,110.,10010.]
- for i in xrange(15):
+ for i in range(15):
self.assertTrue(abs(expected1[i]-ptr[i])<1e-12);
pass
#check that fields remains the same geometrically
- for j in xrange(5):
+ for j in range(5):
res=f.getValueOn(loc[2*j:2*(j+1)]);
- for i in xrange(3):
+ for i in range(3):
self.assertTrue(abs(values1[i+3*j]-res[i])<1e-12);
pass
pass
self.assertTrue(not f.isEqual(fCpy,1e-12,1e-12));
expected2=[21.,1021.,22.,1022.,23.,1023.,24.,1024.,25.,1025.,26.,1026., 11.,1011.,12.,1012.,13.,1013.,14.,1014.,15.,1015.,16.,1016., 41.,1041.,42.,1042., 1.,1001.,2.,1002., 31.,1031.,32.,1032.]
ptr=f.getArray().getValues();
- for i in xrange(36):
+ for i in range(36):
self.assertTrue(abs(expected2[i]-ptr[i])<1e-12);
pass
renumber2=[2,1,4,0,3]
self.assertTrue(not f.isEqual(fCpy,1e-12,1e-12));
expected3=[21.,1021.,22.,1022.,23.,1023.,11.,1011.,12.,1012.,13.,1013.,41.,1041.,42.,1042.,43.,1043.,44.,1044.,1.,1001.,2.,1002.,3.,1003.,4.,1004.,31.,1031.,32.,1032.,33.,1033.,34.,1034.]
ptr=f.getArray().getValues();
- for i in xrange(36):
+ for i in range(36):
self.assertTrue(abs(expected3[i]-ptr[i])<1e-12);
pass
f.renumberCells(renumber2,False);#perform reverse operation of renumbering to check that the resulting field is equal.
renumber1=[0,4,1,3,5,2,6,7,8]
loc=[0.5432,-0.2432, 0.5478,0.1528]
expected1=[9.0272, 109.0272, 10009.0272, 11.4124,111.4124,10011.4124]
- for j in xrange(2):
+ for j in range(2):
res=f.getValueOn(loc[2*j:2*j+2]);
- for i in xrange(3):
+ for i in range(3):
self.assertTrue(abs(expected1[i+3*j]-res[i])<1e-12);
pass
pass
self.assertTrue(f.isEqual(fCpy,1e-12,1e-12));
f.renumberNodes(renumber1);
self.assertTrue(not f.isEqual(fCpy,1e-12,1e-12));
- for j in xrange(2):
+ for j in range(2):
res=f.getValueOn(loc[2*j:2*j+2]);
- for i in xrange(3):
+ for i in range(3):
self.assertTrue(abs(expected1[i+3*j]-res[i])<1e-12);
pass
pass
expected2=[7.,107.,10007.,9.,109.,10009.,12.,112.,10012.,10.,110.,10010.,8.,108.,10008.,11.,111.,10011.,13.,113.,10013.,14.,114.,10014.,15.,115.,10015.]
- for i in xrange(27):
+ for i in range(27):
self.assertTrue(abs(expected2[i]-f.getArray().getValues()[i])<1e-12);
pass
renumber2=[0,2,5,3,1,4,6,7,8]
types=mesh.getAllGeoTypes();
types.sort()
self.assertEqual(5,len(types));
- expected1=[NORM_POLYGON, NORM_TRI3, NORM_QUAD4, NORM_TRI6, NORM_QUAD8]
+ expected1 = [NORM_POLYGON, NORM_TRI3, NORM_QUAD4, NORM_TRI6, NORM_QUAD8]
expected1.sort()
self.assertEqual(expected1,types);
self.assertTrue(mesh.isPresenceOfQuadratic());
self.assertEqual(None,cellCor);
self.assertNotEqual(None,nodeCor);
expected1=[0, 1, 3, 4, 5, 6, 7, 8, 9]
- for i in xrange(9):
+ for i in range(9):
self.assertEqual(expected1[i],nodeCor.getIJ(i,0));
pass
pass
f2=m2.getMeasureField(False);
self.assertEqual(5,f1.getArray().getNumberOfTuples());
self.assertEqual(1,f2.getArray().getNumberOfTuples());
- for i in xrange(5):
+ for i in range(5):
self.assertAlmostEqual(expected1[i],f1.getIJ(i,0),12);
pass
self.assertAlmostEqual(expected1[0],f2.getIJ(0,0),12);
f2=m2.getMeasureField(False);
self.assertEqual(5,f1.getArray().getNumberOfTuples());
self.assertEqual(1,f2.getArray().getNumberOfTuples());
- for i in xrange(5):
+ for i in range(5):
self.assertAlmostEqual(expected1[i],f1.getIJ(i,0),12);
pass
self.assertAlmostEqual(expected1[0],f2.getIJ(0,0),12);
f1.changeUnderlyingMesh(mesh2,10,1e-12);
#self.assertTrue(f1.getMesh()==mesh2);
expected1=[7.,107.,9.,109.,8.,108.,10.,110.,11.,111.,12.,112.,13.,113.,15.,115.,14.,114.,16.,116.]
- for i in xrange(20):
+ for i in range(20):
self.assertAlmostEqual(expected1[i],f1.getArray().getIJ(0,i),12);
pass
#
f1.changeUnderlyingMesh(mesh2,10,1e-12);
#self.assertTrue(f1.getMesh()==mesh2);
expected2=[7.,107.,17.,117.,8.,108.,10.,110.,11.,111.,12.,112.,13.,113.,15.,115.,14.,114.,16.,116.,9.,109.]
- for i in xrange(22):
+ for i in range(22):
self.assertAlmostEqual(expected2[i],f1.getArray().getIJ(0,i),12);
pass
pass
#
f3=f1.dot(f2);
expected1=[842.,1820.,2816.,3830.,4862.,5912.,6980.,8066.,9170.,10292.]
- for i in xrange(10):
+ for i in range(10):
self.assertAlmostEqual(expected1[i],f3.getIJ(i,0),9);
pass
#
f4=f1.crossProduct(f2);
expected2=[-93., 186., -93., -392., 784., -392., -691., 1382., -691., -990., 1980., -990., -1289., 2578., -1289., -1588., 3176., -1588., -1887., 3774., -1887., -2186., 4372., -2186., -2485., 4970., -2485., -2784., 5568., -2784.]
- for i in xrange(30):
+ for i in range(30):
self.assertAlmostEqual(expected2[i],f4.getIJ(0,i),9);
pass
pass
#
f3=f1.max(f2);
expected1=[7.,108.,207.,9.,108.,209.,9.,110.,209.,11.,110.,211.,11.,112.,211.,13.,112.,213.,13.,114.,213.,15.,114.,215.,15.,116.,215.,17.,116.,217.]
- for i in xrange(30):
+ for i in range(30):
self.assertAlmostEqual(expected1[i],f3.getIJ(0,i),9);
pass
#
f4=f1.min(f2);
expected2=[6.,107.,206.,8.,107.,208.,8.,109.,208.,10.,109.,210.,10.,111.,210.,12.,111.,212.,12.,113.,212.,14.,113.,214.,14.,115.,214.,16.,115.,216.]
- for i in xrange(30):
+ for i in range(30):
self.assertAlmostEqual(expected2[i],f4.getIJ(0,i),9);
pass
#
#
f1.applyLin(2.,3.,0);
expected1=[17.,107.,19.,108.,21.,109.,23.,110.,25.,111.,27.,112.,29.,113.,31.,114.,33.,115.,35.,116.]
- for i in xrange(20):
+ for i in range(20):
self.assertAlmostEqual(expected1[i],f1.getIJ(0,i),9);
pass
#
f1.applyLin(4.,5.,1);
#
expected2=[17.,433.,19.,437.,21.,441.,23.,445.,25.,449.,27.,453.,29.,457.,31.,461.,33.,465.,35.,469.]
- for i in xrange(20):
+ for i in range(20):
self.assertAlmostEqual(expected2[i],f1.getIJ(0,i),9);
pass
expected3=[2.,413.,3.,417.,4.,421.,5.,425.,6.,429.,7.,433.,8.,437.,9.,441.,10.,445.,11.,449.]
- for i in xrange(20):
+ for i in range(20):
self.assertAlmostEqual(expected3[i],f1.getEndArray().getIJ(0,i),9);
pass
#
#
f1.checkConsistencyLight();
da=f1.findIdsInRange(2.9,7.1);
- self.failUnlessEqual(5,da.getNbOfElems());
+ self.assertEqual(5,da.getNbOfElems());
expected1=[2,3,5,7,9]
- self.failUnlessEqual(expected1,list(da.getValues()));
+ self.assertEqual(expected1,list(da.getValues()));
da=f1.findIdsInRange(8.,12.);
- self.failUnlessEqual(4,da.getNbOfElems());
+ self.assertEqual(4,da.getNbOfElems());
expected2=[1,4,6,8]
- self.failUnlessEqual(expected2,list(da.getValues()));
+ self.assertEqual(expected2,list(da.getValues()));
#
pass
part1=[2,1,4]
f2=f1[part1];
f2.zipCoords()
- self.failUnlessEqual(3,f2.getNumberOfTuples());
- self.failUnlessEqual(2,f2.getNumberOfComponents());
+ self.assertEqual(3,f2.getNumberOfTuples());
+ self.assertEqual(2,f2.getNumberOfComponents());
expected1=[5.,105.,4.,104.,7.,107.]
- for i in xrange(6):
+ for i in range(6):
self.assertAlmostEqual(f2.getIJ(0,i),expected1[i],12);
pass
- self.failUnlessEqual(3,f2.getMesh().getNumberOfCells());
- self.failUnlessEqual(6,f2.getMesh().getNumberOfNodes());
- self.failUnlessEqual(2,f2.getMesh().getSpaceDimension());
- self.failUnlessEqual(2,f2.getMesh().getMeshDimension());
+ self.assertEqual(3,f2.getMesh().getNumberOfCells());
+ self.assertEqual(6,f2.getMesh().getNumberOfNodes());
+ self.assertEqual(2,f2.getMesh().getSpaceDimension());
+ self.assertEqual(2,f2.getMesh().getMeshDimension());
m2C=f2.getMesh();
- self.failUnlessEqual(13,m2C.getNodalConnectivityArrayLen());
+ self.assertEqual(13,m2C.getNodalConnectivityArrayLen());
expected2=[0.2, -0.3, 0.7, -0.3, 0.2, 0.2, 0.7, 0.2, 0.2, 0.7, 0.7, 0.7]
- for i in xrange(12):
+ for i in range(12):
self.assertAlmostEqual(expected2[i],m2C.getCoords().getIJ(0,i),12);
pass
expected3=[3,2,3,1,3,0,2,1,4,4,5,3,2]
- self.failUnlessEqual(expected3,list(m2C.getNodalConnectivity().getValues()));
+ self.assertEqual(expected3,list(m2C.getNodalConnectivity().getValues()));
expected4=[0,4,8,13]
- self.failUnlessEqual(expected4,list(m2C.getNodalConnectivityIndex().getValues()));
+ self.assertEqual(expected4,list(m2C.getNodalConnectivityIndex().getValues()));
# Test with field on nodes.
f1=MEDCouplingFieldDouble.New(ON_NODES,ONE_TIME);
f1.setTime(2.3,5,6);
f1.setArray(array);
part2=[1,2]
f2=f1.buildSubPart(part2);
- self.failUnlessEqual(4,f2.getNumberOfTuples());
- self.failUnlessEqual(2,f2.getNumberOfComponents());
+ self.assertEqual(4,f2.getNumberOfTuples());
+ self.assertEqual(2,f2.getNumberOfComponents());
expected5=[4.,104.,5.,105.,7.,107.,8.,108.]
- for i in xrange(8):
+ for i in range(8):
self.assertAlmostEqual(f2.getIJ(0,i),expected5[i],12);
pass
- self.failUnlessEqual(2,f2.getMesh().getNumberOfCells());
- self.failUnlessEqual(4,f2.getMesh().getNumberOfNodes());
- self.failUnlessEqual(2,f2.getMesh().getSpaceDimension());
- self.failUnlessEqual(2,f2.getMesh().getMeshDimension());
+ self.assertEqual(2,f2.getMesh().getNumberOfCells());
+ self.assertEqual(4,f2.getMesh().getNumberOfNodes());
+ self.assertEqual(2,f2.getMesh().getSpaceDimension());
+ self.assertEqual(2,f2.getMesh().getMeshDimension());
m2C=f2.getMesh();
- self.failUnlessEqual(8,m2C.getNodalConnectivityArrayLen());
- for i in xrange(8):#8 is not an error
+ self.assertEqual(8,m2C.getNodalConnectivityArrayLen());
+ for i in range(8): # 8 is not an error
self.assertAlmostEqual(expected2[i],m2C.getCoords().getIJ(0,i),12);
pass
- self.failUnlessEqual(expected3[:4],list(m2C.getNodalConnectivity().getValues())[4:]);
- self.failUnlessEqual(expected3[4:8],list(m2C.getNodalConnectivity().getValues())[:4]);
- self.failUnlessEqual(expected4[:3],list(m2C.getNodalConnectivityIndex().getValues()));
+ self.assertEqual(expected3[:4],list(m2C.getNodalConnectivity().getValues())[4:]);
+ self.assertEqual(expected3[4:8],list(m2C.getNodalConnectivity().getValues())[:4]);
+ self.assertEqual(expected4[:3],list(m2C.getNodalConnectivityIndex().getValues()));
#idem previous because nodes of cell#4 are not fully present in part3
part3=[1,2]
arrr=DataArrayInt.New();
arrr.setValues(part3,2,1);
f2=f1.buildSubPart(arrr);
- self.failUnlessEqual(4,f2.getNumberOfTuples());
- self.failUnlessEqual(2,f2.getNumberOfComponents());
- for i in xrange(8):
+ self.assertEqual(4,f2.getNumberOfTuples());
+ self.assertEqual(2,f2.getNumberOfComponents());
+ for i in range(8):
self.assertAlmostEqual(f2.getIJ(0,i),expected5[i],12);
pass
- self.failUnlessEqual(2,f2.getMesh().getNumberOfCells());
- self.failUnlessEqual(4,f2.getMesh().getNumberOfNodes());
- self.failUnlessEqual(2,f2.getMesh().getSpaceDimension());
- self.failUnlessEqual(2,f2.getMesh().getMeshDimension());
+ self.assertEqual(2,f2.getMesh().getNumberOfCells());
+ self.assertEqual(4,f2.getMesh().getNumberOfNodes());
+ self.assertEqual(2,f2.getMesh().getSpaceDimension());
+ self.assertEqual(2,f2.getMesh().getMeshDimension());
m2C=f2.getMesh();
- self.failUnlessEqual(8,m2C.getNodalConnectivityArrayLen());
- for i in xrange(8):#8 is not an error
+ self.assertEqual(8,m2C.getNodalConnectivityArrayLen());
+ for i in range(8): # 8 is not an error
self.assertAlmostEqual(expected2[i],m2C.getCoords().getIJ(0,i),12);
pass
- self.failUnlessEqual(expected3[:4],list(m2C.getNodalConnectivity().getValues())[4:8]);
- self.failUnlessEqual(expected3[4:8],list(m2C.getNodalConnectivity().getValues())[:4]);
- self.failUnlessEqual(expected4[:3],list(m2C.getNodalConnectivityIndex().getValues()));
+ self.assertEqual(expected3[:4],list(m2C.getNodalConnectivity().getValues())[4:8]);
+ self.assertEqual(expected3[4:8],list(m2C.getNodalConnectivity().getValues())[:4]);
+ self.assertEqual(expected4[:3],list(m2C.getNodalConnectivityIndex().getValues()));
#
part4=[1,2,4]
f2=f1.buildSubPart(part4);
- self.failUnlessEqual(6,f2.getNumberOfTuples());
- self.failUnlessEqual(2,f2.getNumberOfComponents());
+ self.assertEqual(6,f2.getNumberOfTuples());
+ self.assertEqual(2,f2.getNumberOfComponents());
expected6=[4.,104.,5.,105.,7.,107.,8.,108.,10.,110.,11.,111.]
- for i in xrange(12):
+ for i in range(12):
self.assertAlmostEqual(f2.getIJ(0,i),expected6[i],12);
pass
- self.failUnlessEqual(3,f2.getMesh().getNumberOfCells());
- self.failUnlessEqual(6,f2.getMesh().getNumberOfNodes());
- self.failUnlessEqual(2,f2.getMesh().getSpaceDimension());
- self.failUnlessEqual(2,f2.getMesh().getMeshDimension());
+ self.assertEqual(3,f2.getMesh().getNumberOfCells());
+ self.assertEqual(6,f2.getMesh().getNumberOfNodes());
+ self.assertEqual(2,f2.getMesh().getSpaceDimension());
+ self.assertEqual(2,f2.getMesh().getMeshDimension());
m2C=f2.getMesh();
- self.failUnlessEqual(13,m2C.getNodalConnectivityArrayLen());
- for i in xrange(12):
+ self.assertEqual(13,m2C.getNodalConnectivityArrayLen());
+ for i in range(12):
self.assertAlmostEqual(expected2[i],m2C.getCoords().getIJ(0,i),12);
pass
- self.failUnlessEqual(expected3[0:4],list(m2C.getNodalConnectivity().getValues())[4:8]);
- self.failUnlessEqual(expected3[4:8],list(m2C.getNodalConnectivity().getValues())[0:4]);
- self.failUnlessEqual(expected3[8:13],list(m2C.getNodalConnectivity().getValues())[8:13]);
- self.failUnlessEqual(expected4,list(m2C.getNodalConnectivityIndex().getValues()));
+ self.assertEqual(expected3[0:4],list(m2C.getNodalConnectivity().getValues())[4:8]);
+ self.assertEqual(expected3[4:8],list(m2C.getNodalConnectivity().getValues())[0:4]);
+ self.assertEqual(expected3[8:13],list(m2C.getNodalConnectivity().getValues())[8:13]);
+ self.assertEqual(expected4,list(m2C.getNodalConnectivityIndex().getValues()));
pass
def testDoublyContractedProduct1(self):
f2.checkConsistencyLight();
self.assertEqual(1,f2.getNumberOfComponents());
self.assertEqual(5,f2.getNumberOfTuples());
- for i in xrange(5):
+ for i in range(5):
self.assertAlmostEqual(3906.56,f2.getIJ(i,0),9);
pass
#
self.assertEqual(CONST_ON_TIME_INTERVAL,f2.getTimeDiscretization());
self.assertEqual(1,f2.getNumberOfComponents());
self.assertEqual(5,f2.getNumberOfValues());
- for i in xrange(5):
+ for i in range(5):
self.assertAlmostEqual(-2.42,f2.getIJ(i,0),13);
pass
#6 components multi arrays with end array not defined
self.assertEqual(LINEAR_TIME,f2.getTimeDiscretization());
self.assertEqual(1,f2.getArray().getNumberOfComponents());
self.assertEqual(9,f2.getNumberOfTuples());
- for i in xrange(9):
+ for i in range(9):
self.assertAlmostEqual(137.335,f2.getIJ(i,0),10);
pass
#6 components multi arrays with end array defined
self.assertAlmostEqual(3.8,time2,12);
self.assertEqual(7,it);
self.assertEqual(3,order);
- for i in xrange(9):
+ for i in range(9):
self.assertAlmostEqual(137.335,f2.getIJ(i,0),10);
self.assertAlmostEqual(1289.685,f2.getEndArray().getIJ(i,0),9);
pass
self.assertAlmostEqual(7.8,time2,12);
self.assertEqual(10,it);
self.assertEqual(2,order);
- for i in xrange(5):
+ for i in range(5):
self.assertAlmostEqual(3.267,f2.getIJ(i,0),13);
pass
pass
self.assertEqual(3,f2.getNumberOfComponents());
self.assertEqual(5,f2.getNumberOfTuples());
expected1=[13.638813677891717,-4.502313844635971,-2.2364998332557486]
- for i in xrange(5):
+ for i in range(5):
self.assertAlmostEqual(expected1[0],f2.getIJ(i,0),13);
self.assertAlmostEqual(expected1[1],f2.getIJ(i,1),13);
self.assertAlmostEqual(expected1[2],f2.getIJ(i,2),13);
0.7381111277307373, 0.06458838384003074, -0.6715804522117897,#eigenvect 1
-0.4012053603397987, 0.8423032781211455, -0.3599436712889738#eigenvect 2
]
- for i in xrange(5):
+ for i in range(5):
self.assertAlmostEqual(expected1[0],f2.getIJ(i,0),13);
self.assertAlmostEqual(expected1[1],f2.getIJ(i,1),13);
self.assertAlmostEqual(expected1[2],f2.getIJ(i,2),13);
self.assertEqual(9,f2.getNumberOfComponents());
self.assertEqual(5,f2.getNumberOfTuples());
expected1=[-2.6538108356290113, 2.855831037649208, -1.1111111111111067, 3.461891643709813, -4.775022956841121, 2.2222222222222143, -1.1111111111111054, 2.222222222222214, -1.1111111111111072]
- for i in xrange(5):
+ for i in range(5):
self.assertAlmostEqual(expected1[0],f2.getIJ(i,0),13);
self.assertAlmostEqual(expected1[1],f2.getIJ(i,1),13);
self.assertAlmostEqual(expected1[2],f2.getIJ(i,2),13);
self.assertEqual(6,f2.getNumberOfComponents());
self.assertEqual(5,f2.getNumberOfTuples());
expected3=[-0.3617705098531818, -0.8678630828458127, -0.026843764174972983, 0.5539957431465833, 0.13133439560823013, -0.05301294502145887]
- for i in xrange(5):
+ for i in range(5):
self.assertAlmostEqual(expected3[0],f2.getIJ(i,0),13);
self.assertAlmostEqual(expected3[1],f2.getIJ(i,1),13);
self.assertAlmostEqual(expected3[2],f2.getIJ(i,2),13);
self.assertEqual(4,f2.getNumberOfComponents());
self.assertEqual(5,f2.getNumberOfTuples());
expected2=[-1.8595041322314059, 0.9504132231404963, 1.404958677685951, -0.49586776859504156]
- for i in xrange(5):
+ for i in range(5):
self.assertAlmostEqual(expected2[0],f2.getIJ(i,0),13);
self.assertAlmostEqual(expected2[1],f2.getIJ(i,1),13);
self.assertAlmostEqual(expected2[2],f2.getIJ(i,2),13);
f2.checkConsistencyLight();
self.assertEqual(1,f2.getNumberOfComponents());
self.assertEqual(5,f2.getNumberOfTuples());
- for i in xrange(5):
+ for i in range(5):
self.assertAlmostEqual(15.9,f2.getIJ(i,0),13);
pass
#
f2.checkConsistencyLight();
self.assertEqual(1,f2.getNumberOfComponents());
self.assertEqual(5,f2.getNumberOfTuples());
- for i in xrange(5):
+ for i in range(5):
self.assertAlmostEqual(25.8,f2.getIJ(i,0),13);
pass
#
f2.checkConsistencyLight();
self.assertEqual(1,f2.getNumberOfComponents());
self.assertEqual(5,f2.getNumberOfTuples());
- for i in xrange(5):
+ for i in range(5):
self.assertAlmostEqual(5.7,f2.getIJ(i,0),13);
pass
#
self.assertEqual(6,f2.getNumberOfComponents());
self.assertEqual(5,f2.getNumberOfTuples());
expected1=[-1.1,0.,1.1,4.5,5.6,6.7]
- for i in xrange(5):
+ for i in range(5):
self.assertAlmostEqual(expected1[0],f2.getIJ(i,0),13);
self.assertAlmostEqual(expected1[1],f2.getIJ(i,1),13);
self.assertAlmostEqual(expected1[2],f2.getIJ(i,2),13);
f2.checkConsistencyLight();
self.assertEqual(1,f2.getNumberOfComponents());
self.assertEqual(5,f2.getNumberOfTuples());
- for i in xrange(5):
+ for i in range(5):
self.assertAlmostEqual(8.3606219864313918,f2.getIJ(i,0),13);
pass
#
f2.checkConsistencyLight();
self.assertEqual(1,f2.getNumberOfComponents());
self.assertEqual(5,f2.getNumberOfTuples());
- for i in xrange(5):
+ for i in range(5):
self.assertAlmostEqual(5.6,f2.getIJ(i,0),13);
pass
#
d2,d2I=array.maxPerTupleWithCompoId()
self.assertEqual(1,d2.getNumberOfComponents());
self.assertEqual(5,d2.getNumberOfTuples());
- for i in xrange(5):
+ for i in range(5):
self.assertAlmostEqual(5.6,d2.getIJ(i,0),13);
pass
self.assertTrue(d2I.isEqual(DataArrayInt([4,3,2,0,1])))
self.assertEqual(3,f1.getNumberOfComponents());
self.assertEqual(5,f1.getNumberOfTuples());
expected1=[1.2,2.3,3.4, 1.2,3.4,4.5, 3.4,4.5,5.6, 5.6,1.2,2.3, 4.5,5.6,1.2]
- for i in xrange(15):
+ for i in range(15):
self.assertAlmostEqual(expected1[i],f1.getIJ(0,i),13);
pass
f1.changeNbOfComponents(4,7.77);
self.assertEqual(4,f1.getNumberOfComponents());
self.assertEqual(5,f1.getNumberOfTuples());
expected2=[1.2,2.3,3.4,7.77, 1.2,3.4,4.5,7.77, 3.4,4.5,5.6,7.77, 5.6,1.2,2.3,7.77, 4.5,5.6,1.2,7.77]
- for i in xrange(20):
+ for i in range(20):
self.assertAlmostEqual(expected2[i],f1.getIJ(0,i),13);
pass
#
f1.checkConsistencyLight();
self.assertEqual(5,f1.getNumberOfComponents());
self.assertEqual(5,f1.getNumberOfTuples());
- for i in xrange(5):
+ for i in range(5):
self.assertAlmostEqual(arr1[0],f1.getIJ(i,0),13);
self.assertAlmostEqual(arr1[1],f1.getIJ(i,1),13);
self.assertAlmostEqual(arr1[2],f1.getIJ(i,2),13);
f1.checkConsistencyLight();
self.assertEqual(5,f1.getNumberOfComponents());
self.assertEqual(5,f1.getNumberOfTuples());
- for i in xrange(5):
+ for i in range(5):
self.assertAlmostEqual(arr1[4],f1.getIJ(i,0),13);
self.assertAlmostEqual(arr1[3],f1.getIJ(i,1),13);
self.assertAlmostEqual(arr1[2],f1.getIJ(i,2),13);
self.assertEqual(5,f1.getNumberOfTuples());
self.assertEqual(1,f1.getNumberOfComponents());
expected1=[1.,1.4142135623730951, 1.4142135623730951,1.,1.]
- for i in xrange(5):
+ for i in range(5):
self.assertAlmostEqual(expected1[i],f1.getIJ(i,0),14);
pass
#
self.assertEqual(5,f1.getNumberOfTuples());
self.assertEqual(1,f1.getNumberOfComponents());
expected2=[1.4142135623730951, 1.7320508075688772, 1.7320508075688772, 1.4142135623730951, 1.4142135623730951]
- for i in xrange(5):
+ for i in range(5):
self.assertAlmostEqual(expected2[i],f1.getIJ(i,0),14);
pass
pass
values1=[-0.1,0.23333333333333336,0.56666666666666665,0.4,0.9]
tmp=f1.getArray().getValues();
self.assertEqual(len(values1),len(tmp))
- for i in xrange(len(values1)):
+ for i in range(len(values1)):
self.assertTrue(abs(values1[i]-tmp[i])<1.e-12);
pass
#
values2=[-0.9,0.1,1.1,-0.4,0.6,1.6,0.1,1.1,2.1]
tmp=f1.getArray().getValues();
self.assertEqual(len(values2),len(tmp))
- for i in xrange(len(values2)):
+ for i in range(len(values2)):
self.assertTrue(abs(values2[i]-tmp[i])<1.e-12);
pass
f1=MEDCouplingFieldDouble.New(ON_NODES,LINEAR_TIME);
tmp=f1.getArray().getValues();
values2Bis=[-0.9,0.1,1.1,-0.4,0.6,1.6,0.1,1.1,2.1]
self.assertEqual(len(values2Bis),len(tmp))
- for i in xrange(len(values2Bis)):
+ for i in range(len(values2Bis)):
self.assertTrue(abs(values2Bis[i]-tmp[i])<1.e-12);
pass
tmp=f1.getEndArray().getValues();
self.assertEqual(len(values2Bis),len(tmp))
- for i in xrange(len(values2Bis)):
+ for i in range(len(values2Bis)):
self.assertTrue(abs(values2Bis[i]-tmp[i])<1.e-12);
pass
#
values3=[-0.6,-1.2,-0.1,-0.2,0.4,0.8,-0.1,-0.2,0.4,0.8,0.9,1.8,0.4,0.8,0.9,1.8,1.4,2.8]
tmp=f1.getArray().getValues();
self.assertEqual(len(values3),len(tmp))
- for i in xrange(len(values3)):
+ for i in range(len(values3)):
self.assertTrue(abs(values3[i]-tmp[i])<1.e-12);
pass
values4=f1.accumulate();
f1.checkConsistencyLight();
self.assertEqual(1,f1.getNumberOfComponents());
self.assertEqual(5,f1.getNumberOfTuples());
- for i in xrange(5):
+ for i in range(5):
self.assertAlmostEqual(0.07,f1.getIJ(i,0),16);
pass
f1.assign(0.09);
f1.checkConsistencyLight();
self.assertEqual(1,f1.getNumberOfComponents());
self.assertEqual(5,f1.getNumberOfTuples());
- for i in xrange(5):
+ for i in range(5):
self.assertAlmostEqual(0.09,f1.getIJ(i,0),16);
pass
#
f1.checkConsistencyLight();
self.assertEqual(1,f1.getNumberOfComponents());
self.assertEqual(9,f1.getNumberOfTuples());
- for i in xrange(9):
+ for i in range(9):
self.assertAlmostEqual(0.08,f1.getIJ(i,0),16);
pass
self.assertEqual(1,f1.getEndArray().getNumberOfComponents());
self.assertEqual(9,f1.getEndArray().getNumberOfTuples());
- for i in xrange(9):
+ for i in range(9):
self.assertAlmostEqual(0.08,f1.getEndArray().getIJ(i,0),16);
pass
pass
self.assertEqual(3,f.getNumberOfTuples());
self.assertEqual(1,f.getNumberOfComponents());
expected1=[1.1,2.4,4.4]
- for i in xrange(3):
+ for i in range(3):
self.assertAlmostEqual(expected1[i],f.getIJ(i,0),12);
pass
coords=m.getCoordinatesAndOwner();
self.assertEqual(4,coords.getNumberOfTuples());
self.assertEqual(1,coords.getNumberOfComponents());
- for i in xrange(4):
+ for i in range(4):
self.assertAlmostEqual(discX[i],coords.getIJ(i,0),12);
pass
coords=m.computeCellCenterOfMass();
self.assertEqual(3,coords.getNumberOfTuples());
self.assertEqual(1,coords.getNumberOfComponents());
expected1_3=[2.85,4.6,8.]
- for i in xrange(3):
+ for i in range(3):
self.assertAlmostEqual(expected1_3[i],coords.getIJ(i,0),12);
pass
#
self.assertEqual(6,f.getNumberOfTuples());
self.assertEqual(1,f.getNumberOfComponents());
expected2=[12.21,26.64,48.84,24.64,53.76,98.56]
- for i in xrange(6):
+ for i in range(6):
self.assertAlmostEqual(expected2[i],f.getIJ(i,0),12);
pass
coords=m.getCoordinatesAndOwner();
self.assertEqual(12,coords.getNumberOfTuples());
self.assertEqual(2,coords.getNumberOfComponents());
expected2_2=[2.3,12.3,3.4,12.3,5.8,12.3,10.2,12.3, 2.3,23.4,3.4,23.4,5.8,23.4,10.2,23.4, 2.3,45.8,3.4,45.8,5.8,45.8,10.2,45.8]
- for i in xrange(24):
+ for i in range(24):
self.assertAlmostEqual(expected2_2[i],coords.getIJ(0,i),12);
pass
coords=m.computeCellCenterOfMass();
self.assertEqual(6,coords.getNumberOfTuples());
self.assertEqual(2,coords.getNumberOfComponents());
expected2_3=[2.85,17.85,4.6,17.85,8.,17.85, 2.85,34.6,4.6,34.6,8.,34.6]
- for i in xrange(12):
+ for i in range(12):
self.assertAlmostEqual(expected2_3[i],coords.getIJ(0,i),12);
pass
#
self.assertEqual(24,f.getNumberOfTuples());
self.assertEqual(1,f.getNumberOfComponents());
expected3=[23.199, 50.616, 92.796, 46.816, 102.144, 187.264, 0.6105, 1.332, 2.442, 1.232, 2.688, 4.928, 10.7448, 23.4432, 42.9792, 21.6832, 47.3088, 86.7328, 6.5934, 14.3856, 26.3736, 13.3056, 29.0304, 53.2224]
- for i in xrange(24):
+ for i in range(24):
self.assertAlmostEqual(expected3[i],f.getIJ(i,0),12);
pass
coords=m.getCoordinatesAndOwner();
2.3,12.3,1.25, 3.4,12.3,1.25, 5.8,12.3,1.25, 10.2,12.3,1.25, 2.3,23.4,1.25, 3.4,23.4,1.25, 5.8,23.4,1.25, 10.2,23.4,1.25, 2.3,45.8,1.25, 3.4,45.8,1.25, 5.8,45.8,1.25, 10.2,45.8,1.25,
2.3,12.3,2.13, 3.4,12.3,2.13, 5.8,12.3,2.13, 10.2,12.3,2.13, 2.3,23.4,2.13, 3.4,23.4,2.13, 5.8,23.4,2.13, 10.2,23.4,2.13, 2.3,45.8,2.13, 3.4,45.8,2.13, 5.8,45.8,2.13, 10.2,45.8,2.13,
2.3,12.3,2.67, 3.4,12.3,2.67, 5.8,12.3,2.67, 10.2,12.3,2.67, 2.3,23.4,2.67, 3.4,23.4,2.67, 5.8,23.4,2.67, 10.2,23.4,2.67, 2.3,45.8,2.67, 3.4,45.8,2.67, 5.8,45.8,2.67, 10.2,45.8,2.67];
- for i in xrange(180):
+ for i in range(180):
self.assertAlmostEqual(expected3_2[i],coords.getIJ(0,i),12);
pass
coords=m.computeCellCenterOfMass();
2.85,17.85,1.225,4.6,17.85,1.225,8.,17.85,1.225, 2.85,34.6,1.225,4.6,34.6,1.225,8.,34.6,1.225,
2.85,17.85,1.69,4.6,17.85,1.69,8.,17.85,1.69, 2.85,34.6,1.69,4.6,34.6,1.69,8.,34.6,1.69,
2.85,17.85,2.4,4.6,17.85,2.4,8.,17.85,2.4, 2.85,34.6,2.4,4.6,34.6,2.4,8.,34.6,2.4];
- for i in xrange(72):
+ for i in range(72):
self.assertAlmostEqual(expected3_3[i],coords.getIJ(0,i),12);
pass
pass
self.assertEqual(18,f.getNumberOfTuples());
self.assertEqual(2,f.getNumberOfComponents());
expected1=[-0.6, -0.6, 0.4, 0.4, 1.4, 1.4, -0.6, -0.6, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 1.4, 1.4, -0.6, -0.6, 0.4, 0.4, 1.4, 1.4, -0.6, -0.6, 1.4, 1.4, -0.6, -0.6, 0.4, 0.4, 1.4, 1.4, 0.4, 0.4]
- for i in xrange(36):
+ for i in range(36):
self.assertAlmostEqual(expected1[i],f.getIJ(0,i),12);
pass
self.assertTrue(f.zipCoords());
f.checkConsistencyLight();
expected2=[-0.6, -0.6, 1.4, 1.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 1.4, 1.4, -0.6, -0.6, 0.4, 0.4, 1.4, 1.4, 1.4, 1.4, -0.6, -0.6, 0.4, 0.4, 1.4, 1.4, 0.4, 0.4]
- for i in xrange(30):
+ for i in range(30):
self.assertAlmostEqual(expected2[i],f.getIJ(0,i),12);
pass
self.assertTrue(not f.zipCoords());
f.checkConsistencyLight();
- for i in xrange(30):
+ for i in range(30):
self.assertAlmostEqual(expected2[i],f.getIJ(0,i),12);
pass
self.assertTrue(f.getArray().getInfoOnComponent(0)=="titi");
expected1=[-0.05, -0.05, 0.3666666666666667, 0.3666666666666667, 0.53333333333333321, 0.53333333333333321,
-0.05, -0.05, 0.45, 0.45, 0.53333333333333321, 0.53333333333333321, -0.05, -0.05, 0.45, 0.45,
0.36666666666666659, 0.36666666666666659, 0.033333333333333326, 0.033333333333333326];
- for i in xrange(20):
+ for i in range(20):
self.assertAlmostEqual(expected1[i],f.getIJ(0,i),12);
pass
f.getArray().setInfoOnComponent(0,"titi");
-0.05, -0.05, 0.45, 0.45, 0.36666666666666659, 0.36666666666666659, 0.033333333333333326, 0.033333333333333326];
self.assertEqual(7,f.getNumberOfTuples());
self.assertEqual(2,f.getNumberOfComponents());
- for i in xrange(14):
+ for i in range(14):
self.assertAlmostEqual(expected2[i],f.getIJ(0,i),12);
pass
self.assertTrue(f.getArray().getInfoOnComponent(0)=="titi");
-0.3, -0.3, 0.2, 0.2, 0.7, 0.7];
self.assertEqual(9,f2.getNumberOfTuples());
self.assertEqual(2,f2.getNumberOfComponents());
- for i in xrange(18):
+ for i in range(18):
self.assertAlmostEqual(expected3[i],f2.getIJ(0,i),12);
pass
self.assertTrue(f2.zipConnectivity(0));
self.assertEqual(9,f2.getNumberOfTuples());
self.assertEqual(2,f2.getNumberOfComponents());
- for i in xrange(18):
+ for i in range(18):
self.assertAlmostEqual(expected3[i],f2.getIJ(0,i),12);
pass
pass
self.assertTrue(b.getInfoOnComponent(0)=="toto");
self.assertTrue(b.getInfoOnComponent(1)=="tata");
expected1=[3.1, 13.1, 2.1, 12.1, 7.1, 17.1, 1.1, 11.1, 6.1, 16.1, 5.1, 15.1, 4.1, 14.1]
- for i in xrange(14):
+ for i in range(14):
self.assertAlmostEqual(expected1[i],b.getIJ(0,i),14);
pass
#
self.assertTrue(d.getInfoOnComponent(0)=="toto");
self.assertTrue(d.getInfoOnComponent(1)=="tata");
expected2=[3, 13, 2, 12, 7, 17, 1, 11, 6, 16, 5, 15, 4, 14]
- for i in xrange(14):
+ for i in range(14):
self.assertEqual(expected2[i],d.getIJ(0,i));
pass
pass
self.assertTrue(b.getInfoOnComponent(0)=="toto");
self.assertTrue(b.getInfoOnComponent(1)=="tata");
expected1=[5.1,15.1,3.1,13.1,1.1,11.1,7.1,17.1,6.1,16.1]
- for i in xrange(10):
+ for i in range(10):
self.assertAlmostEqual(expected1[i],b.getIJ(0,i),14);
pass
#
self.assertTrue(d.getInfoOnComponent(0)=="toto");
self.assertTrue(d.getInfoOnComponent(1)=="tata");
expected2=[5,15,3,13,1,11,7,17,6,16]
- for i in xrange(10):
+ for i in range(10):
self.assertEqual(expected2[i],d.getIJ(0,i));
pass
pass
self.assertEqual(7,a.getNumberOfTuples());
self.assertEqual(2,a.getNumberOfComponents());
expected1=[3.1, 13.1, 2.1, 12.1, 7.1, 17.1, 1.1, 11.1, 6.1, 16.1, 5.1, 15.1, 4.1, 14.1]
- for i in xrange(14):
+ for i in range(14):
self.assertAlmostEqual(expected1[i],a.getIJ(0,i),14);
pass
#
self.assertEqual(7,c.getNumberOfTuples());
self.assertEqual(2,c.getNumberOfComponents());
expected2=[3, 13, 2, 12, 7, 17, 1, 11, 6, 16, 5, 15, 4, 14]
- for i in xrange(14):
+ for i in range(14):
self.assertEqual(expected2[i],c.getIJ(0,i));
pass
pass
self.assertTrue(b.getInfoOnComponent(0)=="toto");
self.assertTrue(b.getInfoOnComponent(1)=="tata");
expected1=[4.1, 14.1, 2.1, 12.1, 1.1, 11.1, 7.1, 17.1, 6.1, 16.1, 5.1, 15.1, 3.1, 13.1]
- for i in xrange(14):
+ for i in range(14):
self.assertAlmostEqual(expected1[i],b.getIJ(0,i),14);
pass
#
self.assertTrue(d.getInfoOnComponent(0)=="toto");
self.assertTrue(d.getInfoOnComponent(1)=="tata");
expected2=[4, 14, 2, 12, 1, 11, 7, 17, 6, 16, 5, 15, 3, 13]
- for i in xrange(14):
+ for i in range(14):
self.assertEqual(expected2[i],d.getIJ(0,i));
pass
pass
self.assertEqual(7,a.getNumberOfTuples());
self.assertEqual(2,a.getNumberOfComponents());
expected1=[4.1, 14.1, 2.1, 12.1, 1.1, 11.1, 7.1, 17.1, 6.1, 16.1, 5.1, 15.1, 3.1, 13.1]
- for i in xrange(14):
+ for i in range(14):
self.assertAlmostEqual(expected1[i],a.getIJ(0,i),14);
pass
#
self.assertEqual(7,c.getNumberOfTuples());
self.assertEqual(2,c.getNumberOfComponents());
expected2=[4, 14, 2, 12, 1, 11, 7, 17, 6, 16, 5, 15, 3, 13]
- for i in xrange(14):
+ for i in range(14):
self.assertEqual(expected2[i],c.getIJ(0,i));
pass
pass
self.assertTrue(b.getInfoOnComponent(0)=="toto");
self.assertTrue(b.getInfoOnComponent(1)=="tata");
expected1=[5.1,15.1,3.1,13.1,1.1,11.1,7.1,17.1,6.1,16.1]
- for i in xrange(10):
+ for i in range(10):
self.assertAlmostEqual(expected1[i],b.getIJ(0,i),14);
pass
#
self.assertTrue(d.getInfoOnComponent(0)=="toto");
self.assertTrue(d.getInfoOnComponent(1)=="tata");
expected2=[5,15,3,13,1,11,7,17,6,16]
- for i in xrange(10):
+ for i in range(10):
self.assertEqual(expected2[i],d.getIJ(0,i));
pass
pass
self.assertEqual(3,ws.getNumberOfTuples());
self.assertEqual(1,ws.getNumberOfComponents());
expected1=[1,4,8]
- for i in xrange(3):
+ for i in range(3):
self.assertEqual(expected1[i],ws.getIJ(i,0));
pass
a=DataArrayDouble.New();
self.assertAlmostEqual(-4.56,m,12);
self.assertEqual(3,ws.getNumberOfTuples());
self.assertEqual(1,ws.getNumberOfComponents());
- for i in xrange(3):
+ for i in range(3):
self.assertEqual(expected1[i],ws.getIJ(i,0));
pass
pass
self.assertEqual(4,ws.getNumberOfTuples());
self.assertEqual(1,ws.getNumberOfComponents());
expected1=[0,3,7,17]
- for i in xrange(4):
+ for i in range(4):
self.assertEqual(expected1[i],ws.getIJ(i,0));
pass
#
self.assertAlmostEqual(-8.71,m,12);
self.assertEqual(4,ws.getNumberOfTuples());
self.assertEqual(1,ws.getNumberOfComponents());
- for i in xrange(4):
+ for i in range(4):
self.assertEqual(expected1[i],ws.getIJ(i,0));
pass
pass
self.assertEqual(f2.getNumberOfTuples(),3);
self.assertEqual(1,m2.getMeshDimension());
self.assertEqual(1,m2.getSpaceDimension());
- for i in xrange(3):
+ for i in range(3):
self.assertAlmostEqual(f1.getIJ(i,0),f2.getIJ(i,0),10);
pass
da=DataArrayDouble.New();
self.assertEqual(f2.getNumberOfTuples(),6);
self.assertEqual(2,m2.getMeshDimension());
self.assertEqual(2,m2.getSpaceDimension());
- for i in xrange(6):
+ for i in range(6):
self.assertAlmostEqual(f1.getIJ(i,0),f2.getIJ(i,0),10);
pass
#
self.assertEqual(f2.getNumberOfTuples(),24);
self.assertEqual(3,m2.getMeshDimension());
self.assertEqual(3,m2.getSpaceDimension());
- for i in xrange(24):
+ for i in range(24):
self.assertAlmostEqual(f1.getIJ(i,0),f2.getIJ(i,0),10);
pass
#
self.assertEqual(6,da2.getNumberOfTuples());
self.assertEqual(1,da2.getNumberOfComponents());
expected1=[1,3,0,5,2,4]
- for i in xrange(6):
+ for i in range(6):
self.assertEqual(expected1[i],da2.getIJ(i,0));
pass
da3=da2.invertArrayN2O2O2N(6);
- for i in xrange(6):
+ for i in range(6):
self.assertEqual(arr1[i],da3.getIJ(i,0));
pass
#
self.assertEqual(6,da2.getNumberOfTuples());
self.assertEqual(1,da2.getNumberOfComponents());
expected2=[5,7,8,0,3,2]
- for i in xrange(6):
+ for i in range(6):
self.assertEqual(expected2[i],da2.getIJ(i,0));
pass
da3=da2.invertArrayN2O2O2N(10);
- for i in xrange(10):
+ for i in range(10):
self.assertEqual(arr2[i],da3.getIJ(i,0));
pass
pass
a1.setValues(arr1,5,4);
expp=[21.,22.,23.,24.]
self.assertEqual(4,len(a1.getTuple(2)));
- for i in xrange(4):
+ for i in range(4):
self.assertAlmostEqual(expp[i],a1.getTuple(2)[i],12)
pass
a1.setInfoOnComponent(0,"aaaa");
self.assertTrue(a2.getInfoOnComponent(4)=="aaaa");
self.assertTrue(a2.getInfoOnComponent(5)=="aaaa");
expected1=[2.,3.,2.,3.,1.,1., 12.,13.,12.,13.,11.,11., 22.,23.,22.,23.,21.,21., 32.,33.,32.,33.,31.,31., 42.,43.,42.,43.,41.,41.]
- for i in xrange(30):
+ for i in range(30):
self.assertAlmostEqual(expected1[i],a2.getIJ(0,i),14);
pass
a3=a1.convertToIntArr();
self.assertTrue(a4.getInfoOnComponent(3)=="cccc");
self.assertTrue(a4.getInfoOnComponent(4)=="aaaa");
self.assertTrue(a4.getInfoOnComponent(5)=="aaaa");
- for i in xrange(30):
+ for i in range(30):
self.assertEqual(int(expected1[i]),a4.getIJ(0,i));
pass
# setSelectedComponents
self.assertTrue(a2.getInfoOnComponent(4)=="aaaa");
self.assertTrue(a2.getInfoOnComponent(5)=="aaaa");
expected2=[2.,4.,3.,3.,1.,1., 12.,14.,13.,13.,11.,11., 22.,24.,23.,23.,21.,21., 32.,34.,33.,33.,31.,31., 42.,44.,43.,43.,41.,41.]
- for i in xrange(30):
+ for i in range(30):
self.assertAlmostEqual(expected2[i],a2.getIJ(0,i),14);
pass
a6=a5.convertToIntArr();
self.assertTrue(a4.getInfoOnComponent(3)=="cccc");
self.assertTrue(a4.getInfoOnComponent(4)=="aaaa");
self.assertTrue(a4.getInfoOnComponent(5)=="aaaa");
- for i in xrange(30):
+ for i in range(30):
self.assertEqual(int(expected2[i]),a4.getIJ(0,i));
pass
# test of throw
self.assertTrue(f2.getArray().getInfoOnComponent(4)=="aaaa");
self.assertTrue(f2.getArray().getInfoOnComponent(5)=="aaaa");
expected1=[2.,3.,2.,3.,1.,1., 12.,13.,12.,13.,11.,11., 22.,23.,22.,23.,21.,21., 32.,33.,32.,33.,31.,31., 42.,43.,42.,43.,41.,41.]
- for i in xrange(30):
+ for i in range(30):
self.assertAlmostEqual(expected1[i],f2.getIJ(0,i),14);
pass
#setSelectedComponents
self.assertTrue(f2.getArray().getInfoOnComponent(4)=="aaaa");
self.assertTrue(f2.getArray().getInfoOnComponent(5)=="aaaa");
expected2=[2.,4.,3.,3.,1.,1., 12.,14.,13.,13.,11.,11., 22.,24.,23.,23.,21.,21., 32.,34.,33.,33.,31.,31., 42.,44.,43.,43.,41.,41.]
- for i in xrange(30):
+ for i in range(30):
self.assertAlmostEqual(expected2[i],f2.getIJ(0,i),14);
pass
#
da4=da3.fromNoInterlace();
self.assertEqual(5,da4.getNumberOfTuples());
self.assertEqual(3,da4.getNumberOfComponents());# it's not a bug. Avoid to have 1 million components !
- for i in xrange(15):
+ for i in range(15):
self.assertAlmostEqual(expected1[i],da4.getIJ(0,i),14);
pass
pass
da4=da3.toNoInterlace();
self.assertEqual(5,da4.getNumberOfTuples());
self.assertEqual(3,da4.getNumberOfComponents());# it's not a bug. Avoid to have 1 million components !
- for i in xrange(15):
+ for i in range(15):
self.assertAlmostEqual(expected1[i],da4.getIJ(0,i),14);
pass
pass
da.setValues(tab1,2,2);
da2=da.fromPolarToCart();
expected1=[1.9601331556824833,0.39733866159012243, 1.9121054682112213,1.6105442180942275]
- for i in xrange(4):
+ for i in range(4):
self.assertAlmostEqual(expected1[i],da2.getIJ(0,i),13);
pass
pass
da.setValues(tab1,2,3);
da2=da.fromCylToCart();
expected1=[1.9601331556824833,0.39733866159012243,4., 1.9121054682112213,1.6105442180942275,9.]
- for i in xrange(6):
+ for i in range(6):
self.assertAlmostEqual(expected1[i],da2.getIJ(0,i),13);
pass
pass
da.setValues(tab1,2,3);
da2=da.fromSpherToCart();
expected1=[0.37959212195737485,0.11742160338765303,1.9601331556824833, 1.1220769624465328,1.1553337045129035,1.9121054682112213]
- for i in xrange(6):
+ for i in range(6):
self.assertAlmostEqual(expected1[i],da2.getIJ(0,i),13);
pass
pass
self.assertEqual(NORM_PYRA5,mesh.getTypeOfCell(1));
self.assertEqual(NORM_TETRA4,mesh.getTypeOfCell(2));
self.assertEqual(NORM_PYRA5,mesh.getTypeOfCell(3));
- for i in xrange(4):
+ for i in range(4):
self.assertAlmostEqual(f1.getArray().getIJ(0,i),f2.getArray().getIJ(0,i),5);
pass
pass
self.assertEqual(24,i.getNumberOfCellsWithType(NORM_QUAD4));
expected1=[0.25,0.75,2.0625]
j=i.getMeasureField(True);
- for ii in xrange(12):
- for k in xrange(3):
+ for ii in range(12):
+ for k in range(3):
self.assertAlmostEqual(expected1[k],j.getIJ(0,ii*3+k),10);
pass
pass
expected2=[0.62200846792814113, 0.16666666666681595, 1.4513530918323276, 0.38888888888923495, 2.6293994326053212, 0.7045454545460802, 0.45534180126145435, 0.45534180126150181, 1.0624642029433926, 1.0624642029435025, 1.9248539780597826, 1.9248539780599816, 0.16666666666661334, 0.62200846792815856, 0.38888888888876294, 1.4513530918323678, 0.70454545454522521, 2.629399432605394, -0.16666666666674007, 0.62200846792812436, -0.38888888888906142, 1.4513530918322881, -0.70454545454576778, 2.6293994326052488, -0.45534180126154766, 0.45534180126140844, -1.0624642029436118, 1.0624642029432834, -1.9248539780601803, 1.9248539780595841, -0.62200846792817499, 0.1666666666665495, -1.451353091832408, 0.388888888888613, -2.6293994326054668, 0.70454545454495332, -0.62200846792810593, -0.16666666666680507, -1.451353091832247, -0.38888888888921297, -2.6293994326051746, -0.70454545454604123, -0.45534180126135926, -0.45534180126159562, -1.0624642029431723, -1.0624642029437235, -1.9248539780593836, -1.9248539780603811, -0.1666666666664828, -0.62200846792819242, -0.38888888888846079, -1.4513530918324489, -0.70454545454467987, -2.6293994326055397, 0.16666666666687083, -0.62200846792808862, 0.38888888888936374, -1.4513530918322073, 0.70454545454631357, -2.6293994326051022, 0.45534180126164348, -0.45534180126131207, 1.0624642029438327, -1.0624642029430627, 1.9248539780605791, -1.9248539780591853, 0.62200846792821063, -0.16666666666641802, 1.4513530918324888, -0.38888888888831086, 2.6293994326056125, -0.70454545454440853]
m=i.computeCellCenterOfMass();
- for i in xrange(72):
+ for i in range(72):
self.assertAlmostEqual(expected2[i],m.getIJ(0,i),10);
pass
#
g.checkConsistencyLight();
expected1=[ 0.4330127018922193, 0.4330127018922193, 0.649519052838329, 1.2990381056766578, 1.299038105676658, 1.948557158514987, 2.1650635094610955, 2.1650635094610964, 3.2475952641916446, 3.031088913245533, 3.0310889132455352, 4.546633369868303 ]
f1=g.getMeasureField(True);
- for i in xrange(12):
+ for i in range(12):
self.assertAlmostEqual(expected1[i],f1.getIJ(0,i),12);
pass
expected2=[0.625, 0.21650635094610962, 1.625, 0.21650635094610959, 2.8750000000000004, 0.21650635094610965, 1.1250000000000002, 1.0825317547305482, 2.125, 1.0825317547305482, 3.3750000000000004, 1.0825317547305484, 2.125, 2.8145825622994254, 3.125, 2.8145825622994254, 4.375, 2.8145825622994254, 3.6250000000000009, 5.4126587736527414, 4.625, 5.4126587736527414, 5.875, 5.4126587736527414]
f2=g.computeCellCenterOfMass();
- for i in xrange(24):
+ for i in range(24):
self.assertAlmostEqual(expected2[i],f2.getIJ(0,i),12);
pass
pass
self.assertTrue(tmp2);
self.assertEqual(444,tmp3);
expected1=[1.327751058489274, 4.2942574094314701, 13.024068164857139, 1.3069177251569044, 4.1484240761012954, 12.297505664866796, 1.270833333332571, 3.8958333333309674, 11.039062499993179, 1.2291666666659207, 3.6041666666644425, 9.585937499993932, 1.1930822748415895, 3.3515759238941376, 8.3274943351204556, 1.1722489415082769, 3.2057425905609289, 7.6009318351210622, 1.1722489415082862, 3.2057425905609884, 7.6009318351213713, 1.1930822748416161, 3.3515759238943001, 8.3274943351212727, 1.2291666666659564, 3.6041666666646734, 9.5859374999950777, 1.2708333333326081, 3.8958333333311868, 11.039062499994293, 1.3069177251569224, 4.1484240761014384, 12.297505664867627, 1.3277510584902354, 4.2942574094346071, 13.024068164866796]
- for ii in xrange(12):
- for jj in xrange(36):
+ for ii in range(12):
+ for jj in range(36):
self.assertAlmostEqual(expected1[jj],f2.getIJ(0,ii*36+jj),9);
pass
#
self.assertEqual(7,da.getNumberOfTuples());
self.assertEqual(1,da.getNumberOfComponents());
expected2=[0,0,1,2,3,4,4]
- for i in xrange(7):
+ for i in range(7):
self.assertEqual(expected2[i],da.getIJ(i,0));
pass
m.checkConsistencyLight();
self.assertEqual(NORM_TRI3,m.getTypeOfCell(6));
expected1=[0.125,0.125,0.125,0.125,0.25,0.125,0.125]
f=m.getMeasureField(False);
- for i in xrange(7):
+ for i in range(7):
self.assertAlmostEqual(expected1[i]*sqrt(2.),f.getIJ(i,0),10);
pass
types=m.getAllGeoTypes();
da=m.simplexize(1);
self.assertEqual(7,da.getNumberOfTuples());
self.assertEqual(1,da.getNumberOfComponents());
- for i in xrange(7):
+ for i in range(7):
self.assertEqual(expected2[i],da.getIJ(i,0));
pass
m.checkConsistencyLight();
self.assertEqual(NORM_TRI3,m.getTypeOfCell(5));
self.assertEqual(NORM_TRI3,m.getTypeOfCell(6));
f=m.getMeasureField(False);
- for i in xrange(7):
+ for i in range(7):
self.assertAlmostEqual(expected1[i]*sqrt(2.),f.getIJ(i,0),10);
pass
pass
self.assertTrue(f1.simplexize(0));
f1.checkConsistencyLight();
expected1=[10.,110.,10.,110.,20.,120.,30.,130.,40.,140.,50.,150.,50.,150.]
- for i in xrange(14):
+ for i in range(14):
self.assertAlmostEqual(expected1[i],f1.getIJ(0,i),10);
pass
self.assertTrue(not f1.simplexize(0));
- for i in xrange(14):
+ for i in range(14):
self.assertAlmostEqual(expected1[i],f1.getIJ(0,i),10);
pass
#
self.assertTrue(da1.getInfoOnComponent(4)=="c2da3");
#
expected1=[7.,7.,0.,0.,0., 7.,7.,10.,100.,1000., 7.,7.,20.,200.,2000., 7.,7.,30.,300.,3000., 7.,7.,40.,400.,4000.,7.,7.,50.,500.,5000.,7.,7.,60.,600.,6000.]
- for i in xrange(35):
+ for i in range(35):
self.assertAlmostEqual(expected1[i],da1.getIJ(0,i),10);
pass
#
self.assertTrue(dai1.getInfoOnComponent(2)=="c0da3");
self.assertTrue(dai1.getInfoOnComponent(3)=="c1da3");
self.assertTrue(dai1.getInfoOnComponent(4)=="c2da3");
- for i in xrange(35):
+ for i in range(35):
self.assertEqual(int(expected1[i]),dai1.getIJ(0,i));
pass
# test of static method DataArrayDouble::meld
self.assertTrue(da4.getInfoOnComponent(2)=="c0da3");
self.assertTrue(da4.getInfoOnComponent(3)=="c1da3");
self.assertTrue(da4.getInfoOnComponent(4)=="c2da3");
- for i in xrange(35):
+ for i in range(35):
self.assertAlmostEqual(expected1[i],da4.getIJ(0,i),10);
pass
# test of static method DataArrayInt::meld
self.assertTrue(dai4.getInfoOnComponent(2)=="c0da3");
self.assertTrue(dai4.getInfoOnComponent(3)=="c1da3");
self.assertTrue(dai4.getInfoOnComponent(4)=="c2da3");
- for i in xrange(35):
+ for i in range(35):
self.assertEqual(int(expected1[i]),dai4.getIJ(0,i));
pass
pass
self.assertTrue(f3.getArray().getInfoOnComponent(1)=="ccc");
self.assertTrue(f3.getArray().getInfoOnComponent(2)=="aaa");
expected1=[5.,5.,12.,5.,5.,23.,5.,5.,34.,5.,5.,45.,5.,5.,56.]
- for i in xrange(15):
+ for i in range(15):
self.assertAlmostEqual(expected1[i],f3.getIJ(0,i),12);
pass
time,dt,it=f3.getTime();
self.assertTrue(f6.getArray().getInfoOnComponent(0)=="bbb");
self.assertTrue(f6.getArray().getInfoOnComponent(1)=="ccc");
self.assertTrue(f6.getArray().getInfoOnComponent(2)=="aaa");
- for i in xrange(15):
+ for i in range(15):
self.assertAlmostEqual(expected1[i],f6.getIJ(0,i),12);
pass
#
da,b,newNbOfNodes=m3.mergeNodesCenter(0.01);
self.assertEqual(9,m3.getNumberOfNodes());
expected1=[-0.299,-0.3, 0.201,-0.3, 0.701,-0.3, -0.299,0.2, 0.201,0.2, 0.701,0.2, -0.299,0.7, 0.201,0.7, 0.701,0.7]
- for i in xrange(18):
+ for i in range(18):
self.assertAlmostEqual(expected1[i],m3.getCoords().getIJ(0,i),13);
pass
#
f4=MEDCouplingFieldDouble.MergeFields([f1,f2,f3]);
self.assertEqual(15,f4.getMesh().getNumberOfCells());
expected1=[2.,2.,2.,2.,2.,2.,2.,2.,2.,2., 5.,5.,5.,5.,5.,5.,5.,5.,5.,5., 7.,7.,7.,7.,7.,7.,7.,7.,7.,7.]
- for i in xrange(30):
+ for i in range(30):
self.assertAlmostEqual(expected1[i],f4.getIJ(0,i),13);
pass
#
self.assertEqual(8,b.getNumberOfTuples());
self.assertEqual(1,b.getNumberOfComponents());
expected1=[0,2,4,5,6,9,10,11]
- for i in xrange(8):
+ for i in range(8):
self.assertEqual(expected1[i],b.getIJ(0,i));
pass
pass
self.assertEqual(7,b.getNumberOfTuples());
self.assertEqual(1,b.getNumberOfComponents());
expected1=[0,1,3,5,7,8,18]
- for i in xrange(7):
+ for i in range(7):
self.assertEqual(expected1[i],b.getIJ(0,i));
pass
b=DataArrayInt.BuildUnion([a,c]);
self.assertEqual(7,b.getNumberOfTuples());
self.assertEqual(1,b.getNumberOfComponents());
expected1=[0,1,3,5,7,8,18]
- for i in xrange(7):
+ for i in range(7):
self.assertEqual(expected1[i],b.getIJ(0,i));
pass
pass
self.assertEqual(2,b.getNumberOfTuples());
self.assertEqual(1,b.getNumberOfComponents());
expected1=[3,8]
- for i in xrange(2):
+ for i in range(2):
self.assertEqual(expected1[i],b.getIJ(0,i));
pass
b=DataArrayInt.BuildIntersection([a,c]);
self.assertEqual(2,b.getNumberOfTuples());
self.assertEqual(1,b.getNumberOfComponents());
expected1=[3,8]
- for i in xrange(2):
+ for i in range(2):
self.assertEqual(expected1[i],b.getIJ(0,i));
pass
pass
self.assertEqual(6,b.getNumberOfTuples());
self.assertEqual(1,b.getNumberOfComponents());
expected1=[2,3,1,0,2,6]
- for i in xrange(6):
+ for i in range(6):
self.assertEqual(expected1[i],b.getIJ(0,i));
pass
pass
self.assertTrue(b.getInfoOnComponent(0)=="toto");
self.assertTrue(b.getInfoOnComponent(1)=="tata");
expected1=[5.1,15.1,3.1,13.1,1.1,11.1,7.1,17.1,6.1,16.1]
- for i in xrange(10):
+ for i in range(10):
self.assertAlmostEqual(expected1[i],b.getIJ(0,i),14);
pass
arr4=[4,-1,0,6,5]
self.assertTrue(d.getInfoOnComponent(0)=="toto");
self.assertTrue(d.getInfoOnComponent(1)=="tata");
expected2=[5,15,3,13,1,11,7,17,6,16]
- for i in xrange(10):
+ for i in range(10):
self.assertEqual(expected2[i],d.getIJ(0,i));
pass
self.assertRaises(InterpKernelException,c.selectByTupleIdSafe,arr4);
self.assertEqual(13,da1.getNumberOfTuples());
#
expected1=[-1.,0.,0.,1.,1.,0.,0.,-1.,0.707106781186548,0.707106781186548,0.,-1.,0.,1.,1.,0.,0.,1.,1.,0.,-1.,0.,0.,1.,1.,0.];
- for i in xrange(26):
+ for i in range(26):
self.assertAlmostEqual(expected1[i],da1.getIJ(0,i),14);
pass
pass
#self.assertRaises(InterpKernelException,f2.__idiv__,f1) # mem leaks
self.assertTrue(f1.isEqual(f3,1e-10,1e-10));
expected1=[-0.5, 0.0, 0.0, 0.33333333333333331, 0.25, 0.0, 0.0, -0.20000000000000001, 0.117851130197758, 0.117851130197758, 0.0, -0.14285714285714285, 0.0, 0.125, 0.1111111111111111, 0.0, 0.0, 0.10000000000000001, 0.090909090909090912, 0.0, -0.083333333333333329, 0.0, 0.0, 0.076923076923076927, 0.071428571428571425, 0.0]
- for i in xrange(26):
+ for i in range(26):
self.assertAlmostEqual(expected1[i],f3.getIJ(0,i),10);
pass
pass
self.assertEqual(12,da1.getNbOfElems());
self.assertEqual(4,da1.getNumberOfComponents());
self.assertEqual(3,da1.getNumberOfTuples());
- for i in xrange(12):
+ for i in range(12):
self.assertEqual(i,da1.getIJ(0,i));
#
da1.rearrange(6);
self.assertEqual(12,da1.getNbOfElems());
self.assertEqual(6,da1.getNumberOfComponents());
self.assertEqual(2,da1.getNumberOfTuples());
- for i in xrange(12):
+ for i in range(12):
self.assertEqual(i,da1.getIJ(0,i));
#
self.assertRaises(InterpKernelException,da1.rearrange,7);
self.assertEqual(12,da1.getNbOfElems());
self.assertEqual(12,da1.getNumberOfComponents());
self.assertEqual(1,da1.getNumberOfTuples());
- for i in xrange(12):
+ for i in range(12):
self.assertEqual(i,da1.getIJ(0,i));
#
da1.rearrange(3);
self.assertEqual(12,da1.getNbOfElems());
self.assertEqual(3,da1.getNumberOfComponents());
self.assertEqual(4,da1.getNumberOfTuples());
- for i in xrange(12):
+ for i in range(12):
self.assertEqual(i,da1.getIJ(0,i));
#double
da2=da1.convertToDblArr();
self.assertEqual(12,da2.getNbOfElems());
self.assertEqual(4,da2.getNumberOfComponents());
self.assertEqual(3,da2.getNumberOfTuples());
- for i in xrange(12):
+ for i in range(12):
self.assertAlmostEqual(float(i),da2.getIJ(0,i),14);
#
da2.rearrange(6);
self.assertEqual(12,da2.getNbOfElems());
self.assertEqual(6,da2.getNumberOfComponents());
self.assertEqual(2,da2.getNumberOfTuples());
- for i in xrange(12):
+ for i in range(12):
self.assertAlmostEqual(float(i),da2.getIJ(0,i),14);
#
self.assertRaises(InterpKernelException,da2.rearrange,7);
self.assertEqual(12,da2.getNbOfElems());
self.assertEqual(1,da2.getNumberOfComponents());
self.assertEqual(12,da2.getNumberOfTuples());
- for i in xrange(12):
+ for i in range(12):
self.assertAlmostEqual(float(i),da2.getIJ(0,i),14);
#
da2.rearrange(3);
self.assertEqual(12,da2.getNbOfElems());
self.assertEqual(3,da2.getNumberOfComponents());
self.assertEqual(4,da2.getNumberOfTuples());
- for i in xrange(12):
+ for i in range(12):
self.assertAlmostEqual(float(i),da2.getIJ(0,i),14);
pass
d.sort()
self.assertEqual(5,d.getNumberOfTuples());
self.assertEqual(1,d.getNumberOfComponents());
- for i in xrange(5):
+ for i in range(5):
self.assertAlmostEqual(float(expect3[i]),d.getIJ(i,0),14);
pass
pass
self.assertEqual(2,b.getNumberOfComponents());
self.assertEqual(3,b.getNumberOfTuples());
expected1=[0.36666666666666665,-0.13333333333333333,-0.05,-0.05,0.45,0.45];
- for i in xrange(6):
+ for i in range(6):
self.assertAlmostEqual(expected1[i],b.getIJ(0,i),14);
pass
pass
self.assertEqual(1,b.getNumberOfComponents());
self.assertEqual(3,b.getNumberOfTuples());
expected1=[0.125,0.25,0.25];
- for i in xrange(3):
+ for i in range(3):
self.assertAlmostEqual(expected1[i],b.getIJ(0,i),14);
pass
pass
self.assertEqual(3,b.getArray().getNumberOfComponents());
self.assertEqual(3,b.getArray().getNumberOfTuples());
expected1=[0.,0.,-1.,0.,0.,-1.,0.,0.,-1.];
- for i in xrange(9):
+ for i in range(9):
self.assertAlmostEqual(expected1[i],b.getArray().getIJ(0,i),14);
pass
pass
from math import pi,e,sqrt,cos,sin
from datetime import datetime
from MEDCouplingDataForTest import MEDCouplingDataForTest
-import rlcompleter,readline # this line has to be here, to ensure a usability of MEDCoupling/MEDLoader. B4 removing it please notify to anthony.geay@cea.fr
+import rlcompleter,readline # this line has to be here, to ensure a usability of MEDCoupling/MEDLoader. B4 removing it please notify to anthony.geay@edf.fr
class MEDCouplingBasicsTest3(unittest.TestCase):
def testSwigGetItem1(self):
da.iota(7)
da.rearrange(5)
da.setInfoOnComponent(0,"X [m]") ; da.setInfoOnComponent(1,"Y [km]") ; da.setInfoOnComponent(2,"Y [m]")
- da.setInfoOnComponent(3,"Z [W]") ; da.setInfoOnComponent(4,"ZZ [km]") ;
+ da.setInfoOnComponent(3,"Z [W]") ; da.setInfoOnComponent(4,"ZZ [km]") ;
da[:,2]=3
self.assertEqual([7, 8, 3, 10, 11, 12, 13, 3, 15, 16, 17, 18, 3, 20, 21, 22, 23, 3, 25, 26],da.getValues())
da.rearrange(1) ; da.iota(7) ; da.rearrange(5)
da.iota(7)
da.rearrange(5)
da.setInfoOnComponent(0,"X [m]") ; da.setInfoOnComponent(1,"Y [km]") ; da.setInfoOnComponent(2,"Y [m]")
- da.setInfoOnComponent(3,"Z [W]") ; da.setInfoOnComponent(4,"ZZ [km]") ;
+ da.setInfoOnComponent(3,"Z [W]") ; da.setInfoOnComponent(4,"ZZ [km]") ;
da[:,2]=3.
self.assertEqual([7., 8., 3., 10., 11., 12., 13., 3., 15., 16., 17., 18., 3., 20., 21., 22., 23., 3., 25., 26.],da.getValues())
da.rearrange(1) ; da.iota(7) ; da.rearrange(5)
da-=8
st2=da.getHiddenCppPointer()
self.assertEqual(st1,st2)
- self.assertEqual(range(12),da.getValues())
+ self.assertEqual(list(range(12)), da.getValues())
da+=da1
st2=da.getHiddenCppPointer()
self.assertEqual(st1,st2)
da-=8
st2=da.getHiddenCppPointer()
self.assertEqual(st1,st2)
- self.assertEqual(range(12),da.getValues())
+ self.assertEqual(list(range(12)), da.getValues())
da+=da1
st2=da.getHiddenCppPointer()
self.assertEqual(st1,st2)
it2=da2.__iter__()
i=0
for it in da:
- pt=it2.next()
+ pt = next(it2)
it[:]=pt
pass
self.assertTrue(da.isEqual(da2))
it2=da2.__iter__()
i=0
for it in da:
- pt=it2.next()
+ pt = next(it2)
it[:]=pt
pass
self.assertTrue(da.isEqual(da2,1e-12))
def testDAIAggregateMulti1(self):
a=DataArrayInt.New()
- a.setValues(range(4),2,2)
+ a.setValues(list(range(4)), 2, 2)
a.setName("aa")
b=DataArrayInt.New()
- b.setValues(range(6),3,2)
+ b.setValues(list(range(6)), 3, 2)
c=DataArrayInt.Aggregate([a,b])
- self.assertEqual(range(4)+range(6),c.getValues())
+ self.assertEqual(list(range(4)) + list(range(6)), c.getValues())
self.assertEqual("aa",c.getName())
self.assertEqual(5,c.getNumberOfTuples())
self.assertEqual(2,c.getNumberOfComponents())
self.assertEqual(0,m.getMeshDimension());
types1=m.getAllGeoTypes();
self.assertEqual([NORM_POINT1],types1);
- for i in xrange(4):
+ for i in range(4):
conn=m.getNodeIdsOfCell(i);
self.assertEqual([i],conn);
self.assertTrue(NORM_POINT1==m.getTypeOfCell(i));
hs=dt.getHotSpotsTime();
self.assertEqual(6,len(hs));
expected1=[0.2,0.7,1.2,1.35,1.7,2.7]
- for i in xrange(6):
+ for i in range(6):
self.assertAlmostEqual(expected1[i],hs[i],12);
pass
meshId,arrId,arrIdInField,fieldId=dt.getIdsOnTimeRight(0.2);
da2=da.checkAndPreparePermutation();
self.assertEqual(8,da2.getNumberOfTuples());
self.assertEqual(1,da2.getNumberOfComponents());
- for i in xrange(8):
+ for i in range(8):
self.assertEqual(expect1[i],da2.getIJ(i,0));
pass
#
self.assertEqual(1,da2.getNumberOfComponents());
self.assertEqual(5,da2.getNumberOfTuples());
expected1=[32.,34.,36.,38.,40.]
- for i in xrange(5):
+ for i in range(5):
self.assertAlmostEqual(expected1[i],da2.getIJ(0,i),12);
pass
da2=da.applyFunc(1,"y+z");
expected2=[12.,14.,16.,18.,20.]
- for i in xrange(5):
+ for i in range(5):
self.assertAlmostEqual(expected2[i],da2.getIJ(0,i),12);
pass
#
f1.applyFuncCompo(1,"y+z");
self.assertEqual(1,f1.getNumberOfComponents());
self.assertEqual(5,f1.getNumberOfTuples());
- for i in xrange(5):
+ for i in range(5):
self.assertAlmostEqual(expected1[i],f1.getArray().getIJ(0,i),12);
pass
#
vs[1]="y";
da2=da.applyFuncNamedCompo(1,vs,"y+z");
expected1=[32.,34.,36.,38.,40.]
- for i in xrange(5):
+ for i in range(5):
self.assertAlmostEqual(expected1[i],da2.getIJ(0,i),12);
pass
self.assertRaises(InterpKernelException, da.applyFuncNamedCompo, 1, ["x","y","z","a"],"x+a")
f1.applyFuncNamedCompo(1,vs,"y+z");
self.assertEqual(1,f1.getNumberOfComponents());
self.assertEqual(5,f1.getNumberOfTuples());
- for i in xrange(5):
+ for i in range(5):
self.assertAlmostEqual(expected1[i],f1.getArray().getIJ(0,i),12);
pass
pass
self.assertEqual(1,f1.getNumberOfComponents());
self.assertEqual(9,f1.getNumberOfTuples());
expected1=[0.2, 0.7, 1.2, 0.7, 1.2, 1.7, 1.2, 1.7, 2.2]
- for i in xrange(9):
+ for i in range(9):
self.assertAlmostEqual(expected1[i],f1.getArray().getIJ(0,i),12);
pass
pass
self.assertEqual(1,f1.getNumberOfComponents());
self.assertEqual(9,f1.getNumberOfTuples());
expected1=[0.2, 0.7, 1.2, 0.7, 1.2, 1.7, 1.2, 1.7, 2.2]
- for i in xrange(9):
+ for i in range(9):
self.assertAlmostEqual(expected1[i],f1.getArray().getIJ(0,i),12);
pass
pass
self.assertEqual(3,resToTest.getNumberOfComponents());
self.assertEqual(2,resToTest.getNumberOfTuples());
expected1=[0.6,0.6,0.6, 0.6,0.6,0.6]
- for i in xrange(6):
+ for i in range(6):
self.assertAlmostEqual(expected1[i],resToTest.getIJ(0,i),14);
pass
#
2.32,1.52,0.0, 1.6,1.32,0.0, 3.52,1.26,0.0,#TRI6
2.6,1.6,0.0, 2.4,1.8,0.0, 2.4,1.2,0.0, 2.3,1.46,0.0,#QUAD4
2.32,2.68,0.0, 2.6,2.42,0.0, 2.8,2.46,0.0, 2.74,2.28,0.0 ];#QUAD8
- for i in xrange(39):
+ for i in range(39):
self.assertAlmostEqual(expected2[i],resToTest.getIJ(0,i),14);
pass
#
self.assertEqual(3,resToTest.getNumberOfComponents());
self.assertEqual(8,resToTest.getNumberOfTuples());#2+3+4+4 gauss points for resp TRI3,TRI6,QUAD4,QUAD8
expected3=[1.312,3.15,1.02, 0.56,3.3,0.6, 2.18,1.1,0.2, 1.18,1.54,0.98, 1.56,0.3,3.6, 1.613,0.801,4.374, 2.6,2.4,2.3, 2.31232,2.3933985,1.553255]
- for i in xrange(24):
+ for i in range(24):
self.assertAlmostEqual(expected3[i],resToTest.getIJ(0,i),14);
pass
#
loc=[2.27,1.3]
locs=f.getValueOnMulti(loc);
expected1=[6.0921164547752236, 7.1921164547752232, 8.2921164547752255]
- for i in xrange(3):
+ for i in range(3):
self.assertAlmostEqual(expected1[i],locs.getIJ(0,i),12);
pass
pass
loc=[0.64637931739890486, -0.16185896817550552, 0.22678966365273748]
locs=f.getValueOnMulti(loc);
expected1=[10.0844021968047]
- for i in xrange(1):
+ for i in range(1):
self.assertAlmostEqual(expected1[i],locs.getIJ(0,i),12);
pass
pass
locs=f.getValueOnMulti(loc);
self.assertEqual(5,locs.getNumberOfTuples());
self.assertEqual(3,locs.getNumberOfComponents());
- for j in xrange(15):
+ for j in range(15):
self.assertAlmostEqual(values1[j],locs.getIJ(0,j),12);
pass
# Testing ON_NODES
locs=f.getValueOnMulti(loc3);
self.assertEqual(4,locs.getNumberOfTuples());
self.assertEqual(3,locs.getNumberOfComponents());
- for i in xrange(12):
+ for i in range(12):
self.assertAlmostEqual(expected2[i],locs.getIJ(0,i),12);
pass
#
self.assertEqual(7,d2.getNumberOfTuples());
self.assertEqual(1,d2.getNumberOfComponents());
expected1=[0,1,3,4,7,8,9]
- for i in xrange(7):
+ for i in range(7):
self.assertEqual(expected1[i],d2.getIJ(0,i));
pass
d.rearrange(2);
self.assertEqual(5,d3.getNumberOfTuples());
self.assertEqual(1,d3.getNumberOfComponents());
expected2=[0,1,4,8,9]
- for i in xrange(5):
+ for i in range(5):
self.assertEqual(expected2[i],d3.getIJ(0,i));
pass
pass
d.computeOffsets();
self.assertEqual(6,d.getNumberOfTuples());
self.assertEqual(1,d.getNumberOfComponents());
- for i in xrange(6):
+ for i in range(6):
self.assertEqual(expected1[i],d.getIJ(0,i));
pass
pass
self.assertEqual(1,bary.getNumberOfTuples());
self.assertEqual(3,bary.getNumberOfComponents());
expected1=[0.,0.,1.]
- for i in xrange(3):
+ for i in range(3):
self.assertAlmostEqual(expected1[i],bary.getIJ(0,i),12);
pass
d1=DataArrayInt.New();
expected4=[[1,2,3,4,5,0],[7,6,11,10,9,8],[1,7,8,2],[2,8,9,3],[3,9,10,4],[4,10,11,5],[5,11,6,0],[0,6,7,1]];
expected2=[NORM_POLYGON, NORM_POLYGON, NORM_QUAD4, NORM_QUAD4, NORM_QUAD4, NORM_QUAD4, NORM_QUAD4, NORM_QUAD4];
expected3=[6,6,4,4,4,4,4,4]
- for i in xrange(8):
+ for i in range(8):
self.assertTrue(m2.getTypeOfCell(i)==expected2[i]);
v=m2.getNodeIdsOfCell(i);
self.assertTrue(len(v)==expected3[i]);
d1.transformWithIndArr(d);
self.assertEqual(12,d1.getNumberOfTuples());
self.assertEqual(1,d1.getNumberOfComponents());
- for i in xrange(12):
+ for i in range(12):
self.assertEqual(expected[i],d1.getIJ(i,0));
pass
#
d1.transformWithIndArr(tab1)
self.assertEqual(12,d1.getNumberOfTuples());
self.assertEqual(1,d1.getNumberOfComponents());
- for i in xrange(12):
+ for i in range(12):
self.assertEqual(expected[i],d1.getIJ(i,0));
pass
pass
da2=da.buildPermArrPerLevel();
self.assertEqual(12,da2.getNumberOfTuples());
self.assertEqual(1,da2.getNumberOfComponents());
- for i in xrange(12):
+ for i in range(12):
self.assertEqual(expected1[i],da2.getIJ(i,0));
pass
pass
self.assertEqual(4,da2.getNumberOfTuples());
self.assertEqual(3,da2.getNumberOfComponents());
expected1=[1,1,8,12,9,9,14,15,14,14,12,14]
- for i in xrange(12):
+ for i in range(12):
self.assertEqual(expected1[i],da2.getIJ(0,i));
pass
da1.substractEqual(da);
expected2=[3,5,0,-2,3,5,2,3,6,8,12,12]
- for i in xrange(12):
+ for i in range(12):
self.assertEqual(expected2[i],da1.getIJ(0,i));
pass
da1.rearrange(1); da1.iota(2); da1.rearrange(3);
da1.addEqual(da);
- for i in xrange(12):
+ for i in range(12):
self.assertEqual(expected1[i],da1.getIJ(0,i));
pass
da1.rearrange(1); da1.iota(2); da1.rearrange(3);
self.assertEqual(4,da2.getNumberOfTuples());
self.assertEqual(3,da2.getNumberOfComponents());
expected3=[-2,-6,16,35,18,14,48,54,40,33,0,13]
- for i in xrange(12):
+ for i in range(12):
self.assertEqual(expected3[i],da2.getIJ(0,i));
pass
da.divideEqual(da1);
self.assertEqual(4,da.getNumberOfTuples());
self.assertEqual(3,da.getNumberOfComponents());
expected4=[0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0]
- for i in xrange(12):
+ for i in range(12):
self.assertEqual(expected4[i],da.getIJ(0,i));
pass
da.setValues(arr1,4,3);
da1.multiplyEqual(da);
self.assertEqual(4,da1.getNumberOfTuples());
self.assertEqual(3,da1.getNumberOfComponents());
- for i in xrange(12):
+ for i in range(12):
self.assertEqual(expected3[i],da1.getIJ(0,i));
pass
da1.rearrange(1); da1.iota(2); da1.rearrange(3);
da2=DataArrayInt.Divide(da,da1);
self.assertEqual(4,da2.getNumberOfTuples());
self.assertEqual(3,da2.getNumberOfComponents());
- for i in xrange(12):
+ for i in range(12):
self.assertEqual(expected4[i],da2.getIJ(0,i));
pass
da1.applyInv(321);
self.assertEqual(4,da1.getNumberOfTuples());
self.assertEqual(3,da1.getNumberOfComponents());
expected5=[160,107,80,64,53,45,40,35,32,29,26,24]
- for i in xrange(12):
+ for i in range(12):
self.assertEqual(expected5[i],da1.getIJ(0,i));
pass
da1.applyDivideBy(2);
self.assertEqual(4,da1.getNumberOfTuples());
self.assertEqual(3,da1.getNumberOfComponents());
expected6=[80,53,40,32,26,22,20,17,16,14,13,12]
- for i in xrange(12):
+ for i in range(12):
self.assertEqual(expected6[i],da1.getIJ(0,i));
pass
expected7=[3,4,5,4,5,1,6,3,2,0,6,5]
da1.applyModulus(7);
- for i in xrange(12):
+ for i in range(12):
self.assertEqual(expected7[i],da1.getIJ(0,i));
pass
da1.applyLin(1,1);
expected8=[3,3,3,3,3,1,3,3,0,0,3,3]
da1.applyRModulus(3);
- for i in xrange(12):
+ for i in range(12):
self.assertEqual(expected8[i],da1.getIJ(0,i));
pass
pass
expected1=[1,32,29,23,41,36]
self.assertEqual(47,da0.getNumberOfTuples());
self.assertEqual(1,da0.getNumberOfComponents());
- for i in xrange(47):
+ for i in range(47):
self.assertEqual(expected0[i],da0.getIJ(0,i));
pass
self.assertEqual(6,da5.getNumberOfTuples());
self.assertEqual(1,da5.getNumberOfComponents());
- for i in xrange(6):
+ for i in range(6):
self.assertEqual(expected1[i],da5.getIJ(0,i));
pass
expected2=[0,1,2,3,4,0,5,6,7,4,8,9,1,7,10,11,12,13,14,5,15,16,17,8,18,19,20,10,21,22,23,2,13,24,25,21,16,26,27,12,19,28,29,15,22,30,31,18,36,26,28,30,24,37,32,33,34,35,38,36,39,40,41,42,37,38,43,44,45,46]
self.assertEqual(70,da1.getNumberOfTuples());
self.assertEqual(1,da1.getNumberOfComponents());
- for i in xrange(70):
+ for i in range(70):
self.assertEqual(expected2[i],da1.getIJ(0,i));
pass
expected3=[0,4,8,12,16,20,24,28,32,36,40,44,48,53,58,64,70]
self.assertEqual(17,da2.getNumberOfTuples());
self.assertEqual(1,da2.getNumberOfComponents());
- for i in xrange(17):
+ for i in range(17):
self.assertEqual(expected3[i],da2.getIJ(0,i));
pass
expected4=[0,2,4,6,7,9,11,12,14,16,17,19,20,22,24,25,27,29,30,32,34,35,37,39,40,42,43,45,46,48,49,51,52,53,54,55,56,58,60,62,63,64,65,66,67,68,69,70]
#expected4=[0,2,4,6,7,9,11,12,14,16,17,19,20,22,24,25,27,29,30,32,34,35,37,39,40,42,43,45,46,48,49,51,52,54,56,57,58,59,60,62,63,64,65,66,67,68,69,70];
self.assertEqual(48,da4.getNumberOfTuples());
self.assertEqual(1,da4.getNumberOfComponents());
- for i in xrange(48):
+ for i in range(48):
self.assertEqual(expected4[i],da4.getIJ(0,i));
pass
expected5=[0,1,0,3,0,7,0,1,2,1,4,1,2,3,2,5,2,3,6,3,4,9,4,8,4,5,10,5,9,5,6,11,6,10,6,7,8,7,11,7,8,12,8,9,12,9,10,12,10,11,12,11,13,13,13,13,12,14,13,15,14,15,14,14,14,14,15,15,15,15]
self.assertEqual(70,da3.getNumberOfTuples());
self.assertEqual(1,da3.getNumberOfComponents());
- for i in xrange(70):
+ for i in range(70):
self.assertEqual(expected5[i],da3.getIJ(0,i));
pass
pass
expected1=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,36,37,32,33,34,35,38,39,40,41,42,43,44,45,46]
self.assertEqual(47,da0.getNumberOfTuples());
self.assertEqual(1,da0.getNumberOfComponents());
- for i in xrange(47):
+ for i in range(47):
self.assertEqual(expected0[i],da0.getIJ(0,i));
pass
self.assertEqual(2,da1.getNumberOfTuples());
#
self.assertEqual(47,da2.getNumberOfTuples());
self.assertEqual(1,da2.getNumberOfComponents());
- for i in xrange(47):
+ for i in range(47):
self.assertEqual(expected1[i],da2.getIJ(0,i));
pass
pass
d3=d.transformWithIndArrR(d1);
self.assertEqual(6,d3.getNumberOfTuples());
self.assertEqual(1,d3.getNumberOfComponents());
- for i in xrange(6):
+ for i in range(6):
self.assertEqual(expected[i],d3.getIJ(i,0));
pass
#
d3=d.transformWithIndArrR(tab2)
self.assertEqual(6,d3.getNumberOfTuples());
self.assertEqual(1,d3.getNumberOfComponents());
- for i in xrange(6):
+ for i in range(6):
self.assertEqual(expected[i],d3.getIJ(i,0));
pass
pass
#
expected1=[1,1,0,0,0,1,1,0,1]
expected2=[2,1,0,3,2,3,4,1,0]
- for i in xrange(9):
+ for i in range(9):
self.assertEqual(expected1[i],e.getIJ(i,0));
self.assertEqual(expected2[i],f.getIJ(i,0));
pass
self.assertEqual(11,f.getNumberOfTuples());
self.assertEqual(1,f.getNumberOfComponents());
expected1=[0,1,2,6,7,8,9,10,11,12,13]
- for i in xrange(11):
+ for i in range(11):
self.assertEqual(expected1[i],f.getIJ(i,0));
pass
pass
d.computeOffsetsFull();
self.assertEqual(7,d.getNumberOfTuples());
self.assertEqual(1,d.getNumberOfComponents());
- for i in xrange(7):
+ for i in range(7):
self.assertEqual(expected1[i],d.getIJ(0,i));
pass
pass
self.assertTrue(f1.isEqual(f2,1e-12,1e-12));
#
pass
-
+
def testGetDistributionOfTypes1(self):
m=MEDCouplingDataForTest.build2DTargetMesh_1();
tab1=[2,0,1,3,4]
m3.setName(m.getName());
self.assertTrue(m.isEqual(m3,1e-12));
pass
-
+
def testChangeUnderlyingMeshWithCMesh1(self):
mesh=MEDCouplingCMesh.New();
coordsX=DataArrayDouble.New();
self.assertEqual(0,c.getNbOfElems());
self.assertEqual(1,cI.getNbOfElems());
self.assertEqual([0],cI.getValues())
-
+
array12=[0.]*(6*5)
da.setValues(array12,6,5) #bad NumberOfComponents
self.assertRaises(InterpKernelException, da.findCommonTuples, 1e-2);
expected1=[2.301,1.2,1.3,0.8]
dv=da.getDifferentValues(1e-2);
self.assertEqual(4,dv.getNbOfElems());
- for i in xrange(4):
+ for i in range(4):
self.assertAlmostEqual(expected1[i],dv.getIJ(i,0),14);
pass
#
dv=da.getDifferentValues(2e-1);
expected2=[2.301,1.3,0.8]
self.assertEqual(3,dv.getNbOfElems());
- for i in xrange(3):
+ for i in range(3):
self.assertAlmostEqual(expected2[i],dv.getIJ(i,0),14);
pass
pass
a.setValues(arr,6,1);
self.assertEqual(2,a.back());
a.reverse();
- for i in xrange(6):
+ for i in range(6):
self.assertEqual(arr[5-i],a.getIJ(i,0));
pass
a.setValues(arr[:-1],5,1);
a.reverse();
- for i in xrange(5):
+ for i in range(5):
self.assertEqual(arr[4-i],a.getIJ(i,0));
pass
#
b=DataArrayDouble.New();
b.setValues(arr2,6,1);
b.reverse();
- for i in xrange(6):
+ for i in range(6):
self.assertAlmostEqual(arr2[5-i],b.getIJ(i,0),14);
pass
b.setValues(arr2[:5],5,1);
self.assertAlmostEqual(9.,b.back(),14)
b.reverse();
- for i in xrange(5):
+ for i in range(5):
self.assertAlmostEqual(arr2[4-i],b.getIJ(i,0),14);
pass
pass
self.assertEqual(expected6,conn.getValues());
pass
+ def testIntersect2DMeshesTmp1(self):
+ m1c=MEDCouplingCMesh.New();
+ coordsX=DataArrayDouble.New();
+ arrX=[ -1., 1., 2., 4. ]
+ coordsX.setValues(arrX,4,1);
+ m1c.setCoordsAt(0,coordsX);
+ coordsY=DataArrayDouble.New();
+ arrY=[ -2., 2., 4., 8. ]
+ coordsY.setValues(arrY,4,1);
+ m1c.setCoordsAt(1,coordsY);
+ m1=m1c.buildUnstructured()
+ m1bis=m1.buildPartOfMySelf([3,4,5],False)
+ m2=m1.deepCopy()
+ m2=m2.buildPartOfMySelf([0,1,2],False)
+ m2.translate([0.5,0.5])
+ #
+ m3,d1,d2=MEDCouplingUMesh.Intersect2DMeshes(m1bis,m2,1e-10)
+ expected1=[0,0,1,1,1,2,2,2]
+ expected2=[0,-1,0,1,-1,1,2,-1]
+ self.assertEqual(8,d1.getNumberOfTuples());
+ self.assertEqual(8,d2.getNumberOfTuples());
+ self.assertEqual(8,m3.getNumberOfCells());
+ self.assertEqual(22,m3.getNumberOfNodes());
+ self.assertEqual(2,m3.getSpaceDimension());
+ self.assertEqual(expected1,d1.getValues());
+ self.assertEqual(expected2,d2.getValues());
+ expected3=[5,17,1,16,12,5,16,0,4,5,17,12,5,18,1,17,13,5,19,2,18,13,5,17,5,6,19,13,5,20,2,19,14,5,21,3,20,14,5,19,6,7,21,14]
+ expected4=[0,5,12,17,22,28,33,38,44]
+ expected5=[-1.0,2.0,1.0,2.0,2.0,2.0,4.0,2.0,-1.0,4.0,1.0,4.0,2.0,4.0,4.0,4.0,-0.5,-1.5,1.5,-1.5,2.5,-1.5,4.5,-1.5,-0.5,2.5,1.5,2.5,2.5,2.5,4.5,2.5,-0.5,2.0,1.0,2.5,1.5,2.0,2.0,2.5,2.5,2.0,4.0,2.5]
+ self.assertEqual(44,m3.getNodalConnectivity().getNumberOfTuples());
+ self.assertEqual(9,m3.getNodalConnectivityIndex().getNumberOfTuples());
+ self.assertEqual(expected3,m3.getNodalConnectivity().getValues());
+ self.assertEqual(expected4,m3.getNodalConnectivityIndex().getValues());
+ for i in range(44):
+ self.assertAlmostEqual(expected5[i],m3.getCoords().getIJ(0,i),12);
+ pass
+ pass
+
def testFindNodesOnLine1(self):
mesh=MEDCouplingDataForTest.build2DTargetMesh_1();
pt=[-0.3,-0.3]
self.assertEqual(expected1,res.getValues());
pass
+ def testIntersect2DMeshesTmp2(self):
+ m1c=MEDCouplingCMesh.New();
+ coordsX1=DataArrayDouble.New();
+ arrX1=[ 0., 1., 1.5, 2. ]
+ coordsX1.setValues(arrX1,4,1);
+ m1c.setCoordsAt(0,coordsX1);
+ coordsY1=DataArrayDouble.New();
+ arrY1=[ 0., 1.5, 3.]
+ coordsY1.setValues(arrY1,3,1);
+ m1c.setCoordsAt(1,coordsY1);
+ m1=m1c.buildUnstructured();
+ m2c=MEDCouplingCMesh.New();
+ coordsX2=DataArrayDouble.New();
+ arrX2=[ 0., 1., 2. ]
+ coordsX2.setValues(arrX2,3,1);
+ m2c.setCoordsAt(0,coordsX2);
+ coordsY2=DataArrayDouble.New();
+ arrY2=[ 0., 1., 3.]
+ coordsY2.setValues(arrY2,3,1);
+ m2c.setCoordsAt(1,coordsY2);
+ m2=m2c.buildUnstructured();
+ #
+ m3,d1,d2=MEDCouplingUMesh.Intersect2DMeshes(m1,m2,1e-10)
+ #
+ expected1=[0,0,1,1,2,2,3,4,5]
+ expected2=[0,2,1,3,1,3,2,3,3]
+ self.assertEqual(9,d1.getNumberOfTuples());
+ self.assertEqual(9,d2.getNumberOfTuples());
+ self.assertEqual(9,m3.getNumberOfCells());
+ self.assertEqual(22,m3.getNumberOfNodes());
+ self.assertEqual(2,m3.getSpaceDimension());
+ self.assertEqual(expected1,d1.getValues());
+ self.assertEqual(expected2,d2.getValues());
+ expected3=[5,16,13,12,15,5,15,4,5,16,5,21,2,13,16,5,16,5,6,21,5,17,14,2,21,5,21,6,7,17,5,4,18,19,5,5,5,19,10,6,5,6,10,20,7]
+ expected4=[0,5,10,15,20,25,30,35,40,45]
+ expected5=[0.0,0.0,1.0,0.0,1.5,0.0,2.0,0.0,0.0,1.5,1.0,1.5,1.5,1.5,2.0,1.5,0.0,3.0,1.0,3.0,1.5,3.0,2.0,3.0,0.0,0.0,1.0,0.0,2.0,0.0,0.0,1.0,1.0,1.0,2.0,1.0,0.0,3.0,1.0,3.0,2.0,3.0,1.5,1.0]
+ self.assertEqual(45,m3.getNodalConnectivity().getNumberOfTuples());
+ self.assertEqual(10,m3.getNodalConnectivityIndex().getNumberOfTuples());
+ self.assertEqual(expected3,m3.getNodalConnectivity().getValues());
+ self.assertEqual(expected4,m3.getNodalConnectivityIndex().getValues());
+ for i in range(44):
+ self.assertAlmostEqual(expected5[i],m3.getCoords().getIJ(0,i),12);
+ pass
+ pass
+
def testBuildPartOfMySelfSafe1(self):
mesh=MEDCouplingDataForTest.build2DTargetMesh_1()
self.assertRaises(InterpKernelException,mesh.buildPartOfMySelf,[0,-1,4,2],True)
self.assertRaises(InterpKernelException,mesh.buildPartOfMySelf,[0,4,5,4],True)
pass
+ def testIntersect2DMeshesTmp3(self):
+ m1Coords=[0.,0.,1.,0.,1.5,0.,0.,1.,0.,1.5,-1.,0.,-1.5,0.,0.,-1,0.,-1.5,0.5,0.,1.25,0.,0.70710678118654757,0.70710678118654757,1.0606601717798214,1.0606601717798214,0.,0.5,0.,1.25,-0.70710678118654757,0.70710678118654757,-1.0606601717798214,1.0606601717798214,-0.5,0.,-1.25,0.,-0.70710678118654757,-0.70710678118654757,-1.0606601717798214,-1.0606601717798214,0.,-0.5,0.,-1.25,0.70710678118654757,-0.70710678118654757,1.0606601717798214,-1.0606601717798214];
+ m1Conn=[0,3,1,13,11,9, 3,4,2,1,14,12,10,11, 5,3,0,15,13,17, 6,4,3,5,16,14,15,18, 5,0,7,17,21,19, 6,5,7,8,18,19,22,20, 0,1,7,9,23,21, 1,2,8,7,10,24,22,23];
+ m1=MEDCouplingUMesh.New();
+ m1.setMeshDimension(2);
+ m1.allocateCells(8);
+ m1.insertNextCell(NORM_TRI6,6,m1Conn[0:6]);
+ m1.insertNextCell(NORM_QUAD8,8,m1Conn[6:14]);
+ m1.insertNextCell(NORM_TRI6,6,m1Conn[14:20]);
+ m1.insertNextCell(NORM_QUAD8,8,m1Conn[20:28]);
+ m1.insertNextCell(NORM_TRI6,6,m1Conn[28:34]);
+ m1.insertNextCell(NORM_QUAD8,8,m1Conn[34:42]);
+ m1.insertNextCell(NORM_TRI6,6,m1Conn[42:48]);
+ m1.insertNextCell(NORM_QUAD8,8,m1Conn[48:56]);
+ m1.finishInsertingCells();
+ myCoords1=DataArrayDouble.New();
+ myCoords1.setValues(m1Coords,25,2);
+ m1.setCoords(myCoords1);
+ #
+ m2Coords=[0.,0.,1.1,0.,1.1,1.,0.,1.,1.7,0.,1.7,1.,-1.1,1.,-1.1,0.,-1.7,0.,-1.7,1.,-1.7,-1,-1.1,-1.,0.,-1.,1.1,-1,1.7,-1.]
+ m2Conn=[0,3,2,1, 1,2,5,4, 7,6,3,0, 8,9,6,7, 7,0,12,11, 8,7,11,10, 0,1,13,12, 1,4,14,13]
+ m2=MEDCouplingUMesh.New();
+ m2.setMeshDimension(2);
+ m2.allocateCells(8);
+ for i in range(8):
+ m2.insertNextCell(NORM_QUAD4,4,m2Conn[4*i:4*(i+1)])
+ pass
+ m2.finishInsertingCells();
+ myCoords2=DataArrayDouble.New();
+ myCoords2.setValues(m2Coords,15,2);
+ m2.setCoords(myCoords2);
+ #
+ m3,d1,d2=MEDCouplingUMesh.Intersect2DMeshes(m1,m2,1e-10)
+ m3.unPolyze()
+ #
+ expected1=[0,1,1,1,2,3,3,3,4,5,5,5,6,7,7,7]
+ expected2=[0,0,1,-1,2,2,3,-1,4,4,5,-1,6,6,7,-1]
+ self.assertEqual(16,d1.getNumberOfTuples());
+ self.assertEqual(16,d2.getNumberOfTuples());
+ self.assertEqual(16,m3.getNumberOfCells());
+ self.assertEqual(104,m3.getNumberOfNodes());
+ self.assertEqual(2,m3.getSpaceDimension());
+ self.assertEqual(expected1,d1.getValues());
+ self.assertEqual(expected2,d2.getValues());
+ expected3=[6,28,1,25,44,45,46,8,26,1,28,27,47,48,49,50,8,40,2,26,27,51,52,53,54,8,28,4,40,27,55,56,57,58,6,28,25,5,59,60,61,8,28,5,32,31,62,63,64,65,8,32,6,41,31,66,67,68,69,8,41,4,28,31,70,71,72,73,6,25,37,5,74,75,76,8,32,5,37,36,77,78,79,80,8,42,6,32,36,81,82,83,84,8,37,8,42,36,85,86,87,88,6,1,37,25,89,90,91,8,37,1,26,38,92,93,94,95,8,26,2,43,38,96,97,98,99,8,43,8,37,38,100,101,102,103]
+ expected4=[0,7,16,25,34,41,50,59,68,75,84,93,102,109,118,127,136]
+ expected5=[0.,0.,1.,0.,1.5,0.,0.,1.,0.,1.5,-1.,0.,-1.5,0.,0.,-1.,0.,-1.5,0.5,0.,1.25,0.,0.7071067811865476,0.7071067811865476,1.0606601717798214,1.0606601717798214,0.,0.5,0.,1.25,-0.7071067811865476,0.7071067811865476,-1.0606601717798214,1.0606601717798214,-0.5,0.,-1.25,0.,-0.7071067811865476,-0.7071067811865476,-1.0606601717798214,-1.0606601717798214,0.,-0.5,0.,-1.25,0.7071067811865476,-0.7071067811865476,1.0606601717798214,-1.0606601717798214,0.,0.,1.1,0.,1.1,1.,0.,1.,1.7,0.,1.7,1.,-1.1,1.,-1.1,0.,-1.7,0.,-1.7,1.,-1.7,-1.,-1.1,-1.,0.,-1.,1.1,-1.,1.7,-1.,1.118033988749895,1.,-1.118033988749895,1.,-1.118033988749895,-1.,1.118033988749895,-1.,0.7071067811865477,0.7071067811865476,0.5,0.,0.,0.5,1.05,0.,0.7071067811865475,0.7071067811865477,0.55,1.,1.1,0.5,1.4012585384440737,0.535233134659635,1.3,0.,1.1,0.5,1.1090169943749475,1.,0.,1.25,0.6123724356957946,1.369306393762915,1.1090169943749475,1.,0.55,1.,0.,0.5,-0.5,0.,-0.7071067811865477,0.7071067811865476,-0.7071067811865475,0.7071067811865477,-1.05,0.,-1.1,0.5,-0.55,1.,-1.3,0.,-1.4012585384440737,0.5352331346596344,-1.1090169943749475,1.,-1.1,0.5,-0.6123724356957941,1.3693063937629155,0.,1.25,-0.55,1.,-1.1090169943749475,1.,0.,-0.5,-0.7071067811865475,-0.7071067811865477,-0.5,0.,-1.05,0.,-0.7071067811865478,-0.7071067811865475,-0.55,-1.,-1.1,-0.5,-1.4012585384440734,-0.5352331346596354,-1.3,0.,-1.1,-0.5,-1.1090169943749475,-1.,0.,-1.25,-0.6123724356957945,-1.369306393762915,-1.1090169943749475,-1.,-0.55,-1.,0.7071067811865475,-0.7071067811865477,0.,-0.5,0.5,0.,0.7071067811865477,-0.7071067811865475,1.05,0.,1.1,-0.5,0.55,-1.,1.3,0.,1.4012585384440737,-0.535233134659635,1.1090169943749475,-1.,1.1,-0.5,0.6123724356957946,-1.369306393762915,0.,-1.25,0.55,-1.,1.1090169943749475,-1.0]
+ self.assertEqual(136,m3.getNodalConnectivity().getNumberOfTuples());
+ self.assertEqual(17,m3.getNodalConnectivityIndex().getNumberOfTuples());
+ self.assertEqual(expected3,m3.getNodalConnectivity().getValues());
+ self.assertEqual(expected4,m3.getNodalConnectivityIndex().getValues());
+ for i in range(208):
+ self.assertAlmostEqual(expected5[i],m3.getCoords().getIJ(0,i),12);
+ pass
+ pass
+
def testUMeshTessellate2D1(self):
m1Coords=[0.,0.,1.,0.,1.5,0.,0.,1.,0.,1.5,-1.,0.,-1.5,0.,0.,-1,0.,-1.5,0.5,0.,1.25,0.,0.70710678118654757,0.70710678118654757,1.0606601717798214,1.0606601717798214,0.,0.5,0.,1.25,-0.70710678118654757,0.70710678118654757,-1.0606601717798214,1.0606601717798214,-0.5,0.,-1.25,0.,-0.70710678118654757,-0.70710678118654757,-1.0606601717798214,-1.0606601717798214,0.,-0.5,0.,-1.25,0.70710678118654757,-0.70710678118654757,1.0606601717798214,-1.0606601717798214];
m1Conn=[0,3,1,13,11,9, 3,4,2,1,14,12,10,11, 5,3,0,15,13,17, 6,4,3,5,16,14,15,18, 5,0,7,17,21,19, 6,5,7,8,18,19,22,20, 0,1,7,9,23,21, 1,2,8,7,10,24,22,23];
expected3=[5,0,3,25,26,1,5,3,4,27,28,2,1,26,25,5,5,29,30,3,0,5,6,31,32,4,3,30,29,5,5,5,0,7,33,34,5,6,5,34,33,7,8,35,36,5,0,1,37,38,7,5,1,2,39,40,8,7,38,37]
expected4=[0,6,15,21,30,36,45,51,60]
expected5=[0.,0.,1.,0.,1.5,0.,0.,1.,0.,1.5,-1.,0.,-1.5,0.,0.,-1.,0.,-1.5,0.5,0.,1.25,0.,0.7071067811865476,0.7071067811865476,1.0606601717798214,1.0606601717798214,0.,0.5,0.,1.25,-0.7071067811865476,0.7071067811865476,-1.0606601717798214,1.0606601717798214,-0.5,0.,-1.25,0.,-0.7071067811865476,-0.7071067811865476,-1.0606601717798214,-1.0606601717798214,0.,-0.5,0.,-1.25,0.7071067811865476,-0.7071067811865476,1.0606601717798214,-1.0606601717798214,0.479425538604203,0.8775825618903728,0.8414709848078964,0.54030230586814,0.7191383079063044,1.3163738428355591,1.2622064772118446,0.8104534588022099,-0.877582561890373,0.4794255386042027,-0.5403023058681399,0.8414709848078964,-1.3163738428355596,0.7191383079063038,-0.8104534588022098,1.2622064772118446,-0.4794255386042031,-0.8775825618903728,-0.8414709848078965,-0.5403023058681399,-0.7191383079063045,-1.3163738428355591,-1.2622064772118449,-0.8104534588022098,0.8775825618903729,-0.47942553860420295,0.54030230586814,-0.8414709848078964,1.3163738428355594,-0.7191383079063043,0.8104534588022099,-1.2622064772118446]
- for i in xrange(82):
+ for i in range(82):
self.assertAlmostEqual(expected5[i],m12.getCoords().getIJ(0,i),12);
pass
self.assertEqual(60,m12.getNodalConnectivity().getNumberOfTuples());
myCoords = DataArrayDouble.New(mcoords, 3, 2)
m1.setCoords(myCoords)
-
+
m2 = m1.deepCopy()
m2.tessellate2D(0.1)
# If the following raises, the test will fail automatically:
m2.checkConsistency(0.0) # eps param not used
+ def testIntersect2DMeshesTmp4(self):
+ m1Coords=[0.,0.,1.,0.,1.5,0.,0.,1.,0.,1.5,-1.,0.,-1.5,0.,0.,-1,0.,-1.5,0.5,0.,1.25,0.,0.70710678118654757,0.70710678118654757,1.0606601717798214,1.0606601717798214,0.,0.5,0.,1.25,-0.70710678118654757,0.70710678118654757,-1.0606601717798214,1.0606601717798214,-0.5,0.,-1.25,0.,-0.70710678118654757,-0.70710678118654757,-1.0606601717798214,-1.0606601717798214,0.,-0.5,0.,-1.25,0.70710678118654757,-0.70710678118654757,1.0606601717798214,-1.0606601717798214];
+ m1Conn=[0,3,1,13,11,9, 3,4,2,1,14,12,10,11, 5,3,0,15,13,17, 6,4,3,5,16,14,15,18, 5,0,7,17,21,19, 6,5,7,8,18,19,22,20, 0,1,7,9,23,21, 1,2,8,7,10,24,22,23];
+ m1=MEDCouplingUMesh.New();
+ m1.setMeshDimension(2);
+ m1.allocateCells(8);
+ m1.insertNextCell(NORM_TRI6,6,m1Conn[0:6]);
+ m1.insertNextCell(NORM_QUAD8,8,m1Conn[6:14]);
+ m1.insertNextCell(NORM_TRI6,6,m1Conn[14:20]);
+ m1.insertNextCell(NORM_QUAD8,8,m1Conn[20:28]);
+ m1.insertNextCell(NORM_TRI6,6,m1Conn[28:34]);
+ m1.insertNextCell(NORM_QUAD8,8,m1Conn[34:42]);
+ m1.insertNextCell(NORM_TRI6,6,m1Conn[42:48]);
+ m1.insertNextCell(NORM_QUAD8,8,m1Conn[48:56]);
+ m1.finishInsertingCells();
+ myCoords1=DataArrayDouble.New();
+ myCoords1.setValues(m1Coords,25,2);
+ m1.setCoords(myCoords1);
+ #
+ m2Coords=[0.,0.,1.1,0.,1.1,1.,0.,1.,1.7,0.,1.7,1.,-1.1,1.,-1.1,0.,-1.7,0.,-1.7,1.,-1.7,-1,-1.1,-1.,0.,-1.,1.1,-1,1.7,-1.]
+ m2Conn=[0,3,2,1, 1,2,5,4, 7,6,3,0, 8,9,6,7, 7,0,12,11, 8,7,11,10, 0,1,13,12, 1,4,14,13]
+ m2=MEDCouplingUMesh.New();
+ m2.setMeshDimension(2);
+ m2.allocateCells(8);
+ for i in range(8):
+ m2.insertNextCell(NORM_QUAD4,4,m2Conn[4*i:4*(i+1)])
+ pass
+ m2.finishInsertingCells();
+ myCoords2=DataArrayDouble.New();
+ myCoords2.setValues(m2Coords,15,2);
+ m2.setCoords(myCoords2);
+ #
+ m3,d1,d2=MEDCouplingUMesh.Intersect2DMeshes(m2,m1,1e-10)
+ m3.unPolyze()
+ #
+ expected1=[0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7]
+ expected2=[0,1,1,-1,2,3,3,-1,4,5,5,-1,6,7,7,-1]
+ self.assertEqual(16,d1.getNumberOfTuples());
+ self.assertEqual(16,d2.getNumberOfTuples());
+ self.assertEqual(16,m3.getNumberOfCells());
+ self.assertEqual(104,m3.getNumberOfNodes());
+ self.assertEqual(2,m3.getSpaceDimension());
+ self.assertEqual(expected1,d1.getValues());
+ self.assertEqual(expected2,d2.getValues());
+ expected3=[6,16,15,18,44,45,46,8,18,2,1,16,47,48,49,50,8,17,1,2,40,51,52,53,54,8,40,5,4,17,55,56,57,58,6,18,15,20,59,60,61,8,20,7,6,18,62,63,64,65,8,41,6,7,21,66,67,68,69,8,21,8,9,41,70,71,72,73,6,20,15,22,74,75,76,8,22,11,7,20,77,78,79,80,8,21,7,11,42,81,82,83,84,8,42,10,8,21,85,86,87,88,6,22,15,16,89,90,91,8,16,1,13,22,92,93,94,95,8,43,13,1,17,96,97,98,99,8,17,4,14,43,100,101,102,103]
+ expected4=[0,7,16,25,34,41,50,59,68,75,84,93,102,109,118,127,136]
+ expected5=[0.,0.,1.1, 0.,1.1,1.,0.,1.,1.7,0.,1.7,1.,-1.1,1.,-1.1,0.,-1.7,0.,-1.7,1.,-1.7,-1.,-1.1,-1.,0.,-1.,1.1,-1.,1.7,-1.,0.,0.,1.,0.,1.5,0.,0.,1.,0.,1.5,-1.,0.,-1.5,0.,0.,-1.,0.,-1.5,0.5,0.,1.25,0.,0.7071067811865476,0.7071067811865476,1.0606601717798214,1.0606601717798214,0.,0.5,0.,1.25,-0.7071067811865476,0.7071067811865476,-1.0606601717798214,1.0606601717798214,-0.5,0.,-1.25,0.,-0.7071067811865476,-0.7071067811865476,-1.0606601717798214,-1.0606601717798214,0.,-0.5,0.,-1.25,0.7071067811865476,-0.7071067811865476,1.0606601717798214,-1.0606601717798214,1.1180339887498951,1.,-1.1180339887498951,1.,-1.1180339887498951,-1.,1.1180339887498951,-1.,0.5,0.,0.,0.5,0.7071067811865477,0.7071067811865476,0.55,1.,1.1,0.5,1.05,0.,0.7071067811865477,0.7071067811865475,1.3,0.,1.1,0.5,1.1090169943749475,1.,1.4012585384440737,0.535233134659635,1.4090169943749475,1.,1.7,0.5,1.6,0.,1.4012585384440737,0.535233134659635,0.,0.5,-0.5,0.,-0.7071067811865477,0.7071067811865476,-1.05,0.,-1.1,0.5,-0.55,1.,-0.7071067811865478,0.7071067811865475,-1.1090169943749475,1.,-1.1,0.5,-1.3,0.,-1.4012585384440737,0.5352331346596344,-1.6,0.,-1.7,0.5,-1.4090169943749475,1.,-1.4012585384440737,0.5352331346596344,-0.5,0.,0.,-0.5,-0.7071067811865475,-0.7071067811865477,-0.55,-1.,-1.1,-0.5,-1.05,0.,-0.7071067811865475,-0.7071067811865477,-1.3,0.,-1.1,-0.5,-1.1090169943749475,-1.,-1.4012585384440734,-0.5352331346596354,-1.4090169943749475,-1.,-1.7,-0.5,-1.6,0.,-1.4012585384440732,-0.5352331346596354,0.,-0.5,0.5,0.,0.7071067811865475,-0.7071067811865477,1.05,0.,1.1,-0.5,0.55,-1.,0.7071067811865475,-0.7071067811865477,1.1090169943749475,-1.,1.1,-0.5,1.3,0.,1.4012585384440737,-0.535233134659635,1.6,0.,1.7,-0.5,1.4090169943749475,-1.,1.4012585384440737,-0.535233134659635]
+ self.assertEqual(136,m3.getNodalConnectivity().getNumberOfTuples());
+ self.assertEqual(17,m3.getNodalConnectivityIndex().getNumberOfTuples());
+ self.assertEqual(expected3,m3.getNodalConnectivity().getValues());
+ self.assertEqual(expected4,m3.getNodalConnectivityIndex().getValues());
+ for i in range(208):
+ self.assertAlmostEqual(expected5[i],m3.getCoords().getIJ(0,i),12);
+ pass
+ pass
+
def testGetCellIdsCrossingPlane1(self):
mesh3D,mesh2D=MEDCouplingDataForTest.build3DExtrudedUMesh_1();
vec=[-0.07,1.,0.07]
self.assertEqual(expected1,ids.getValues());
self.assertEqual(expected2,slice1.getNodalConnectivity().getValues());
self.assertEqual(expected3,slice1.getNodalConnectivityIndex().getValues());
- for i in xrange(171):
+ for i in range(171):
self.assertAlmostEqual(expected4[i],slice1.getCoords().getIJ(0,i),12);
pass
# 2nd slice based on already existing nodes of mesh3D.
self.assertEqual(expected1,ids.getValues());
self.assertEqual(expected5,slice1.getNodalConnectivity().getValues());
self.assertEqual(expected6,slice1.getNodalConnectivityIndex().getValues());
- for i in xrange(180):
+ for i in range(180):
self.assertAlmostEqual(expected7[i],slice1.getCoords().getIJ(0,i),12);
pass
# 3rd slice based on shared face of mesh3D.
self.assertEqual(expected8,ids.getValues());
self.assertEqual(expected9,slice1.getNodalConnectivity().getValues());
self.assertEqual(expected10,slice1.getNodalConnectivityIndex().getValues());
- for i in xrange(135):
+ for i in range(135):
self.assertAlmostEqual(expected11[i],slice1.getCoords().getIJ(0,i),12);
pass
pass
self.assertEqual(expected1,ids.getValues());
self.assertEqual(expected2,slice1.getNodalConnectivity().getValues());
self.assertEqual(expected3,slice1.getNodalConnectivityIndex().getValues());
- for i in xrange(171):
+ for i in range(171):
self.assertAlmostEqual(expected4[i],slice1.getCoords().getIJ(0,i),12);
pass
#
self.assertEqual(expected5,ids.getValues());
self.assertEqual(expected6,slice1.getNodalConnectivity().getValues());
self.assertEqual(expected7,slice1.getNodalConnectivityIndex().getValues());
- for i in xrange(135):
+ for i in range(135):
self.assertAlmostEqual(expected8[i],slice1.getCoords().getIJ(0,i),12);
pass
pass
expected1=[1.,11.,2.,12.,4.,14.,6.,16.,7.,17.]
self.assertEqual(5,tmp.getNumberOfTuples());
self.assertEqual(2,tmp.getNumberOfComponents());
- for i in xrange(10):
+ for i in range(10):
self.assertAlmostEqual(expected1[i],tmp.getIJ(0,i),14);
pass
p=[(0,2),(0,2),(5,6)]
expected2=[1.,11.,2.,12.,1.,11.,2.,12.,6.,16.]
self.assertEqual(5,tmp.getNumberOfTuples());
self.assertEqual(2,tmp.getNumberOfComponents());
- for i in xrange(10):
+ for i in range(10):
self.assertAlmostEqual(expected2[i],tmp.getIJ(0,i),14);
pass
p=[(0,2),(-1,2),(5,6)]
dac=da.deepCopy();
dac.setContigPartOfSelectedValuesSlice(1,da2,2,4,1);
expected3=[1.,11.,0.,30.,11.,41.,4.,14.,5.,15.,6.,16.,7.,17.]
- for i in xrange(14):
+ for i in range(14):
self.assertAlmostEqual(expected3[i],dac.getIJ(0,i),14);
pass
#
self.assertRaises(InterpKernelException,dac.setContigPartOfSelectedValuesSlice,3,da2,5,0,1);
dac.setContigPartOfSelectedValuesSlice(3,da2,1,5,1);
expected4=[1.,11.,2.,12.,3.,13.,9.,39.,0.,30.,11.,41.,12.,42.]
- for i in xrange(14):
+ for i in range(14):
self.assertAlmostEqual(expected4[i],dac.getIJ(0,i),14);
pass
#
ids.setIJ(0,0,2); ids.setIJ(1,0,0); ids.setIJ(2,0,4);
dac.setContigPartOfSelectedValues(2,da2,ids);
expected5=[1.,11.,2.,12.,0.,30.,8.,38.,12.,42.,6.,16.,7.,17.]
- for i in xrange(14):
+ for i in range(14):
self.assertAlmostEqual(expected5[i],dac.getIJ(0,i),14);
pass
#
dac=da.deepCopy();
dac.setContigPartOfSelectedValues(4,da2,ids);
expected6=[1.,11.,2.,12.,3.,13.,4.,14.,0.,30.,0.,30.,9.,39.]
- for i in xrange(14):
+ for i in range(14):
self.assertAlmostEqual(expected6[i],dac.getIJ(0,i),14);
pass
pass
expected1=[1,11,2,12,4,14,6,16,7,17]
self.assertEqual(5,tmp.getNumberOfTuples());
self.assertEqual(2,tmp.getNumberOfComponents());
- for i in xrange(10):
+ for i in range(10):
self.assertEqual(expected1[i],tmp.getIJ(0,i));
pass
p=[(0,2),(0,2),(5,6)]
expected2=[1,11,2,12,1,11,2,12,6,16]
self.assertEqual(5,tmp.getNumberOfTuples());
self.assertEqual(2,tmp.getNumberOfComponents());
- for i in xrange(10):
+ for i in range(10):
self.assertEqual(expected2[i],tmp.getIJ(0,i));
pass
p=[(0,2),(-1,2),(5,6)]
dac=da.deepCopy();
dac.setContigPartOfSelectedValuesSlice(1,da2,2,4,1);
expected3=[1,11,0,30,11,41,4,14,5,15,6,16,7,17]
- for i in xrange(14):
+ for i in range(14):
self.assertEqual(expected3[i],dac.getIJ(0,i));
pass
#
self.assertRaises(InterpKernelException,dac.setContigPartOfSelectedValuesSlice,3,da2,5,0,1);
dac.setContigPartOfSelectedValuesSlice(3,da2,1,5,1);
expected4=[1,11,2,12,3,13,9,39,0,30,11,41,12,42]
- for i in xrange(14):
+ for i in range(14):
self.assertEqual(expected4[i],dac.getIJ(0,i));
pass
#
ids.setIJ(0,0,2); ids.setIJ(1,0,0); ids.setIJ(2,0,4);
dac.setContigPartOfSelectedValues(2,da2,ids);
expected5=[1,11,2,12,0,30,8,38,12,42,6,16,7,17]
- for i in xrange(14):
+ for i in range(14):
self.assertEqual(expected5[i],dac.getIJ(0,i));
pass
#
dac=da.deepCopy();
dac.setContigPartOfSelectedValues(4,da2,ids);
expected6=[1,11,2,12,3,13,4,14,0,30,0,30,9,39]
- for i in xrange(14):
+ for i in range(14):
self.assertEqual(expected6[i],dac.getIJ(0,i));
pass
pass
m1.setCoords(myCoords1);
#
vec1=[0.,0.,1.]
- for i in xrange(18):
+ for i in range(18):
vec2=[3.*cos(pi/9.*i),3.*sin(pi/9.*i)];
m1Cpy=m1.deepCopy();
m1Cpy.translate(vec2);
d2=d1.convertToIntArr();
#
d1.abs();
- for i in xrange(12):
+ for i in range(12):
self.assertAlmostEqual(expected1[i],d1.getIJ(0,i),14);
pass
#
expected2=[2,3,5,6,7,8,9,10,11,12,13,15]
d2.abs();
- for i in xrange(12):
+ for i in range(12):
self.assertEqual(expected2[i],d2.getIJ(0,i));
pass
#
self.assertEqual(5,arr1.getNumberOfTuples());
self.assertEqual(3,arr1.getNumberOfComponents());
expected1=[5.7,57.,570.,6.5,65.,650.,5.,50.,500.,8.,80.,800.,7.,70.,700.]
- for i in xrange(15):
+ for i in range(15):
self.assertAlmostEqual(expected1[i],arr1.getIJ(0,i),14);
pass
pass
m1c.setCoordsAt(0,coordsX);
expected1=[[0,1],[1,2],[2,3],[3,4]]
self.assertEqual(4,m1c.getNumberOfCells())
- for i in xrange(m1c.getNumberOfCells()):
+ for i in range(m1c.getNumberOfCells()):
self.assertEqual(expected1[i],m1c.getNodeIdsOfCell(i))
pass
# test in 2D
self.assertEqual(12,m1c.getNumberOfCells())
self.assertEqual(20,m1c.getNumberOfNodes())
expected2=[[0,1,6,5],[1,2,7,6],[2,3,8,7],[3,4,9,8],[5,6,11,10],[6,7,12,11],[7,8,13,12],[8,9,14,13],[10,11,16,15],[11,12,17,16],[12,13,18,17],[13,14,19,18]]
- for i in xrange(m1c.getNumberOfCells()):
+ for i in range(m1c.getNumberOfCells()):
self.assertEqual(expected2[i],m1c.getNodeIdsOfCell(i))
pass
# test in 3D
self.assertEqual(60,m1c.getNumberOfNodes())
expected3=[[0,1,6,5,20,21,26,25],[1,2,7,6,21,22,27,26],[2,3,8,7,22,23,28,27],[3,4,9,8,23,24,29,28],[5,6,11,10,25,26,31,30],[6,7,12,11,26,27,32,31],[7,8,13,12,27,28,33,32],[8,9,14,13,28,29,34,33],[10,11,16,15,30,31,36,35],[11,12,17,16,31,32,37,36],[12,13,18,17,32,33,38,37],[13,14,19,18,33,34,39,38],[20,21,26,25,40,41,46,45],[21,22,27,26,41,42,47,46],[22,23,28,27,42,43,48,47],[23,24,29,28,43,44,49,48],[25,26,31,30,45,46,51,50],[26,27,32,31,46,47,52,51],[27,28,33,32,47,48,53,52],[28,29,34,33,48,49,54,53],[30,31,36,35,50,51,56,55],[31,32,37,36,51,52,57,56],[32,33,38,37,52,53,58,57],[33,34,39,38,53,54,59,58]]
self.assertEqual(24,m1c.getNumberOfCells())
- for i in xrange(m1c.getNumberOfCells()):
+ for i in range(m1c.getNumberOfCells()):
self.assertEqual(expected3[i],m1c.getNodeIdsOfCell(i))
pass
pass
-
+
pass
if __name__ == '__main__':
from math import pi,e,sqrt,cos,sin
from datetime import datetime
from MEDCouplingDataForTest import MEDCouplingDataForTest
-import rlcompleter,readline # this line has to be here, to ensure a usability of MEDCoupling/MEDLoader. B4 removing it please notify to anthony.geay@cea.fr
+import rlcompleter,readline # this line has to be here, to ensure a usability of MEDCoupling/MEDLoader. B4 removing it please notify to anthony.geay@edf.fr
from sys import platform
def checkFreeMemory(size):
dic['free'] = tmp
dic['used'] = int(dic['total']) - int(dic['free'])
ret = dic['free'] > size
- #TODO: extend this method for Windows OS
+ #TODO: extend this method for Windows OS
return ret
class MEDCouplingBasicsTest4(unittest.TestCase):
def testSwigDADOp4(self):
- da=DataArrayDouble.New(range(6,30),12,2)
+ da = DataArrayDouble.New(list(range(6, 30)), 12, 2)
self.assertEqual(12,da.getNumberOfTuples());
self.assertEqual(2,da.getNumberOfComponents());
- for i in xrange(24):
+ for i in range(24):
self.assertAlmostEqual(da.getIJ(0,i),float(i+6),13)
pass
# operator transpose
da.transpose()
self.assertEqual(2,da.getNumberOfTuples());
self.assertEqual(12,da.getNumberOfComponents());
- for i in xrange(24):
+ for i in range(24):
self.assertAlmostEqual(da.getIJ(0,i),float(i+6),13)
pass
da.transpose()
da2=DataArrayDouble.New(12,1)
da2.iota(0.)
dabis=-da
- for i in xrange(24):
+ for i in range(24):
self.assertAlmostEqual(dabis.getIJ(0,i),-float(i+6),13)
pass
# operator+=
da+=da2
expected1=[6.,7.,9.,10.,12.,13.,15.,16.,18.,19.,21.,22.,24.,25.,27.,28.,30.,31.,33.,34.,36.,37.,39.,40.]
- for i in xrange(24):
+ for i in range(24):
self.assertAlmostEqual(da.getIJ(0,i),expected1[i],13)
pass
da=-dabis
expected2=[106.,108.,108.,110.,110.,112.,112.,114.,114.,116.,116.,118.,118.,120.,120.,122.,122.,124.,124.,126.,126.,128.,128.,130.]
self.assertEqual(12,da.getNumberOfTuples());
self.assertEqual(2,da.getNumberOfComponents());
- for i in xrange(24):
+ for i in range(24):
self.assertAlmostEqual(da.getIJ(0,i),expected2[i],13)
pass
for pos,elt in enumerate(dabis):
self.assertAlmostEqual(li[0],100.,13) ; self.assertAlmostEqual(li[1],101.,13)
pass
# operator-=
- da=DataArrayDouble.New(range(6,30),12,2)
- da2=DataArrayDouble.New(range(12),12,1)
+ da = DataArrayDouble.New(list(range(6, 30)), 12, 2)
+ da2 = DataArrayDouble.New(list(range(12)), 12, 1)
dabis=-da
da-=da2
expected1=[6.,7.,7.,8.,8.,9.,9.,10.,10.,11.,11.,12.,12.,13.,13.,14.,14.,15.,15.,16.,16.,17.,17.,18.]
- for i in xrange(24):
+ for i in range(24):
self.assertAlmostEqual(da.getIJ(0,i),expected1[i],13)
pass
da=-dabis
expected2=[-94.,-94.,-92.,-92.,-90.,-90.,-88.,-88.,-86.,-86.,-84.,-84.,-82.,-82.,-80.,-80.,-78.,-78.,-76.,-76.,-74.,-74.,-72.,-72.]
self.assertEqual(12,da.getNumberOfTuples());
self.assertEqual(2,da.getNumberOfComponents());
- for i in xrange(24):
+ for i in range(24):
self.assertAlmostEqual(da.getIJ(0,i),expected2[i],13)
pass
for pos,elt in enumerate(dabis):
self.assertEqual(12,da.getNumberOfTuples());
self.assertEqual(2,da.getNumberOfComponents());
expected3=[-88.,-87.,-84.,-83.,-80.,-79.,-76.,-75.,-72.,-71.,-68.,-67.,-64.,-63.,-60.,-59.,-56.,-55.,-52.,-51.,-48.,-47.,-44.,-43.]
- for i in xrange(24):
+ for i in range(24):
self.assertAlmostEqual(da.getIJ(0,i),expected3[i],13)
pass
# operator*=
- da=DataArrayDouble.New(range(6,30),12,2)
- da2=DataArrayDouble.New(range(12),12,1)
+ da = DataArrayDouble.New(list(range(6, 30)), 12, 2)
+ da2 = DataArrayDouble.New(list(range(12)), 12, 1)
dabis=-da
da*=da2
expected1=[0.,0.,8.,9.,20.,22.,36.,39.,56.,60.,80.,85.,108.,114.,140.,147.,176.,184.,216.,225.,260.,270.,308.,319.]
- for i in xrange(24):
+ for i in range(24):
self.assertAlmostEqual(da.getIJ(0,i),expected1[i],13)
pass
da=-dabis
expected2=[600.,707.,800.,909.,1000.,1111.,1200.,1313.,1400.,1515.,1600.,1717.,1800.,1919.,2000.,2121.,2200.,2323.,2400.,2525.,2600.,2727.,2800.,2929.]
self.assertEqual(12,da.getNumberOfTuples());
self.assertEqual(2,da.getNumberOfComponents());
- for i in xrange(24):
+ for i in range(24):
self.assertAlmostEqual(da.getIJ(0,i),expected2[i],13)
pass
for pos,elt in enumerate(dabis):
self.assertEqual(12,da.getNumberOfTuples());
self.assertEqual(2,da.getNumberOfComponents());
expected3=[-3600.,-4949.,-6400.,-8181.,-10000.,-12221.,-14400.,-17069.,-19600.,-22725.,-25600.,-29189.,-32400.,-36461.,-40000.,-44541.,-48400.,-53429.,-57600.,-63125.,-67600.,-73629.,-78400.,-84941.0]
- for i in xrange(24):
+ for i in range(24):
self.assertAlmostEqual(da.getIJ(0,i),expected3[i],13)
pass
# operator/=
- da=DataArrayDouble.New(range(6,30),12,2)
- da2=DataArrayDouble.New(range(1,13),12,1)
+ da = DataArrayDouble.New(list(range(6, 30)), 12, 2)
+ da2 = DataArrayDouble.New(list(range(1, 13)), 12, 1)
dabis=-da
da/=da2
expected1=[6.0,7.0,4.0,4.5,3.3333333333333335,3.6666666666666665,3.0,3.25,2.8,3.0,2.6666666666666665,2.8333333333333335,2.5714285714285716,2.7142857142857144,2.5,2.625,2.4444444444444446,2.5555555555555554,2.4,2.5,2.3636363636363638,2.4545454545454546,2.3333333333333335,2.4166666666666665]
- for i in xrange(24):
+ for i in range(24):
self.assertAlmostEqual(da.getIJ(0,i),expected1[i],13)
pass
da=-dabis
expected2=[0.06,0.06930693069306931,0.08,0.0891089108910891,0.1,0.10891089108910891,0.12,0.12871287128712872,0.14,0.1485148514851485,0.16,0.16831683168316833,0.18,0.18811881188118812,0.2,0.2079207920792079,0.22,0.22772277227722773,0.24,0.24752475247524752,0.26,0.26732673267326734,0.28,0.2871287128712871]
self.assertEqual(12,da.getNumberOfTuples());
self.assertEqual(2,da.getNumberOfComponents());
- for i in xrange(24):
+ for i in range(24):
self.assertAlmostEqual(da.getIJ(0,i),expected2[i],13)
pass
for pos,elt in enumerate(dabis):
self.assertEqual(12,da.getNumberOfTuples());
self.assertEqual(2,da.getNumberOfComponents());
expected3=[-0.01, -0.009900990099009901, -0.01, -0.009900990099009901, -0.01, -0.009900990099009901, -0.01, -0.009900990099009901, -0.01, -0.009900990099009901, -0.01, -0.009900990099009901, -0.01, -0.009900990099009901, -0.01, -0.009900990099009901, -0.01, -0.009900990099009901, -0.01, -0.009900990099009901, -0.01, -0.009900990099009901, -0.01, -0.0099009900990099]
- for i in xrange(24):
+ for i in range(24):
self.assertAlmostEqual(da.getIJ(0,i),expected3[i],13)
pass
pass
def testSwigDAIOp4(self):
- da=DataArrayInt.New(range(6,30),12,2)
+ da = DataArrayInt.New(list(range(6, 30)), 12, 2)
self.assertEqual(12,da.getNumberOfTuples());
self.assertEqual(2,da.getNumberOfComponents());
- for i in xrange(24):
+ for i in range(24):
self.assertEqual(da.getIJ(0,i),i+6)
pass
# operator transpose
da.transpose()
self.assertEqual(2,da.getNumberOfTuples());
self.assertEqual(12,da.getNumberOfComponents());
- for i in xrange(24):
+ for i in range(24):
self.assertEqual(da.getIJ(0,i),i+6)
pass
da.transpose()
da2=DataArrayInt.New(12,1)
da2.iota(0)
dabis=-da
- for i in xrange(24):
+ for i in range(24):
self.assertEqual(dabis.getIJ(0,i),-(i+6))
pass
# operator+=
da+=da2
expected1=[6,7,9,10,12,13,15,16,18,19,21,22,24,25,27,28,30,31,33,34,36,37,39,40]
- for i in xrange(24):
+ for i in range(24):
self.assertEqual(da.getIJ(0,i),expected1[i])
pass
da=-dabis
expected2=[106,108,108,110,110,112,112,114,114,116,116,118,118,120,120,122,122,124,124,126,126,128,128,130]
self.assertEqual(12,da.getNumberOfTuples());
self.assertEqual(2,da.getNumberOfComponents());
- for i in xrange(24):
+ for i in range(24):
self.assertEqual(da.getIJ(0,i),expected2[i])
pass
for pos,elt in enumerate(dabis):
self.assertEqual(li[0],100) ; self.assertEqual(li[1],101)
pass
# operator-=
- da=DataArrayInt.New(range(6,30),12,2)
- da2=DataArrayInt.New(range(12),12,1)
+ da = DataArrayInt.New(list(range(6, 30)), 12, 2)
+ da2 = DataArrayInt.New(list(range(12)), 12, 1)
dabis=-da
da-=da2
expected1=[6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,14,14,15,15,16,16,17,17,18]
- for i in xrange(24):
+ for i in range(24):
self.assertEqual(da.getIJ(0,i),expected1[i])
pass
da=-dabis
expected2=[-94,-94,-92,-92,-90,-90,-88,-88,-86,-86,-84,-84,-82,-82,-80,-80,-78,-78,-76,-76,-74,-74,-72,-72]
self.assertEqual(12,da.getNumberOfTuples());
self.assertEqual(2,da.getNumberOfComponents());
- for i in xrange(24):
+ for i in range(24):
self.assertEqual(da.getIJ(0,i),expected2[i])
pass
for pos,elt in enumerate(dabis):
self.assertEqual(12,da.getNumberOfTuples());
self.assertEqual(2,da.getNumberOfComponents());
expected3=[-88,-87,-84,-83,-80,-79,-76,-75,-72,-71,-68,-67,-64,-63,-60,-59,-56,-55,-52,-51,-48,-47,-44,-43]
- for i in xrange(24):
+ for i in range(24):
self.assertEqual(da.getIJ(0,i),expected3[i])
pass
# operator*=
- da=DataArrayInt.New(range(6,30),12,2)
- da2=DataArrayInt.New(range(12),12,1)
+ da = DataArrayInt.New(list(range(6, 30)), 12, 2)
+ da2 = DataArrayInt.New(list(range(12)), 12, 1)
dabis=-da
da*=da2
expected1=[0,0,8,9,20,22,36,39,56,60,80,85,108,114,140,147,176,184,216,225,260,270,308,319]
- for i in xrange(24):
+ for i in range(24):
self.assertEqual(da.getIJ(0,i),expected1[i])
pass
da=-dabis
expected2=[600,707,800,909,1000,1111,1200,1313,1400,1515,1600,1717,1800,1919,2000,2121,2200,2323,2400,2525,2600,2727,2800,2929]
self.assertEqual(12,da.getNumberOfTuples());
self.assertEqual(2,da.getNumberOfComponents());
- for i in xrange(24):
+ for i in range(24):
self.assertEqual(da.getIJ(0,i),expected2[i])
pass
for pos,elt in enumerate(dabis):
self.assertEqual(12,da.getNumberOfTuples());
self.assertEqual(2,da.getNumberOfComponents());
expected3=[-3600,-4949,-6400,-8181,-10000,-12221,-14400,-17069,-19600,-22725,-25600,-29189,-32400,-36461,-40000,-44541,-48400,-53429,-57600,-63125,-67600,-73629,-78400,-84941.0]
- for i in xrange(24):
+ for i in range(24):
self.assertEqual(da.getIJ(0,i),expected3[i])
pass
# operator/=
- da=DataArrayInt.New(range(6,30),12,2)
- da2=DataArrayInt.New(range(1,13),12,1)
+ da = DataArrayInt.New(list(range(6, 30)), 12, 2)
+ da2 = DataArrayInt.New(list(range(1, 13)), 12, 1)
dabis=-da
da/=da2
expected1=[6,7,4,4,3,3,3,3,2,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2]
- for i in xrange(24):
+ for i in range(24):
self.assertEqual(da.getIJ(0,i),expected1[i])
pass
da=-dabis
self.assertEqual(12,da.getNumberOfTuples());
self.assertEqual(2,da.getNumberOfComponents());
expected2=[3,2,4,3,5,3,6,4,7,5,8,5,9,6,10,7,11,7,12,8,13,9,14,9]
- for i in xrange(24):
+ for i in range(24):
self.assertEqual(da.getIJ(0,i),expected2[i])
pass
pass
self.assertEqual(4,da3.getNumberOfTuples());
self.assertEqual(3,da3.getNumberOfComponents());
expected1=[10.,11.,12.,16.,17.,14.,17.,8.,13.,21.,20.,22.]
- for i in xrange(12):
+ for i in range(12):
self.assertAlmostEqual(da3.getIJ(0,i),expected1[i],13)
pass
da3=da2+da
self.assertEqual(4,da3.getNumberOfTuples());
self.assertEqual(3,da3.getNumberOfComponents());
- for i in xrange(12):
+ for i in range(12):
self.assertAlmostEqual(da3.getIJ(0,i),expected1[i],13)
pass
# Test new API of classmethod DataArrayDouble.New
da=DataArrayDouble.New(vals)
self.assertEqual(12,da.getNumberOfTuples());
self.assertEqual(1,da.getNumberOfComponents());
- for i in xrange(12):
+ for i in range(12):
self.assertAlmostEqual(da.getIJ(0,i),vals[i],13)
pass
da=DataArrayDouble.New(vals,12)
self.assertEqual(12,da.getNumberOfTuples());
self.assertEqual(1,da.getNumberOfComponents());
- for i in xrange(12):
+ for i in range(12):
self.assertAlmostEqual(da.getIJ(0,i),vals[i],13)
pass
da=DataArrayDouble.New(vals,1,12)
self.assertEqual(1,da.getNumberOfTuples());
self.assertEqual(12,da.getNumberOfComponents());
- for i in xrange(12):
+ for i in range(12):
self.assertAlmostEqual(da.getIJ(0,i),vals[i],13)
pass
da=DataArrayDouble.New(vals,6,2)
self.assertEqual(6,da.getNumberOfTuples());
self.assertEqual(2,da.getNumberOfComponents());
- for i in xrange(12):
+ for i in range(12):
self.assertAlmostEqual(da.getIJ(0,i),vals[i],13)
pass
da=DataArrayDouble.New(vals,4,3)
self.assertEqual(4,da.getNumberOfTuples());
self.assertEqual(3,da.getNumberOfComponents());
- for i in xrange(12):
+ for i in range(12):
self.assertAlmostEqual(da.getIJ(0,i),vals[i],13)
pass
self.assertRaises(InterpKernelException,DataArrayDouble.New,vals,11);
self.assertEqual(4,da3.getNumberOfTuples());
self.assertEqual(3,da3.getNumberOfComponents());
expected1=[10,11,12,16,17,14,17,8,13,21,20,22]
- for i in xrange(12):
+ for i in range(12):
self.assertEqual(da3.getIJ(0,i),expected1[i])
pass
da3=da2+da
self.assertEqual(4,da3.getNumberOfTuples());
self.assertEqual(3,da3.getNumberOfComponents());
- for i in xrange(12):
+ for i in range(12):
self.assertEqual(da3.getIJ(0,i),expected1[i])
pass
da3=da+DataArrayInt.New(da2.getValues())
da=DataArrayDouble.New(vals)
self.assertEqual(12,da.getNumberOfTuples());
self.assertEqual(1,da.getNumberOfComponents());
- for i in xrange(12):
+ for i in range(12):
self.assertEqual(da.getIJ(0,i),vals[i])
pass
da=DataArrayDouble.New(vals,12)
self.assertEqual(12,da.getNumberOfTuples());
self.assertEqual(1,da.getNumberOfComponents());
- for i in xrange(12):
+ for i in range(12):
self.assertEqual(da.getIJ(0,i),vals[i])
pass
da=DataArrayDouble.New(vals,1,12)
self.assertEqual(1,da.getNumberOfTuples());
self.assertEqual(12,da.getNumberOfComponents());
- for i in xrange(12):
+ for i in range(12):
self.assertEqual(da.getIJ(0,i),vals[i])
pass
da=DataArrayDouble.New(vals,6,2)
self.assertEqual(6,da.getNumberOfTuples());
self.assertEqual(2,da.getNumberOfComponents());
- for i in xrange(12):
+ for i in range(12):
self.assertEqual(da.getIJ(0,i),vals[i])
pass
da=DataArrayDouble.New(vals,4,3)
self.assertEqual(4,da.getNumberOfTuples());
self.assertEqual(3,da.getNumberOfComponents());
- for i in xrange(12):
+ for i in range(12):
self.assertEqual(da.getIJ(0,i),vals[i])
pass
self.assertRaises(InterpKernelException,DataArrayDouble.New,vals,11);
self.assertEqual(8,da2.getNumberOfTuples());
self.assertEqual(1,da2.getNumberOfComponents());
expected1=[8,11,12,9,4,5,6,7]
- for i in xrange(8):
+ for i in range(8):
self.assertEqual(expected1[i],da2.getIJ(i,0));
pass
#
self.assertTrue(da1==None);
self.assertEqual(9,da2.getNumberOfTuples());
self.assertEqual(1,da2.getNumberOfComponents());
- for i in xrange(9):
+ for i in range(9):
self.assertEqual(8+i,da2.getIJ(i,0));
pass
#
self.assertEqual(expected2,mesh3D_4.getNodalConnectivity().getValues());
self.assertEqual(expected3,mesh2D_4.getNodalConnectivity().getValues());
self.assertEqual(expected4,mesh2D_5.getNodalConnectivity().getValues());
- for i in xrange(78):
+ for i in range(78):
self.assertAlmostEqual(expected5[i],mesh3D_4.getCoords().getIJ(0,i),12);
pass
#
self.assertEqual(expected6,mesh3D_4.getNodalConnectivity().getValues());
self.assertEqual(expected7,mesh2D_4.getNodalConnectivity().getValues());
self.assertEqual(expected8,mesh2D_5.getNodalConnectivity().getValues());
- for i in xrange(57):
+ for i in range(57):
self.assertAlmostEqual(expected9[i],mesh3D_4.getCoords().getIJ(0,i),12);
pass
#
pass
-
+
def testComputeNeighborsOfCells1(self):
m=MEDCouplingDataForTest.build2DTargetMesh_1();
d1,d2=m.computeNeighborsOfCells();
self.assertTrue(subMesh.isEqual(m5,1e-12))
self.assertRaises(InterpKernelException,m.buildPartOfMySelf,[1,5],True);
pass
-
+
def testSwigGetItem3(self):
da=DataArrayInt.New([4,5,6])
self.assertEqual(5,da[1])
res=d1.getMinMaxPerComponent();
self.assertTrue(isinstance(res,list))
self.assertEqual(3,len(res))
- for i in xrange(3):
+ for i in range(3):
self.assertTrue(isinstance(res[i],tuple))
self.assertEqual(2,len(res[i]))
pass
expected1=[-0.9,1.3,1.7,2.1,3.,3.]
- for i in xrange(6):
- self.assertAlmostEqual(expected1[i],res[i/2][i%2],14)
+ for i in range(6):
+ self.assertAlmostEqual(expected1[i], res[i // 2][i % 2], 14)
pass
#
d1.rearrange(2);
res=d1.getMinMaxPerComponent();
self.assertTrue(isinstance(res,list))
self.assertEqual(2,len(res))
- for i in xrange(2):
+ for i in range(2):
self.assertTrue(isinstance(res[i],tuple))
self.assertEqual(2,len(res[i]))
pass
expected2=[1.,3.,-0.9,3.]
- for i in xrange(4):
- self.assertAlmostEqual(expected2[i],res[i/2][i%2],14)
+ for i in range(4):
+ self.assertAlmostEqual(expected2[i], res[i // 2][i % 2], 14)
pass
#
d1.rearrange(1);
res=d1.getMinMaxPerComponent();
self.assertTrue(isinstance(res,list))
self.assertEqual(1,len(res))
- for i in xrange(1):
+ for i in range(1):
self.assertTrue(isinstance(res[i],tuple))
self.assertEqual(2,len(res[i]))
pass
expected3=[-0.9,3.]
- for i in xrange(2):
- self.assertAlmostEqual(expected3[i],res[i/2][i%2],14)
+ for i in range(2):
+ self.assertAlmostEqual(expected3[i], res[i // 2][i % 2], 14)
pass
pass
def testDataArrayIntGetHashCode1(self):
- d1=DataArrayInt.New(range(3545))
- d2=DataArrayInt.New(range(3545))
+ d1 = DataArrayInt.New(list(range(3545)))
+ d2 = DataArrayInt.New(list(range(3545)))
self.assertEqual(d2.getHashCode(),d1.getHashCode())
self.assertEqual(232341068,d1.getHashCode())
d1[886]=6
d-=2
d%=7
pass
-
+
def testSwigDAIOp5(self):
d=DataArrayInt.New([4,5,6,10,3,-1],2,3)
self.toSeeIfDaIIopsAreOK(d)
dExp=DataArrayInt.New([2,4,6,0,0,6],2,3)
self.assertTrue(d.isEqual(dExp));
pass
-
+
def toSeeIfDaDIopsAreOK(self,d):
d+=5
d*=6
#
m=MEDCouplingUMesh.New("convexhull",2);
m.allocateCells(331);
- for i in xrange(331):
+ for i in range(331):
m.insertNextCell(NORM_POLYGON,conn[connI[i]:connI[i+1]]);
pass
m.finishInsertingCells();
expected3=[1.,2.,4.,5.,6.,7.]
self.assertEqual(6,ard1.getNumberOfTuples());
self.assertEqual(1,ard1.getNumberOfComponents());
- for i in xrange(6):
+ for i in range(6):
self.assertAlmostEqual(expected3[i],ard1.getIJ(i,0),12)
pass
ard2.sort(False);
expected4=[7.,6.,5.,4.,2.,1.]
self.assertEqual(6,ard2.getNumberOfTuples());
self.assertEqual(1,ard2.getNumberOfComponents());
- for i in xrange(6):
+ for i in range(6):
self.assertAlmostEqual(expected4[i],ard2.getIJ(i,0),12)
pass
pass
-
+
def testPartitionBySpreadZone1(self):
m=MEDCouplingDataForTest.build2DTargetMesh_1();
m4=MEDCouplingUMesh.MergeUMeshes([m,m[-3:],m[0:2]]);
pass
def testSwigBugNonRegressionZipDA(self):
- angles=map(lambda x:pi/3*x,xrange(6))
+ angles = [pi / 3 * x for x in range(6)]
radius=3
#
dad=DataArrayDouble.New(6, 2)
valuesToTest=f.getValueOnMulti(targetPointCoordsX);
self.assertEqual(40,valuesToTest.getNumberOfTuples());
self.assertEqual(1,valuesToTest.getNumberOfComponents());
- for i in xrange(40):
+ for i in range(40):
self.assertAlmostEqual(targetFieldValsExpected[i],valuesToTest.getIJ(i,0),10)
pass
fd=f.getDiscretization()
coords=DataArrayDouble([0.,0.,0.,1.,1.,1.,1.,0.,0.,0.5,0.5,1.,1.,0.5,0.5,0.],8,2)
mQ8=MEDCouplingUMesh("",2) ; mQ8.setCoords(coords)
mQ8.allocateCells(1)
- mQ8.insertNextCell(NORM_QUAD8,range(8))
+ mQ8.insertNextCell(NORM_QUAD8, list(range(8)))
mQ8.finishInsertingCells()
mQ4=MEDCouplingUMesh("",2) ; mQ4.setCoords(coords)
mQ4.allocateCells(1)
- mQ4.insertNextCell(NORM_QUAD4,range(4))
+ mQ4.insertNextCell(NORM_QUAD4, list(range(4)))
mQ4.finishInsertingCells()
mT3=MEDCouplingUMesh("",2) ; mT3.setCoords(coords)
mT3.allocateCells(1)
- mT3.insertNextCell(NORM_TRI3,range(3))
+ mT3.insertNextCell(NORM_TRI3, list(range(3)))
mT3.finishInsertingCells()
tr=[[0.,0.],[2.,0.], [0.,2.],[2.,2.],[4.,2.],[6.,2.],[8.,2.],[10.,2.],[12.,2.],[0.,4.],[2.,4.],[4.,4.],[6.,4.],[8.,4.],[10.,4.],[12.,4.],[14.,4.],[16.,4.],[18.,4.],[20.,4.],[22.,4.]]
self.assertRaises(InterpKernelException,arr.transformWithIndArr,d)
pass
+ def testIntersect2DMeshesTmp6(self):
+ # coordinates
+ coords=DataArrayDouble.New([2.7554552980815448e-15,45,-45,5.5109105961630896e-15,-31.819805153394636,31.81980515339464,2.8779199779962799e-15,47,2.8166876380389124e-15,46,-47,5.7558399559925599e-15,-33.234018715767732,33.234018715767739,-46,5.6333752760778247e-15],8,2);
+ # connectivity
+ conn=DataArrayInt.New([8,0,3,5,1,4,6,7,2])
+ connI=DataArrayInt.New([0,9]);
+ m1=MEDCouplingUMesh.New("Fixe",2);
+ m1.setCoords(coords);
+ m1.setConnectivity(conn,connI,True);
+ #
+ coords=DataArrayDouble.New([-7.3800475508445391,41.854329503018846,-3.7041190667754655,42.338274668899189,-3.7041190667754655,45.338274668899189,-7.3800475508445382,44.854329503018839,-5.5473631693521845,42.136406608386956,-3.7041190667754655,43.838274668899189,-5.5420833088100014,45.09630208595901,-7.3800475508445382,43.354329503018839,-3.7041190667754651,52.338274668899189,-7.3800475508445382,51.854329503018839,-3.7041190667754655,48.838274668899189,-5.5420833088100014,52.09630208595901,-7.3800475508445382,48.354329503018839],13,2);
+ # connectivity
+ conn=DataArrayInt.New([8,0,1,2,3,4,5,6,7,8,3,2,8,9,6,10,11,12]);
+ connI=DataArrayInt.New([0,9,18]);
+ #
+ m2=MEDCouplingUMesh.New("Mobile",2);
+ m2.setCoords(coords);
+ m2.setConnectivity(conn,connI,True);
+ #
+ m3,d1,d2=MEDCouplingUMesh.Intersect2DMeshes(m1,m2,1e-10);
+ self.assertTrue(d1.isEqual(DataArrayInt([0,0,0,0])));
+ self.assertTrue(d2.isEqual(DataArrayInt([0,1,-1,-1])));
+ self.assertEqual(4,m3.getNumberOfCells());
+ self.assertEqual(4,d1.getNumberOfTuples());
+ self.assertEqual(4,d2.getNumberOfTuples());
+ self.assertEqual(43,m3.getNumberOfNodes());
+ dI,areMerged,newNbOfNodes=m3.mergeNodes(1e-12)
+ self.assertEqual(35,m3.getNumberOfNodes());
+ m3.zipCoords();
+ self.assertEqual(23,m3.getNumberOfNodes());
+ #
+ f=m3.getMeasureField(True);
+ valuesExpected=DataArrayDouble([1.6603638692585716,5.747555728471923,129.68907101754394,7.4162714498559694])
+ self.assertTrue(f.getArray().isEqual(valuesExpected,1e-12))
+ pass
+
def testDAPushBack(self):
d=DataArrayDouble(0,1)
- for i in xrange(8):
+ for i in range(8):
d.pushBackSilent(i)
pass
self.assertEqual(d.getNumberOfTuples(),8)
self.assertTrue(d.isEqual(DataArrayDouble([4.44,5.55,6.66]),1e-12))
#
d=DataArrayInt(0,1)
- for i in xrange(8):
+ for i in range(8):
d.pushBackSilent(i)
pass
self.assertEqual(d.getNumberOfTuples(),8)
#
m0=MEDCouplingUMesh("m",3) ; m0.allocateCells(0); m0.insertNextCell(NORM_TETRA4,[0,1,2,3]); #Well oriented
m1=MEDCouplingUMesh("m",3) ; m1.allocateCells(0); m1.insertNextCell(NORM_PYRA5,[0,1,2,3,4]); #Well oriented
- m2=MEDCouplingUMesh("m",3) ; m2.allocateCells(0); m2.insertNextCell(NORM_PENTA6,[0,1,2,3,4,5]); #Well oriented
+ m2=MEDCouplingUMesh("m",3) ; m2.allocateCells(0); m2.insertNextCell(NORM_PENTA6,[0,1,2,3,4,5]); #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)
self.assertRaises(InterpKernelException,m4.insertNextCell,NORM_HEXGP12,[0,1,2,3,4,5,6,7,8,9,10,11,12]);
m=MEDCouplingMesh.MergeMeshes([m0,m1,m2,m3,m4])
expected1=DataArrayDouble([0.16666666666666666,0.3333333333333333,0.5,1.,1.])
for v in vects:
- for i in xrange(nbOfDisc):
+ for i in range(nbOfDisc):
mm=m.deepCopy()
mm.rotate([0.,0.,0.],[0.3,0.7,0.2],float(i)/float(nbOfDisc)*2*pi)
mm2=mm.deepCopy()
#
mOK=m.deepCopy()
m0=MEDCouplingUMesh("m",3) ; m0.allocateCells(0); m0.insertNextCell(NORM_TETRA4,[0,2,1,3]); #Not well oriented
- m1=MEDCouplingUMesh("m",3) ; m1.allocateCells(0); m1.insertNextCell(NORM_PYRA5,[0,1,2,3,4]); #Well oriented
- m2=MEDCouplingUMesh("m",3) ; m2.allocateCells(0); m2.insertNextCell(NORM_PENTA6,[0,1,2,3,4,5]); #Well oriented
+ m1=MEDCouplingUMesh("m",3) ; m1.allocateCells(0); m1.insertNextCell(NORM_PYRA5,[0,1,2,3,4]); #Well oriented
+ m2=MEDCouplingUMesh("m",3) ; m2.allocateCells(0); m2.insertNextCell(NORM_PENTA6,[0,1,2,3,4,5]); #Well oriented
m3=MEDCouplingUMesh("m",3) ; m3.allocateCells(0); m3.insertNextCell(NORM_HEXA8,[0,3,2,1,4,7,6,5]); #Not well oriented
m4=MEDCouplingUMesh("m",3) ; m4.allocateCells(0); m4.insertNextCell(NORM_HEXGP12,[0,5,4,3,2,1,6,11,10,9,8,7]); #Not 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])
expected2=DataArrayDouble([-0.16666666666666666,0.3333333333333333,0.5,-1.,-1.])
for v in vects:
- for i in xrange(nbOfDisc):
+ for i in range(nbOfDisc):
mm=m.deepCopy()
mm.rotate([0.,0.,0.],[0.3,0.7,0.2],float(i)/float(nbOfDisc)*2*pi)
mm2=mm.deepCopy() ; mm3=mm.deepCopy() ; mm3.convertAllToPoly()
pass
#
m0=MEDCouplingUMesh("m",3) ; m0.allocateCells(0); m0.insertNextCell(NORM_TETRA4,[0,1,2,3]); #Well oriented
- 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
+ m1=MEDCouplingUMesh("m",3) ; m1.allocateCells(0); m1.insertNextCell(NORM_PYRA5,[0,3,2,1,4]); #Not well oriented
+ m2=MEDCouplingUMesh("m",3) ; m2.allocateCells(0); m2.insertNextCell(NORM_PENTA6,[0,2,1,3,5,4]); #Not well oriented
m3=MEDCouplingUMesh("m",3) ; m3.allocateCells(0); m3.insertNextCell(NORM_HEXA8,[0,1,2,3,4,5,6,7]); #Well oriented
- m4=MEDCouplingUMesh("m",3) ; m4.allocateCells(0); m4.insertNextCell(NORM_HEXGP12,range(12)); #Well oriented
+ m4 = MEDCouplingUMesh("m", 3) ; m4.allocateCells(0); m4.insertNextCell(NORM_HEXGP12, list(range(12))); # Well oriented
m0.setCoords(c0) ; m1.setCoords(c1) ; m2.setCoords(c2) ; m3.setCoords(c3) ; m4.setCoords(c4)
m=MEDCouplingMesh.MergeMeshes([m0,m1,m2,m3,m4])
expected3=DataArrayDouble([0.16666666666666666,-0.3333333333333333,-0.5,1.,1.])
for v in vects:
- for i in xrange(nbOfDisc):
+ for i in range(nbOfDisc):
mm=m.deepCopy()
mm.rotate([0.,0.,0.],[0.3,0.7,0.2],float(i)/float(nbOfDisc)*2*pi)
mm2=mm.deepCopy() ; mm3=mm.deepCopy() ; mm3.convertAllToPoly()
def testSwig2CellOrientation1(self):
coords=DataArrayDouble([-0.21606,-0.10803,0.29999999999999999,-0.21606,-0.10803,0.37700000000000006,0,-0.10803,0.29999999999999999,0,-0.10803,0.37700000000000006,0,0.10803,0.29999999999999999,0,0.10803,0.37700000000000006,-0.21606,0.10803,0.29999999999999999,-0.21606,0.10803,0.37700000000000006,0,0.03601,0.29999999999999999,0,0.03601,0.37700000000000006,0,-0.03601,0.29999999999999999,0,-0.03601,0.37700000000000006],12,3)
conn=[[0,2,10,8,4,6],[1,3,11,9,5,7],[0,1,3,2],[2,3,11,10],[10,11,9,8],[8,9,5,4],[4,5,7,6],[6,7,1,0]]
- for i in xrange(256):
+ for i in range(256):
mesh=MEDCouplingUMesh("FluidMesh_1",3);
mesh.allocateCells(0)
conn2=[elt[:] for elt in conn]
coords=DataArrayDouble([0.,0.,1.,1.,1.,0.]) ; m.setCoords(coords)
da=DataArrayInt([0,1,2])
m.allocateCells(0)
- for i in xrange(5):
+ for i in range(5):
m.insertNextCell(NORM_TRI3,da)
pass
self.assertTrue(m.getNodalConnectivity().isEqual(DataArrayInt([3,0,1,2,3,0,1,2,3,0,1,2,3,0,1,2,3,0,1,2])))
#
da=DataArrayInt([0,1,2,3])
m.allocateCells(0)
- for i in xrange(5):
+ for i in range(5):
m.insertNextCell(NORM_TRI3,3,da)
pass
self.assertTrue(m.getNodalConnectivity().isEqual(DataArrayInt([3,0,1,2,3,0,1,2,3,0,1,2,3,0,1,2,3,0,1,2])))
pass
def testSwigSetItem3(self):
- # 1-2
+ # 1-2
d=DataArrayDouble([0,0,0,0,0,0,0,0,0,0,0,0],6,2)
d[3]=[1,2]
self.assertTrue(d.isEqual(DataArrayDouble([0,0,0,0,0,0,1,2,0,0,0,0],6,2),1e-14))
d=DataArrayDouble([0,0,0,0,0,0,0,0,0,0,0,0],6,2)
d[1::2,:]=[3,9]
self.assertTrue(d.isEqual(DataArrayDouble([0,0,3,9,0,0,3,9,0,0,3,9],6,2),1e-14))
- # 1-2
+ # 1-2
d=DataArrayInt([0,0,0,0,0,0,0,0,0,0,0,0],6,2)
d[3]=[1,2]
self.assertTrue(d.isEqual(DataArrayInt([0,0,0,0,0,0,1,2,0,0,0,0],6,2)))
m3D.convertLinearCellsToQuadratic(0)
m3D.checkConsistency()
# check of new m3D content
- coordsExp2=[coordsExp.changeNbOfComponents(3,i) for i in xrange(4)]
- coordsExp3=[DataArrayDouble.Meld(cooTmp[:,[0,1]],cooTmp[:,2]+(0.5+float(i))) for i in xrange(3)]
+ coordsExp2 = [coordsExp.changeNbOfComponents(3, i) for i in range(4)]
+ coordsExp3 = [DataArrayDouble.Meld(cooTmp[:, [0, 1]], cooTmp[:, 2] + (0.5 + float(i))) for i in range(3)]
coordsExp4=DataArrayDouble.Aggregate([coordsExp2[0],coordsExp3[0],coordsExp2[1],coordsExp3[1],coordsExp2[2],coordsExp3[2],coordsExp2[3]])
c=DataArrayDouble.Aggregate(m3D.getCoords(),coordsExp4)
self.assertEqual(len(coordsExp4),115)
def testSwig2DataArrayAsciiChar1(self):
alpha=DataArrayInt(26) ; alpha.iota(ord("A"))
d=DataArrayAsciiChar(alpha.getValues(),2,13)
- d.setInfoOnComponents(["c%i"%(v) for v in xrange(13)])
+ d.setInfoOnComponents(["c%i" % (v) for v in range(13)])
self.assertEqual('ABCDEFGHIJKLM',d.getTuple(0))
self.assertEqual('NOPQRSTUVWXYZ',d.getTuple(1))
self.assertEqual(2,d.getNumberOfTuples())
self.assertTrue(mea.getArray().isEqual(DataArrayDouble([-0.08504076274779823,-0.06378057206084897,-0.08504076274779869,-0.10630095343474463,-0.12756114412169625,-0.10630095343474734,-0.0637805720608491,-0.0850407627477968,-0.1063009534347449,-0.0850407627477994,-0.10630095343474809,-0.1275611441216954,-0.037205333702161475,-0.037205333702161475,-0.037205333702161475,-0.037205333702161475,-0.047835429045636084,-0.047835429045636084,-0.047835429045636084,-0.047835429045636084,-0.05846552438911087,-0.05846552438911087,-0.05846552438911087,-0.05846552438911087,-0.037205333702161725,-0.037205333702161725,-0.037205333702161725,-0.037205333702161725,-0.047835429045635834,-0.047835429045635834,-0.047835429045635834,-0.047835429045635834,-0.05846552438911058,-0.05846552438911058,-0.05846552438911058,-0.05846552438911058,-0.03879154890291829,-0.03879154890291829,-0.03879154890291829,-0.04120270848015563,-0.04120270848015563,-0.04120270848015563,-0.03393028948486933,-0.03393028948486933,-0.03393028948486933,-0.03151955746491709,-0.03151955746491709,-0.03151955746491709,-0.02424752187358276,-0.02424752187358276,-0.02424752187358276,-0.026657914642918758,-0.026657914642918758,-0.026657914642918758,-0.04120270848015456,-0.04120270848015456,-0.04120270848015456,-0.03879154890291757,-0.03879154890291757,-0.03879154890291757,-0.031519557464916595,-0.031519557464916595,-0.031519557464916595,-0.03393028948487046,-0.03393028948487046,-0.03393028948487046,-0.0266579146429191,-0.0266579146429191,-0.0266579146429191,-0.024247521873582645,-0.024247521873582645,-0.024247521873582645,-0.01851718920904466,-0.01851718920904466,-0.01851718920904466,-0.01851718920904466,-0.029627502734471456,-0.029627502734471456,-0.029627502734471456,-0.029627502734471456,-0.04740400437515433,-0.015150427534672922,-0.015150427534672922,-0.015150427534672922,-0.015150427534672922,-0.024240684055476674,-0.024240684055476674,-0.024240684055476674,-0.024240684055476674,-0.038785094488762675,-0.011783665860301345,-0.011783665860301345,-0.011783665860301345,-0.011783665860301345,-0.018853865376482152,-0.018853865376482152,-0.018853865376482152,-0.018853865376482152,-0.030166184602371443,-0.018517189209044892,-0.018517189209044892,-0.018517189209044892,-0.018517189209044892,-0.029627502734471827,-0.029627502734471827,-0.029627502734471827,-0.029627502734471827,-0.04740400437515492,-0.015150427534672776,-0.015150427534672776,-0.015150427534672776,-0.015150427534672776,-0.02424068405547644,-0.02424068405547644,-0.02424068405547644,-0.02424068405547644,-0.03878509448876231,-0.011783665860301277,-0.011783665860301277,-0.011783665860301277,-0.011783665860301277,-0.01885386537648204,-0.01885386537648204,-0.01885386537648204,-0.01885386537648204,-0.030166184602371266]),1e-14))
f=MEDCouplingFieldDouble(ft)
arr=DataArrayDouble(126,2)
- arr[:,0]=range(126)
- arr[:,1]=range(126)
+ arr[:, 0] = list(range(126))
+ arr[:, 1] = list(range(126))
arr[:,1]+=1000
f.setArray(arr)
f.checkConsistencyLight()
def testSwig2DAReverseMultiCompo1(self):
d=DataArrayDouble(6,2)
- d[:,0]=range(6)
- d[:,1]=range(10,16)
+ d[:, 0] = list(range(6))
+ d[:, 1] = list(range(10, 16))
d.reverse()
self.assertTrue(d.isEqual(DataArrayDouble([5.,15.,4.,14.,3.,13.,2.,12.,1.,11.,0.,10.],6,2),1e-14))
d=DataArrayDouble(7,2)
- d[:,0]=range(7)
- d[:,1]=range(10,17)
+ d[:, 0] = list(range(7))
+ d[:, 1] = list(range(10, 17))
d.reverse()
self.assertTrue(d.isEqual(DataArrayDouble([6.,16.,5.,15.,4.,14.,3.,13.,2.,12.,1.,11.,0.,10.],7,2),1e-14))
#
d=DataArrayInt(6,2)
- d[:,0]=range(6)
- d[:,1]=range(10,16)
+ d[:, 0] = list(range(6))
+ d[:, 1] = list(range(10, 16))
d.reverse()
self.assertTrue(d.isEqual(DataArrayInt([5,15,4,14,3,13,2,12,1,11,0,10],6,2)))
d=DataArrayInt(7,2)
- d[:,0]=range(7)
- d[:,1]=range(10,17)
+ d[:, 0] = list(range(7))
+ d[:, 1] = list(range(10, 17))
d.reverse()
self.assertTrue(d.isEqual(DataArrayInt([6,16,5,15,4,14,3,13,2,12,1,11,0,10],7,2)))
pass
d4**=d3
self.assertTrue(d4.isEqual(DataArrayDouble([1.,sqrt(2.),1.4422495703074083,sqrt(2.)]),1e-14))
pass
-
+
def testSwig2Baryenter3DForCellsWithVolumeZero1(self):
coo=DataArrayDouble([0.,0.,0.,1.,0.,0.,0.,1.,0.],3,3)
m2=MEDCouplingUMesh("mesh",2)
d=DataArrayDouble()
self.assertTrue(len(d.__repr__())<120)
d.alloc(1000,0) ; self.assertTrue(len(d.__repr__())<100)
- for i in xrange(100):
+ for i in range(100):
d.alloc(i,1) ; d.iota(1.1234567890123456) ; d*=1e123
self.assertTrue(len(d.__repr__())<500)
pass
- for i in xrange(50):
+ for i in range(50):
d.alloc(i,2) ; d.rearrange(1) ; d.iota(1.1234567890123456) ; d.rearrange(2) ; d*=1e123
self.assertTrue(len(d.__repr__())<500)
pass
d.alloc(4000,1) ; d.iota() ; self.assertTrue(len(d.__repr__())<500)
- for i in xrange(2,4):
+ for i in range(2, 4):
d.alloc(362880,1) ; d.iota() ; d.rearrange(i) ; self.assertTrue(len(d.__repr__())<500)
pass
d.alloc(0,9)
d=DataArrayInt()
self.assertTrue(len(d.__repr__())<100)
d.alloc(1000,0) ; self.assertTrue(len(d.__repr__())<100)
- for i in xrange(100):
+ for i in range(100):
d.alloc(i,1) ; d.iota(123456789)
self.assertTrue(len(d.__repr__())<500)
pass
- for i in xrange(50):
+ for i in range(50):
d.alloc(i,2) ; d.rearrange(1) ; d.iota(123456789) ; d.rearrange(2)
self.assertTrue(len(d.__repr__())<500)
pass
d.alloc(4000,1) ; d.iota() ; self.assertTrue(len(d.__repr__())<500)
- for i in xrange(2,10):
+ for i in range(2, 10):
d.alloc(362880,1) ; d.iota() ; d.rearrange(i) ; self.assertTrue(len(d.__repr__())<500)
pass
d.alloc(0,9)
d.alloc(1000,3) ; d.fillWithValue(127)
self.assertTrue(len(d.__repr__())<500)
pass
-
+
def testSwig2MeshComputeIsoBarycenterOfNodesPerCell1(self):
coo=DataArrayDouble([26.17509821414239,5.0374,200.,26.175098214142388,-5.0374,200.,17.450065476094927,20.1496,200.,8.725032738047464,25.187,200.,43.62516369023732,5.0374,200.,34.90013095218986,10.0748,200.,34.900130952189855,-10.0748,200.,43.625163690237315,-5.0374,200.,26.175098214142402,25.187,200.,26.175098214142395,35.2618,200.,17.45006547609493,40.2992,200.,8.725032738047469,35.2618,200.,26.17509821414239,5.0374,200.,26.175098214142388,-5.0374,200.,17.450065476094927,20.1496,200.,8.725032738047464,25.187,200.,43.62516369023732,5.0374,200.,34.90013095218986,10.0748,200.,34.900130952189855,-10.0748,200.,43.625163690237315,-5.0374,200.,26.175098214142402,25.187,200.,26.175098214142395,35.2618,200.,17.45006547609493,40.2992,200.,8.725032738047469,35.2618,200.],24,3)
m=MEDCouplingUMesh.New("toto",3)
m2.allocateCells(0)
m2.setCoords(coo)
conn2=[[0,3,5,1,7,4,6,2],[12,14,16,18,13,15,17,19],[0,12,18,3,8,19,11,7],[3,18,16,5,11,17,10,4],[5,16,14,1,10,15,9,6],[1,14,12,0,9,13,8,2]]
- for i in xrange(6):
+ for i in range(6):
m2.insertNextCell(NORM_QUAD8,conn2[i])
pass
self.assertTrue(m2.isEqual(a,1e-12))
conn4=[[0,2,3,1,8,9,10,11,20],[4,5,6,7,15,14,13,12,25],[0,4,7,2,16,12,17,8,21],[2,7,6,3,17,13,18,9,22],[3,6,5,1,18,14,19,10,23],[1,5,4,0,19,15,16,11,24]]
m4=MEDCouplingUMesh("mesh",2)
m4.allocateCells(0)
- for i in xrange(6):
+ for i in range(6):
m4.insertNextCell(NORM_QUAD9,conn4[i])
pass
m4.setCoords(coo2)
self.assertTrue(d.isEqual(DataArrayInt([0,0,0,0,0,0])))
self.assertTrue(e.isEqual(DataArrayInt([0,1,2,3,4,5,6])))
pass
-
+
def testSwigAdvGauss(self):
f=MEDCouplingFieldTemplate(ON_GAUSS_PT)
f.setDiscretization(None)
f=MEDCouplingFieldDouble(ON_CELLS)
f.setMesh(m)
arr=DataArrayDouble(5,2)
- arr[:,0]=range(5) ; arr[:,1]=2*arr[:,0]
+ arr[:, 0] = list(range(5)) ; arr[:, 1] = 2 * arr[:, 0]
f2=f.clone(True)
self.assertRaises(InterpKernelException,f.__add__,2)
- self.assertRaises(InterpKernelException,f.__add__,range(5))
+ self.assertRaises(InterpKernelException, f.__add__, list(range(5)))
self.assertRaises(InterpKernelException,f.__add__,arr)
self.assertRaises(InterpKernelException,f.__add__,f2)
f.setArray(DataArrayDouble())
self.assertRaises(InterpKernelException,f.__add__,2)
- self.assertRaises(InterpKernelException,f.__add__,range(5))
+ self.assertRaises(InterpKernelException, f.__add__, list(range(5)))
self.assertRaises(InterpKernelException,f.__add__,arr)
self.assertRaises(InterpKernelException,f.__add__,f2)
self.assertRaises(InterpKernelException,f.__getitem__,(slice(None),0))
f.getArray().alloc(5,2)
- f.getArray()[:,0]=range(5) ; f.getArray()[:,1]=f.getArray()[:,0]+7
+ f.getArray()[:, 0] = list(range(5)) ; f.getArray()[:, 1] = f.getArray()[:, 0] + 7
ff=f+2
ff.checkConsistencyLight()
self.assertTrue(ff.getArray().isEqual(DataArrayDouble([(2,9),(3,10),(4,11),(5,12),(6,13)]),1e-12))
f=MEDCouplingFieldDouble(ON_CELLS)
f.setMesh(m)
arr=DataArrayDouble(5,2)
- arr[:,0]=range(5) ; arr[:,1]=2*arr[:,0]
+ arr[:, 0] = list(range(5)) ; arr[:, 1] = 2 * arr[:, 0]
f2=f.clone(True)
self.assertRaises(InterpKernelException,f.__sub__,2)
- self.assertRaises(InterpKernelException,f.__sub__,range(5))
+ self.assertRaises(InterpKernelException, f.__sub__, list(range(5)))
self.assertRaises(InterpKernelException,f.__sub__,arr)
self.assertRaises(InterpKernelException,f.__sub__,f2)
f.setArray(DataArrayDouble())
self.assertRaises(InterpKernelException,f.__sub__,2)
- self.assertRaises(InterpKernelException,f.__sub__,range(5))
+ self.assertRaises(InterpKernelException, f.__sub__, list(range(5)))
self.assertRaises(InterpKernelException,f.__sub__,arr)
self.assertRaises(InterpKernelException,f.__sub__,f2)
self.assertRaises(InterpKernelException,f.__getitem__,(slice(None),0))
f.getArray().alloc(5,2)
- f.getArray()[:,0]=range(5) ; f.getArray()[:,1]=f.getArray()[:,0]+7
+ f.getArray()[:, 0] = list(range(5)) ; f.getArray()[:, 1] = f.getArray()[:, 0] + 7
ff=f-2
ff.checkConsistencyLight()
self.assertTrue(ff.getArray().isEqual(DataArrayDouble([(-2,5),(-1,6),(0,7),(1,8),(2,9)]),1e-12))
f=MEDCouplingFieldDouble(ON_CELLS)
f.setMesh(m)
arr=DataArrayDouble(5,2)
- arr[:,0]=range(5) ; arr[:,1]=2*arr[:,0]
+ arr[:, 0] = list(range(5)) ; arr[:, 1] = 2 * arr[:, 0]
f2=f.clone(True)
self.assertRaises(InterpKernelException,f.__mul__,2)
- self.assertRaises(InterpKernelException,f.__mul__,range(5))
+ self.assertRaises(InterpKernelException, f.__mul__, list(range(5)))
self.assertRaises(InterpKernelException,f.__mul__,arr)
self.assertRaises(InterpKernelException,f.__mul__,f2)
f.setArray(DataArrayDouble())
self.assertRaises(InterpKernelException,f.__mul__,2)
- self.assertRaises(InterpKernelException,f.__mul__,range(5))
+ self.assertRaises(InterpKernelException, f.__mul__, list(range(5)))
self.assertRaises(InterpKernelException,f.__mul__,arr)
self.assertRaises(InterpKernelException,f.__mul__,f2)
self.assertRaises(InterpKernelException,f.__getitem__,(slice(None),0))
f.getArray().alloc(5,2)
- f.getArray()[:,0]=range(5) ; f.getArray()[:,1]=f.getArray()[:,0]+7
+ f.getArray()[:, 0] = list(range(5)) ; f.getArray()[:, 1] = f.getArray()[:, 0] + 7
ff=f*2
ff.checkConsistencyLight()
self.assertTrue(ff.getArray().isEqual(DataArrayDouble([(0,14),(2,16),(4,18),(6,20),(8,22)]),1e-12))
f=MEDCouplingFieldDouble(ON_CELLS)
f.setMesh(m)
arr=DataArrayDouble(5,2)
- arr[:,0]=range(1,6) ; arr[:,1]=2*arr[:,0]
+ arr[:, 0] = list(range(1, 6)) ; arr[:, 1] = 2 * arr[:, 0]
f2=f.clone(True)
self.assertRaises(InterpKernelException,f.__div__,2)
- self.assertRaises(InterpKernelException,f.__div__,range(5))
+ self.assertRaises(InterpKernelException, f.__div__, list(range(5)))
self.assertRaises(InterpKernelException,f.__div__,arr)
self.assertRaises(InterpKernelException,f.__div__,f2)
f.setArray(DataArrayDouble())
self.assertRaises(InterpKernelException,f.__div__,2)
- self.assertRaises(InterpKernelException,f.__div__,range(5))
+ self.assertRaises(InterpKernelException, f.__div__, list(range(5)))
self.assertRaises(InterpKernelException,f.__div__,arr)
self.assertRaises(InterpKernelException,f.__div__,f2)
self.assertRaises(InterpKernelException,f.__getitem__,(slice(None),0))
f.getArray().alloc(5,2)
- f.getArray()[:,0]=range(5) ; f.getArray()[:,1]=f.getArray()[:,0]+7
+ f.getArray()[:, 0] = list(range(5)) ; f.getArray()[:, 1] = f.getArray()[:, 0] + 7
self.assertRaises(InterpKernelException,f.__div__,0)
ff=f/2
ff.checkConsistencyLight()
arr[:]=[1,1,3,2,0]
f2=f.clone(True)
self.assertRaises(InterpKernelException,f.__div__,2)
- self.assertRaises(InterpKernelException,f.__div__,range(5))
+ self.assertRaises(InterpKernelException, f.__div__, list(range(5)))
self.assertRaises(InterpKernelException,f.__div__,arr)
self.assertRaises(InterpKernelException,f.__div__,f2)
f.setArray(DataArrayDouble())
self.assertRaises(InterpKernelException,f.__div__,2)
- self.assertRaises(InterpKernelException,f.__div__,range(5))
+ self.assertRaises(InterpKernelException, f.__div__, list(range(5)))
self.assertRaises(InterpKernelException,f.__div__,arr)
self.assertRaises(InterpKernelException,f.__div__,f2)
self.assertRaises(InterpKernelException,f.__getitem__,(slice(None),0))
f.getArray().alloc(5,1)
- f.getArray()[:]=range(2,7)
+ f.getArray()[:] = list(range(2, 7))
ff=f**2
ff.checkConsistencyLight()
self.assertTrue(ff.getArray().isEqual(DataArrayDouble([4,9,16,25,36]),1e-12))
f=MEDCouplingFieldDouble(ON_CELLS)
f.setMesh(m)
arr=DataArrayDouble(5,2)
- arr[:,0]=range(5) ; arr[:,1]=2*arr[:,0]
+ arr[:, 0] = list(range(5)) ; arr[:, 1] = 2 * arr[:, 0]
f2=f.clone(True)
self.assertRaises(InterpKernelException,f.__iadd__,2)
- self.assertRaises(InterpKernelException,f.__iadd__,range(5))
+ self.assertRaises(InterpKernelException, f.__iadd__, list(range(5)))
self.assertRaises(InterpKernelException,f.__iadd__,arr)
self.assertRaises(InterpKernelException,f.__iadd__,f2)
f.setArray(DataArrayDouble())
self.assertRaises(InterpKernelException,f.__iadd__,2)
- self.assertRaises(InterpKernelException,f.__iadd__,range(5))
+ self.assertRaises(InterpKernelException, f.__iadd__, list(range(5)))
self.assertRaises(InterpKernelException,f.__iadd__,arr)
self.assertRaises(InterpKernelException,f.__iadd__,f2)
f.getArray().alloc(5,2)
- f.getArray()[:,0]=range(5) ; f.getArray()[:,1]=f.getArray()[:,0]+7
+ f.getArray()[:, 0] = list(range(5)) ; f.getArray()[:, 1] = f.getArray()[:, 0] + 7
f.checkConsistencyLight()
f+=2
f.checkConsistencyLight()
f=MEDCouplingFieldDouble(ON_CELLS)
f.setMesh(m)
arr=DataArrayDouble(5,2)
- arr[:,0]=range(5) ; arr[:,1]=2*arr[:,0]
+ arr[:, 0] = list(range(5)) ; arr[:, 1] = 2 * arr[:, 0]
f2=f.clone(True)
self.assertRaises(InterpKernelException,f.__isub__,2)
- self.assertRaises(InterpKernelException,f.__isub__,range(5))
+ self.assertRaises(InterpKernelException, f.__isub__, list(range(5)))
self.assertRaises(InterpKernelException,f.__isub__,arr)
self.assertRaises(InterpKernelException,f.__isub__,f2)
f.setArray(DataArrayDouble())
self.assertRaises(InterpKernelException,f.__isub__,2)
- self.assertRaises(InterpKernelException,f.__isub__,range(5))
+ self.assertRaises(InterpKernelException, f.__isub__, list(range(5)))
self.assertRaises(InterpKernelException,f.__isub__,arr)
self.assertRaises(InterpKernelException,f.__isub__,f2)
f.getArray().alloc(5,2)
- f.getArray()[:,0]=range(5) ; f.getArray()[:,1]=f.getArray()[:,0]+7
+ f.getArray()[:, 0] = list(range(5)) ; f.getArray()[:, 1] = f.getArray()[:, 0] + 7
f.checkConsistencyLight()
f-=2
f.checkConsistencyLight()
f=MEDCouplingFieldDouble(ON_CELLS)
f.setMesh(m)
arr=DataArrayDouble(5,2)
- arr[:,0]=range(5) ; arr[:,1]=2*arr[:,0]
+ arr[:, 0] = list(range(5)) ; arr[:, 1] = 2 * arr[:, 0]
f2=f.clone(True)
self.assertRaises(InterpKernelException,f.__imul__,2)
- self.assertRaises(InterpKernelException,f.__imul__,range(5))
+ self.assertRaises(InterpKernelException, f.__imul__, list(range(5)))
self.assertRaises(InterpKernelException,f.__imul__,arr)
self.assertRaises(InterpKernelException,f.__imul__,f2)
f.setArray(DataArrayDouble())
self.assertRaises(InterpKernelException,f.__imul__,2)
- self.assertRaises(InterpKernelException,f.__imul__,range(5))
+ self.assertRaises(InterpKernelException, f.__imul__, list(range(5)))
self.assertRaises(InterpKernelException,f.__imul__,arr)
self.assertRaises(InterpKernelException,f.__imul__,f2)
f.getArray().alloc(5,2)
- f.getArray()[:,0]=range(5) ; f.getArray()[:,1]=f.getArray()[:,0]+7
+ f.getArray()[:, 0] = list(range(5)) ; f.getArray()[:, 1] = f.getArray()[:, 0] + 7
f.checkConsistencyLight()
f*=2
f.checkConsistencyLight()
f=MEDCouplingFieldDouble(ON_CELLS)
f.setMesh(m)
arr=DataArrayDouble(5,2)
- arr[:,0]=range(1,6) ; arr[:,1]=2*arr[:,0]
+ arr[:, 0] = list(range(1, 6)) ; arr[:, 1] = 2 * arr[:, 0]
f2=f.clone(True)
self.assertRaises(InterpKernelException,f.__idiv__,2)
- self.assertRaises(InterpKernelException,f.__idiv__,range(5))
+ self.assertRaises(InterpKernelException, f.__idiv__, list(range(5)))
self.assertRaises(InterpKernelException,f.__idiv__,arr)
self.assertRaises(InterpKernelException,f.__idiv__,f2)
f.setArray(DataArrayDouble())
self.assertRaises(InterpKernelException,f.__idiv__,2)
- self.assertRaises(InterpKernelException,f.__idiv__,range(5))
+ self.assertRaises(InterpKernelException, f.__idiv__, list(range(5)))
self.assertRaises(InterpKernelException,f.__idiv__,arr)
self.assertRaises(InterpKernelException,f.__idiv__,f2)
f.getArray().alloc(5,2)
- f.getArray()[:,0]=range(5) ; f.getArray()[:,1]=f.getArray()[:,0]+7
+ f.getArray()[:, 0] = list(range(5)) ; f.getArray()[:, 1] = f.getArray()[:, 0] + 7
f.checkConsistencyLight()
f/=2
f.checkConsistencyLight()
f=MEDCouplingFieldDouble(ON_CELLS)
f.setMesh(m)
arr=DataArrayDouble(5,2)
- arr[:,0]=range(1,6) ; arr[:,1]=2*arr[:,0]
+ arr[:, 0] = list(range(1, 6)) ; arr[:, 1] = 2 * arr[:, 0]
f2=f.clone(True)
self.assertRaises(InterpKernelException,f.__ipow__,2)
- self.assertRaises(InterpKernelException,f.__ipow__,range(5))
+ self.assertRaises(InterpKernelException, f.__ipow__, list(range(5)))
self.assertRaises(InterpKernelException,f.__ipow__,arr)
self.assertRaises(InterpKernelException,f.__ipow__,f2)
f.setArray(DataArrayDouble())
self.assertRaises(InterpKernelException,f.__ipow__,2)
- self.assertRaises(InterpKernelException,f.__ipow__,range(5))
+ self.assertRaises(InterpKernelException, f.__ipow__, list(range(5)))
self.assertRaises(InterpKernelException,f.__ipow__,arr)
self.assertRaises(InterpKernelException,f.__ipow__,f2)
f.getArray().alloc(5,2)
- f.getArray()[:,0]=range(5) ; f.getArray()[:,1]=f.getArray()[:,0]+7
+ f.getArray()[:, 0] = list(range(5)) ; f.getArray()[:, 1] = f.getArray()[:, 0] + 7
f.checkConsistencyLight()
f**=2
f.checkConsistencyLight()
f=MEDCouplingFieldDouble(ON_CELLS)
f.setMesh(m)
arr=DataArrayDouble(5,2)
- arr[:,0]=range(5) ; arr[:,1]=2*arr[:,0]
+ arr[:, 0] = list(range(5)) ; arr[:, 1] = 2 * arr[:, 0]
f2=f.clone(True)
self.assertRaises(InterpKernelException,f.__radd__,2)
- self.assertRaises(InterpKernelException,f.__radd__,range(5))
+ self.assertRaises(InterpKernelException, f.__radd__, list(range(5)))
self.assertRaises(InterpKernelException,f.__radd__,arr)
self.assertRaises(InterpKernelException,f.__radd__,f2)
f.setArray(DataArrayDouble())
self.assertRaises(InterpKernelException,f.__radd__,2)
- self.assertRaises(InterpKernelException,f.__radd__,range(5))
+ self.assertRaises(InterpKernelException, f.__radd__, list(range(5)))
self.assertRaises(InterpKernelException,f.__radd__,arr)
self.assertRaises(InterpKernelException,f.__radd__,f2)
self.assertRaises(InterpKernelException,f.__getitem__,(slice(None),0))
f.getArray().alloc(5,2)
- f.getArray()[:,0]=range(5) ; f.getArray()[:,1]=f.getArray()[:,0]+7
+ f.getArray()[:, 0] = list(range(5)) ; f.getArray()[:, 1] = f.getArray()[:, 0] + 7
ff=2+f
ff.checkConsistencyLight()
self.assertTrue(ff.getArray().isEqual(DataArrayDouble([(2,9),(3,10),(4,11),(5,12),(6,13)]),1e-12))
f=MEDCouplingFieldDouble(ON_CELLS)
f.setMesh(m)
arr=DataArrayDouble(5,2)
- arr[:,0]=range(5) ; arr[:,1]=2*arr[:,0]
+ arr[:, 0] = list(range(5)) ; arr[:, 1] = 2 * arr[:, 0]
f2=f.clone(True)
self.assertRaises(InterpKernelException,f.__rsub__,2)
- self.assertRaises(InterpKernelException,f.__rsub__,range(5))
+ self.assertRaises(InterpKernelException, f.__rsub__, list(range(5)))
self.assertRaises(InterpKernelException,f.__rsub__,arr)
self.assertRaises(InterpKernelException,f.__rsub__,f2)
f.setArray(DataArrayDouble())
self.assertRaises(InterpKernelException,f.__rsub__,2)
- self.assertRaises(InterpKernelException,f.__rsub__,range(5))
+ self.assertRaises(InterpKernelException, f.__rsub__, list(range(5)))
self.assertRaises(InterpKernelException,f.__rsub__,arr)
self.assertRaises(InterpKernelException,f.__rsub__,f2)
self.assertRaises(InterpKernelException,f.__getitem__,(slice(None),0))
f.getArray().alloc(5,2)
- f.getArray()[:,0]=range(5) ; f.getArray()[:,1]=f.getArray()[:,0]+7
+ f.getArray()[:, 0] = list(range(5)) ; f.getArray()[:, 1] = f.getArray()[:, 0] + 7
ff=2-f
ff.checkConsistencyLight()
self.assertTrue(ff.getArray().isEqual(DataArrayDouble([(2,-5),(1,-6),(0,-7),(-1,-8),(-2,-9)]),1e-12))
f=MEDCouplingFieldDouble(ON_CELLS)
f.setMesh(m)
arr=DataArrayDouble(5,2)
- arr[:,0]=range(5) ; arr[:,1]=2*arr[:,0]
+ arr[:, 0] = list(range(5)) ; arr[:, 1] = 2 * arr[:, 0]
f2=f.clone(True)
self.assertRaises(InterpKernelException,f.__rmul__,2)
- self.assertRaises(InterpKernelException,f.__rmul__,range(5))
+ self.assertRaises(InterpKernelException, f.__rmul__, list(range(5)))
self.assertRaises(InterpKernelException,f.__rmul__,arr)
self.assertRaises(InterpKernelException,f.__rmul__,f2)
f.setArray(DataArrayDouble())
self.assertRaises(InterpKernelException,f.__rmul__,2)
- self.assertRaises(InterpKernelException,f.__rmul__,range(5))
+ self.assertRaises(InterpKernelException, f.__rmul__, list(range(5)))
self.assertRaises(InterpKernelException,f.__rmul__,arr)
self.assertRaises(InterpKernelException,f.__rmul__,f2)
self.assertRaises(InterpKernelException,f.__getitem__,(slice(None),0))
f.getArray().alloc(5,2)
- f.getArray()[:,0]=range(5) ; f.getArray()[:,1]=f.getArray()[:,0]+7
+ f.getArray()[:, 0] = list(range(5)) ; f.getArray()[:, 1] = f.getArray()[:, 0] + 7
ff=2*f
ff.checkConsistencyLight()
self.assertTrue(ff.getArray().isEqual(DataArrayDouble([(0,14),(2,16),(4,18),(6,20),(8,22)]),1e-12))
f=MEDCouplingFieldDouble(ON_CELLS)
f.setMesh(m)
arr=DataArrayDouble(5,2)
- arr[:,0]=range(1,6) ; arr[:,1]=2*arr[:,0]
+ arr[:, 0] = list(range(1, 6)) ; arr[:, 1] = 2 * arr[:, 0]
f2=f.clone(True)
self.assertRaises(InterpKernelException,f.__rdiv__,2)
- self.assertRaises(InterpKernelException,f.__rdiv__,range(5))
+ self.assertRaises(InterpKernelException, f.__rdiv__, list(range(5)))
self.assertRaises(InterpKernelException,f.__rdiv__,arr)
self.assertRaises(InterpKernelException,f.__rdiv__,f2)
f.setArray(DataArrayDouble())
self.assertRaises(InterpKernelException,f.__rdiv__,2)
- self.assertRaises(InterpKernelException,f.__rdiv__,range(5))
+ self.assertRaises(InterpKernelException, f.__rdiv__, list(range(5)))
self.assertRaises(InterpKernelException,f.__rdiv__,arr)
self.assertRaises(InterpKernelException,f.__rdiv__,f2)
self.assertRaises(InterpKernelException,f.__getitem__,(slice(None),0))
f.getArray().alloc(5,2)
- f.getArray()[:,0]=range(1,6) ; f.getArray()[:,1]=f.getArray()[:,0]+7
+ f.getArray()[:, 0] = list(range(1, 6)) ; f.getArray()[:, 1] = f.getArray()[:, 0] + 7
ff=2/f
ff.checkConsistencyLight()
self.assertTrue(ff.getArray().isEqual(DataArrayDouble([(2,0.25),(1,0.22222222222222221),(0.66666666666666663,0.20000000000000001),(0.5,0.18181818181818182),(0.40000000000000002,0.16666666666666666)]),1e-12))
m=MEDCouplingDataForTest.build2DTargetMesh_1()
f=MEDCouplingFieldDouble(ON_CELLS)
f.setMesh(m)
- arr=DataArrayDouble(5,2) ; arr[:,0]=range(7,12) ; arr[:,1]=100+arr[:,0]
+ arr = DataArrayDouble(5, 2) ; arr[:, 0] = list(range(7, 12)) ; arr[:, 1] = 100 + arr[:, 0]
f.setArray(arr)
f.checkConsistencyLight()
ff=f[1:-1:2]
#ON_NODES
f=MEDCouplingFieldDouble(ON_NODES)
f.setMesh(m)
- arr=DataArrayDouble(9,2) ; arr[:,0]=range(7,16) ; arr[:,1]=100+arr[:,0]
+ arr = DataArrayDouble(9, 2) ; arr[:, 0] = list(range(7, 16)) ; arr[:, 1] = 100 + arr[:, 0]
f.setArray(arr)
f.checkConsistencyLight()
ff=f[1:-1:2]
#ON_GAUSS_NE
f=MEDCouplingFieldDouble(ON_GAUSS_NE)
f.setMesh(m)
- arr=DataArrayDouble(18,2) ; arr[:,0]=range(7,25) ; arr[:,1]=100+arr[:,0]
+ arr = DataArrayDouble(18, 2) ; arr[:, 0] = list(range(7, 25)) ; arr[:, 1] = 100 + arr[:, 0]
f.setArray(arr)
f.checkConsistencyLight()
ff=f[1:-1:2]
f.setGaussLocalizationOnCells([3],[0,0,1,0,1,1,1,0],[1.1,1.1,2.2,2.2,3.,3.],[0.2,0.4,0.4]);
f.setGaussLocalizationOnCells([1],[0,0,1,0,1,0],[1.1,1.1,2.2,2.2,3.,3.,4.,4.],[0.1,0.1,0.4,0.4]);
f.setGaussLocalizationOnCells([2],[0,0,1,0,1,0],[1.1,1.1,2.2,2.2,3.,3.,4.,4.,5.,5.],[0.1,0.1,0.4,0.3,0.1]);
- arr=DataArrayDouble(16,2) ; arr[:,0]=range(7,23) ; arr[:,1]=100+arr[:,0]
+ arr = DataArrayDouble(16, 2) ; arr[:, 0] = list(range(7, 23)) ; arr[:, 1] = 100 + arr[:, 0]
f.setArray(arr)
f.checkConsistencyLight()
ff=f[1:-1:2]
time_deb = datetime.now()
a1=DataArrayDouble(len(d))
b1=DataArrayInt(len(d))
- m1s=[m1[i] for i in xrange(m1.getNumberOfCells())]
+ m1s = [m1[i] for i in range(m1.getNumberOfCells())]
for j,pt in enumerate(d):
eter=1e308
fter=-1
m=MEDCouplingUMesh("mesh",2)
m.setCoords(coo)
m.allocateCells()
- for i in xrange(24):
+ for i in range(24):
m.insertNextCell(NORM_QUAD4,conn[4*i:4*i+4])
pass
m.checkConsistency()
d[:,1]*=pi/180. # angle in radian
d=d.fromPolarToCart()
d+=zeBary
- m=MEDCouplingUMesh("quad8",2) ; m.allocateCells() ; m.insertNextCell(NORM_QUAD8,range(8)) ; m.setCoords(d)
+ m = MEDCouplingUMesh("quad8", 2) ; m.allocateCells() ; m.insertNextCell(NORM_QUAD8, list(range(8))) ; m.setCoords(d)
self.assertTrue(m.computeCellCenterOfMass().isEqual(DataArrayDouble(zeBary,1,2),1e-13))
self.assertAlmostEqual(float(m.getMeasureField(False).getArray()),pi*zeRadius*zeRadius,12)
tri32D=m.buildDescendingConnectivity()[0][0] ; tri32D.zipCoords()
d[:,1]*=pi/180. # angle in radian
d=d.fromPolarToCart()
d+=zeBary
- m=MEDCouplingUMesh("tri6",2) ; m.allocateCells() ; m.insertNextCell(NORM_TRI6,range(6)) ; m.setCoords(d)
+ m = MEDCouplingUMesh("tri6", 2) ; m.allocateCells() ; m.insertNextCell(NORM_TRI6, list(range(6))) ; m.setCoords(d)
self.assertTrue(m.computeCellCenterOfMass().isEqual(DataArrayDouble(zeBary,1,2),1e-13))
self.assertAlmostEqual(float(m.getMeasureField(False).getArray()),pi*zeRadius*zeRadius,12)
# spaceDim=3 TRI6 becomes TRI3 ... for the moment
d[:,1]*=pi/180. # angle in radian
d=d.fromPolarToCart()
d+=zeBary
- m=MEDCouplingUMesh("qpolyg",2) ; m.allocateCells() ; m.insertNextCell(NORM_QPOLYG,range(10)) ; m.setCoords(d)
+ m = MEDCouplingUMesh("qpolyg", 2) ; m.allocateCells() ; m.insertNextCell(NORM_QPOLYG, list(range(10))) ; m.setCoords(d)
self.assertTrue(m.computeCellCenterOfMass().isEqual(DataArrayDouble(zeBary,1,2),1e-13))
self.assertAlmostEqual(float(m.getMeasureField(False).getArray()),pi*zeRadius*zeRadius,12)
# spaceDim=3 QPOLYG becomes POLYG ... for the moment
s=slice(18,1,-2)
self.assertEqual(DataArray.GetNumberOfItemGivenBESRelative(s),9)
self.assertRaises(InterpKernelException,DataArray.GetNumberOfItemGivenBES,s)
- self.assertEqual(sum([DataArray.GetNumberOfItemGivenBESRelative(DataArray.GetSlice(s,i,4)) for i in xrange(4)]),DataArray.GetNumberOfItemGivenBESRelative(s))
+ self.assertEqual(sum([DataArray.GetNumberOfItemGivenBESRelative(DataArray.GetSlice(s, i, 4)) for i in range(4)]), DataArray.GetNumberOfItemGivenBESRelative(s))
self.assertEqual(DataArray.GetSlice(s,0,4),slice(18,14,-2))
self.assertEqual(DataArray.GetSlice(s,1,4),slice(14,10,-2))
self.assertEqual(DataArray.GetSlice(s,2,4),slice(10,6,-2))
#
maxNbCSN=nbOfCellsSharingNodes.getMaxValue()[0]
arr3=DataArrayDouble(f.getMesh().getNumberOfNodes(),f.getArray().getNumberOfComponents()) ; arr3[:]=0.
- for i in xrange(1,maxNbCSN+1):
+ for i in range(1, maxNbCSN + 1):
ids=nbOfCellsSharingNodes.findIdsEqual(i)
if len(ids)==0:
continue
m=MEDCoupling1SGTUMesh("m",NORM_QUAD4)
mem_m=m.getHeapMemorySize()
m.allocateCells(5)
- self.assertIn(m.getHeapMemorySize()-mem_m,xrange(5*4*4,5*4*4+32))
+ self.assertIn(m.getHeapMemorySize() - mem_m, 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])
valuesToTest=f.getValueOnMulti(targetPointCoordsXY);
self.assertEqual(196,valuesToTest.getNumberOfTuples());
self.assertEqual(1,valuesToTest.getNumberOfComponents());
- for i in xrange(40):
+ for i in range(40):
self.assertAlmostEqual(targetFieldValsExpected[i],valuesToTest.getIJ(i,0),10)
pass
fd=f.getDiscretization()
#
trs=[[0.,0.,-1.],[0.,0.,1.],[1.,0.,0.],[0.,-1.,0.],[-1.,0.,0.],[0.,1.,0.]]
for i,t in enumerate(trs):
- for j in xrange(64):
+ for j in range(64):
j2=(j//16) ; j1=((j%16)//4) ; j0=(j%4)
m11=m1.deepCopy()
m11.rotate([0.,0.,0.],[0.,0.,1.],float(j0)*pi/2)
m=MEDCouplingUMesh("mesh",2) ; m.setCoords(coo)
m.allocateCells()
# the cell description is exactly those described in the description of TRI7 in MED file 3.0.7 documentation
- m.insertNextCell(NORM_TRI7,range(7))
+ m.insertNextCell(NORM_TRI7, list(range(7)))
refCoords=[0.,0.,1.,0.,0.,1.,0.5,0.,0.5,0.5,0.,0.5,0.3333333333333333,0.3333333333333333]
gaussCoords=[0.3333333333333333,0.3333333333333333,0.470142064105115,0.470142064105115,0.05971587178977,0.470142064105115,0.470142064105115,0.05971587178977,0.101286507323456,0.101286507323456,0.797426985353088,0.101286507323456,0.101286507323456,0.797426985353088]
weights=[0.062969590272413,0.062969590272413,0.062969590272413,0.066197076394253,0.066197076394253,0.066197076394253,0.1125]
def testSwigBugOnUnpackingTuplesInDataArray1(self):
inp=DataArrayDouble([(1,2,3),(4,5,6),(7,8,9),(10,11,12)])
it=inp.__iter__()
- r=it.next()
+ r = next(it)
self.assertRaises(StopIteration,r.__getitem__,4)
self.assertEqual(len(r),3)
a,b,c=r
- r=it.next()
+ r = next(it)
self.assertEqual(len(r),3)
d,e,f=r
- r=it.next()
+ r = next(it)
self.assertEqual(len(r),3)
g,h,i=r
- r=it.next()
+ r = next(it)
self.assertEqual(len(r),3)
j,k,l=r
self.assertTrue(inp.isEqual(DataArrayDouble([a,b,c,d,e,f,g,h,i,j,k,l],4,3),1e-12))
########
inp=DataArrayInt([(1,2,3),(4,5,6),(7,8,9),(10,11,12)])
it=inp.__iter__()
- r=it.next()
+ r = next(it)
self.assertRaises(StopIteration,r.__getitem__,4)
self.assertEqual(len(r),3)
a,b,c=r
- r=it.next()
+ r = next(it)
self.assertEqual(len(r),3)
d,e,f=r
- r=it.next()
+ r = next(it)
self.assertEqual(len(r),3)
g,h,i=r
- r=it.next()
+ r = next(it)
self.assertEqual(len(r),3)
j,k,l=r
self.assertTrue(inp.isEqual(DataArrayInt([a,b,c,d,e,f,g,h,i,j,k,l],4,3)))
self.assertTrue(isinstance(g0[0],MEDCouplingCartesianAMRPatchGF))
g1=amr.retrieveGridsAt(1)
self.assertEqual(5,len(g1))
- for i in xrange(5):
+ for i in range(5):
self.assertTrue(isinstance(g1[i],MEDCouplingCartesianAMRPatch))
pass
pass
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);
li=[]
liExp3D=[(0,0,0),(1,0,0),(2,0,0),(3,0,0),(0,1,0),(1,1,0),(2,1,0),(3,1,0),(0,2,0),(1,2,0),(2,2,0),(3,2,0),(0,0,1),(1,0,1),(2,0,1),(3,0,1),(0,1,1),(1,1,1),(2,1,1),(3,1,1),(0,2,1),(1,2,1),(2,2,1),(3,2,1)]
self.assertEqual(24,m.getNumberOfCells())
- for i in xrange(m.getNumberOfCells()):
+ for i in range(m.getNumberOfCells()):
li.append(m.getLocationFromCellId(i))
pass
self.assertEqual(liExp3D,li)
li=[]
liExp2D=[(0,0),(1,0),(2,0),(3,0),(0,1),(1,1),(2,1),(3,1),(0,2),(1,2),(2,2),(3,2)]
self.assertEqual(12,m.getNumberOfCells())
- for i in xrange(m.getNumberOfCells()):
+ for i in range(m.getNumberOfCells()):
li.append(m.getLocationFromCellId(i))
pass
self.assertEqual(liExp2D,li)
arrX=DataArrayDouble(5) ; arrX.iota()
m=MEDCouplingCMesh() ; m.setCoords(arrX)
self.assertEqual(4,m.getNumberOfCells())
- for i in xrange(m.getNumberOfCells()):
+ for i in range(m.getNumberOfCells()):
self.assertEqual((i,),m.getLocationFromCellId(i))
pass
self.assertRaises(InterpKernelException,m.getLocationFromCellId,4)
li=[]
liExp3D=[(0,0,0),(1,0,0),(2,0,0),(3,0,0),(4,0,0),(0,1,0),(1,1,0),(2,1,0),(3,1,0),(4,1,0),(0,2,0),(1,2,0),(2,2,0),(3,2,0),(4,2,0),(0,3,0),(1,3,0),(2,3,0),(3,3,0),(4,3,0),(0,0,1),(1,0,1),(2,0,1),(3,0,1),(4,0,1),(0,1,1),(1,1,1),(2,1,1),(3,1,1),(4,1,1),(0,2,1),(1,2,1),(2,2,1),(3,2,1),(4,2,1),(0,3,1),(1,3,1),(2,3,1),(3,3,1),(4,3,1),(0,0,2),(1,0,2),(2,0,2),(3,0,2),(4,0,2),(0,1,2),(1,1,2),(2,1,2),(3,1,2),(4,1,2),(0,2,2),(1,2,2),(2,2,2),(3,2,2),(4,2,2),(0,3,2),(1,3,2),(2,3,2),(3,3,2),(4,3,2)]
self.assertEqual(60,m.getNumberOfNodes())
- for i in xrange(m.getNumberOfNodes()):
+ for i in range(m.getNumberOfNodes()):
li.append(m.getLocationFromNodeId(i))
pass
self.assertEqual(liExp3D,li)
li=[]
liExp2D=[(0,0),(1,0),(2,0),(3,0),(4,0),(0,1),(1,1),(2,1),(3,1),(4,1),(0,2),(1,2),(2,2),(3,2),(4,2),(0,3),(1,3),(2,3),(3,3),(4,3)]
self.assertEqual(20,m.getNumberOfNodes())
- for i in xrange(m.getNumberOfNodes()):
+ for i in range(m.getNumberOfNodes()):
li.append(m.getLocationFromNodeId(i))
pass
self.assertEqual(liExp2D,li)
arrX=DataArrayDouble(5) ; arrX.iota()
m=MEDCouplingCMesh() ; m.setCoords(arrX)
self.assertEqual(5,m.getNumberOfNodes())
- for i in xrange(m.getNumberOfNodes()):
+ for i in range(m.getNumberOfNodes()):
self.assertEqual((i,),m.getLocationFromNodeId(i))
pass
self.assertRaises(InterpKernelException,m.getLocationFromCellId,5)
st0=d.repr() ; st1=str(d) ; st2=d.reprNotTooLong()
self.assertNotEqual(st0,st1) # 1001 tuples ( > 1000) -> str(d)==d.reprNotTooLong()
self.assertEqual(st1,st2)
- self.assertIn(len(st2),xrange(0,1000)) # no more than 1000 characters
+ self.assertIn(len(st2), 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),xrange(0,1000)) # no more than 1000 characters
+ self.assertIn(len(st2), list(range(0, 1000))) # no more than 1000 characters
pass
def testExtrudedMeshWithoutZipCoords1(self):
coo=DataArrayDouble([(0,2),(2,0),(6,4),(4,9)])
m=MEDCoupling1SGTUMesh("mesh",NORM_QUAD4) ; m.setCoords(coo)
exp3=sqrt(85.)
- for delta in xrange(4):
- c=[(elt+delta)%4 for elt in xrange(4)]
+ for delta in range(4):
+ c = [(elt + delta) % 4 for elt in range(4)]
m.setNodalConnectivity(DataArrayInt(c))
self.assertAlmostEqual(m.computeDiameterField().getArray()[0],exp3,12)
m2=m.buildUnstructured() ; m2.convertLinearCellsToQuadratic(0)
# QUAD4 - spacedim = 3
coo=DataArrayDouble([(0.26570992384234871,2.0405889913271817,-0.079134238105786903),(2.3739976619218064,0.15779148692781009,0.021842842914139737),(6.1207841448393197,4.3755532938679655,0.43666375769970678),(3.8363255342943359,9.2521096041694229,0.41551170895942313)])
m=MEDCoupling1SGTUMesh("mesh",NORM_QUAD4) ; m.setCoords(coo)
- for delta in xrange(4):
- c=[(elt+delta)%4 for elt in xrange(4)]
+ for delta in range(4):
+ c = [(elt + delta) % 4 for elt in range(4)]
m.setNodalConnectivity(DataArrayInt(c))
self.assertAlmostEqual(m.computeDiameterField().getArray()[0],exp3,12)
m2=m.buildUnstructured() ; m2.convertLinearCellsToQuadratic(0)
m=MEDCoupling1SGTUMesh("mesh",NORM_PENTA6) ; m.setCoords(coo)
exp4=2.5041256256889888
self.assertAlmostEqual(exp4,coo.buildEuclidianDistanceDenseMatrix().getMaxValue()[0],12)# <- the definition of diameter
- for delta in xrange(3):
- c=[(elt+delta)%3 for elt in xrange(3)]
+ for delta in range(3):
+ c = [(elt + delta) % 3 for elt in range(3)]
c+=[elt+3 for elt in c]
m.setNodalConnectivity(DataArrayInt(c))
self.assertAlmostEqual(m.computeDiameterField().getArray()[0],exp4,12)
m=MEDCoupling1SGTUMesh("mesh",NORM_HEXA8) ; m.setCoords(coo)
exp5=2.5366409441884215
self.assertAlmostEqual(exp5,coo.buildEuclidianDistanceDenseMatrix().getMaxValue()[0],12)# <- the definition of diameter
- for delta in xrange(4):
- c=[(elt+delta)%4 for elt in xrange(4)]
+ for delta in range(4):
+ c = [(elt + delta) % 4 for elt in range(4)]
c+=[elt+4 for elt in c]
m.setNodalConnectivity(DataArrayInt(c))
self.assertAlmostEqual(m.computeDiameterField().getArray()[0],exp5,12)
m=MEDCoupling1SGTUMesh("mesh",NORM_PYRA5) ; m.setCoords(coo)
exp6=2.1558368027391386
self.assertAlmostEqual(exp6,coo.buildEuclidianDistanceDenseMatrix().getMaxValue()[0],12)# <- the definition of diameter
- for delta in xrange(4):
- c=[(elt+delta)%4 for elt in xrange(4)]
+ for delta in range(4):
+ c = [(elt + delta) % 4 for elt in range(4)]
c+=[4]
m.setNodalConnectivity(DataArrayInt(c))
self.assertAlmostEqual(m.computeDiameterField().getArray()[0],exp6,12)
m=MEDCoupling1SGTUMesh("mesh",NORM_PYRA5) ; m.setCoords(coo)
exp7=1.4413563787228953
self.assertAlmostEqual(exp7,coo.buildEuclidianDistanceDenseMatrix().getMaxValue()[0],12)# <- the definition of diameter
- for delta in xrange(4):
- c=[(elt+delta)%4 for elt in xrange(4)]
+ for delta in range(4):
+ c = [(elt + delta) % 4 for elt in range(4)]
c+=[4]
m.setNodalConnectivity(DataArrayInt(c))
self.assertAlmostEqual(m.computeDiameterField().getArray()[0],exp7,12)
exp8=1.7131322579364157
self.assertAlmostEqual(exp8,coo.buildEuclidianDistanceDenseMatrix().getMaxValue()[0],12)# <- the definition of diameter
for c in [[0,1,2,3],[0,3,2,1],[0,1,3,2],[0,2,3,1],[0,3,1,2],[0,2,1,3]]:
- for i in xrange(4):
+ for i in range(4):
m.setNodalConnectivity(DataArrayInt([(elt+i)%4 for elt in c]))
self.assertAlmostEqual(m.computeDiameterField().getArray()[0],exp8,12)
m2=m.buildUnstructured() ; m2.convertLinearCellsToQuadratic(0)
if(!PySlice_Check(slic))
throw INTERP_KERNEL::Exception("ExtractFromIndexedArraysSlice (wrap) : the first param is not a pyslice !");
Py_ssize_t strt=2,stp=2,step=2;
- PySliceObject *sliC=reinterpret_cast<PySliceObject *>(slic);
if(!arrIndxIn)
throw INTERP_KERNEL::Exception("ExtractFromIndexedArraysSlice (wrap) : last array is null !");
arrIndxIn->checkAllocated();
if(arrIndxIn->getNumberOfComponents()!=1)
throw INTERP_KERNEL::Exception("ExtractFromIndexedArraysSlice (wrap) : number of components of last argument must be equal to one !");
- GetIndicesOfSlice(sliC,arrIndxIn->getNumberOfTuples(),&strt,&stp,&step,"ExtractFromIndexedArraysSlice (wrap) : Invalid slice regarding nb of elements !");
+ GetIndicesOfSlice(slic,arrIndxIn->getNumberOfTuples(),&strt,&stp,&step,"ExtractFromIndexedArraysSlice (wrap) : Invalid slice regarding nb of elements !");
DataArrayInt *arrOut=0,*arrIndexOut=0;
MEDCouplingUMesh::ExtractFromIndexedArraysSlice(strt,stp,step,arrIn,arrIndxIn,arrOut,arrIndexOut);
PyObject *ret=PyTuple_New(2);
import os
__filename=os.environ.get('PYTHONSTARTUP')
if __filename and os.path.isfile(__filename):
- execfile(__filename)
+ exec(open(__filename).read())
pass
%}
#ifndef __MEDCOUPLINGDATAARRAYTYPEMAPS_I__
#define __MEDCOUPLINGDATAARRAYTYPEMAPS_I__
+#if PY_VERSION_HEX >= 0x03000000
+#define PyInt_AS_LONG PyLong_AS_LONG
+#endif
+
#include "InterpKernelAutoPtr.hxx"
#include "MEDCouplingDataArrayTraits.hxx"
* This method is an extention of PySlice_GetIndices but less
* open than PySlice_GetIndicesEx that accepts too many situations.
*/
-void GetIndicesOfSlice(PySliceObject *slice, Py_ssize_t length, Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step, const char *msgInCaseOfFailure)
+void GetIndicesOfSlice(PyObject *slice, Py_ssize_t length, Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step, const char *msgInCaseOfFailure)
{
- int ret(PySlice_GetIndices(slice,length,start,stop,step));
+ int ret(PySlice_GetIndices(
+#if PY_VERSION_HEX >= 0x03000000
+ slice,
+#else
+ reinterpret_cast<PySliceObject *>(slice),
+#endif
+ length,start,stop,step));
if(ret==0)
return ;
if(*step>0 && *start==*stop && length==*start)
/*!
* This method allows to retrieve slice info from \a slice.
*/
-void GetIndicesOfSliceExplicitely(PySliceObject *slice, Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step, const char *msgInCaseOfFailure)
+void GetIndicesOfSliceExplicitely(PyObject *slice, Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step, const char *msgInCaseOfFailure)
{
- int ret(PySlice_GetIndices(slice,std::numeric_limits<int>::max(),start,stop,step));
+ int ret(PySlice_GetIndices(
+#if PY_VERSION_HEX >= 0x03000000
+ slice,
+#else
+ reinterpret_cast<PySliceObject *>(slice),
+#endif
+ std::numeric_limits<int>::max(),start,stop,step));
if(ret==0)
{
if(*start!=std::numeric_limits<int>::max() && *stop!=std::numeric_limits<int>::max())
SWIGINTERN PyObject *MEDCoupling_DataArrayInt_toNumPyArray(MEDCoupling::DataArrayInt *self);
SWIGINTERN PyObject *MEDCoupling_DataArrayDouble_toNumPyArray(MEDCoupling::DataArrayDouble *self);
-PyObject *ToCSRMatrix(const std::vector<std::map<int,double> >& m, int nbCols) throw(INTERP_KERNEL::Exception)
+PyObject *ToCSRMatrix(const std::vector<std::map<int,double> >& m, int nbCols)
{
int nbRows((int)m.size());
MEDCoupling::MCAuto<MEDCoupling::DataArrayInt> indPtr(MEDCoupling::DataArrayInt::New()),indices(MEDCoupling::DataArrayInt::New());
return ret;
}
-static PyObject *convertDataArrayChar(MEDCoupling::DataArrayChar *dac, int owner) throw(INTERP_KERNEL::Exception)
+static PyObject *convertDataArrayChar(MEDCoupling::DataArrayChar *dac, int owner)
{
PyObject *ret=0;
if(!dac)
return ret;
}
-static PyObject *convertDataArray(MEDCoupling::DataArray *dac, int owner) throw(INTERP_KERNEL::Exception)
+static PyObject *convertDataArray(MEDCoupling::DataArray *dac, int owner)
{
PyObject *ret=0;
if(!dac)
return ret;
}
-static PyObject *convertIntArrToPyList(const int *ptr, int size) throw(INTERP_KERNEL::Exception)
+static PyObject *convertIntArrToPyList(const int *ptr, int size)
{
PyObject *ret=PyList_New(size);
for(int i=0;i<size;i++)
return ret;
}
-static PyObject *convertIntArrToPyList2(const std::vector<int>& v) throw(INTERP_KERNEL::Exception)
+static PyObject *convertIntArrToPyList2(const std::vector<int>& v)
{
int size=v.size();
PyObject *ret=PyList_New(size);
return ret;
}
-static PyObject *convertIntArrToPyList3(const std::set<int>& v) throw(INTERP_KERNEL::Exception)
+static PyObject *convertIntArrToPyList3(const std::set<int>& v)
{
int size=v.size();
PyObject *ret=PyList_New(size);
return ret;
}
-static PyObject *convertIntArrToPyListOfTuple(const int *vals, int nbOfComp, int nbOfTuples) throw(INTERP_KERNEL::Exception)
+static bool convertPyObjectToStrNT(PyObject *obj, std::string& ret)
+{
+ if(PyString_Check(obj))
+ {
+ ret=PyString_AsString(obj);
+ return true;
+ }
+#if PY_VERSION_HEX >= 0x03000000
+ else if(PyUnicode_Check(obj))
+ {
+ ret=PyUnicode_AsUTF8(obj);
+ return true;
+ }
+#endif
+ return false;
+}
+
+static std::string convertPyObjectToStr(PyObject *obj, const char *msg=NULL)
+{
+ std::string ret;
+ if(PyString_Check(obj))
+ ret=PyString_AsString(obj);
+#if PY_VERSION_HEX >= 0x03000000
+ else if(PyUnicode_Check(obj))
+ ret=PyUnicode_AsUTF8(obj);
+#endif
+ else
+ {
+ std::ostringstream oss;
+ if(msg)
+ oss << msg;
+ else
+ oss << "PyWrap convertPyObjectToStr : expect a sting like py object !";
+ throw INTERP_KERNEL::Exception(oss.str());
+ }
+ return ret;
+}
+
+static PyObject *convertIntArrToPyListOfTuple(const int *vals, int nbOfComp, int nbOfTuples)
{
PyObject *ret=PyList_New(nbOfTuples);
for(int i=0;i<nbOfTuples;i++)
return ret;
}
-static int *convertPyToNewIntArr2(PyObject *pyLi, int *size) throw(INTERP_KERNEL::Exception)
+static int *convertPyToNewIntArr2(PyObject *pyLi, int *size)
{
if(PyList_Check(pyLi))
{
}
}
-static PyObject *convertFromVectorPairInt(const std::vector< std::pair<int,int> >& arr) throw(INTERP_KERNEL::Exception)
+static PyObject *convertFromVectorPairInt(const std::vector< std::pair<int,int> >& arr)
{
PyObject *ret=PyList_New(arr.size());
for(std::size_t i=0;i<arr.size();i++)
return ret;
}
-static void convertPyToVectorPairInt(PyObject *pyLi, std::vector< std::pair<int,int> >& arr) throw(INTERP_KERNEL::Exception)
+static void convertPyToVectorPairInt(PyObject *pyLi, std::vector< std::pair<int,int> >& arr)
{
const char msg[]="list must contain tuples of 2 integers only or tuple must contain tuples of 2 integers only !";
if(PyList_Check(pyLi))
throw INTERP_KERNEL::Exception(msg);
}
-static void convertPyToVectorPairStringInt(PyObject *pyLi, std::vector< std::pair<std::string,int> >& arr) throw(INTERP_KERNEL::Exception)
+static void convertPyToVectorPairStringInt(PyObject *pyLi, std::vector< std::pair<std::string,int> >& arr)
{
const char msg[]="convertPyToVectorPairStringInt : list must contain tuples of 2 integers only or tuple must contain tuples of 1 string and 1 integer only !";
if(PyList_Check(pyLi))
if(sz2!=2)
throw INTERP_KERNEL::Exception(msg);
PyObject *o_0=PyTuple_GetItem(o,0);
- if(!PyString_Check(o_0))
- throw INTERP_KERNEL::Exception(msg);
PyObject *o_1=PyTuple_GetItem(o,1);
+ arr[i].first=convertPyObjectToStr(o_0,msg);
if(!PyInt_Check(o_1))
throw INTERP_KERNEL::Exception(msg);
- arr[i].first=PyString_AsString(o_0);
arr[i].second=(int)PyInt_AS_LONG(o_1);
}
else
if(sz2!=2)
throw INTERP_KERNEL::Exception(msg);
PyObject *o_0=PyTuple_GetItem(o,0);
- if(!PyString_Check(o_0))
- throw INTERP_KERNEL::Exception(msg);
PyObject *o_1=PyTuple_GetItem(o,1);
+ arr[i].first=convertPyObjectToStr(o_0,msg);
if(!PyInt_Check(o_1))
throw INTERP_KERNEL::Exception(msg);
- arr[i].first=PyString_AsString(o_0);
arr[i].second=(int)PyInt_AS_LONG(o_1);
}
else
throw INTERP_KERNEL::Exception(msg);
}
-static void convertPyToNewIntArr3(PyObject *pyLi, std::vector<int>& arr) throw(INTERP_KERNEL::Exception)
+static void convertPyToNewIntArr3(PyObject *pyLi, std::vector<int>& arr)
{
if(PyList_Check(pyLi))
{
}
}
-static void convertPyToNewIntArr4(PyObject *pyLi, int recurseLev, int nbOfSubPart, std::vector<int>& arr) throw(INTERP_KERNEL::Exception)
+static void convertPyToNewIntArr4(PyObject *pyLi, int recurseLev, int nbOfSubPart, std::vector<int>& arr)
{
if(recurseLev<0)
throw INTERP_KERNEL::Exception("convertPyToNewIntArr4 : invalid list of integers level of recursion !");
throw INTERP_KERNEL::Exception("convertPyToNewIntArr4 : not a list nor a tuple recursively !");
}
-static void checkFillArrayWithPyList(int size1, int size2, int& nbOfTuples, int& nbOfComp) throw(INTERP_KERNEL::Exception)
+static void checkFillArrayWithPyList(int size1, int size2, int& nbOfTuples, int& nbOfComp)
{
if(nbOfTuples==-1)
{
throw INTERP_KERNEL::Exception("fillArrayWithPyListInt3 : Unrecognized type ! Should be a composition of tuple,list,int !");
}
-static std::vector<int> fillArrayWithPyListInt2(PyObject *pyLi, int& nbOfTuples, int& nbOfComp) throw(INTERP_KERNEL::Exception)
+static std::vector<int> fillArrayWithPyListInt2(PyObject *pyLi, int& nbOfTuples, int& nbOfComp)
{
std::vector<int> ret;
int size1=-1,size2=-1;
return ret;
}
-static bool fillStringVector(PyObject *pyLi, std::vector<std::string>& vec) throw(INTERP_KERNEL::Exception)
+static bool fillStringVector(PyObject *pyLi, std::vector<std::string>& vec)
{
if(PyList_Check(pyLi))
{
for(int i=0;i<sz;i++)
{
PyObject *o=PyList_GetItem(pyLi,i);
- if(PyString_Check(o))
- vec[i]=PyString_AsString(o);
- else
+ if(!convertPyObjectToStrNT(o,vec[i]))
return false;
}
return true;
for(int i=0;i<sz;i++)
{
PyObject *o=PyTuple_GetItem(pyLi,i);
- if(PyString_Check(o))
- vec[i]=PyString_AsString(o);
- else
+ if(!convertPyObjectToStrNT(o,vec[i]))
return false;
}
return true;
else
return false;
}
-static void convertPyToVectorOfVectorOfString(PyObject *pyLi, std::vector< std::vector<std::string> >& arr) throw(INTERP_KERNEL::Exception)
+static void convertPyToVectorOfVectorOfString(PyObject *pyLi, std::vector< std::vector<std::string> >& arr)
{
const char msg[]="convertPyToVectorOfVectorOfString : expecting list of list of strings !";
if(PyList_Check(pyLi))
throw INTERP_KERNEL::Exception(msg);
}
-static bool fillIntVector(PyObject *pyLi, std::vector<int>& vec) throw(INTERP_KERNEL::Exception)
+static bool fillIntVector(PyObject *pyLi, std::vector<int>& vec)
{
if(PyList_Check(pyLi))
{
return false;
}
-static void convertPyToVectorOfVectorOfInt(PyObject *pyLi, std::vector< std::vector<int> >& arr) throw(INTERP_KERNEL::Exception)
+static void convertPyToVectorOfVectorOfInt(PyObject *pyLi, std::vector< std::vector<int> >& arr)
{
const char msg[]="convertPyToVectorOfVectorOfInt : expecting list of list of strings !";
if(PyList_Check(pyLi))
throw INTERP_KERNEL::Exception(msg);
}
-static void convertPyToVectorPairStringVecString(PyObject *pyLi, std::vector< std::pair<std::string, std::vector<std::string> > >& arr) throw(INTERP_KERNEL::Exception)
+static void convertPyToVectorPairStringVecString(PyObject *pyLi, std::vector< std::pair<std::string, std::vector<std::string> > >& arr)
{
const char msg[]="convertPyToVectorPairStringVecString : expecting list of tuples containing each exactly 2 items : one string and one vector of string !";
if(PyList_Check(pyLi))
throw INTERP_KERNEL::Exception(msg);
std::pair<std::string, std::vector<std::string> > item;
PyObject *o_0=PyTuple_GetItem(o,0);
- if(!PyString_Check(o_0))
- throw INTERP_KERNEL::Exception(msg);
- item.first=PyString_AsString(o_0);
+ item.first=convertPyObjectToStr(o_0,msg);
PyObject *o_1=PyTuple_GetItem(o,1);
if(!fillStringVector(o_1,item.second))
throw INTERP_KERNEL::Exception(msg);
throw INTERP_KERNEL::Exception(msg);
std::pair<std::string, std::vector<std::string> > item;
PyObject *o_0=PyTuple_GetItem(o,0);
- if(!PyString_Check(o_0))
- throw INTERP_KERNEL::Exception(msg);
- item.first=PyString_AsString(o_0);
+ item.first=convertPyObjectToStr(o_0,msg);
PyObject *o_1=PyTuple_GetItem(o,1);
if(!fillStringVector(o_1,item.second))
throw INTERP_KERNEL::Exception(msg);
}
template<class T>
-PyObject *convertDblArrToPyList(const T *ptr, int size) throw(INTERP_KERNEL::Exception)
+PyObject *convertDblArrToPyList(const T *ptr, int size)
{
PyObject *ret(PyList_New(size));
for(int i=0;i<size;i++)
return ret;
}
-static PyObject *convertDblArrToPyList2(const std::vector<double>& v) throw(INTERP_KERNEL::Exception)
+static PyObject *convertDblArrToPyList2(const std::vector<double>& v)
{
int size(v.size());
PyObject *ret(PyList_New(size));
}
template<class T>
-PyObject *convertDblArrToPyListOfTuple(const T *vals, int nbOfComp, int nbOfTuples) throw(INTERP_KERNEL::Exception)
+PyObject *convertDblArrToPyListOfTuple(const T *vals, int nbOfComp, int nbOfTuples)
{
PyObject *ret(PyList_New(nbOfTuples));
for(int i=0;i<nbOfTuples;i++)
return ret;
}
-static PyObject *convertCharArrToPyListOfTuple(const char *vals, int nbOfComp, int nbOfTuples) throw(INTERP_KERNEL::Exception)
+static PyObject *convertCharArrToPyListOfTuple(const char *vals, int nbOfComp, int nbOfTuples)
{
PyObject *ret=PyList_New(nbOfTuples);
INTERP_KERNEL::AutoPtr<char> tmp=new char[nbOfComp+1]; tmp[nbOfComp]='\0';
return ret;
}
-static double *convertPyToNewDblArr2(PyObject *pyLi, int *size) throw(INTERP_KERNEL::Exception)
+static double *convertPyToNewDblArr2(PyObject *pyLi, int *size)
{
if(PyList_Check(pyLi))
{
throw INTERP_KERNEL::Exception("fillArrayWithPyListDbl3 : Unrecognized type ! Should be a composition of tuple,list,int and float !");
}
-static std::vector<double> fillArrayWithPyListDbl2(PyObject *pyLi, int& nbOfTuples, int& nbOfComp) throw(INTERP_KERNEL::Exception)
+static std::vector<double> fillArrayWithPyListDbl2(PyObject *pyLi, int& nbOfTuples, int& nbOfComp)
{
std::vector<double> ret;
int size1=-1,size2=-1;
*
* switch between (int,vector<int>,DataArrayInt)
*/
-static void convertIntStarLikePyObjToCpp(PyObject *value, int& sw, int& iTyypp, std::vector<int>& stdvecTyypp, MEDCoupling::DataArrayInt *& daIntTyypp, MEDCoupling::DataArrayIntTuple *&daIntTuple) throw(INTERP_KERNEL::Exception)
+static void convertIntStarLikePyObjToCpp(PyObject *value, int& sw, int& iTyypp, std::vector<int>& stdvecTyypp, MEDCoupling::DataArrayInt *& daIntTyypp, MEDCoupling::DataArrayIntTuple *&daIntTuple)
{
sw=-1;
if(PyInt_Check(value))
*
* switch between (int,vector<int>,DataArrayInt)
*/
-static const int *convertIntStarLikePyObjToCppIntStar(PyObject *value, int& sw, int& sz, int& iTyypp, std::vector<int>& stdvecTyypp) throw(INTERP_KERNEL::Exception)
+static const int *convertIntStarLikePyObjToCppIntStar(PyObject *value, int& sw, int& sz, int& iTyypp, std::vector<int>& stdvecTyypp)
{
sw=-1;
if(PyInt_Check(value))
* switch between (int,vector<int>,DataArrayInt)
*/
template<class T>
-void considerPyObjAsATStarLikeObject(PyObject *value, int& sw, T& iTyypp, std::vector<T>& stdvecTyypp, typename MEDCoupling::Traits<T>::ArrayType *& daIntTyypp, swig_type_info *ti) throw(INTERP_KERNEL::Exception)
+void considerPyObjAsATStarLikeObject(PyObject *value, int& sw, T& iTyypp, std::vector<T>& stdvecTyypp, typename MEDCoupling::Traits<T>::ArrayType *& daIntTyypp, swig_type_info *ti)
{
sw=-1;
if(PyFloat_Check(value))
*
* switch between (int,vector<int>,DataArrayInt)
*/
-static void convertDoubleStarLikePyObjToCpp(PyObject *value, int& sw, double& iTyypp, std::vector<double>& stdvecTyypp, MEDCoupling::DataArrayDoubleTuple *& daIntTyypp) throw(INTERP_KERNEL::Exception)
+static void convertDoubleStarLikePyObjToCpp(PyObject *value, int& sw, double& iTyypp, std::vector<double>& stdvecTyypp, MEDCoupling::DataArrayDoubleTuple *& daIntTyypp)
{
sw=-1;
if(PyFloat_Check(value))
*
* switch between (int,vector<int>,DataArrayInt)
*/
-static void convertIntStarOrSliceLikePyObjToCpp(PyObject *value, int nbelem, int& sw, int& iTyypp, std::vector<int>& stdvecTyypp, std::pair<int, std::pair<int,int> >& p, MEDCoupling::DataArrayInt *& daIntTyypp) throw(INTERP_KERNEL::Exception)
+static void convertIntStarOrSliceLikePyObjToCpp(PyObject *value, int nbelem, int& sw, int& iTyypp, std::vector<int>& stdvecTyypp, std::pair<int, std::pair<int,int> >& p, MEDCoupling::DataArrayInt *& daIntTyypp)
{
const char *msg="5 types accepted : integer, tuple of integer, list of integer, slice, DataArrayInt, DataArrayIntTuple";
sw=-1;
if(PySlice_Check(value))
{
Py_ssize_t strt=2,stp=2,step=2;
- PySliceObject *oC=reinterpret_cast<PySliceObject *>(value);
- GetIndicesOfSlice(oC,nbelem,&strt,&stp,&step,"Slice in subscriptable object DataArray invalid !");
+ GetIndicesOfSlice(value,nbelem,&strt,&stp,&step,"Slice in subscriptable object DataArray invalid !");
p.first=strt;
p.second.first=stp;
p.second.second=step;
/*!
* Idem than convertIntStarOrSliceLikePyObjToCpp
*/
-static void convertIntStarOrSliceLikePyObjToCppWithNegIntInterp(PyObject *value, int nbelem, int& sw, int& iTyypp, std::vector<int>& stdvecTyypp, std::pair<int, std::pair<int,int> >& p, MEDCoupling::DataArrayInt *& daIntTyypp) throw(INTERP_KERNEL::Exception)
+static void convertIntStarOrSliceLikePyObjToCppWithNegIntInterp(PyObject *value, int nbelem, int& sw, int& iTyypp, std::vector<int>& stdvecTyypp, std::pair<int, std::pair<int,int> >& p, MEDCoupling::DataArrayInt *& daIntTyypp)
{
convertIntStarOrSliceLikePyObjToCpp(value,nbelem,sw,iTyypp,stdvecTyypp,p,daIntTyypp);
if(sw==1)
* if python slice -> cpp pair sw=3
* if python DataArrayIntTuple -> cpp DataArrayIntTuple sw=4 . WARNING The returned pointer can be the null pointer !
*/
-static void convertObjToPossibleCpp22(PyObject *value, int nbelem, int& sw, int& iTyypp, std::vector<int>& stdvecTyypp, std::pair<int, std::pair<int,int> >& p, MEDCoupling::DataArrayIntTuple *& daIntTyypp) throw(INTERP_KERNEL::Exception)
+static void convertObjToPossibleCpp22(PyObject *value, int nbelem, int& sw, int& iTyypp, std::vector<int>& stdvecTyypp, std::pair<int, std::pair<int,int> >& p, MEDCoupling::DataArrayIntTuple *& daIntTyypp)
{
sw=-1;
if(PyInt_Check(value))
if(PySlice_Check(value))
{
Py_ssize_t strt=2,stp=2,step=2;
- PySliceObject *oC=reinterpret_cast<PySliceObject *>(value);
- GetIndicesOfSlice(oC,nbelem,&strt,&stp,&step,"Slice in subscriptable object DataArray invalid !");
+ GetIndicesOfSlice(value,nbelem,&strt,&stp,&step,"Slice in subscriptable object DataArray invalid !");
p.first=strt;
p.second.first=stp;
p.second.second=step;
* if python not null pointer of DataArrayChar -> cpp DataArrayChar sw=4
* switch between (int,string,vector<string>,DataArrayChar)
*/
-static void convertObjToPossibleCpp6(PyObject *value, int& sw, char& cTyp, std::string& sType, std::vector<std::string>& vsType, MEDCoupling::DataArrayChar *& dacType) throw(INTERP_KERNEL::Exception)
+static void convertObjToPossibleCpp6(PyObject *value, int& sw, char& cTyp, std::string& sType, std::vector<std::string>& vsType, MEDCoupling::DataArrayChar *& dacType)
{
const char *msg="4 types accepted : string, list or tuple of strings having same size, not null DataArrayChar instance.";
sw=-1;
return;
}
}
+#if PY_VERSION_HEX >= 0x03000000
+ if(PyUnicode_Check(value))
+ {
+ Py_ssize_t sz;
+ const char *pt = PyUnicode_AsUTF8AndSize(value, &sz);
+ if(sz==1)
+ {
+ cTyp=pt[0];
+ sw=1;
+ return;
+ }
+ else
+ {
+ sType=pt;
+ sw=2;
+ return;
+ }
+ }
+#endif
if(PyTuple_Check(value))
{
int size=PyTuple_Size(value);
for(int i=0;i<size;i++)
{
PyObject *o=PyTuple_GetItem(value,i);
- if(PyString_Check(o))
- vsType[i]=PyString_AsString(o);
- else
+ try
+ {
+ vsType[i]=convertPyObjectToStr(o);
+ }
+ catch(INTERP_KERNEL::Exception& e)
{
std::ostringstream oss; oss << "Tuple as been detected but element #" << i << " is not a string ! only tuples of strings accepted !";
throw INTERP_KERNEL::Exception(oss.str().c_str());
for(int i=0;i<size;i++)
{
PyObject *o=PyList_GetItem(value,i);
- if(PyString_Check(o))
- vsType[i]=PyString_AsString(o);
- else
+ try
+ {
+ vsType[i]=convertPyObjectToStr(o);
+ }
+ catch(INTERP_KERNEL::Exception& e)
{
- std::ostringstream oss; oss << "List as been detected but element #" << i << " is not string ! only lists of strings accepted !";
+ std::ostringstream oss; oss << "List as been detected but element #" << i << " is not a string ! only tuples of strings accepted !";
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
}
*/
static void convertObjToPossibleCpp3(PyObject *value, int nbTuple, int nbCompo, int& sw, int& it, int& ic, std::vector<int>& vt, std::vector<int>& vc,
std::pair<int, std::pair<int,int> >& pt, std::pair<int, std::pair<int,int> >& pc,
- MEDCoupling::DataArrayInt *&dt, MEDCoupling::DataArrayInt *&dc) throw(INTERP_KERNEL::Exception)
+ MEDCoupling::DataArrayInt *&dt, MEDCoupling::DataArrayInt *&dc)
{
if(!PyTuple_Check(value))
{
* if value tuple[int,double] -> cpp std::vector<double> sw=4
*/
static const double *convertObjToPossibleCpp5_Safe(PyObject *value, int& sw, double& val, MEDCoupling::DataArrayDouble *&d, MEDCoupling::DataArrayDoubleTuple *&e, std::vector<double>& f,
- const char *msg, int nbTuplesExpected, int nbCompExpected, bool throwIfNullPt) throw(INTERP_KERNEL::Exception)
+ const char *msg, int nbTuplesExpected, int nbCompExpected, bool throwIfNullPt)
{
sw=-1;
if(PyFloat_Check(value))
* if value tuple[int,double] -> cpp std::vector<double> sw=4
*/
static const double *convertObjToPossibleCpp5_Safe2(PyObject *value, int& sw, double& val, MEDCoupling::DataArrayDouble *&d, MEDCoupling::DataArrayDoubleTuple *&e, std::vector<double>& f,
- const char *msg, int nbCompExpected, bool throwIfNullPt, int& nbTuples) throw(INTERP_KERNEL::Exception)
+ const char *msg, int nbCompExpected, bool throwIfNullPt, int& nbTuples)
{
sw=-1;
if(PyFloat_Check(value))
* if value tuple[int,double] -> cpp std::vector<double> sw=4
*/
static const double *convertObjToPossibleCpp5_SingleCompo(PyObject *value, int& sw, double& val, std::vector<double>& f,
- const char *msg, bool throwIfNullPt, int& nbTuples) throw(INTERP_KERNEL::Exception)
+ const char *msg, bool throwIfNullPt, int& nbTuples)
{
MEDCoupling::DataArrayDouble *d=0;
MEDCoupling::DataArrayDoubleTuple *e=0;
return NewMethWrapCallInitOnlyIfDictWithSingleEltInInputGeneral<SinglePyObjToBePutInATuple>(cls,args,clsName);
}
-static PyObject *convertPartDefinition(MEDCoupling::PartDefinition *pd, int owner) throw(INTERP_KERNEL::Exception)
+static PyObject *convertPartDefinition(MEDCoupling::PartDefinition *pd, int owner)
{
PyObject *ret=0;
if(!pd)
targetMesh=MEDCouplingUMesh.New();
targetMesh.setMeshDimension(3);
targetMesh.allocateCells(12);
- for i in xrange(8):
+ for i in range(8):
targetMesh.insertNextCell(NORM_HEXA8,8,targetConn[8*i:8*i+8]);
pass
targetMesh.finishInsertingCells();
targetMesh=MEDCouplingUMesh.New();
targetMesh.setMeshDimension(3);
targetMesh.allocateCells(12);
- for i in xrange(8):
+ for i in range(8):
targetMesh.insertNextCell(NORM_HEXA8,8,targetConn[8*i:8*(i+1)]);
pass
targetMesh.finishInsertingCells();
ret=MEDCouplingUMesh.New("1DSourceMesh",1);
ret.allocateCells(4);
conn=[0,1,2,3,1,2,3,4]
- for i in xrange(4):
+ for i in range(4):
ret.insertNextCell(NORM_SEG2,2,conn[2*i:2*i+2]);
pass
ret.finishInsertingCells();
15,24,25,16,12,21,22,13,
16,25,26,17,13,22,23,14];
mesh.allocateCells(8);
- for i in xrange(8):
+ for i in range(8):
mesh.insertNextCell(NORM_HEXA8,8,conn[8*i:8*(i+1)])
pass
mesh.finishInsertingCells();
mesh.setCoords(coo);
mesh2.setCoords(coo);
mesh.allocateCells(16);
- for i in xrange(12):
+ for i in range(12):
mesh.insertNextCell(NORM_TETRA4,4,conn[4*i:4*i+4])
pass
mesh.insertNextCell(NORM_PYRA5,5,conn[48:53])
#[1,34,29,23,41,32]
conn2=[0,5,1,14,18,17,8,7,4,9,5,2, 12,8,9,13,6,7,8,9]
mesh2.allocateCells(6);
- for i in xrange(4):
+ for i in range(4):
mesh2.insertNextCell(NORM_TRI3,3,conn2[3*i:3*i+3])
pass
mesh2.insertNextCell(NORM_QUAD4,4,conn2[12:16])
m.setCoords(coo)
m.allocateCells()
conn=[[11,8,13],[11,13,12],[8,9,13],[9,14,13],[9,10,15],[9,15,14],[12,13,19],[13,16,19],[13,14,17],[13,17,16],[14,15,17],[15,18,17],[0,1,4,3],[1,2,5,4],[2,6,7,5],[3,4,8,11],[4,5,9,8],[5,7,10,9],[20,22,21,28,41,51],[21,25,20,29,42,51],[22,23,21,30,43,41],[23,27,21,31,35,43],[23,38,24,32,44,52],[24,27,23,33,31,52],[25,21,50,29,45,53],[21,39,50,34,46,45],[21,27,26,35,47,54],[26,39,21,36,34,54],[27,24,26,33,48,47],[24,40,26,37,49,48],[50,39,56,55,46,62,58,71],[39,26,57,56,36,63,59,62],[26,40,61,57,49,64,60,63],[55,56,17,18,58,65,68,72],[56,57,16,17,59,66,69,65],[57,61,19,16,60,67,70,66]]
- for i in xrange(0,12):
+ for i in range(0, 12):
m.insertNextCell(NORM_TRI3,conn[i])
pass
- for i in xrange(12,18):
+ for i in range(12, 18):
m.insertNextCell(NORM_QUAD4,conn[i])
pass
- for i in xrange(18,30):
+ for i in range(18, 30):
m.insertNextCell(NORM_TRI6,conn[i])
pass
- for i in xrange(30,36):
+ for i in range(30, 36):
m.insertNextCell(NORM_QUAD8,conn[i])
pass
fff=MEDCouplingFieldDouble.New(ON_GAUSS_PT) ; fff.setName("CH1RB") ; fff.setNature(IntensiveMaximum)
fff.setMesh(m)
- fff.setGaussLocalizationOnCells(range(0,12),[0.,0.,1.,0.,0.,1.],[0.3333333333333333,0.3333333333333333],[0.5])
- fff.setGaussLocalizationOnCells(range(12,18),[-1.,-1.,1.,-1.,1.,1.,-1.,1.],[-0.577350269189626,-0.577350269189626,0.577350269189626,-0.577350269189626,0.577350269189626,0.577350269189626,-0.577350269189626,0.577350269189626],[1.,1.,1.,1.])
- fff.setGaussLocalizationOnCells(range(18,30),[0.,0.,1.,0.,0.,1.,0.5, 0.,0.5, 0.5, 0.,0.5],[0.16666666666666666,0.16666666666666666,0.6666666666666666,0.16666666666666666,0.16666666666666666,0.6666666666666666],[0.16666666666666666,0.16666666666666666,0.16666666666666666])
- fff.setGaussLocalizationOnCells(range(30,36),[-1.,-1.,1.,-1.,1.,1.,-1.,1.,0.,-1.,1.,0.,0.,1.,-1.,0.],[-0.774596669241483,-0.774596669241483,0.774596669241483,-0.774596669241483,0.774596669241483,0.774596669241483,-0.774596669241483,0.774596669241483,0.0,-0.774596669241483,0.774596669241483,0.0,0.0,0.774596669241483,-0.774596669241483,0.0,0.0,0.0],[0.30864197530864196,0.30864197530864196,0.30864197530864196,0.30864197530864196,0.49382716049382713,0.49382716049382713,0.49382716049382713,0.49382716049382713,0.7901234567901234])
+ fff.setGaussLocalizationOnCells(list(range(0, 12)), [0., 0., 1., 0., 0., 1.], [0.3333333333333333, 0.3333333333333333], [0.5])
+ fff.setGaussLocalizationOnCells(list(range(12, 18)), [-1., -1., 1., -1., 1., 1., -1., 1.], [-0.577350269189626, -0.577350269189626, 0.577350269189626, -0.577350269189626, 0.577350269189626, 0.577350269189626, -0.577350269189626, 0.577350269189626], [1., 1., 1., 1.])
+ fff.setGaussLocalizationOnCells(list(range(18, 30)), [0., 0., 1., 0., 0., 1., 0.5, 0., 0.5, 0.5, 0., 0.5], [0.16666666666666666, 0.16666666666666666, 0.6666666666666666, 0.16666666666666666, 0.16666666666666666, 0.6666666666666666], [0.16666666666666666, 0.16666666666666666, 0.16666666666666666])
+ fff.setGaussLocalizationOnCells(list(range(30, 36)), [-1., -1., 1., -1., 1., 1., -1., 1., 0., -1., 1., 0., 0., 1., -1., 0.], [-0.774596669241483, -0.774596669241483, 0.774596669241483, -0.774596669241483, 0.774596669241483, 0.774596669241483, -0.774596669241483, 0.774596669241483, 0.0, -0.774596669241483, 0.774596669241483, 0.0, 0.0, 0.774596669241483, -0.774596669241483, 0.0, 0.0, 0.0], [0.30864197530864196, 0.30864197530864196, 0.30864197530864196, 0.30864197530864196, 0.49382716049382713, 0.49382716049382713, 0.49382716049382713, 0.49382716049382713, 0.7901234567901234])
return MEDCouplingFieldTemplate(fff)
# 2D usecase2 for interpolation Gauss Pt-> Gauss Pt. Coming from ASTER : Please, do not touch
m.setCoords(coo)
m.allocateCells(0)
conn=[[198,194,200],[198,200,199],[194,195,200],[195,201,200],[195,196,202],[195,202,201],[196,197,202],[197,203,202],[199,200,205],[199,205,204],[200,201,205],[201,206,205],[201,202,207],[201,207,206],[202,203,207],[203,208,207],[204,205,210],[204,210,209],[205,206,210],[206,211,210],[206,207,212],[206,212,211],[207,208,212],[208,213,212],[209,210,215],[209,215,214],[210,211,215],[211,216,215],[211,212,217],[211,217,216],[212,213,217],[213,218,217],[214,215,157],[214,157,158],[215,216,157],[216,156,157],[216,217,155],[216,155,156],[217,218,155],[218,163,155],[169,170,174,173],[170,171,175,174],[171,172,176,175],[172,189,190,176],[173,174,178,177],[174,175,179,178],[175,176,180,179],[176,190,191,180],[177,178,182,181],[178,179,183,182],[179,180,184,183],[180,191,192,184],[181,182,186,185],[182,183,187,186],[183,184,188,187],[184,192,193,188],[185,186,194,198],[186,187,195,194],[187,188,196,195],[188,193,197,196],[0,2,1,27,62,89],[1,7,0,28,63,89],[2,3,1,29,64,62],[3,9,1,30,36,64],[3,5,4,31,65,90],[4,9,3,32,30,90],[5,6,4,33,66,65],[6,11,4,34,39,66],[7,1,8,28,67,91],[8,12,7,35,68,91],[1,9,8,36,69,67],[9,14,8,37,42,69],[9,4,10,32,70,92],[10,14,9,38,37,92],[4,11,10,39,71,70],[11,16,10,40,45,71],[12,8,13,35,72,93],[13,17,12,41,73,93],[8,14,13,42,74,72],[14,19,13,43,48,74],[14,10,15,38,75,94],[15,19,14,44,43,94],[10,16,15,45,76,75],[16,21,15,46,51,76],[17,13,18,41,77,95],[18,22,17,47,78,95],[13,19,18,48,79,77],[19,24,18,49,54,79],[19,15,20,44,80,96],[20,24,19,50,49,96],[15,21,20,51,81,80],[21,26,20,52,57,81],[22,18,23,47,82,97],[23,59,22,53,83,97],[18,24,23,54,84,82],[24,60,23,55,85,84],[24,20,25,50,86,98],[25,60,24,56,55,98],[20,26,25,57,87,86],[26,61,25,58,88,87],[59,23,100,99,53,135,115,164],[23,60,101,100,85,136,116,135],[60,25,102,101,56,137,117,136],[25,61,131,102,88,138,118,137],[99,100,104,103,115,139,119,165],[100,101,105,104,116,140,120,139],[101,102,106,105,117,141,121,140],[102,131,132,106,118,142,122,141],[103,104,108,107,119,143,123,166],[104,105,109,108,120,144,124,143],[105,106,110,109,121,145,125,144],[106,132,133,110,122,146,126,145],[107,108,112,111,123,147,127,167],[108,109,113,112,124,148,128,147],[109,110,114,113,125,149,129,148],[110,133,134,114,126,150,130,149],[111,112,155,163,127,151,159,168],[112,113,156,155,128,152,160,151],[113,114,157,156,129,153,161,152],[114,134,158,157,130,154,162,153]]
- for i in xrange(0,40):
+ for i in range(0, 40):
m.insertNextCell(NORM_TRI3,conn[i])
pass
- for i in xrange(40,60):
+ for i in range(40, 60):
m.insertNextCell(NORM_QUAD4,conn[i])
pass
- for i in xrange(60,100):
+ for i in range(60, 100):
m.insertNextCell(NORM_TRI6,conn[i])
pass
- for i in xrange(100,120):
+ for i in range(100, 120):
m.insertNextCell(NORM_QUAD8,conn[i])
pass
fff=MEDCouplingFieldDouble.New(ON_GAUSS_PT) ; fff.setName("CH2RB") ; fff.setNature(IntensiveMaximum)
fff.setMesh(m)
- fff.setGaussLocalizationOnCells(range(0,40),[0.,0.,1.,0.,0.,1.],[0.3333333333333333,0.3333333333333333],[0.5])
- fff.setGaussLocalizationOnCells(range(40,60),[-1.,-1.,1.,-1.,1.,1.,-1.,1.],[-0.577350269189626,-0.577350269189626,0.577350269189626,-0.577350269189626,0.577350269189626,0.577350269189626,-0.577350269189626,0.577350269189626],[1.,1.,1.,1.])
- fff.setGaussLocalizationOnCells(range(60,100),[0.,0.,1.,0.,0.,1.,0.5, 0.,0.5, 0.5, 0.,0.5],[0.16666666666666666,0.16666666666666666,0.6666666666666666,0.16666666666666666,0.16666666666666666,0.6666666666666666],[0.16666666666666666,0.16666666666666666,0.16666666666666666])
- fff.setGaussLocalizationOnCells(range(100,120),[-1.,-1.,1.,-1.,1.,1.,-1.,1.,0.,-1.,1.,0.,0.,1.,-1.,0.],[-0.774596669241483,-0.774596669241483,0.774596669241483,-0.774596669241483,0.774596669241483,0.774596669241483,-0.774596669241483,0.774596669241483,0.0,-0.774596669241483,0.774596669241483,0.0,0.0,0.774596669241483,-0.774596669241483,0.0,0.0,0.0],[0.30864197530864196,0.30864197530864196,0.30864197530864196,0.30864197530864196,0.49382716049382713,0.49382716049382713,0.49382716049382713,0.49382716049382713,0.7901234567901234])
+ fff.setGaussLocalizationOnCells(list(range(0, 40)), [0., 0., 1., 0., 0., 1.], [0.3333333333333333, 0.3333333333333333], [0.5])
+ fff.setGaussLocalizationOnCells(list(range(40, 60)), [-1., -1., 1., -1., 1., 1., -1., 1.], [-0.577350269189626, -0.577350269189626, 0.577350269189626, -0.577350269189626, 0.577350269189626, 0.577350269189626, -0.577350269189626, 0.577350269189626], [1., 1., 1., 1.])
+ fff.setGaussLocalizationOnCells(list(range(60, 100)), [0., 0., 1., 0., 0., 1., 0.5, 0., 0.5, 0.5, 0., 0.5], [0.16666666666666666, 0.16666666666666666, 0.6666666666666666, 0.16666666666666666, 0.16666666666666666, 0.6666666666666666], [0.16666666666666666, 0.16666666666666666, 0.16666666666666666])
+ fff.setGaussLocalizationOnCells(list(range(100, 120)), [-1., -1., 1., -1., 1., 1., -1., 1., 0., -1., 1., 0., 0., 1., -1., 0.], [-0.774596669241483, -0.774596669241483, 0.774596669241483, -0.774596669241483, 0.774596669241483, 0.774596669241483, -0.774596669241483, 0.774596669241483, 0.0, -0.774596669241483, 0.774596669241483, 0.0, 0.0, 0.774596669241483, -0.774596669241483, 0.0, 0.0, 0.0], [0.30864197530864196, 0.30864197530864196, 0.30864197530864196, 0.30864197530864196, 0.49382716049382713, 0.49382716049382713, 0.49382716049382713, 0.49382716049382713, 0.7901234567901234])
return MEDCouplingFieldTemplate(fff)
# 3D usecase1 for interpolation Gauss Pt-> Gauss Pt. Coming from ASTER : Please, do not touch
conn=[[3,10,8,4],[19,22,23,20,14],[0,6,1,3,8,4],[4,8,10,5,9,11],[12,16,17,14,19,20],[14,20,23,15,21,24],[1,2,5,4,6,7,9,8],[12,13,15,14,17,18,21,20]]
m.insertNextCell(NORM_TETRA4,conn[0])
m.insertNextCell(NORM_PYRA5,conn[1])
- for i in xrange(2,6):
+ for i in range(2, 6):
m.insertNextCell(NORM_PENTA6,conn[i])
pass
m.insertNextCell(NORM_HEXA8,conn[6])
conn=[[3,10,8,4],[19,22,23,20,14],[0,6,1,3,8,4],[4,8,10,5,9,11],[12,16,17,14,19,20],[14,20,23,15,21,24],[1,2,5,4,6,7,9,8],[12,13,15,14,17,18,21,20]]
m.insertNextCell(NORM_TETRA4,conn[0])
m.insertNextCell(NORM_PYRA5,conn[1])
- for i in xrange(2,6):
+ for i in range(2, 6):
m.insertNextCell(NORM_PENTA6,conn[i])
pass
m.insertNextCell(NORM_HEXA8,conn[6])
fff.setGaussLocalizationOnCells([6,7],[-1.,-1.,-1.,-1.,1.,-1.,1.,1.,-1.,1.,-1.,-1.,-1.,-1.,1.,-1.,1.,1.,1.,1.,1.,1.,-1.,1.],[-0.577350269189626,-0.577350269189626,-0.577350269189626,-0.577350269189626,-0.577350269189626,0.577350269189626,-0.577350269189626,0.577350269189626,-0.577350269189626,-0.577350269189626,0.577350269189626,0.577350269189626,0.577350269189626,-0.577350269189626,-0.577350269189626,0.577350269189626,-0.577350269189626,0.577350269189626,0.577350269189626,0.577350269189626,-0.577350269189626,0.577350269189626,0.577350269189626,0.577350269189626],[1.,1.,1.,1.,1.,1.,1.,1.])
return MEDCouplingFieldTemplate(fff)
- def buildCircle(self, center_X, center_Y, radius):
+ def buildCircle(self, center_X, center_Y, radius):
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 = range(4)
+ connec = list(range(4))
baseMesh = MEDCouplingUMesh.New("circle", 2)
baseMesh.allocateCells(1)
- meshCoords = DataArrayDouble.New(coords, len(coords)/2, 2)
+ meshCoords = DataArrayDouble.New(coords, len(coords) // 2, 2)
meshCoords += (center_X, center_Y)
baseMesh.setCoords(meshCoords)
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])
connec = [7,5,3,1, 6,4,2,0]
baseMesh = MEDCouplingUMesh.New("circle", 2)
baseMesh.allocateCells(1)
- meshCoords = DataArrayDouble.New(coords, len(coords)/2, 2)
+ meshCoords = DataArrayDouble.New(coords, len(coords) // 2, 2)
meshCoords += (center_X, center_Y)
baseMesh.setCoords(meshCoords)
fileName = "testExample_MEDCouplingFieldDouble_WriteVTK"
fs = [ field1, field2, field3 ] # field series
writtenFileName=MEDCouplingFieldDouble.WriteVTK( fileName, fs )
- print "The file name with correct extension is : %s"%(writtenFileName)
+ print("The file name with correct extension is : %s"%(writtenFileName))
#! [PySnippet_MEDCouplingFieldDouble_WriteVTK_1]
import os
os.remove( writtenFileName )
#! [Snippet_DataArrayInt_getTuple_1]
#! [Snippet_DataArrayInt_getTuple_2]
for tpl in dv:
- print tpl
+ print(tpl)
#! [Snippet_DataArrayInt_getTuple_2]
return
da.setValues(arr1,6,1)
da2=da.invertArrayO2N2N2O(6)
expected1=[1,3,0,5,2,4]
- for i in xrange(6):
+ for i in range(6):
self.assertEqual(expected1[i],da2.getIJ(i,0))
pass
#! [PySnippet_DataArrayInt_invertArrayO2N2N2O_1]
da.setValues(arr1,6,1)
da2=da.invertArrayN2O2O2N(7)
expected1=[1,3,0,5,2,4,-1]
- for i in xrange(6):
+ for i in range(6):
self.assertEqual(expected1[i],da2.getIJ(i,0))
pass
#! [PySnippet_DataArrayInt_invertArrayN2O2O2N_1]
#! [PySnippet_DataArrayDouble_getIdsInRange_1]
da=DataArrayDouble()
da.alloc( 10, 1 )
- da[ :, :] = range(10)
+ da[ :, :] = list(range(10))
da2 = da.findIdsInRange( 2.5, 6 )
#! [PySnippet_DataArrayDouble_getIdsInRange_1]
return
dv=da.getDifferentValues(2e-1)
expected2=[2.301,1.3,0.8]
self.assertEqual(3,dv.getNbOfElems())
- for i in xrange(3):
+ for i in range(3):
self.assertAlmostEqual(expected2[i],dv.getIJ(i,0),14)
pass
#! [Snippet_DataArrayDouble_getDifferentValues1]
self.assertEqual(3,f2.getNumberOfTuples())
self.assertEqual(2,f2.getNumberOfComponents())
expected1=[5.,105.,4.,104.,7.,107.]
- for i in xrange(6):
+ for i in range(6):
self.assertAlmostEqual(f2.getIJ(0,i),expected1[i],12)
pass
self.assertEqual(3,f2.getMesh().getNumberOfCells())
m2C=f2.getMesh()
self.assertEqual(13,m2C.getNodalConnectivityArrayLen())
expected2=[0.2, -0.3, 0.7, -0.3, 0.2, 0.2, 0.7, 0.2, 0.2, 0.7, 0.7, 0.7]
- for i in xrange(12):
+ for i in range(12):
self.assertAlmostEqual(expected2[i],m2C.getCoords().getIJ(0,i),12)
pass
expected3=[3,2,3,1,3,0,2,1,4,4,5,3,2]
self.assertEqual(4,f2.getNumberOfTuples())
self.assertEqual(2,f2.getNumberOfComponents())
expected5=[4.,104.,5.,105.,7.,107.,8.,108.]
- for i in xrange(8):
+ for i in range(8):
self.assertAlmostEqual(f2.getIJ(0,i),expected5[i],12)
pass
self.assertEqual(2,f2.getMesh().getNumberOfCells())
self.assertEqual(2,f2.getMesh().getMeshDimension())
m2C=f2.getMesh()
self.assertEqual(8,m2C.getNodalConnectivityArrayLen())
- for i in xrange(8):#8 is not an error
+ for i in range(8): # 8 is not an error
self.assertAlmostEqual(expected2[i],m2C.getCoords().getIJ(0,i),12)
pass
self.assertEqual(expected3[:4],[int(i) for i in m2C.getNodalConnectivity()][4:])
f2=f1.buildSubPart(arrr)
self.assertEqual(4,f2.getNumberOfTuples())
self.assertEqual(2,f2.getNumberOfComponents())
- for i in xrange(8):
+ for i in range(8):
self.assertAlmostEqual(f2.getIJ(0,i),expected5[i],12)
pass
self.assertEqual(2,f2.getMesh().getNumberOfCells())
self.assertEqual(2,f2.getMesh().getMeshDimension())
m2C=f2.getMesh()
self.assertEqual(8,m2C.getNodalConnectivityArrayLen())
- for i in xrange(8):#8 is not an error
+ for i in range(8): # 8 is not an error
self.assertAlmostEqual(expected2[i],m2C.getCoords().getIJ(0,i),12)
pass
self.assertEqual(expected3[:4],[int(i) for i in m2C.getNodalConnectivity()][4:8])
self.assertEqual(6,f2.getNumberOfTuples())
self.assertEqual(2,f2.getNumberOfComponents())
expected6=[4.,104.,5.,105.,7.,107.,8.,108.,10.,110.,11.,111.]
- for i in xrange(12):
+ for i in range(12):
self.assertAlmostEqual(f2.getIJ(0,i),expected6[i],12)
pass
self.assertEqual(3,f2.getMesh().getNumberOfCells())
self.assertEqual(2,f2.getMesh().getMeshDimension())
m2C=f2.getMesh()
self.assertEqual(13,m2C.getNodalConnectivityArrayLen())
- for i in xrange(12):
+ for i in range(12):
self.assertAlmostEqual(expected2[i],m2C.getCoords().getIJ(0,i),12)
pass
self.assertEqual(expected3[0:4],m2C.getNodalConnectivity().getValues()[4:8])
DataArrayDouble.__imul__=MEDCouplingDataArrayDoubleImul
DataArrayDouble.__idiv__=MEDCouplingDataArrayDoubleIdiv
DataArrayDouble.__ipow__=MEDCouplingDataArrayDoubleIpow
+DataArrayDouble.__truediv__=DataArrayDouble.__div__
+DataArrayDouble.__itruediv__=MEDCouplingDataArrayDoubleIdiv
+DataArrayDouble.__rtruediv__=DataArrayDouble.__rdiv__
+DataArrayDouble.__floordiv__=DataArrayDouble.__div__
+DataArrayDouble.__ifloordiv__=MEDCouplingDataArrayDoubleIdiv
+DataArrayDouble.__rfloordiv__=DataArrayDouble.__rdiv__
DataArrayInt.__new__=classmethod(MEDCouplingDataArrayIntnew)
DataArrayInt.__iadd__=MEDCouplingDataArrayIntIadd
DataArrayInt.__idiv__=MEDCouplingDataArrayIntIdiv
DataArrayInt.__imod__=MEDCouplingDataArrayIntImod
DataArrayInt.__ipow__=MEDCouplingDataArrayIntIpow
+DataArrayInt.__truediv__=DataArrayInt.__div__
+DataArrayInt.__itruediv__=MEDCouplingDataArrayIntIdiv
+DataArrayInt.__rtruediv__=DataArrayInt.__rdiv__
+DataArrayInt.__floordiv__=DataArrayInt.__div__
+DataArrayInt.__ifloordiv__=MEDCouplingDataArrayIntIdiv
+DataArrayInt.__rfloordiv__=DataArrayInt.__rdiv__
DataArrayByte.__new__=classmethod(MEDCouplingDataArrayBytenew)
DataArrayFloat.__isub__=MEDCouplingDataArrayFloatIsub
DataArrayFloat.__imul__=MEDCouplingDataArrayFloatImul
DataArrayFloat.__idiv__=MEDCouplingDataArrayFloatIdiv
+DataArrayFloat.__itruediv__=MEDCouplingDataArrayFloatIdiv
+DataArrayFloat.__ifloordiv__=MEDCouplingDataArrayFloatIdiv
MEDCouplingFieldDouble.__new__=classmethod(MEDCouplingFieldDoublenew)
MEDCouplingFieldDouble.__iadd__=MEDCouplingFieldDoubleIadd
MEDCouplingFieldDouble.__imul__=MEDCouplingFieldDoubleImul
MEDCouplingFieldDouble.__idiv__=MEDCouplingFieldDoubleIdiv
MEDCouplingFieldDouble.__ipow__=MEDCouplingFieldDoubleIpow
+MEDCouplingFieldDouble.__truediv__=MEDCouplingFieldDouble.__div__
+MEDCouplingFieldDouble.__rtruediv__=MEDCouplingFieldDouble.__rdiv__
+MEDCouplingFieldDouble.__itruediv__=MEDCouplingFieldDoubleIdiv
+MEDCouplingFieldDouble.__floordiv__=MEDCouplingFieldDouble.__div__
+MEDCouplingFieldDouble.__rfloordiv__=MEDCouplingFieldDouble.__rdiv__
+MEDCouplingFieldDouble.__ifloordiv__=MEDCouplingFieldDoubleIdiv
MEDCouplingFieldInt.__new__=classmethod(MEDCouplingFieldIntnew)
DataArrayDoubleTuple.__isub__=MEDCouplingDataArrayDoubleTupleIsub
DataArrayDoubleTuple.__imul__=MEDCouplingDataArrayDoubleTupleImul
DataArrayDoubleTuple.__idiv__=MEDCouplingDataArrayDoubleTupleIdiv
+DataArrayDoubleTuple.__itruediv__=MEDCouplingDataArrayDoubleTupleIdiv
+DataArrayDoubleTuple.__ifloordiv__=MEDCouplingDataArrayDoubleTupleIdiv
DataArrayIntTuple.__iadd__=MEDCouplingDataArrayIntTupleIadd
DataArrayIntTuple.__isub__=MEDCouplingDataArrayIntTupleIsub
DataArrayIntTuple.__imul__=MEDCouplingDataArrayIntTupleImul
DataArrayIntTuple.__idiv__=MEDCouplingDataArrayIntTupleIdiv
+DataArrayIntTuple.__itruediv__=MEDCouplingDataArrayIntTupleIdiv
+DataArrayIntTuple.__ifloordiv__=MEDCouplingDataArrayIntTupleIdiv
DataArrayIntTuple.__imod__=MEDCouplingDataArrayIntTupleImod
DenseMatrix.__iadd__=ParaMEDMEMDenseMatrixIadd
MEDCouplingIMesh.__new__=classmethod(MEDCouplingIMeshnew)
MEDCouplingMappedExtrudedMesh.__new__=classmethod(MEDCouplingExtrudedMeshnew)
+DataArrayAsciiCharIterator.__next__ = DataArrayAsciiCharIterator.next
+DataArrayIntIterator.__next__ = DataArrayIntIterator.next
+DataArrayDoubleIterator.__next__ = DataArrayDoubleIterator.next
+MEDCouplingUMeshCellIterator.__next__ = MEDCouplingUMeshCellIterator.next
+MEDCouplingUMeshCellByTypeIterator.__next__ = MEDCouplingUMeshCellByTypeIterator.next
+
del INTERPKERNELExceptionReduce
del MEDCouplingDataArrayDoublenew
del MEDCouplingDataArrayDoubleIadd
from math import pi,e,sqrt,cos,sin
from datetime import datetime
from MEDCouplingDataForTest import MEDCouplingDataForTest
-import rlcompleter,readline # this line has to be here, to ensure a usability of MEDCoupling/MEDLoader. B4 removing it please notify to anthony.geay@cea.fr
+import rlcompleter,readline # this line has to be here, to ensure a usability of MEDCoupling/MEDLoader. B4 removing it please notify to anthony.geay@edf.fr
class MEDCouplingIntersectTest(unittest.TestCase):
def testSwig2NonRegressionBugIntersectMeshes1(self):
self.assertEqual(9,m3.getNodalConnectivityIndex().getNumberOfTuples());
self.assertEqual(expected3,m3.getNodalConnectivity().getValues());
self.assertEqual(expected4,m3.getNodalConnectivityIndex().getValues());
- for i in xrange(44):
+ for i in range(44):
self.assertAlmostEqual(expected5[i],m3.getCoords().getIJ(0,i),12);
pass
pass
self.assertEqual(10,m3.getNodalConnectivityIndex().getNumberOfTuples());
self.assertEqual(expected3,m3.getNodalConnectivity().getValues());
self.assertEqual(expected4,m3.getNodalConnectivityIndex().getValues());
- for i in xrange(44):
+ for i in range(44):
self.assertAlmostEqual(expected5[i],m3.getCoords().getIJ(0,i),12);
pass
pass
m2=MEDCouplingUMesh.New();
m2.setMeshDimension(2);
m2.allocateCells(8);
- for i in xrange(8):
+ for i in range(8):
m2.insertNextCell(NORM_QUAD4,4,m2Conn[4*i:4*(i+1)])
pass
m2.finishInsertingCells();
self.assertEqual(17,m3.getNodalConnectivityIndex().getNumberOfTuples());
self.assertEqual(expected3,m3.getNodalConnectivity().getValues());
self.assertEqual(expected4,m3.getNodalConnectivityIndex().getValues());
- for i in xrange(208):
+ for i in range(208):
self.assertAlmostEqual(expected5[i],m3.getCoords().getIJ(0,i),12);
pass
pass
m2=MEDCouplingUMesh.New();
m2.setMeshDimension(2);
m2.allocateCells(8);
- for i in xrange(8):
+ for i in range(8):
m2.insertNextCell(NORM_QUAD4,4,m2Conn[4*i:4*(i+1)])
pass
m2.finishInsertingCells();
self.assertEqual(17,m3.getNodalConnectivityIndex().getNumberOfTuples());
self.assertEqual(expected3,m3.getNodalConnectivity().getValues());
self.assertEqual(expected4,m3.getNodalConnectivityIndex().getValues());
- for i in xrange(208):
+ for i in range(208):
self.assertAlmostEqual(expected5[i],m3.getCoords().getIJ(0,i),12);
pass
pass
expected1=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,16,16,17,18,19,19,20,20,20,20,20,21,21,22,23,23,24,24,24,24,24,25,25,26,27,27,28,28,28,28,28,29,29,30,31,31,32,32,32,32,32,32,32,32,32,33,33,33,34,35,35,35,36,36,36,36,36,37,37,38,39,39,40,40,40,40,40,41,41,42,43,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59]
expected2=[-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,2,-1,-1,-1,0,-1,0,2,4,5,-1,4,-1,-1,0,-1,0,2,4,5,-1,4,-1,-1,0,-1,0,2,4,5,-1,4,-1,-1,0,-1,0,1,2,3,4,5,6,7,-1,4,6,-1,-1,0,1,-1,1,3,6,7,-1,6,-1,-1,1,-1,1,3,6,7,-1,6,-1,-1,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1]
f3=m3.getMeasureField(False).getArray().getValues();
- for i in xrange(105):
+ for i in range(105):
self.assertAlmostEqual(areaExpected[i],f3[i],10)
pass
self.assertEqual(expected1,d1.getValues())
baseMesh = MEDCouplingUMesh.New("box_circle", 2)
baseMesh.allocateCells(2)
- meshCoords = DataArrayDouble.New(coords, len(coords)/2, 2)
+ meshCoords = DataArrayDouble.New(coords, len(coords) // 2, 2)
meshCoords.setInfoOnComponents(["X [au]", "Y [au]"])
baseMesh.setCoords(meshCoords)
def testIntersect2DMeshesTmp7(self):
eps = 1.0e-8
coords = [-0.5,-0.5, -0.5, 0.5, 0.5, 0.5, 0.5,-0.5]
- connec = range(4)
+ connec = list(range(4))
m1 = MEDCouplingUMesh.New("box", 2)
m1.allocateCells(1)
- meshCoords = DataArrayDouble.New(coords, len(coords)/2, 2)
+ meshCoords = DataArrayDouble.New(coords, len(coords) // 2, 2)
m1.setCoords(meshCoords)
m1.insertNextCell(NORM_POLYGON, connec)
m1.finishInsertingCells()
i=MEDCouplingIMesh("mesh",2,[5,5],[0.,0.],[1.,1.])
m1=i.buildUnstructured()
m2=MEDCouplingUMesh("mesh",1) ; m2.setCoords(DataArrayDouble([0.5,2.,2.25,2.,2.5,2.,2.75,2.,3.,2.,4.,2.,5.,2.],7,2)) ; m2.allocateCells()
- for i in xrange(6):
+ for i in range(6):
m2.insertNextCell(NORM_SEG2,[i,i+1])
pass
a,b,c,d=MEDCouplingUMesh.Intersect2DMeshWith1DLine(m1,m2,1e-12)
i=MEDCouplingIMesh("mesh",2,[5,5],[0.,0.],[1.,1.])
m1=i.buildUnstructured()
m2=MEDCouplingUMesh("mesh",1) ; m2.setCoords(DataArrayDouble([(0.75,3.25),(0.5,3.5),(0.25,3.25)])) ; m2.allocateCells()
- for i in xrange(2):
+ for i in range(2):
m2.insertNextCell(NORM_SEG2,[i,i+1])
pass
a,b,c,d=MEDCouplingUMesh.Intersect2DMeshWith1DLine(m1,m2,1e-12)
i=MEDCouplingIMesh("mesh",2,[5,5],[0.,0.],[1.,1.])
m1=i.buildUnstructured()
m2=MEDCouplingUMesh("mesh",1) ; m2.setCoords(DataArrayDouble([(1.,0.),(3.,2.),(1.,4.)])) ; m2.allocateCells()
- for i in xrange(2):
+ for i in range(2):
m2.insertNextCell(NORM_SEG2,[i,i+1])
pass
a,b,c,d=MEDCouplingUMesh.Intersect2DMeshWith1DLine(m1,m2,1e-12)
connec = [0,1]
m_line = MEDCouplingUMesh("seg", 1)
m_line.allocateCells(1)
- meshCoords = DataArrayDouble.New(coords, len(coords)/2, 2)
+ meshCoords = DataArrayDouble.New(coords, len(coords) // 2, 2)
m_line.setCoords(meshCoords)
m_line.insertNextCell(NORM_SEG2, connec)
a, b, c, d = MEDCouplingUMesh.Intersect2DMeshWith1DLine(m_circ, m_line, eps)
coords2 = [0., 1.3, -1.3, 0., -0.6, 0.6, 0., -1.3, -0.5, -0.5]
connec2, cI2 = [NORM_SEG3, 0, 1, 2, NORM_SEG3, 1, 3, 4], [0,4,8]
m_line = MEDCouplingUMesh("seg", 1)
- m_line.setCoords(DataArrayDouble(coords2, len(coords2)/2, 2))
+ m_line.setCoords(DataArrayDouble(coords2, len(coords2) // 2, 2))
m_line.setConnectivity(DataArrayInt(connec2), DataArrayInt(cI2))
a, b, c, d = MEDCouplingUMesh.Intersect2DMeshWith1DLine(m, m_line, eps)
self.assertTrue(a.getCoords().getHiddenCppPointer()==b.getCoords().getHiddenCppPointer())
coords2 = [-1., 0.25, 1., 0.25]
connec2, cI2 = [NORM_SEG2, 0, 1], [0,3]
m_line = MEDCouplingUMesh.New("seg", 1)
- m_line.setCoords(DataArrayDouble(coords2, len(coords2)/2, 2))
+ m_line.setCoords(DataArrayDouble(coords2, len(coords2) // 2, 2))
m_line.setConnectivity(DataArrayInt(connec2), DataArrayInt(cI2))
m_line2 = m_line.deepCopy()
m2 = m.deepCopy()
coords2 = [-2., 1., 2., 1.0]
connec2, cI2 = [NORM_SEG2, 0, 1], [0,3]
m_line = MEDCouplingUMesh("seg", 1)
- m_line.setCoords(DataArrayDouble(coords2, len(coords2)/2, 2))
+ m_line.setCoords(DataArrayDouble(coords2, len(coords2) // 2, 2))
m_line.setConnectivity(DataArrayInt(connec2), DataArrayInt(cI2))
a, b, c, d = MEDCouplingUMesh.Intersect2DMeshWith1DLine(m, m_line, eps)
self.assertTrue(a.getCoords().getHiddenCppPointer()==b.getCoords().getHiddenCppPointer())
coords2 = [-2., 0., 2., 0.]
connec2, cI2 = [NORM_SEG2, 0, 1], [0,3]
m_line = MEDCouplingUMesh.New("seg", 1)
- m_line.setCoords(DataArrayDouble(coords2, len(coords2)/2, 2))
+ m_line.setCoords(DataArrayDouble(coords2, len(coords2) // 2, 2))
m_line.setConnectivity(DataArrayInt(connec2), DataArrayInt(cI2))
a, b, c, d = MEDCouplingUMesh.Intersect2DMeshWith1DLine(m, m_line, eps)
self.assertTrue(a.getCoords().getHiddenCppPointer()==b.getCoords().getHiddenCppPointer())
coords2 = [1., 2., 1., -2.]
connec2, cI2 = [NORM_SEG2, 0, 1], [0,3]
m_line = MEDCouplingUMesh("seg", 1)
- m_line.setCoords(DataArrayDouble(coords2, len(coords2)/2, 2))
+ m_line.setCoords(DataArrayDouble(coords2, len(coords2) // 2, 2))
m_line.setConnectivity(DataArrayInt(connec2), DataArrayInt(cI2))
a, b, c, d = MEDCouplingUMesh.Intersect2DMeshWith1DLine(m, m_line, eps)
self.assertTrue(a.getCoords().getHiddenCppPointer()==b.getCoords().getHiddenCppPointer())
conn = [5,5,2,6,4,5,6,3,0,1,5,4,5,10,8,11,9,5,11,2,1,7,10,9]
connI = [0,5,12,17,24]
m = MEDCouplingUMesh("box",2)
- cooArr = DataArrayDouble(coo,len(coo)/2,2)
+ cooArr = DataArrayDouble(coo, len(coo) // 2, 2)
m.setCoords(cooArr)
m.setConnectivity(DataArrayInt(conn),DataArrayInt(connI))
m.mergeNodes(eps)
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
-// Author : Anthony Geay (CEA/DEN)
+// Author : Anthony Geay (EDF R&D)
////////////////////
%typemap(out) MEDCoupling::DataArray*
if(!PySlice_Check(slic))
throw INTERP_KERNEL::Exception("DataArray::GetSlice (wrap) : expecting a pyslice as second (first) parameter !");
Py_ssize_t strt=2,stp=2,step=2;
- PySliceObject *sly=reinterpret_cast<PySliceObject *>(slic);
- GetIndicesOfSliceExplicitely(sly,&strt,&stp,&step,"DataArray::GetSlice (wrap) : the input slice is invalid !");
+ GetIndicesOfSliceExplicitely(slic,&strt,&stp,&step,"DataArray::GetSlice (wrap) : the input slice is invalid !");
int a,b;
DataArray::GetSlice(strt,stp,step,sliceId,nbOfSlices,a,b);
return PySlice_New(PyInt_FromLong(a),PyInt_FromLong(b),PyInt_FromLong(step));
if(!PySlice_Check(slic))
throw INTERP_KERNEL::Exception("DataArray::getSlice (wrap) : expecting a pyslice as second (first) parameter !");
Py_ssize_t strt=2,stp=2,step=2;
- PySliceObject *sly=reinterpret_cast<PySliceObject *>(slic);
- GetIndicesOfSlice(sly,self->getNumberOfTuples(),&strt,&stp,&step,"DataArray::getSlice (wrap) : the input slice is invalid !");
+ GetIndicesOfSlice(slic,self->getNumberOfTuples(),&strt,&stp,&step,"DataArray::getSlice (wrap) : the input slice is invalid !");
int a,b;
DataArray::GetSlice(strt,stp,step,sliceId,nbOfSlices,a,b);
return PySlice_New(PyInt_FromLong(a),PyInt_FromLong(b),PyInt_FromLong(step));
if(!PySlice_Check(slic))
throw INTERP_KERNEL::Exception("DataArray::GetNumberOfItemGivenBES (wrap) : expecting a pyslice as second (first) parameter !");
Py_ssize_t strt=2,stp=2,step=2;
- PySliceObject *sly=reinterpret_cast<PySliceObject *>(slic);
- GetIndicesOfSliceExplicitely(sly,&strt,&stp,&step,"DataArray::GetNumberOfItemGivenBES (wrap) : the input slice is invalid !");
+ GetIndicesOfSliceExplicitely(slic,&strt,&stp,&step,"DataArray::GetNumberOfItemGivenBES (wrap) : the input slice is invalid !");
return DataArray::GetNumberOfItemGivenBES(strt,stp,step,"");
}
if(!PySlice_Check(slic))
throw INTERP_KERNEL::Exception("DataArray::GetNumberOfItemGivenBESRelative (wrap) : expecting a pyslice as second (first) parameter !");
Py_ssize_t strt=2,stp=2,step=2;
- PySliceObject *sly=reinterpret_cast<PySliceObject *>(slic);
- GetIndicesOfSliceExplicitely(sly,&strt,&stp,&step,"DataArray::GetNumberOfItemGivenBESRelative (wrap) : the input slice is invalid !");
+ GetIndicesOfSliceExplicitely(slic,&strt,&stp,&step,"DataArray::GetNumberOfItemGivenBESRelative (wrap) : the input slice is invalid !");
return DataArray::GetNumberOfItemGivenBESRelative(strt,stp,step,"");
}
if(!PySlice_Check(slic))
throw INTERP_KERNEL::Exception("DataArray::getNumberOfItemGivenBES (wrap) : expecting a pyslice as second (first) parameter !");
Py_ssize_t strt=2,stp=2,step=2;
- PySliceObject *sly=reinterpret_cast<PySliceObject *>(slic);
- GetIndicesOfSlice(sly,self->getNumberOfTuples(),&strt,&stp,&step,"DataArray::getNumberOfItemGivenBES (wrap) : the input slice is invalid !");
+ GetIndicesOfSlice(slic,self->getNumberOfTuples(),&strt,&stp,&step,"DataArray::getNumberOfItemGivenBES (wrap) : the input slice is invalid !");
return DataArray::GetNumberOfItemGivenBES(strt,stp,step,"");
}
if(!PySlice_Check(slic))
throw INTERP_KERNEL::Exception("DataArray::getNumberOfItemGivenBESRelative (wrap) : expecting a pyslice as second (first) parameter !");
Py_ssize_t strt=2,stp=2,step=2;
- PySliceObject *sly=reinterpret_cast<PySliceObject *>(slic);
- GetIndicesOfSlice(sly,self->getNumberOfTuples(),&strt,&stp,&step,"DataArray::getNumberOfItemGivenBESRelative (wrap) : the input slice is invalid !");
+ GetIndicesOfSlice(slic,self->getNumberOfTuples(),&strt,&stp,&step,"DataArray::getNumberOfItemGivenBESRelative (wrap) : the input slice is invalid !");
return DataArray::GetNumberOfItemGivenBESRelative(strt,stp,step,"");
}
if(sz!=2)
throw INTERP_KERNEL::Exception("DataArrayDouble.__setstate__ : invalid tuple in input ! Should be of size 2 ! Invalid overwrite of __getstate__ ?");
PyObject *a0(PyTuple_GetItem(inp,0));
- if(!PyString_Check(a0))
- throw INTERP_KERNEL::Exception(MSG);
+ self->setName(convertPyObjectToStr(a0,MSG));
PyObject *a1(PyTuple_GetItem(inp,1));
std::vector<std::string> a1cpp;
if(!fillStringVector(a1,a1cpp))
throw INTERP_KERNEL::Exception(MSG);
- self->setName(PyString_AsString(a0));
self->setInfoOnComponents(a1cpp);
}
}
if(!PySlice_Check(slic))
throw INTERP_KERNEL::Exception("DataArrayInt::buildExplicitArrOfSliceOnScaledArr (wrap) : expecting a pyslice as second (first) parameter !");
Py_ssize_t strt=2,stp=2,step=2;
- PySliceObject *sly=reinterpret_cast<PySliceObject *>(slic);
- GetIndicesOfSliceExplicitely(sly,&strt,&stp,&step,"DataArrayInt::buildExplicitArrOfSliceOnScaledArr (wrap) : the input slice is invalid !");
+ GetIndicesOfSliceExplicitely(slic,&strt,&stp,&step,"DataArrayInt::buildExplicitArrOfSliceOnScaledArr (wrap) : the input slice is invalid !");
if(strt==std::numeric_limits<int>::max() || stp==std::numeric_limits<int>::max())
throw INTERP_KERNEL::Exception("DataArrayInt::buildExplicitArrOfSliceOnScaledArr (wrap) : the input slice contains some unknowns that can't be determined in static method ! Call DataArray::getSlice (non static) instead !");
return self->buildExplicitArrOfSliceOnScaledArr(strt,stp,step);
Py_XINCREF(trueSelf);
return trueSelf;
}
-
PyObject *___idiv___(PyObject *trueSelf, PyObject *obj) throw(INTERP_KERNEL::Exception)
{
MCAuto<DataArrayInt> ret=self->buildDAInt(1,self->getNumberOfCompo());
else
throw INTERP_KERNEL::Exception(msg);
}
+%#if PY_VERSION_HEX >= 0x03000000
+ else if(PyUnicode_Check(nbOfTuples))
+ {
+ if(PyUnicode_GET_LENGTH(nbOfTuples)!=1)
+ throw INTERP_KERNEL::Exception(msg);
+ //DataArrayAsciiChar.New(["abc","de","fghi"],"t")
+ std::vector<std::string> tmp;
+ if(fillStringVector(elt0,tmp))
+ return DataArrayAsciiChar::New(tmp,PyUnicode_AsUTF8(nbOfTuples)[0]);
+ else
+ throw INTERP_KERNEL::Exception(msg);
+ }
+%#endif
else
throw INTERP_KERNEL::Exception(msg);
}
std::copy(PyString_AsString(tupl),PyString_AsString(tupl)+sz,vals.begin());
return self->presenceOfTuple(vals);
}
+%#if PY_VERSION_HEX >= 0x03000000
+ else if(PyUnicode_Check(tupl))
+ {
+ Py_ssize_t sz=PyUnicode_GET_LENGTH(tupl);
+ std::vector<char> vals(sz);
+ std::copy(PyUnicode_AsUTF8(tupl),PyUnicode_AsUTF8(tupl)+sz,vals.begin());
+ return self->presenceOfTuple(vals);
+ }
+%#endif
else
throw INTERP_KERNEL::Exception("DataArrayAsciiChar::presenceOfTuple : only strings in input supported !");
}
std::copy(PyString_AsString(vals),PyString_AsString(vals)+sz,vals2.begin());
return self->presenceOfValue(vals2);
}
+%#if PY_VERSION_HEX >= 0x03000000
+ if(PyUnicode_Check(vals))
+ {
+ Py_ssize_t sz=PyUnicode_GET_LENGTH(vals);
+ std::vector<char> vals2(sz);
+ std::copy(PyUnicode_AsUTF8(vals),PyUnicode_AsUTF8(vals)+sz,vals2.begin());
+ return self->presenceOfValue(vals2);
+ }
+%#endif
else
throw INTERP_KERNEL::Exception("DataArrayAsciiChar::presenceOfValue : only strings in input supported !");
}
std::copy(PyString_AsString(vals),PyString_AsString(vals)+sz,vals2.begin());
return self->findIdFirstEqual(vals2);
}
+%#if PY_VERSION_HEX >= 0x03000000
+ if(PyUnicode_Check(vals))
+ {
+ Py_ssize_t sz=PyUnicode_GET_LENGTH(vals);
+ std::vector<char> vals2(sz);
+ std::copy(PyUnicode_AsUTF8(vals),PyUnicode_AsUTF8(vals)+sz,vals2.begin());
+ return self->findIdFirstEqual(vals2);
+ }
+%#endif
else
throw INTERP_KERNEL::Exception("DataArrayAsciiChar::findIdFirstEqual : only strings in input supported !");
}
std::copy(PyString_AsString(tupl),PyString_AsString(tupl)+sz,vals.begin());
return self->findIdFirstEqualTuple(vals);
}
+%#if PY_VERSION_HEX >= 0x03000000
+ if(PyUnicode_Check(tupl))
+ {
+ Py_ssize_t sz=PyUnicode_GET_LENGTH(tupl);
+ std::vector<char> vals(sz);
+ std::copy(PyUnicode_AsUTF8(tupl),PyUnicode_AsUTF8(tupl)+sz,vals.begin());
+ return self->findIdFirstEqualTuple(vals);
+ }
+%#endif
else
throw INTERP_KERNEL::Exception("DataArrayAsciiChar::findIdFirstEqualTuple : only strings in input supported !");
}
std::copy(PyString_AsString(strOrListOfInt),PyString_AsString(strOrListOfInt)+sz,vals.begin());
return self->findIdSequence(vals);
}
+%#if PY_VERSION_HEX >= 0x03000000
+ else if(PyUnicode_Check(strOrListOfInt))
+ {
+ Py_ssize_t sz=PyUnicode_GET_LENGTH(strOrListOfInt);
+ std::vector<char> vals(sz);
+ std::copy(PyUnicode_AsUTF8(strOrListOfInt),PyUnicode_AsUTF8(strOrListOfInt)+sz,vals.begin());
+ return self->findIdSequence(vals);
+ }
+%#endif
else
throw INTERP_KERNEL::Exception("DataArrayAsciiChar::search : only strings in input supported !");
}
else
throw INTERP_KERNEL::Exception("DataArrayAsciiChar::index : 'this' contains one component and trying to find a string with size different from 1 !");
}
+%#if PY_VERSION_HEX >= 0x03000000
+ if(PyUnicode_Check(obj))
+ {
+ Py_ssize_t sz;
+ char *pt=PyUnicode_AsUTF8AndSize(obj, &sz);
+ if(sz==1)
+ return self->findIdFirstEqual(pt[0]);
+ else
+ throw INTERP_KERNEL::Exception("DataArrayAsciiChar::index : 'this' contains one component and trying to find a string with size different from 1 !");
+ }
+%#endif
else
throw INTERP_KERNEL::Exception("DataArrayAsciiChar::index : 'this' contains one component and trying to find an element which is not an integer !");
}
else
throw INTERP_KERNEL::Exception("DataArrayAsciiChar::__contains__ : 'this' contains one component and trying to find a string with size different from 1 !");
}
+%#if PY_VERSION_HEX >= 0x03000000
+ if(PyUnicode_Check(obj))
+ {
+ Py_ssize_t sz;
+ char *pt=PyUnicode_AsUTF8AndSize(obj, &sz);
+ if(sz==1)
+ return self->presenceOfValue(pt[0]);
+ else
+ throw INTERP_KERNEL::Exception("DataArrayAsciiChar::__contains__ : 'this' contains one component and trying to find a string with size different from 1 !");
+ }
+%#endif
else
throw INTERP_KERNEL::Exception("DataArrayAsciiChar::__contains__ : 'this' contains one component and trying to find an element which is not an integer !");
}
"""Test on DataArrayBytes"""
# use case 1
d=DataArrayByte(256)
- for i in xrange(len(d)):
+ for i in range(len(d)):
d[i]=-128+i
pass
arr=d.toNumPyArray()
- for i in xrange(len(d)):
+ for i in range(len(d)):
self.assertEqual(int(arr[i]),-128+i)
pass
d[0]=7
gc.collect()
# use case 2
d=DataArrayByte(256)
- for i in xrange(len(d)):
+ for i in range(len(d)):
d[i]=-128+i
pass
arr=d.toNumPyArray()
- for i in xrange(len(d)):
+ for i in range(len(d)):
self.assertEqual(int(arr[i]),-128+i)
pass
del d
gc.collect()
# use case 3
d=DataArrayByte(256)
- for i in xrange(len(d)):
+ for i in range(len(d)):
d[i]=-128+i
pass
arr1=d.toNumPyArray()
self.assertEqual(int(arr1[0]),10) ; self.assertEqual(int(arr2[0]),10) ; self.assertEqual(int(arr3[0]),10)
arr2[0]=15 ; self.assertEqual(int(d.getIJ(0,0)),15) ; self.assertEqual(int(arr1[0]),15) ; self.assertEqual(int(arr3[0]),15)
arr1[0]=-128
- for i in xrange(len(d)):
+ for i in range(len(d)):
self.assertEqual(int(arr1[i]),-128+i)
self.assertEqual(int(arr2[i]),-128+i)
self.assertEqual(int(arr3[i]),-128+i)
pass
del arr2
gc.collect()
- for i in xrange(len(d)):
+ for i in range(len(d)):
self.assertEqual(int(arr1[i]),-128+i)
self.assertEqual(int(arr3[i]),-128+i)
pass
del arr1
gc.collect()
- for i in xrange(len(d)):
+ for i in range(len(d)):
self.assertEqual(int(arr3[i]),-128+i)
pass
del arr3
# use case 4
arr=array(0,dtype=int8)
arr.resize(256)
- for i in xrange(256):
+ for i in range(256):
arr[i]=-128+i
pass
d=DataArrayByte(arr)
- for i in xrange(256):
+ for i in range(256):
self.assertEqual(int(d.getIJ(i,0)),-128+i)
pass
del arr
# use case 5
arr=array(0,dtype=int8)
arr.resize(256)
- for i in xrange(256):
+ for i in range(256):
arr[i]=-128+i
pass
d=DataArrayByte(arr)
- for i in xrange(256):
+ for i in range(256):
self.assertEqual(int(d.getIJ(i,0)),-128+i)
pass
del d
from platform import architecture
from sys import getrefcount
-import os,gc,weakref,cPickle,unittest
+import os, gc, weakref, unittest
+import sys
+if sys.version_info.major < 3:
+ import cPickle as pickle
+else:
+ import pickle
class MEDCouplingPickleTest(unittest.TestCase):
@unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
""" Test of a simple DataArrayDouble."""
x=DataArrayDouble(10,1) ; x.iota() ; x.rearrange(2) ; x.setInfoOnComponents(["aa","bbb"])
x.setName("toto")
- pickled=cPickle.dumps(x,cPickle.HIGHEST_PROTOCOL)
- xx=cPickle.loads(pickled)
+ pickled=pickle.dumps(x,pickle.HIGHEST_PROTOCOL)
+ xx=pickle.loads(pickled)
self.assertTrue(xx.isEqual(x,1e-16))
# Bigger to check that the behavior is OK for large strings.
x=DataArrayDouble(1200) ; x.iota() ; x.setInfoOnComponents(["aa"])
x.setName("titi")
- pickled=cPickle.dumps(x,cPickle.HIGHEST_PROTOCOL)
- xx=cPickle.loads(pickled)
+ pickled=pickle.dumps(x,pickle.HIGHEST_PROTOCOL)
+ xx=pickle.loads(pickled)
self.assertTrue(xx.isEqual(x,1e-16))
pass
""" Test of a simple DataArrayInt."""
x=DataArrayInt(10) ; x.iota() ; x.rearrange(2) ; x.setInfoOnComponents(["aa","bbb"])
x.setName("toto")
- pickled=cPickle.dumps(x,cPickle.HIGHEST_PROTOCOL)
- xx=cPickle.loads(pickled)
+ pickled=pickle.dumps(x,pickle.HIGHEST_PROTOCOL)
+ xx=pickle.loads(pickled)
self.assertTrue(xx.isEqual(x))
# Bigger to check that the behavior is OK for large strings.
x=DataArrayInt(1200) ; x.iota() ; x.setInfoOnComponents(["aa"])
x.setName("titi")
- pickled=cPickle.dumps(x,cPickle.HIGHEST_PROTOCOL)
- xx=cPickle.loads(pickled)
+ pickled=pickle.dumps(x,pickle.HIGHEST_PROTOCOL)
+ xx=pickle.loads(pickled)
self.assertTrue(xx.isEqual(x))
pass
m.setName("mesh")
m.getCoords().setInfoOnComponents(["aa","bbb","ddddd"])
m.checkConsistencyLight()
- st=cPickle.dumps(m,cPickle.HIGHEST_PROTOCOL)
- m2=cPickle.loads(st)
+ st=pickle.dumps(m,pickle.HIGHEST_PROTOCOL)
+ m2=pickle.loads(st)
self.assertTrue(m2.isEqual(m,1e-16))
pass
m=MEDCouplingCMesh() ; m.setCoords(arrX,arrY,arrZ)
m.setName("mesh")
m.checkConsistencyLight()
- st=cPickle.dumps(m,cPickle.HIGHEST_PROTOCOL)
- m2=cPickle.loads(st)
+ st=pickle.dumps(m,pickle.HIGHEST_PROTOCOL)
+ m2=pickle.loads(st)
self.assertTrue(m2.isEqual(m,1e-16))
self.assertTrue(m2.getCoordsAt(0).isEqual(arrX,1e-16))
pass
m=MEDCouplingCMesh() ; m.setCoords(arr,arr)
m=m.build1SGTUnstructured()
self.assertTrue(isinstance(m,MEDCoupling1SGTUMesh))
- st=cPickle.dumps(m,cPickle.HIGHEST_PROTOCOL)
- m2=cPickle.loads(st)
+ st=pickle.dumps(m,pickle.HIGHEST_PROTOCOL)
+ m2=pickle.loads(st)
self.assertTrue(m2.isEqual(m,1e-16))
pass
m=m.buildUnstructured() ; m.convertAllToPoly()
m=MEDCoupling1DGTUMesh(m)
self.assertTrue(isinstance(m,MEDCoupling1DGTUMesh))
- st=cPickle.dumps(m,cPickle.HIGHEST_PROTOCOL)
- m2=cPickle.loads(st)
+ st=pickle.dumps(m,pickle.HIGHEST_PROTOCOL)
+ m2=pickle.loads(st)
self.assertTrue(m2.isEqual(m,1e-16))
pass
mesh2D.setCoords(mesh3D.getCoords())
mesh=MEDCouplingMappedExtrudedMesh(mesh3D,mesh2D,0) ; del mesh3D,mesh2D
self.assertTrue(isinstance(mesh,MEDCouplingMappedExtrudedMesh))
- st=cPickle.dumps(mesh,cPickle.HIGHEST_PROTOCOL)
- m2=cPickle.loads(st)
+ st=pickle.dumps(mesh,pickle.HIGHEST_PROTOCOL)
+ m2=pickle.loads(st)
self.assertTrue(m2.isEqual(mesh,1e-16))
pass
#
mesh=MEDCouplingCurveLinearMesh() ; mesh.setCoords(m.getCoords()) ; del m
mesh.setNodeGridStructure([10,5])
- st=cPickle.dumps(mesh,cPickle.HIGHEST_PROTOCOL)
- m2=cPickle.loads(st)
+ st=pickle.dumps(mesh,pickle.HIGHEST_PROTOCOL)
+ m2=pickle.loads(st)
self.assertTrue(m2.isEqual(mesh,1e-16))
pass
""" Test of a MEDCouplingIMesh pickeling."""
m=MEDCouplingIMesh("mesh",3,DataArrayInt([3,1,4]),DataArrayDouble([1.5,2.5,3.5]),DataArrayDouble((0.5,1.,0.25))) ; m.setAxisUnit("km")
m.checkConsistencyLight()
- st=cPickle.dumps(m,cPickle.HIGHEST_PROTOCOL)
- m2=cPickle.loads(st)
+ st=pickle.dumps(m,pickle.HIGHEST_PROTOCOL)
+ m2=pickle.loads(st)
self.assertTrue(m2.isEqual(m,1e-16))
self.assertEqual(m2.getName(),m.getName())
pass
f.getArray().setInfoOnComponents(["u1","vv2"])
f.checkConsistencyLight();
#
- st=cPickle.dumps(f,cPickle.HIGHEST_PROTOCOL)
- f2=cPickle.loads(st)
+ st=pickle.dumps(f,pickle.HIGHEST_PROTOCOL)
+ f2=pickle.loads(st)
self.assertTrue(f2.isEqual(f,1e-16,1e-16))
self.assertTrue(f2.getMesh().isEqual(f.getMesh(),1e-16))
pass
self.assertEqual(2,f.getNbOfGaussLocalization());
array=DataArrayDouble.New();
ptr=18*2*[None]
- for i in xrange(18*2):
+ for i in range(18 * 2):
ptr[i]=float(i+1)
array.setValues(ptr,18,2);
ptr=array.getPointer();
f.setArray(array2);
f.checkConsistencyLight();
####
- st=cPickle.dumps(f,cPickle.HIGHEST_PROTOCOL)
- f2=cPickle.loads(st)
+ st=pickle.dumps(f,pickle.HIGHEST_PROTOCOL)
+ f2=pickle.loads(st)
self.assertTrue(f2.isEqual(f,1e-16,1e-16))
self.assertTrue(f2.getMesh().isEqual(f.getMesh(),1e-16))
pass
eStr="This is an exception."
e=InterpKernelException(eStr)
self.assertEqual(e.what(),eStr)
- st=cPickle.dumps(e,cPickle.HIGHEST_PROTOCOL)
- e2=cPickle.loads(st)
+ st=pickle.dumps(e,pickle.HIGHEST_PROTOCOL)
+ e2=pickle.loads(st)
self.assertTrue(e is not e2)
self.assertTrue(isinstance(e2,InterpKernelException))
self.assertEqual(e2.what(),eStr)
def test14(self):
"""Pickelization of DataArrayBytes"""
x=DataArrayByte(256,1)
- for i in xrange(256):
+ for i in range(256):
x[i]=-128+i
pass
x.rearrange(2) ; x.setInfoOnComponents(["aa","bbb"])
x.setName("toto")
- st=cPickle.dumps(x,cPickle.HIGHEST_PROTOCOL)
- x2=cPickle.loads(st)
+ st=pickle.dumps(x,pickle.HIGHEST_PROTOCOL)
+ x2=pickle.loads(st)
self.assertTrue(x2.isEqual(x))
pass
x=DataArrayFloat(256) ; x.iota()
x.rearrange(2) ; x.setInfoOnComponents(["aa","bbb"])
x.setName("toto")
- st=cPickle.dumps(x,cPickle.HIGHEST_PROTOCOL)
- x2=cPickle.loads(st)
+ st = pickle.dumps(x, pickle.HIGHEST_PROTOCOL)
+ x2 = pickle.loads(st)
self.assertTrue(x2.isEqual(x,1e-7))
pass
f.getArray().setInfoOnComponents(["u1","vv2"])
f.checkConsistencyLight();
#
- st=cPickle.dumps(f,cPickle.HIGHEST_PROTOCOL)
- f2=cPickle.loads(st)
+ st = pickle.dumps(f, pickle.HIGHEST_PROTOCOL)
+ f2 = pickle.loads(st)
self.assertTrue(f2.isEqual(f,1e-16,0))
self.assertTrue(f2.getMesh().isEqual(f.getMesh(),1e-16))
pass
f.getArray().setInfoOnComponents(["u1","vv2"])
f.checkConsistencyLight();
#
- st=cPickle.dumps(f,cPickle.HIGHEST_PROTOCOL)
- f2=cPickle.loads(st)
+ st = pickle.dumps(f, pickle.HIGHEST_PROTOCOL)
+ f2 = pickle.loads(st)
self.assertTrue(f2.isEqual(f,1e-16,0))
self.assertTrue(f2.getMesh().isEqual(f.getMesh(),1e-16))
pass
remapper=MEDCouplingRemapper()
remapper.setPrecision(1e-12);
remapper.setIntersectionType(Triangulation);
- self.failUnless(remapper.prepare(sourceMesh,targetMesh,"P0P0")==1);
+ self.assertTrue(remapper.prepare(sourceMesh,targetMesh,"P0P0")==1);
srcField=MEDCouplingFieldDouble.New(ON_CELLS);
srcField.setNature(IntensiveMaximum);
srcField.setMesh(sourceMesh);
array=DataArrayDouble.New();
ptr=sourceMesh.getNumberOfCells()*[None]
- for i in xrange(sourceMesh.getNumberOfCells()):
+ for i in range(sourceMesh.getNumberOfCells()):
ptr[i]=float(i+7)
pass
array.setValues(ptr,sourceMesh.getNumberOfCells(),1);
self.assertEqual(c,10)
values=trgfield.getArray().getValues();
valuesExpected=[7.5 ,7. ,7.,8.,7.5];
- for i in xrange(targetMesh.getNumberOfCells()):
- self.failUnless(abs(values[i]-valuesExpected[i])<1e-12);
+ for i in range(targetMesh.getNumberOfCells()):
+ self.assertTrue(abs(values[i]-valuesExpected[i])<1e-12);
pass
- self.failUnless(1==trgfield.getArray().getNumberOfComponents());
+ self.assertTrue(1==trgfield.getArray().getNumberOfComponents());
pass
def testPrepareEx1(self):
srcField.setMesh(sourceMesh);
array=DataArrayDouble.New();
ptr=sourceMesh.getNumberOfCells()*[None]
- for i in xrange(sourceMesh.getNumberOfCells()):
+ for i in range(sourceMesh.getNumberOfCells()):
ptr[i]=float(i+7);
pass
array.setValues(ptr,sourceMesh.getNumberOfCells(),1);
valuesExpected=[7.75, 7.0625, 4.220173,8.0]
self.assertEqual(4,trgfield.getArray().getNumberOfTuples());
self.assertEqual(1,trgfield.getArray().getNumberOfComponents());
- for i0 in xrange(4):
+ for i0 in range(4):
self.assertAlmostEqual(valuesExpected[i0],values[i0],12);
pass
pass
srcField.setMesh(sourceMesh);
array=DataArrayDouble.New();
ptr=sourceMesh.getNumberOfCells()*[None]
- for i in xrange(sourceMesh.getNumberOfCells()):
+ for i in range(sourceMesh.getNumberOfCells()):
ptr[i]=float(i+7);
pass
array.setValues(ptr,sourceMesh.getNumberOfCells(),1);
trgfield.setMesh(targetMesh);
array=DataArrayDouble.New();
ptr=targetMesh.getNumberOfCells()*[None]
- for i in xrange(targetMesh.getNumberOfCells()):
+ for i in range(targetMesh.getNumberOfCells()):
ptr[i]=4.220173;
pass
array.setValues(ptr,targetMesh.getNumberOfCells(),1);
valuesExpected=[7.75, 7.0625, 4.220173,8.0]
self.assertEqual(4,trgfield.getArray().getNumberOfTuples());
self.assertEqual(1,trgfield.getArray().getNumberOfComponents());
- for i0 in xrange(4):
+ for i0 in range(4):
self.assertAlmostEqual(valuesExpected[i0],values[i0],12);
pass
pass
rem2=MEDCouplingRemapper() ; rem2.setSplittingPolicy(PLANAR_FACE_5) ; rem2.prepare(src1,trg,"P0P0")
mat1=rem1.getCrudeMatrix() ; mat2=rem2.getCrudeMatrix()
self.assertEqual(1,len(mat1)) ; self.assertEqual(1,len(mat2))
- self.assertEqual(mat1[0].keys(),mat2[0].keys()) ; self.assertEqual([0,1],mat1[0].keys())
+ self.assertEqual(list(mat1[0].keys()),list(mat2[0].keys())) ; self.assertEqual([0,1],list(mat1[0].keys()))
self.assertAlmostEqual(1.25884108122e-06,mat1[0][0],16) ; self.assertAlmostEqual(1.25884108122e-06,mat2[0][0],16)
self.assertAlmostEqual(1.25884086663e-06,mat1[0][1],16) ; self.assertAlmostEqual(1.25884086663e-06,mat2[0][1],16)
#
self.assertEqual(aRemapper.prepare(s,t,'P1P1'),1)
m=aRemapper.getCrudeMatrix()
self.assertEqual(len(m),28)
- for i in xrange(28):
+ for i in range(28):
if i not in [5,6]:
self.assertEqual(len(m[i]),0)
pass
rem=MEDCouplingRemapper()
rem.prepare(src,trg,"P0P0")
# Internal crude sparse matrix computed. Let's manipulate it using CSR matrix in scipy.
- for i in xrange(10):
+ for i in range(10):
m=rem.getCrudeCSRMatrix()
pass
m2=rem.getCrudeCSRMatrix()
a.allocateCells()
conna=[0,1,3,2,1,4,5,3,4,6,7,5,6,8,9,7,8,10,11,9,10,12,13,11,12,14,15,13,14,16,17,15,16,18,19,17,18,20,21,19,20,22,23,21,22,24,25,23,24,26,27,25]
a.setCoords(DataArrayDouble([1.54,0,-0.01,1.54,0.02,-0.01,1.54,0,0.01,1.54,0.02,0.01,1.54,0.04,-0.01,1.54,0.04,0.01,1.54,0.06,-0.01,1.54,0.06,0.01,1.54,0.08,-0.01,1.54,0.08,0.01,1.54,0.1,-0.01,1.54,0.1,0.01,1.54,0.12,-0.01,1.54,0.12,0.01,1.54,0.14,-0.01,1.54,0.14,0.01,1.54,0.16,-0.01,1.54,0.16,0.01,1.54,0.18,-0.01,1.54,0.18,0.01,1.54,0.2,-0.01,1.54,0.2,0.01,1.54,0.22,-0.01,1.54,0.22,0.01,1.54,0.24,-0.01,1.54,0.24,0.01,1.54,0.26,-0.01,1.54,0.26,0.01],28,3))
- for i in xrange(13):
+ for i in range(13):
a.insertNextCell(NORM_QUAD4,conna[4*i:4*(i+1)])
pass
a.finishInsertingCells() ; a.simplexize(0)
connb=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,0,2,39,3,5,40,6,8,41,9,11,42,12,14,43,15,17,44,18,20,45,21,23,46,24,26,47,27,29,48,30,32,49,33,35,50,36,38,51,52,2,39,53,5,40,54,8,41,55,11,42,56,14,43,57,17,44,58,20,45,59,23,46,60,26,47,61,29,48,62,32,49,63,35,50,64,38,51,52,2,65,53,5,66,54,8,67,55,11,68,56,14,69,57,17,70,58,20,71,59,23,72,60,26,73,61,29,74,62,32,75,63,35,76,64,38,77,53,2,65,54,5,66,55,8,67,56,11,68,57,14,69,58,17,70,59,20,71,60,23,72,61,26,73,62,29,74,63,32,75,64,35,76,78,38,77,53,2,40,54,5,41,55,8,42,56,11,43,57,14,44,58,17,45,59,20,46,60,23,47,61,26,48,62,29,49,63,32,50,64,35,51,78,38,79,3,2,40,6,5,41,9,8,42,12,11,43,15,14,44,18,17,45,21,20,46,24,23,47,27,26,48,30,29,49,33,32,50,36,35,51,80,38,79,3,2,1,6,5,4,9,8,7,12,11,10,15,14,13,18,17,16,21,20,19,24,23,22,27,26,25,30,29,28,33,32,31,36,35,34,80,38,37]
b=MEDCouplingUMesh("b",2)
b.allocateCells()
- for i in xrange(104):
+ for i in range(104):
b.insertNextCell(NORM_TRI3,connb[3*i:3*(i+1)])
pass
b.setCoords(DataArrayDouble([1.54,0,-0.01,1.54,0.01,-0.01,1.54,0.01,0,1.54,0.02,-0.01,1.54,0.03,-0.01,1.54,0.03,0,1.54,0.04,-0.01,1.54,0.05,-0.01,1.54,0.05,0,1.54,0.06,-0.01,1.54,0.07,-0.01,1.54,0.07,0,1.54,0.08,-0.01,1.54,0.09,-0.01,1.54,0.09,0,1.54,0.1,-0.01,1.54,0.11,-0.01,1.54,0.11,0,1.54,0.12,-0.01,1.54,0.13,-0.01,1.54,0.13,0,1.54,0.14,-0.01,1.54,0.15,-0.01,1.54,0.15,0,1.54,0.16,-0.01,1.54,0.17,-0.01,1.54,0.17,0,1.54,0.18,-0.01,1.54,0.19,-0.01,1.54,0.19,0,1.54,0.2,-0.01,1.54,0.21,-0.01,1.54,0.21,0,1.54,0.22,-0.01,1.54,0.23,-0.01,1.54,0.23,0,1.54,0.24,-0.01,1.54,0.25,-0.01,1.54,0.25,0,1.54,0,0,1.54,0.02,0,1.54,0.04,0,1.54,0.06,0,1.54,0.08,0,1.54,0.1,0,1.54,0.12,0,1.54,0.14,0,1.54,0.16,0,1.54,0.18,0,1.54,0.2,0,1.54,0.22,0,1.54,0.24,0,1.54,0,0.01,1.54,0.02,0.01,1.54,0.04,0.01,1.54,0.06,0.01,1.54,0.08,0.01,1.54,0.1,0.01,1.54,0.12,0.01,1.54,0.14,0.01,1.54,0.16,0.01,1.54,0.18,0.01,1.54,0.2,0.01,1.54,0.22,0.01,1.54,0.24,0.01,1.54,0.01,0.01,1.54,0.03,0.01,1.54,0.05,0.01,1.54,0.07,0.01,1.54,0.09,0.01,1.54,0.11,0.01,1.54,0.13,0.01,1.54,0.15,0.01,1.54,0.17,0.01,1.54,0.19,0.01,1.54,0.21,0.01,1.54,0.23,0.01,1.54,0.25,0.01,1.54,0.26,0.01,1.54,0.26,0,1.54,0.26,-0.01],81,3))
source=MEDCoupling1SGTUMesh("SourcePrimaire",NORM_SEG2)
source.setCoords(sourceCoo)
source.allocateCells()
- for i in xrange(len(sourceCoo)-1):
+ for i in range(len(sourceCoo) - 1):
source.insertNextCell([i,i+1])
pass
source=source.buildUnstructured()
cI2 = [0, 44]
mTgt = MEDCouplingUMesh("target", 3)
mSrc = MEDCouplingUMesh("src", 3)
- mTgt.setCoords(DataArrayDouble(coo1, len(coo1)/3, 3))
- mSrc.setCoords(DataArrayDouble(coo2, len(coo2)/3, 3))
+ mTgt.setCoords(DataArrayDouble(coo1, len(coo1) // 3, 3))
+ mSrc.setCoords(DataArrayDouble(coo2, len(coo2) // 3, 3))
mTgt.setConnectivity(DataArrayInt(conn1), DataArrayInt(cI1))
mSrc.setConnectivity(DataArrayInt(conn2), DataArrayInt(cI2))
def checkMatrix(self,mat1,mat2,nbCols,eps):
self.assertEqual(len(mat1),len(mat2))
- for i in xrange(len(mat1)):
+ for i in range(len(mat1)):
self.assertTrue(max(mat2[i].keys())<nbCols)
self.assertTrue(max(mat1[i].keys())<nbCols)
self.assertTrue(min(mat2[i].keys())>=0)
targetMesh=MEDCouplingUMesh.New();
targetMesh.setMeshDimension(2);
targetMesh.allocateCells(4);
- for i in xrange(4):
+ for i in range(4):
targetMesh.insertNextCell(NORM_QUAD4,4,targetConn[4*i:4*(i+1)])
pass
targetMesh.finishInsertingCells();
ADD_DEFINITIONS(${PYTHON_DEFINITIONS} ${NUMPY_DEFINITIONS} ${SCIPY_DEFINITIONS})
SET_SOURCE_FILES_PROPERTIES(MEDLoader.i PROPERTIES CPLUSPLUS ON)
-SET_SOURCE_FILES_PROPERTIES(MEDLoader.i PROPERTIES SWIG_DEFINITIONS "-shadow")
+IF ("${PYTHON_VERSION_MAJOR}" STREQUAL "3")
+ SET_SOURCE_FILES_PROPERTIES(MEDLoader.i PROPERTIES SWIG_FLAGS "-py3")
+ELSE()
+ SET_SOURCE_FILES_PROPERTIES(MEDLoader.i PROPERTIES SWIG_DEFINITIONS "-shadow")
+ENDIF()
SET(SWIG_MODULE_MEDLoader_EXTRA_FLAGS "${NUMPY_DEFINITIONS};${SCIPY_DEFINITIONS}")
SET (MEDLoader_SWIG_DPYS_FILES
dictMCTyp={NORM_HEXA8:"hexa8",NORM_POLYHED:"nfaced",NORM_QUAD4:"quad4",NORM_POLYGON:"nsided",NORM_POINT1:"point",NORM_SEG2:"bar2",NORM_SEG3:"bar3",NORM_TRI3:"tria3",NORM_TRI6:"tria6",NORM_QUAD8:"quad8",NORM_TETRA4:"tetra4",NORM_TETRA10:"tetra10",NORM_PYRA5:"pyramid5",NORM_PYRA13:"pyramid13",NORM_PENTA6:"penta6",NORM_PENTA15:"penta15",NORM_HEXA20:"hexa20"}
discSpatial={ON_CELLS:"element",ON_NODES:"node"}
dictCompo={1:"scalar",3:"vector",6:"tensor",9:"tensor9"}
- dictMCTyp2=dict((v,k) for k,v in dictMCTyp.iteritems())
- discSpatial2=dict((v,k) for k,v in discSpatial.iteritems())
- dictCompo2=dict((v,k) for k,v in dictCompo.iteritems())
+ dictMCTyp2 = {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()}
pass
pos+=nbNodes*3*4 ; fd.seek(pos)#np.array(0,dtype='float%i'%(typeOfCoo)).nbytes
typ=fd.read(80).strip() ; pos=fd.tell()
zeK=""
- for k in self.dictMCTyp2.keys():
+ for k in self.dictMCTyp2:
if k in typ:
zeK=k
break
nbOfValsOfTyp=np.memmap(fd,dtype='>i4',mode='r',offset=pos,shape=(1)).tolist()[0]/4
pos+=4
vals=np.zeros(dtype=">f4",shape=(nbOfValsOfTyp*nbCompo))
- for iii in xrange(nbCompo):
+ for iii in range(nbCompo):
valsTmp=np.memmap(fd,dtype='>f4',mode='r',offset=int(pos),shape=(nbOfValsOfTyp))
vals[iii*nbOfValsOfTyp:(iii+1)*nbOfValsOfTyp]=valsTmp
pos+=nbOfValsOfTyp*4
if "TIME\n" in lines:
end=lines.index("TIME\n")
pass
- for i in xrange(ind+1,end):
+ for i in range(ind + 1, end):
m=re.match("^([\w]+)[\s]+\per[\s]+([\w]+)[\s]*\:[\s]*([\w]+)[\s]+([\S]+)$",lines[i])
if m:
if m.groups()[0]=="constant":
pass
expr=re.compile("number[\s]+of[\s]+steps[\s]*\:[\s]*([\d]+)")
- tmp=filter(expr.search,lines)
- if len(tmp)!=0:
- nbOfTimeSteps=int(expr.search(filter(expr.search,lines)[0]).group(1))
+ tmp = [line for line in lines if expr.search(line)]
+ if tmp:
+ nbOfTimeSteps = int(expr.search(tmp[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([line for line in lines if expr.search(line)][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([line for line in lines if expr.search(line)][0]).group(1))
else:
nbOfTimeSteps=1
startIt=0
i+=1
pass
pass
- for ts in xrange(nbOfTimeSteps):
+ for ts in range(nbOfTimeSteps):
i=0
for field in fieldsInfo:
if typeOfFile:
pass
ret=MEDFileData()
ret.setMeshes(m2)
- del mlfields[filter(lambda x: len(mlfields[x])==0,range(len(mlfields)))]
+ del mlfields[[x for x in range(len(mlfields)) if len(mlfields[x]) == 0]]
ret.setFields(mlfields)
return ret
self._ze_top_dict={}
its,areForgottenTS=mdfs.getCommonIterations()
if areForgottenTS:
- print "WARNING : some iterations are NOT present in all fields ! Kept iterations are : %s !"%(str(its))
+ print("WARNING : some iterations are NOT present in all fields ! Kept iterations are : %s !"%(str(its)))
pass
TimeValues=""
for it in its:
for mdf in mdfs:
nbCompo=mdf.getNumberOfComponents()
if nbCompo not in self.dictCompo:
- l=filter(lambda x:x-nbCompo>0,self.dictCompo.keys())
+ l = [x for x in 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(self.dictCompo.keys()))
+ print("Field \"%s\" will be ignored because number of components (%i) is too big to be %s supported by case files !"%(mdf.getName(),nbCompo,str(list(self.dictCompo.keys()))))
continue
pass
- print "WARNING : Field \"%s\" will have its number of components (%i) set to %i, in order to be supported by case files (must be in %s) !"%(mdf.getName(),nbCompo,l[0],str(self.dictCompo.keys()))
+ print("WARNING : Field \"%s\" will have its number of components (%i) set to %i, in order to be supported by case files (must be in %s) !"%(mdf.getName(),nbCompo,l[0],str(list(self.dictCompo.keys()))))
nbCompo=l[0]
pass
if nbCompo in dictVars:
for mdf in mdfs:
nbCompo=mdf.getNumberOfComponents()
if nbCompo not in self.dictCompo:
- l=filter(lambda x:x-nbCompo>0,self.dictCompo.keys())
+ l = [x for x in self.dictCompo if x - nbCompo > 0]
if len(l)==0:
continue;
nbCompo=l[0]
mm.write(self.__str80("coordinates"))
pass
else:
- print "UnManaged type of field for field \"%s\" !"%(mdf.getName())
+ print("UnManaged type of field for field \"%s\" !"%(mdf.getName()))
pass
a=np.memmap(f,dtype='float32',mode='w+',offset=mm.tell(),shape=(nbCompo,end-bg))
b=arr.toNumPyArray() ; b=b.reshape(nbCompo,end-bg)
#
finalVersion=ml.MEDFileVersionOfFileStr(realFnOut)
#
- print("File \"%s\" has been converted to 3.0 successfuly ( %s -> %s ) !\nOutput file is here : \"%s\" !"%(fn,initalVersion,finalVersion,realFnOut))
+ print(("File \"%s\" has been converted to 3.0 successfuly ( %s -> %s ) !\nOutput file is here : \"%s\" !"%(fn,initalVersion,finalVersion,realFnOut)))
pass
if __name__=="__main__":
import argparse
- parser=argparse.ArgumentParser(description=u'Convert a MED file into a MED file with 3.0 version (3.0.8)')
+ parser=argparse.ArgumentParser(description='Convert a MED file into a MED file with 3.0 version (3.0.8)')
parser.add_argument('nameOfMEDFile', type=str, nargs=1,help='File name of the MED file to be converted into 3.0.')
args=parser.parse_args()
nameOfMEDFile=args.nameOfMEDFile[0]
%include "MEDCouplingFinalize.i"
+%pythoncode %{
+MEDFileMeshesIterator.__next__ = MEDFileMeshesIterator.next
+MEDFileAnyTypeFieldMultiTSIterator.__next__ = MEDFileAnyTypeFieldMultiTSIterator.next
+MEDFileFieldsIterator.__next__ = MEDFileFieldsIterator.next
+%}
+
%pythoncode %{
MEDFileUMesh.__new__=classmethod(MEDCouplingMEDFileUMeshnew)
del MEDCouplingMEDFileUMeshnew
MEDFileJoint *__getitem__(PyObject *obj) throw(INTERP_KERNEL::Exception)
{
+ static const char msg[]="MEDFileJoints::__getitem__ : only integer or string with meshname supported !";
if(PyInt_Check(obj))
{
MEDFileJoint *ret=self->getJointAtPos(InterpreteNegativeInt((int)PyInt_AS_LONG(obj),self->getNumberOfJoints()));
ret->incrRef();
return ret;
}
- else if(PyString_Check(obj))
- {
- MEDFileJoint *ret=self->getJointWithName(PyString_AsString(obj));
- if(ret)
- ret->incrRef();
- return ret;
- }
- else
- throw INTERP_KERNEL::Exception("MEDFileJoints::__getitem__ : only integer or string with meshname supported !");
+ MEDFileJoint *ret(self->getJointWithName(convertPyObjectToStr(obj,msg)));
+ if(ret)
+ ret->incrRef();
+ return ret;
}
int __len__() const throw(INTERP_KERNEL::Exception)
MEDFileMesh *__getitem__(PyObject *obj) throw(INTERP_KERNEL::Exception)
{
- if(PyInt_Check(obj))
+ static const char msg[]="MEDFileMeshes::__getitem__ : only integer or string with meshname supported !";
+ if(PyInt_Check(obj))
{
MEDFileMesh *ret=self->getMeshAtPos(InterpreteNegativeInt((int)PyInt_AS_LONG(obj),self->getNumberOfMeshes()));
if(ret)
ret->incrRef();
return ret;
}
- else if(PyString_Check(obj))
- {
- MEDFileMesh *ret=self->getMeshWithName(PyString_AsString(obj));
- if(ret)
- ret->incrRef();
- return ret;
- }
- else
- throw INTERP_KERNEL::Exception("MEDFileMeshes::__getitem__ : only integer or string with meshname supported !");
+ MEDFileMesh *ret(self->getMeshWithName(convertPyObjectToStr(obj,msg)));
+ if(ret)
+ ret->incrRef();
+ return ret;
}
MEDFileMeshes *__setitem__(int obj, MEDFileMesh *mesh) throw(INTERP_KERNEL::Exception)
if(PySlice_Check(elts))
{
Py_ssize_t strt=2,stp=2,step=2;
- PySliceObject *oC=reinterpret_cast<PySliceObject *>(elts);
- GetIndicesOfSlice(oC,self->getNumberOfTS(),&strt,&stp,&step,"MEDFileAnyTypeFieldMultiTS.__delitem__ : error in input slice !");
+ GetIndicesOfSlice(elts,self->getNumberOfTS(),&strt,&stp,&step,"MEDFileAnyTypeFieldMultiTS.__delitem__ : error in input slice !");
self->eraseTimeStepIds2(strt,stp,step);
}
else
else if(elt0 && PySlice_Check(elt0))
{
Py_ssize_t strt=2,stp=2,step=2;
- PySliceObject *oC=reinterpret_cast<PySliceObject *>(elt0);
- GetIndicesOfSlice(oC,self->getNumberOfTS(),&strt,&stp,&step,"MEDFileAnyTypeFieldMultiTS.__getitem__ : error in input slice !");
+ GetIndicesOfSlice(elt0,self->getNumberOfTS(),&strt,&stp,&step,"MEDFileAnyTypeFieldMultiTS.__getitem__ : error in input slice !");
return convertMEDFileFieldMultiTS(self->buildSubPartSlice(strt,stp,step),SWIG_POINTER_OWN | 0);
}
else
int getPosOfField(PyObject *elt0) const throw(INTERP_KERNEL::Exception)
{
- if(elt0 && PyInt_Check(elt0))
+ static const char msg[]="MEDFileFields::getPosOfField : invalid input params ! expected fields[int], fields[string_of_field_name] !";
+ if(!elt0)
+ throw INTERP_KERNEL::Exception(msg);
+ if(PyInt_Check(elt0))
{//fmts[3]
return PyInt_AS_LONG(elt0);
}
- else if(elt0 && PyString_Check(elt0))
- return self->getPosFromFieldName(PyString_AsString(elt0));
- else
- throw INTERP_KERNEL::Exception("MEDFileFields::getPosOfField : invalid input params ! expected fields[int], fields[string_of_field_name] !");
+ return self->getPosFromFieldName(convertPyObjectToStr(elt0,msg));
}
std::vector<int> getPosOfFields(PyObject *elts) const throw(INTERP_KERNEL::Exception)
if(elts && PySlice_Check(elts))
{
Py_ssize_t strt=2,stp=2,step=2;
- PySliceObject *oC=reinterpret_cast<PySliceObject *>(elts);
- GetIndicesOfSlice(oC,self->getNumberOfFields(),&strt,&stp,&step,"MEDFileFields.__delitem__ : error in input slice !");
+ GetIndicesOfSlice(elts,self->getNumberOfFields(),&strt,&stp,&step,"MEDFileFields.__delitem__ : error in input slice !");
self->destroyFieldsAtPos2(strt,stp,step);
}
else
MEDFileParameterMultiTS *__getitem__(PyObject *obj) throw(INTERP_KERNEL::Exception)
{
+ static const char msg[]="MEDFileParameters::__getitem__ : only integer or string with meshname supported !";
if(PyInt_Check(obj))
{
MEDFileParameterMultiTS *ret=self->getParamAtPos(InterpreteNegativeInt((int)PyInt_AS_LONG(obj),self->getNumberOfParams()));
ret->incrRef();
return ret;
}
- else if(PyString_Check(obj))
- {
- MEDFileParameterMultiTS *ret=self->getParamWithName(PyString_AsString(obj));
- if(ret)
- ret->incrRef();
- return ret;
- }
- else
- throw INTERP_KERNEL::Exception("MEDFileParameters::__getitem__ : only integer or string with meshname supported !");
+ MEDFileParameterMultiTS *ret(self->getParamWithName(convertPyObjectToStr(obj,msg)));
+ if(ret)
+ ret->incrRef();
+ return ret;
}
int __len__() const throw(INTERP_KERNEL::Exception)
d=DataArrayDouble.New(6,2)
d[:,0]=3.
-d[:,1]=range(6)
+d[:, 1] = list(range(6))
d[:,1]*=math.pi/3.
d=d.fromPolarToCart()
d.setInfoOnComponents(["X [m]","Y [m]"])
-print d.getValues()
-print d
-print d.magnitude().isUniform(3.,1e-12)
+print(d.getValues())
+print(d)
+print(d.magnitude().isUniform(3.,1e-12))
#
radius=3.
translationToPerform=[[0.,0.],[3./2.*radius,-radius*math.sqrt(3.)/2],[3./2.*radius,radius*math.sqrt(3.)/2],[0.,radius*math.sqrt(3.)],[-3./2.*radius,radius*math.sqrt(3.)/2],[-3./2.*radius,-radius*math.sqrt(3.)/2],[0.,-radius*math.sqrt(3.)]]
oldNbOfTuples=d2.getNumberOfTuples()
c,cI=d2.findCommonTuples(1e-12)
tmp=c[cI[0]:cI[0+1]]
-print tmp
+print(tmp)
a=cI.deltaShiftIndex()
b=a-1
myNewNbOfTuples=oldNbOfTuples-sum(b.getValues())
o2n,newNbOfTuples=DataArrayInt.ConvertIndexArrayToO2N(oldNbOfTuples,c,cI)
-print "Ai je trouve le bon resultat ? %s"%(str(myNewNbOfTuples==newNbOfTuples)) ; assert myNewNbOfTuples==newNbOfTuples
+print("Ai je trouve le bon resultat ? %s"%(str(myNewNbOfTuples==newNbOfTuples))) ; assert myNewNbOfTuples==newNbOfTuples
#
d3=d2.renumberAndReduce(o2n,newNbOfTuples)
n2o=o2n.invertArrayO2N2N2O(newNbOfTuples)
d3_bis=d2[n2o]
-print "Ai je trouve le bon resultat (2) ? %s"%(str(d3.isEqual(d3_bis,1e-12))) ; assert d3.isEqual(d3_bis,1e-12)
+print("Ai je trouve le bon resultat (2) ? %s"%(str(d3.isEqual(d3_bis,1e-12)))) ; assert d3.isEqual(d3_bis,1e-12)
#
d3+=[3.3,4.4]
# d3 contains coordinates
m=MEDCouplingUMesh.New("My7hexagons",2)
m.setCoords(d3)
m.allocateCells(7)
-for i in xrange(7):
+for i in range(7):
m.insertNextCell(NORM_POLYGON,o2n[6*i:6*(i+1)].getValues())
pass
m.finishInsertingCells()
mesh3D.orientCorrectlyPolyhedrons()
mesh3D.sortCellsInMEDFileFrmt()
mesh3D.checkConsistencyLight()
-renum=DataArrayInt.New(60) ; renum[:15]=range(15,30) ; renum[15:30]=range(15) ; renum[30:45]=range(45,60) ; renum[45:]=range(30,45)
+renum = DataArrayInt.New(60) ; renum[:15] = list(range(15, 30)) ; renum[15:30] = list(range(15)) ; renum[30:45] = list(range(45, 60)) ; renum[45:] = list(range(30, 45))
mesh3D.renumberNodes(renum,60)
#
mesh3D.getCoords()[:]*=100.
mesh3D.getCoords().setInfoOnComponents(["X [cm]","Y [cm]","Z [cm]"])
#
zLev=mesh3D.getCoords()[:,2]
-zLev=zLev.getDifferentValues(1e-12)
+zLev = zLev.getDifferentValues(1e-12)
zLev.sort()
#
tmp,cellIdsSol1=mesh3D.buildSlice3D([0.,0.,(zLev[1]+zLev[2])/2],[0.,0.,1.],1e-12)
mesh2D=mesh3D.buildFacePartOfMySelfNode(nodeIds,True)
extMesh=MEDCouplingMappedExtrudedMesh.New(mesh3D,mesh2D,0)
cellIdsSol3=extMesh.getMesh3DIds()[mesh2D.getNumberOfCells():2*mesh2D.getNumberOfCells()]
-for i in xrange(3):
- exec("print cellIdsSol%s.getValues()"%(i+1))
+for i in range(3):
+ exec("print( cellIdsSol%s.getValues())"%(i+1))
#
mesh3DPart=mesh3D[cellIdsSol2] # equivalent to mesh3DPart=mesh3D.buildPartOfMySelf(cellIdsSol2,True)
mesh3DPart.zipCoords()
-print mesh3DPart.checkConsecutiveCellTypesAndOrder([NORM_HEXA8,NORM_POLYHED]) ; assert mesh3DPart.checkConsecutiveCellTypesAndOrder([NORM_HEXA8,NORM_POLYHED])
-print mesh3DPart.checkConsecutiveCellTypes() ; assert mesh3DPart.checkConsecutiveCellTypes()
+print(mesh3DPart.checkConsecutiveCellTypesAndOrder([NORM_HEXA8,NORM_POLYHED])) ; assert mesh3DPart.checkConsecutiveCellTypesAndOrder([NORM_HEXA8,NORM_POLYHED])
+print(mesh3DPart.checkConsecutiveCellTypes()) ; assert mesh3DPart.checkConsecutiveCellTypes()
#print mesh3DPart.advancedRepr()
#
baryXY=bary[:,[0,1]]
magn=bary2.magnitude()
ids=magn.findIdsInRange(0.,1e-12)
idStart=int(ids) # ids is assumed to contain only one value, if not an exception is thrown
-cellIds2Sol2=extMesh.getMesh3DIds()[range(idStart,mesh3D.getNumberOfCells(),mesh2D.getNumberOfCells())]
+cellIds2Sol2 = extMesh.getMesh3DIds()[list(range(idStart, mesh3D.getNumberOfCells(), mesh2D.getNumberOfCells()))]
#
mesh3DSlice2=mesh3D[cellIds2Sol1]
mesh3DSlice2.zipCoords()
f2.setMesh(mesh)
f2.setName("MyField2")
f2.fillFromAnalytic(1,"(x-5.)*(x-5.)+(y-5.)*(y-5.)+(z-5.)*(z-5.)")
-print "f and f2 are equal : %s"%(f.isEqualWithoutConsideringStr(f2,1e-13,1e-12)) ; assert f.isEqualWithoutConsideringStr(f2,1e-13,1e-12)
+print("f and f2 are equal : %s"%(f.isEqualWithoutConsideringStr(f2,1e-13,1e-12))) ; assert f.isEqualWithoutConsideringStr(f2,1e-13,1e-12)
#
ids1=f.getArray().findIdsInRange(0.,5.)
fPart1=f.buildSubPart(ids1)
#Check that fPart1Cpy and fPart1 are the same
fPart1Cpy.substractInPlaceDM(fPart1,12,1e-12)
fPart1Cpy.getArray().abs()
-print "Fields are the same ? %s"%(fPart1Cpy.getArray().accumulate()[0]<1e-12) ; assert fPart1Cpy.getArray().accumulate()[0]<1e-12
+print("Fields are the same ? %s"%(fPart1Cpy.getArray().accumulate()[0]<1e-12)) ; assert fPart1Cpy.getArray().accumulate()[0]<1e-12
#
fPart12=MEDCouplingFieldDouble.MergeFields([fPart1,fPart2])
# evaluation on points
arr2=f.getValueOnMulti(bary)
delta=arr1-arr2
delta.abs()
-print "Check OK : %s"%(delta.accumulate()[0]<1e-12) ; assert delta.accumulate()[0]<1e-12
+print("Check OK : %s"%(delta.accumulate()[0]<1e-12)) ; assert delta.accumulate()[0]<1e-12
#
-print abs(fPart12.integral(0,True)-fPart12.getArray().accumulate()[0])<1e-10 ; assert abs(fPart12.integral(0,True)-fPart12.getArray().accumulate()[0])<1e-10
+print(abs(fPart12.integral(0,True)-fPart12.getArray().accumulate()[0])<1e-10) ; assert abs(fPart12.integral(0,True)-fPart12.getArray().accumulate()[0])<1e-10
fPart12.getMesh().scale([0.,0.,0.],1.2)
-print abs(fPart12.integral(0,True)-fPart12.getArray().accumulate()[0]*1.2*1.2*1.2)<1e-8 ; assert abs(fPart12.integral(0,True)-fPart12.getArray().accumulate()[0]*1.2*1.2*1.2)<1e-8
+print(abs(fPart12.integral(0,True)-fPart12.getArray().accumulate()[0]*1.2*1.2*1.2)<1e-8) ; assert abs(fPart12.integral(0,True)-fPart12.getArray().accumulate()[0]*1.2*1.2*1.2)<1e-8
# Explosion of field
fVec=mesh.fillFromAnalytic(ON_CELLS,3,"(x-5.)*IVec+(y-5.)*JVec+(z-5.)*KVec")
fVecPart1=fVec.buildSubPart(ids1)
WriteUMesh("TargetMesh.med",targetMesh,True)
#
meshRead=ReadUMeshFromFile("TargetMesh.med",targetMesh.getName(),0)
-print "Is the mesh read in file equals targetMesh ? %s"%(meshRead.isEqual(targetMesh,1e-12)) ; assert meshRead.isEqual(targetMesh,1e-12)
+print("Is the mesh read in file equals targetMesh ? %s"%(meshRead.isEqual(targetMesh,1e-12))) ; assert meshRead.isEqual(targetMesh,1e-12)
#
f=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME)
f.setTime(5.6,7,8)
WriteField("MyFirstField.med",f,True)
#
f2=ReadFieldCell("MyFirstField.med",f.getMesh().getName(),0,f.getName(),7,8)
-print "Is the field read in file equals f ? %s"%(f2.isEqual(f,1e-12,1e-12)) ; assert f2.isEqual(f,1e-12,1e-12)
+print("Is the field read in file equals f ? %s"%(f2.isEqual(f,1e-12,1e-12))) ; assert f2.isEqual(f,1e-12,1e-12)
#
WriteUMesh("MySecondField.med",f.getMesh(),True)
WriteFieldUsingAlreadyWrittenMesh("MySecondField.med",f)
WriteFieldUsingAlreadyWrittenMesh("MySecondField.med",f2)
#
f3=ReadFieldCell("MySecondField.med",f.getMesh().getName(),0,f.getName(),7,8)
-print "Is the field read in file equals f ? %s"%(f.isEqual(f3,1e-12,1e-12)) ; assert f.isEqual(f3,1e-12,1e-12)
+print("Is the field read in file equals f ? %s"%(f.isEqual(f3,1e-12,1e-12))) ; assert f.isEqual(f3,1e-12,1e-12)
f4=ReadFieldCell("MySecondField.med",f.getMesh().getName(),0,f.getName(),9,10)
-print "Is the field read in file equals f ? %s"%(f2.isEqual(f4,1e-12,1e-12)) ; assert f2.isEqual(f4,1e-12,1e-12)
+print("Is the field read in file equals f ? %s"%(f2.isEqual(f4,1e-12,1e-12))) ; assert f2.isEqual(f4,1e-12,1e-12)
#####
meshMEDFileRead=MEDFileMesh.New("TargetMesh2.med")
meshRead0=meshMEDFileRead.getMeshAtLevel(0)
meshRead1=meshMEDFileRead.getMeshAtLevel(-1)
-print "Is the mesh at level 0 read in file equals targetMesh ? %s"%(meshRead0.isEqual(targetMesh,1e-12)) ; assert meshRead0.isEqual(targetMesh,1e-12)
-print "Is the mesh at level -1 read in file equals targetMesh ? %s"%(meshRead1.isEqual(targetMesh1,1e-12)) ; assert meshRead1.isEqual(targetMesh1,1e-12)
+print("Is the mesh at level 0 read in file equals targetMesh ? %s"%(meshRead0.isEqual(targetMesh,1e-12))) ; assert meshRead0.isEqual(targetMesh,1e-12)
+print("Is the mesh at level -1 read in file equals targetMesh ? %s"%(meshRead1.isEqual(targetMesh1,1e-12))) ; assert meshRead1.isEqual(targetMesh1,1e-12)
#
-print meshMEDFileRead.getGrpNonEmptyLevels("grp0_Lev0")
+print(meshMEDFileRead.getGrpNonEmptyLevels("grp0_Lev0"))
grp0_0_read=meshMEDFileRead.getGroupArr(0,"grp0_Lev0")
-print "Is group \"grp0_Lev0\" are the same ? %s"%(grp0_0_read.isEqual(grp0_0)) ; assert grp0_0_read.isEqual(grp0_0)
+print("Is group \"grp0_Lev0\" are the same ? %s"%(grp0_0_read.isEqual(grp0_0))) ; assert grp0_0_read.isEqual(grp0_0)
#
# Fields
#
fMEDFileRead=MEDFileField1TS.New("TargetMesh2.med",f.getName(),7,8)
fRead1=fMEDFileRead.getFieldOnMeshAtLevel(ON_CELLS,0,meshMEDFileRead) # fastest method. No read in file.
fRead2=fMEDFileRead.getFieldAtLevel(ON_CELLS,0) # basic method like, mesh is reread in file...
-print "Does the field f remains the same using fast method ? %s"%(fRead1.isEqual(f,1e-12,1e-12)) ; assert fRead1.isEqual(f,1e-12,1e-12)
-print "Does the field f remains the same using slow method ? %s"%(fRead2.isEqual(f,1e-12,1e-12)) ; assert fRead2.isEqual(f,1e-12,1e-12)
+print("Does the field f remains the same using fast method ? %s"%(fRead1.isEqual(f,1e-12,1e-12))) ; assert fRead1.isEqual(f,1e-12,1e-12)
+print("Does the field f remains the same using slow method ? %s"%(fRead2.isEqual(f,1e-12,1e-12))) ; assert fRead2.isEqual(f,1e-12,1e-12)
#
# Writing and Reading fields on profile using MEDLoader advanced API
#
#
fMEDFileRead2=MEDFileField1TS.New("TargetMesh2.med",fPart.getName(),7,8)
fPartRead,pflRead=fMEDFileRead2.getFieldWithProfile(ON_CELLS,0,meshMEDFileRead)
-print fPartRead.isEqualWithoutConsideringStr(fPart.getArray(),1e-12) ; assert fPartRead.isEqualWithoutConsideringStr(fPart.getArray(),1e-12)
-print pflRead.isEqualWithoutConsideringStr(pfl) ; assert pflRead.isEqualWithoutConsideringStr(pfl)
+print(fPartRead.isEqualWithoutConsideringStr(fPart.getArray(),1e-12)) ; assert fPartRead.isEqualWithoutConsideringStr(fPart.getArray(),1e-12)
+print(pflRead.isEqualWithoutConsideringStr(pfl)) ; assert pflRead.isEqualWithoutConsideringStr(pfl)
#####
CellFieldCpy=CellField.deepCopy()
CellFieldCpy.substractInPlaceDM(CellField_read,10,1e-12)
CellFieldCpy.getArray().abs()
-print CellFieldCpy.getArray().isUniform(0.,1e-12)
+print(CellFieldCpy.getArray().isUniform(0.,1e-12))
#
NodeField0_read=ReadFieldNode("proc0.med","mesh",0,"NodeField",5,6)
NodeField1_read=ReadFieldNode("proc1.med","mesh",0,"NodeField",5,6)
NodeFieldCpy=NodeField.deepCopy()
NodeFieldCpy.mergeNodes(1e-10)
NodeFieldCpy.substractInPlaceDM(NodeField_read,10,1e-12)
-print NodeFieldCpy.getArray().isUniform(0.,1e-12) ; assert NodeFieldCpy.getArray().isUniform(0.,1e-12)
+print(NodeFieldCpy.getArray().isUniform(0.,1e-12)) ; assert NodeFieldCpy.getArray().isUniform(0.,1e-12)
#
fileNames=["proc0.med","proc1.med"]
msML=[MEDFileMesh.New(fname) for fname in fileNames]
for ft in fts:
for geoTyp,smth in ft.getFieldSplitedByType():
if geoTyp!=NORM_ERROR:
- smth1=filter(lambda x:x[0]==ON_CELLS,smth)
+ smth1=[x for x in smth if x[0]==ON_CELLS]
arr2s=[ft.getUndergroundDataArray()[elt[1][0]:elt[1][1]] for elt in smth1]
arr1s.append(DataArrayDouble.Aggregate(arr2s))
pass
pass
else:
for ft in fts:
- smth=filter(lambda x:x[0]==NORM_ERROR,ft.getFieldSplitedByType())
+ smth=[x for x in ft.getFieldSplitedByType() if x[0]==NORM_ERROR]
arr2=DataArrayDouble.Aggregate([ft.getUndergroundDataArray()[elt[1][0][1][0]:elt[1][0][1][1]] for elt in smth])
arr1s.append(arr2)
pass
remap.prepare(srcMesh,trgMesh,"P0P0")
#
myMatrix=remap.getCrudeMatrix()
-print myMatrix # pour voir a quoi elle ressemble
+print(myMatrix) # pour voir a quoi elle ressemble
sumByRows=DataArrayDouble(len(myMatrix))
for i,wIt in enumerate(sumByRows):
su=0.
for it in myMatrix[i]:
su+=myMatrix[i][it]
wIt[0]=su
-print "Does interpolation look OK ? %s"%(str(sumByRows.isUniform(1.,1e-12))) ; assert sumByRows.isUniform(1.,1e-12)
+print("Does interpolation look OK ? %s"%(str(sumByRows.isUniform(1.,1e-12)))) ; assert sumByRows.isUniform(1.,1e-12)
#
srcField=MEDCouplingFieldDouble(ON_CELLS,ONE_TIME) ; srcField.setMesh(srcMesh)
srcField.fillFromAnalytic(1,"7-sqrt((x-5.)*(x-5.)+(y-5.)*(y-5.))") ; CellField.getArray().setInfoOnComponent(0,"powercell [W]")
srcField.setNature(IntensiveMaximum)
trgFieldCV=remap.transferField(srcField,1e300)
#
-print "IntensiveMaximum %lf == %lf"%(srcField.integral(True)[0],trgFieldCV.integral(True)[0]) ; assert abs(srcField.integral(True)[0]-trgFieldCV.integral(True)[0])<1e-6
-print "IntensiveMaximum %lf != %lf"%(srcField.getArray().accumulate()[0],trgFieldCV.getArray().accumulate()[0]) ; assert abs(srcField.getArray().accumulate()[0]-trgFieldCV.getArray().accumulate()[0])>1e-6
+print("IntensiveMaximum %lf == %lf"%(srcField.integral(True)[0],trgFieldCV.integral(True)[0])) ; assert abs(srcField.integral(True)[0]-trgFieldCV.integral(True)[0])<1e-6
+print("IntensiveMaximum %lf != %lf"%(srcField.getArray().accumulate()[0],trgFieldCV.getArray().accumulate()[0])) ; assert abs(srcField.getArray().accumulate()[0]-trgFieldCV.getArray().accumulate()[0])>1e-6
#
srcField.setNature(ExtensiveMaximum)
trgFieldI=remap.transferField(srcField,1e300)
#
-print "ExtensiveConservation %lf != %lf"%(srcField.integral(True)[0],trgFieldI.integral(True)[0]) ; assert abs(srcField.integral(True)[0]-trgFieldI.integral(True)[0])>1e-6
-print "ExtensiveConservation %lf == %lf"%(srcField.getArray().accumulate()[0],trgFieldI.getArray().accumulate()[0]) ; assert abs(srcField.getArray().accumulate()[0]-trgFieldI.getArray().accumulate()[0])<1e-6
+print("ExtensiveConservation %lf != %lf"%(srcField.integral(True)[0],trgFieldI.integral(True)[0])) ; assert abs(srcField.integral(True)[0]-trgFieldI.integral(True)[0])>1e-6
+print("ExtensiveConservation %lf == %lf"%(srcField.getArray().accumulate()[0],trgFieldI.getArray().accumulate()[0])) ; assert abs(srcField.getArray().accumulate()[0]-trgFieldI.getArray().accumulate()[0])<1e-6
######
pass
data=MEDFileData(agitateur_file)
ts=data.getFields()[0].getTimeSteps()
-print ts
+print(ts)
#
fMts=data.getFields()["DISTANCE_INTERFACE_ELEM_BODY_ELEM_DOM"]
f1ts=fMts[(2,-1)]
torquePerCellOnSkin=DataArrayDouble.CrossProduct(posSkin,forceVectSkin)
zeTorque=torquePerCellOnSkin.accumulate()
-print "couple = %r N.m"%(zeTorque[2]) ; assert abs(zeTorque[2]-0.37)<1e-2
+print("couple = %r N.m"%(zeTorque[2])) ; assert abs(zeTorque[2]-0.37)<1e-2
speedMts=data.getFields()["VITESSE_ELEM_DOM"]
speed1ts=speedMts[(2,-1)]
speedOnSkin=speedMc.getArray()[tupleIdsInField]
powerSkin=DataArrayDouble.Dot(forceVectSkin,speedOnSkin)
power=powerSkin.accumulate()[0]
-print "power = %r W"%(power) ; assert abs(power-4.22)<1e-2
+print("power = %r W"%(power)) ; assert abs(power-4.22)<1e-2
x2=posSkin[:,0]*posSkin[:,0] ; x2=x2.accumulate()[0]
y2=posSkin[:,1]*posSkin[:,1] ; y2=y2.accumulate()[0]
inertiaSkinValues,inertiaSkinVects=linalg.eig(inertiaSkin)
pos=max(enumerate(inertiaSkinValues),key=lambda x: x[1])[0]
vect0=inertiaSkinVects[pos].tolist()[0]
-print vect0
+print(vect0)
def computeAngle(locAgitateur1ts):
fMc=locAgitateur1ts.getFieldAtLevel(ON_CELLS,0)
pass
angle2=len(ts)*[0.]
-for pos in xrange(2,len(vects)):
+for pos in range(2, len(vects)):
norm1=sqrt(vects[pos-1][0]*vects[pos-1][0]+vects[pos-1][1]*vects[pos-1][1])
norm2=sqrt(vects[pos][0]*vects[pos][0]+vects[pos][1]*vects[pos][1])
crs=vects[pos-1][0]*vects[pos][0]+vects[pos-1][1]*vects[pos][1]
pass
omega=sum(angle2)/(ts[-1][2]-ts[0][2])
-print sum(angle2) ; assert abs(sum(angle2)-1.12)<1e-2
-print "Au pdt (%d,%d) a %r s le couple est de : %r N.m, power/omega=%r N.m"%(ts[2][0],ts[2][1],ts[2][2],zeTorque[2],power/omega)
+print(sum(angle2)) ; assert abs(sum(angle2)-1.12)<1e-2
+print("Au pdt (%d,%d) a %r s le couple est de : %r N.m, power/omega=%r N.m"%(ts[2][0],ts[2][1],ts[2][2],zeTorque[2],power/omega))
assert abs(power/omega-0.37)<1e-2
#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
-# Author : Anthony Geay (CEA/DEN)
+# Author : Anthony Geay (EDF R&D)
from MEDLoader import *
from math import pi,e,sqrt
m2=MEDCouplingUMesh.New("ma",2)
m2.setCoords(coo2)
m2.allocateCells(128)
- nbTri=len(c2tri)/3
- for i in xrange(nbTri):
+ nbTri = len(c2tri) // 3
+ for i in range(nbTri):
m2.insertNextCell(NORM_TRI3,3,c2tri[3*i:3*i+3])
pass
- nbQua=len(c2quad4)/4
- for i in xrange(nbQua):
+ nbQua = len(c2quad4) // 4
+ for i in range(nbQua):
m2.insertNextCell(NORM_QUAD4,4,c2quad4[4*i:4*i+4])
pass
m2.finishInsertingCells()
m1.setCoords(coo2)
c1seg=[0,1,1,2,2,3,3,4,4,9,9,14,14,19,19,24,24,29,29,34,34,39,39,43,43,42,42,41,41,40,40,44,44,35,35,30,30,25,25,20,20,15,15,10,10,5,5,0,43,39,39,34,34,29,29,24,24,19,19,14,14,9,9,4,45,53,53,54,54,55,55,56,56,57,57,58,58,59,59,49,49,60,60,61,61,62,62,52,52,63,63,64,64,65,65,66,66,67,67,68,68,69,69,47,47,70,70,71,71,72,72,45,50,94,94,95,95,96,96,97,97,98,98,99,99,100,100,46,46,101,101,102,102,103,103,48,48,104,104,105,105,106,106,107,107,108,108,109,109,110,110,51,51,111,111,112,112,113,113,50]
m1.allocateCells(80)
- for i in xrange(80):
+ for i in range(80):
m1.insertNextCell(NORM_SEG2,2,c1seg[2*i:2*i+2])
pass
m1.finishInsertingCells()
m0.setCoords(coo2)
c0pt=[44,0,47,48]
m0.allocateCells(4)
- for i in xrange(4):
+ for i in range(4):
m0.insertNextCell(NORM_POINT1,1,[c0pt[i]])
pass
m0.finishInsertingCells()
array=DataArrayDouble.New();
array.alloc(19,2);
ptr=array.getPointer();
- for i in xrange(19*2):
+ for i in range(19 * 2):
array.setIJ(0,i,float(i+7));
pass
f.setArray(array);
array=DataArrayDouble.New();
array.alloc(53,2);
ptr=array.getPointer();
- for i in xrange(53*2):
+ for i in range(53 * 2):
array.setIJ(0,i,float(i+7));
pass
f.setArray(array);
array=DataArrayDouble.New();
array.alloc(53,2);
ptr=array.getPointer();
- for i in xrange(53*2):
+ for i in range(53 * 2):
array.setIJ(0,i,float(i+7));
pass
f.setArray(array);
f.setMesh(m);
array=DataArrayDouble.New();
array.alloc(20,2);
- for i in xrange(2*20):
+ for i in range(2 * 20):
array.setIJ(0,i,float(i+8));
f.setArray(array);
array.setInfoOnComponent(0,"power [W]");
#! [PySnippetMeshAdvAPI1_6]
m0D=ReadUMeshFromFile("file2.med","Example2",-3)
#! [PySnippetMeshAdvAPI1_6]
- for i in xrange(4):
+ for i in range(4):
mm.removeMeshAtLevel(-i)
pass
mm.setMeshAtLevel(0,myMesh1)
mfflds=mfflds.partOfThisLyingOnSpecifiedMeshName(mfmsh[0].getName())
retf=self.__splitFields(mfmsh[0],mfflds,idsLst)
retm=self.__splitMesh(mfmsh[0],idsLst)
- self._mfd_splitted=[MEDFileData() for i in xrange(len(idsLst))]
+ self._mfd_splitted=[MEDFileData() for i in range(len(idsLst))]
for a,b,c in zip(self._mfd_splitted,retf,retm):
a.setFields(b) ; a.setMeshes(c)
pass
pass
def __splitMEDFileField1TS(self,mm,f1ts,idsLst):
- ret=[f1ts.__class__() for i in xrange(len(idsLst))]
+ ret=[f1ts.__class__() 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 xrange(len(idsLst))]
+ ret0 = [MEDFileFields() for i in range(len(idsLst))]
for fmts in mfflds:
if len(fmts.getPflsReallyUsed())!=0:
- print "Field \"%s\" contains profiles ! Not supported yet ! This field will be ignored !"%(fmts.getName())
+ print("Field \"%s\" contains profiles ! Not supported yet ! This field will be ignored !" % (fmts.getName()))
continue
pass
- ret1=[fmts.__class__() for i in xrange(len(idsLst))]
+ ret1=[fmts.__class__() 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 xrange(len(idsLst))]
+ ret0 = [MEDFileMeshes() for i in range(len(idsLst))]
m=mfm.getMeshAtLevel(0)
for ret,ids in zip(ret0,idsLst):
mlPart=mfm.createNewEmpty()
nbOfCompo=4100
arr=MEDLoader.DataArrayDouble(nbOfCompo*3) ; arr.iota()
arr.rearrange(nbOfCompo)
- arr.setInfoOnComponents(["c%i"%(i) for i in xrange(nbOfCompo)])
+ arr.setInfoOnComponents(["c%i" % (i) for i in range(nbOfCompo)])
f.setArray(arr)
f.setName("FieldBigCompo")
MEDLoader.WriteField(fileName,f,True)
m.insertNextCell([0,2,1,3])
m.setCoords(MEDLoader.DataArrayDouble([0.,0.,1.,1.,1.,0.,0.,1.],4,2))
#
- ms=[m.deepCopy() for i in xrange(4)]
+ ms = [m.deepCopy() for i in range(4)]
for i,elt in enumerate(ms):
elt.translate([float(i)*1.5,0.])
pass
m.insertNextCell([0,2,1,3])
m.setCoords(MEDLoader.DataArrayDouble([0.,0.,1.,1.,1.,0.,0.,1.],4,2))
#
- ms=[m.deepCopy() for i in xrange(4)]
+ ms = [m.deepCopy() for i in range(4)]
for i,elt in enumerate(ms):
elt.translate([float(i)*1.5,0.])
pass
mm[0]=m
mm.write(fname,2)
#
- pfl=MEDLoader.DataArrayInt(range(8))
+ pfl = MEDLoader.DataArrayInt(list(range(8)))
pfl.setName("PFL")
#
f=MEDLoader.MEDCouplingFieldDouble(MEDLoader.ON_CELLS)
from MEDLoaderDataForTest import MEDLoaderDataForTest
from distutils.version import LooseVersion
+import sys
+if sys.version_info.major < 3:
+ import cPickle as pickle
+else:
+ import pickle
+
class MEDLoaderTest3(unittest.TestCase):
def testMEDMesh1(self):
fileName="Pyfile18.med"
g2_1.setName("G2")
mm.setGroupsAtLevel(-1,[g1_1,g2_1],False)
g1_N=DataArrayInt.New()
- g1_N.setValues(range(8),8,1)
+ g1_N.setValues(list(range(8)),8,1)
g1_N.setName("G1")
g2_N=DataArrayInt.New()
- g2_N.setValues(range(9),9,1)
+ g2_N.setValues(list(range(9)),9,1)
g2_N.setName("G2")
mm.setGroupsAtLevel(1,[g1_N,g2_N],False)
mm.createGroupOnAll(0,"GrpOnAllCell")
self.assertTrue(g2_N.isEqual(t));
self.assertTrue(mm.existsGroup("GrpOnAllCell"));
t=mm.getGroupArr(0,"GrpOnAllCell")
- self.assertTrue(t.getValues()==range(5))
+ self.assertTrue(t.getValues()==list(range(5)))
#
mmCpy=mm.deepCopy()
self.assertTrue(mm.isEqual(mmCpy,1e-12)[0]) ; del mm
self.assertTrue(not mm2.existsFamily("Family_-8"))
mm2.createGroupOnAll(-1,"GrpOnAllFace")
self.assertTrue(mm2.existsFamily("Family_-8"))
- self.assertEqual(range(3),mm2.getGroupArr(-1,"GrpOnAllFace").getValues())
+ self.assertEqual(list(range(3)),mm2.getGroupArr(-1,"GrpOnAllFace").getValues())
pass
#testing persistence of retrieved arrays
m1=MEDLoaderDataForTest.build2DMesh_1()
m1.renumberCells([0,1,4,2,3,5],False)
tmp=m1.getName();
- m1=m1.buildPartOfMySelf(range(5),True) ; m1.setName(tmp) # suppression of last cell that is a polygon
+ m1=m1.buildPartOfMySelf(list(range(5)),True) ; m1.setName(tmp) # suppression of last cell that is a polygon
mm1=MEDFileUMesh.New() ; mm1.setCoords(m1.getCoords()) ; mm1.setMeshAtLevel(0,m1) ;
mm1.write(fname,2)
ff1=MEDFileField1TS.New()
m1=MEDLoaderDataForTest.build2DMesh_1()
m1.renumberCells([0,1,4,2,3,5],False)
tmp=m1.getName();
- m1=m1.buildPartOfMySelf(range(5),True) ; m1.setName(tmp) # suppression of last cell that is a polygon
+ m1=m1.buildPartOfMySelf(list(range(5)),True) ; m1.setName(tmp) # suppression of last cell that is a polygon
mm1=MEDFileUMesh.New() ; mm1.setCoords(m1.getCoords()) ; mm1.setMeshAtLevel(0,m1) ;
mm1.write(fname,2)
ff1=MEDFileFieldMultiTS.New()
da=DataArrayInt.New(); da.setValues([0,1,3,4,6],5,1) ; da.setName("sup1NodeElt")
#
ff1.setFieldProfile(f1,mm1,0,da)
- m1=m0.buildPartOfMySelf(range(5),True) ; m1.setName(tmp) ; mm1.setMeshAtLevel(0,m1) ;
+ m1=m0.buildPartOfMySelf(list(range(5)),True) ; m1.setName(tmp) ; mm1.setMeshAtLevel(0,m1) ;
mm1.write(fname,2)
ff1.write(fname,0)
f1=ff1.getFieldOnMeshAtLevel(ON_GAUSS_NE,m1,0)
coords=DataArrayDouble([0.,0.,0.,1.,1.,1.,1.,0.,0.,0.5,0.5,1.,1.,0.5,0.5,0.],8,2)
mQ8=MEDCouplingUMesh("",2) ; mQ8.setCoords(coords)
mQ8.allocateCells(1)
- mQ8.insertNextCell(NORM_QUAD8,range(8))
+ mQ8.insertNextCell(NORM_QUAD8,list(range(8)))
mQ8.finishInsertingCells()
mQ4=MEDCouplingUMesh("",2) ; mQ4.setCoords(coords)
mQ4.allocateCells(1)
- mQ4.insertNextCell(NORM_QUAD4,range(4))
+ mQ4.insertNextCell(NORM_QUAD4,list(range(4)))
mQ4.finishInsertingCells()
mT3=MEDCouplingUMesh("",2) ; mT3.setCoords(coords)
mT3.allocateCells(1)
- mT3.insertNextCell(NORM_TRI3,range(3))
+ mT3.insertNextCell(NORM_TRI3,list(range(3)))
mT3.finishInsertingCells()
tr=[[0.,4.],[2.,4.],[4.,4.],[6.,4.],[8.,4.],[10.,4.],[12.,4.],[14.,4.],[16.,4.],[18.,4.],[20.,4.],[0.,0.],[2.,0.], [0.,2.],[2.,2.],[4.,2.],[6.,2.],[8.,2.],[10.,2.],[12.,2.]]
mm.write(fname,2)
#
f1ts=MEDFileField1TS.New()
- pfl=DataArrayInt(range(13)) ; pfl.setName("pfl")
+ pfl=DataArrayInt(list(range(13))) ; pfl.setName("pfl")
self.assertRaises(InterpKernelException,f1ts.setFieldProfile,fInvalid,mm,0,pfl) # fails because no Gauss localization per cell set !
self.assertRaises(InterpKernelException,f1ts.setFieldProfile,fInvalid2,mm,0,pfl) # fails because no Gauss localization set whereas gauss locid per cell given !
f1ts.setFieldProfile(f,mm,0,pfl)
nf1=MEDCouplingFieldInt(ON_NODES)
nf1.setTime(9.,10,-1)
nf1.setMesh(f1.getMesh())
- narr=DataArrayInt(12,2) ; narr.setInfoOnComponents(["aa [u1]","bbbvv [ppp]"]) ; narr[:,0]=range(12) ; narr[:,1]=2*narr[:,0]
+ narr=DataArrayInt(12,2) ; narr.setInfoOnComponents(["aa [u1]","bbbvv [ppp]"]) ; narr[:,0]=list(range(12)) ; narr[:,1]=2*narr[:,0]
nf1.setName("VectorFieldOnNodes") ; nf1.setArray(narr)
nff1=MEDFileIntField1TS.New()
nff1.setFieldNoProfileSBT(nf1)
nf2=MEDCouplingFieldInt(ON_NODES)
nf2.setTime(19.,20,-11)
nf2.setMesh(f1.getMesh())
- narr2=DataArrayInt(8,2) ; narr.setInfoOnComponents(["aapfl [u1]","bbbvvpfl [ppp]"]) ; narr2[:,0]=range(8) ; narr2[:,0]+=10 ; narr2[:,1]=3*narr2[:,0]
+ narr2=DataArrayInt(8,2) ; narr.setInfoOnComponents(["aapfl [u1]","bbbvvpfl [ppp]"]) ; narr2[:,0]=list(range(8)) ; narr2[:,0]+=10 ; narr2[:,1]=3*narr2[:,0]
nf2.setName("VectorFieldOnNodesPfl") ; narr2.setName(nf2.getName()) ; nf2.setArray(narr2)
nff2=MEDFileIntField1TS.New()
npfl=DataArrayInt([1,2,4,5,6,7,10,11]) ; npfl.setName("npfl")
c=DataArrayDouble(12) ; c.iota(); m=MEDCouplingCMesh() ; m.setCoordsAt(0,c) ; m.setName("mesh")
mm=MEDFileCMesh() ; mm.setMesh(m) ; mm.write(fname,2)
f1.setMesh(m)
- arr=DataArrayDouble(12,2) ; arr.setInfoOnComponents(["aa [u1]","bbbvv [ppp]"]) ; arr[:,0]=range(12) ; arr[:,1]=2*arr[:,0]
+ arr=DataArrayDouble(12,2) ; arr.setInfoOnComponents(["aa [u1]","bbbvv [ppp]"]) ; arr[:,0]=list(range(12)) ; arr[:,1]=2*arr[:,0]
f1.setArray(arr)
f1.setName("Field1")
ff1=MEDFileField1TS.New()
self.assertTrue(not ff0.getUndergroundDataArray().isAllocated())
self.assertEqual(ff0.getUndergroundDataArray().getInfoOnComponents(),['X [km]','YY [mm]'])
heap_memory_ref=ff0.getHeapMemorySize()
- self.assertIn(heap_memory_ref,xrange(182,481+2*strMulFac))
+ self.assertIn(heap_memory_ref,xrange(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,xrange(350,536+6*strMulFac))
+ self.assertIn(heap_memory_ref,xrange(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,xrange(1100,1400+2*strMulFac))
+ self.assertIn(heap_memory_ref,xrange(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,xrange(299,536+6*strMulFac))
+ self.assertIn(heap_memory_ref,xrange(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,xrange(5536,10242+(80+26+1)*strMulFac))
+ self.assertIn(heap_memory_ref,xrange(5536,8212+(80+26+1)*strMulFac))
ff0.loadArrays()
self.assertEqual(ff0.getHeapMemorySize()-heap_memory_ref,20*70*8*2)
del ff0
#
ffs=MEDFileFields(fname,False)
heap_memory_ref=ffs.getHeapMemorySize()
- self.assertIn(heap_memory_ref,xrange(5335,11507+(80+50+len(ffs))*strMulFac))
+ self.assertIn(heap_memory_ref,xrange(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
m00=MEDCouplingUMesh("mesh",1) ; m00.setCoords(m0.getCoords()) ; m00.allocateCells(0)
m=MEDFileUMesh()
m.setMeshAtLevel(0,m00)
- m.setRenumFieldArr(1,DataArrayInt(range(10,26)))
+ m.setRenumFieldArr(1,DataArrayInt(list(range(10,26))))
m.setFamilyFieldArr(1,DataArrayInt([-1,-1,-1,-1,-1,-2,-2,-2,-2,-2,-2,0,-1,-3,-3,-3]))
m.write(fname,2)
del m,a,c,m0,m00
m=MEDFileMesh.New(fname)
self.assertEqual((),m.getNonEmptyLevels())
self.assertTrue(m.getCoords().isEqual(DataArrayDouble([(0,0),(1,0),(2,0),(3,0),(0,1),(1,1),(2,1),(3,1),(0,2),(1,2),(2,2),(3,2),(0,3),(1,3),(2,3),(3,3)]),1e-12))
- self.assertTrue(m.getNumberFieldAtLevel(1).isEqual(DataArrayInt(range(10,26))))
+ self.assertTrue(m.getNumberFieldAtLevel(1).isEqual(DataArrayInt(list(range(10,26)))))
self.assertTrue(m.getFamilyFieldAtLevel(1).isEqual(DataArrayInt([-1,-1,-1,-1,-1,-2,-2,-2,-2,-2,-2,0,-1,-3,-3,-3])))
pass
f=MEDCouplingFieldDouble(ON_CELLS,ONE_TIME) ; f.setMesh(m)
f.setName("Field")
arr=DataArrayDouble(25,2) ; arr.setInfoOnComponents(compos)
- arr[:,0]=range(25)
- arr[:,1]=range(100,125)
+ arr[:,0]=list(range(25))
+ arr[:,1]=list(range(100,125))
f.setArray(arr)
WriteField(fileName,f,True)
f=MEDCouplingFieldDouble(ON_NODES,ONE_TIME) ; f.setMesh(m)
f.setName("FieldNode")
arr=DataArrayDouble(36,2) ; arr.setInfoOnComponents(compos)
- arr[:,0]=range(200,236)
- arr[:,1]=range(300,336)
+ arr[:,0]=list(range(200,236))
+ arr[:,1]=list(range(300,336))
f.setArray(arr)
f.checkConsistencyLight()
WriteFieldUsingAlreadyWrittenMesh(fileName,f)
fs=MEDFileFields.LoadPartOf(fileName,False,ms)
fs=fs.deepCopy()
fs[0][0].loadArrays()
- arr=DataArrayDouble(12,2) ; arr[:,0]=range(3,15) ; arr[:,1]=range(103,115)
+ arr = DataArrayDouble(12, 2) ; arr[:, 0] = list(range(3, 15)) ; arr[:, 1] = list(range(103, 115))
arr.setInfoOnComponents(compos)
self.assertTrue(fs[0][0].getUndergroundDataArray().isEqual(arr,1e-12))
fs[1][0].loadArrays()
- arr=DataArrayDouble(21,2) ; arr[:,0]=range(203,224) ; arr[:,1]=range(303,324)
+ arr = DataArrayDouble(21, 2) ; arr[:, 0] = list(range(203, 224)) ; arr[:, 1] = list(range(303, 324))
arr.setInfoOnComponents(compos)
self.assertTrue(fs[1][0].getUndergroundDataArray().isEqual(arr,1e-12))
pass
f=MEDCouplingFieldDouble(ON_CELLS,ONE_TIME) ; f.setMesh(m)
f.setName("Field")
arr=DataArrayDouble(25,2) ; arr.setInfoOnComponents(compos)
- arr[:,0]=range(25)
- arr[:,1]=range(100,125)
+ arr[:,0]=list(range(25))
+ arr[:,1]=list(range(100,125))
f.setArray(arr)
WriteField(fileName,f,True)
f=MEDCouplingFieldDouble(ON_NODES,ONE_TIME) ; f.setMesh(m)
f.setName("FieldNode")
arr=DataArrayDouble(36,2) ; arr.setInfoOnComponents(compos)
- arr[:,0]=range(200,236)
- arr[:,1]=range(300,336)
+ arr[:,0]=list(range(200,236))
+ arr[:,1]=list(range(300,336))
f.setArray(arr)
f.checkConsistencyLight()
WriteFieldUsingAlreadyWrittenMesh(fileName,f)
@unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
def testMEDFileUMeshPickeling1(self):
- import cPickle
outFileName="Pyfile86.med"
c=DataArrayDouble([-0.3,-0.3, 0.2,-0.3, 0.7,-0.3, -0.3,0.2, 0.2,0.2, 0.7,0.2, -0.3,0.7, 0.2,0.7, 0.7,0.7 ],9,2)
c.setInfoOnComponents(["aa","bbb"])
g2_1.setName("G2")
mm.setGroupsAtLevel(-1,[g1_1,g2_1],False)
g1_N=DataArrayInt.New()
- g1_N.setValues(range(8),8,1)
+ g1_N.setValues(list(range(8)),8,1)
g1_N.setName("G1")
g2_N=DataArrayInt.New()
- g2_N.setValues(range(9),9,1)
+ g2_N.setValues(list(range(9)),9,1)
g2_N.setName("G2")
mm.setGroupsAtLevel(1,[g1_N,g2_N],False)
mm.createGroupOnAll(0,"GrpOnAllCell")
self.assertTrue(mm.existsGroup("GrpOnAllCell"));
t=mm.getGroupArr(0,"GrpOnAllCell")
#
- st=cPickle.dumps(mm,cPickle.HIGHEST_PROTOCOL)
- mm2=cPickle.loads(st)
+ st=pickle.dumps(mm,pickle.HIGHEST_PROTOCOL)
+ mm2=pickle.loads(st)
self.assertTrue(mm.isEqual(mm2,1e-12)[0])
self.assertEqual(mm.getAxisType(),AX_CART)
#
mm.setAxisType(AX_CYL)
- st=cPickle.dumps(mm,cPickle.HIGHEST_PROTOCOL)
- mm2=cPickle.loads(st)
+ st=pickle.dumps(mm,pickle.HIGHEST_PROTOCOL)
+ mm2=pickle.loads(st)
self.assertTrue(mm.isEqual(mm2,1e-12)[0])
self.assertEqual(mm2.getAxisType(),AX_CYL)
pass
m=m.buildUnstructured()
m.setName(meshName)
#
- nbOfField=nbPdt/maxPdt
+ nbOfField=nbPdt//maxPdt
fs=MEDFileFields()
- for j in xrange(nbOfField):
+ for j in range(nbOfField):
fmts=MEDFileFieldMultiTS()
s=DataArray.GetSlice(slice(0,nbPdt,1),j,nbOfField)
for i in xrange(s.start,s.stop,s.step):
mesh.setGroupsAtLevel(-1,[grp1,grp2])
import cPickle
- st=cPickle.dumps(mesh,2)
- mm=cPickle.loads(st)
- st2=cPickle.dumps(mm,2)
- mm2=cPickle.loads(st2)
+ st=pickle.dumps(mesh,2)
+ mm=pickle.loads(st)
+ st2=pickle.dumps(mm,2)
+ mm2=pickle.loads(st2)
self.assertTrue(mesh.isEqual(mm2,1e-12)[0])
pass
self.assertTrue(ff2.isEqual(ff,1e-12,1e-12))
# OK now end of joke -> serialization of MEDFileData
import cPickle
- st=cPickle.dumps(mfd,cPickle.HIGHEST_PROTOCOL)
- mfd3=cPickle.loads(st)
+ st=pickle.dumps(mfd,pickle.HIGHEST_PROTOCOL)
+ mfd3=pickle.loads(st)
# check of object
self.assertEqual(len(mfd3.getMeshes()),1)
self.assertEqual(len(mfd3.getFields()),1)
ff3=mfd3.getFields()[0][0].field(mfd3.getMeshes()[0])
self.assertTrue(ff3.isEqual(ff,1e-12,1e-12))
# serialization of MEDFileFields
- st=cPickle.dumps(mfd.getFields(),cPickle.HIGHEST_PROTOCOL)
- fs4=cPickle.loads(st)
+ st=pickle.dumps(mfd.getFields(),pickle.HIGHEST_PROTOCOL)
+ fs4=pickle.loads(st)
ff4=fs4[0][0].field(mfd3.getMeshes()[0])
self.assertTrue(ff4.isEqual(ff,1e-12,1e-12))
# serialization of MEDFileFieldMulitTS
- st=cPickle.dumps(mfd.getFields()[0],cPickle.HIGHEST_PROTOCOL)
- fmts5=cPickle.loads(st)
+ st=pickle.dumps(mfd.getFields()[0],pickle.HIGHEST_PROTOCOL)
+ fmts5=pickle.loads(st)
ff5=fmts5[0].field(mfd3.getMeshes()[0])
self.assertTrue(ff5.isEqual(ff,1e-12,1e-12))
# serialization of MEDFileField1TS
- st=cPickle.dumps(mfd.getFields()[0][0],cPickle.HIGHEST_PROTOCOL)
- f1ts6=cPickle.loads(st)
+ st=pickle.dumps(mfd.getFields()[0][0],pickle.HIGHEST_PROTOCOL)
+ f1ts6=pickle.loads(st)
ff6=f1ts6.field(mfd3.getMeshes()[0])
self.assertTrue(ff6.isEqual(ff,1e-12,1e-12))
# serialization of MEDFileMeshes
- st=cPickle.dumps(mfd.getMeshes(),cPickle.HIGHEST_PROTOCOL)
- ms7=cPickle.loads(st)
+ st=pickle.dumps(mfd.getMeshes(),pickle.HIGHEST_PROTOCOL)
+ ms7=pickle.loads(st)
self.assertEqual(len(ms7),1)
self.assertTrue(ms7[0].isEqual(mfd.getMeshes()[0],1e-12))
pass
mm=MEDFileMesh.New("MEDFileMesh5.med")
self.assertTrue(isinstance(mm,MEDFileCMesh))
import cPickle
- st=cPickle.dumps(mm,cPickle.HIGHEST_PROTOCOL)
- mm2=cPickle.loads(st)
+ st=pickle.dumps(mm,pickle.HIGHEST_PROTOCOL)
+ mm2=pickle.loads(st)
self.assertTrue(isinstance(mm2,MEDFileCMesh))
self.assertTrue(mm.getMesh().isEqual(mm2.getMesh(),1e-12))
# CurveLinear
self.testCurveLinearMesh1() # generates Pyfile55.med
mm=MEDFileMesh.New("Pyfile55.med")
self.assertTrue(isinstance(mm,MEDFileCurveLinearMesh))
- st=cPickle.dumps(mm,cPickle.HIGHEST_PROTOCOL)
- mm3=cPickle.loads(st)
+ st=pickle.dumps(mm,pickle.HIGHEST_PROTOCOL)
+ mm3=pickle.loads(st)
self.assertTrue(isinstance(mm3,MEDFileCurveLinearMesh))
self.assertTrue(mm.getMesh().isEqual(mm3.getMesh(),1e-12))
self.testInt32InMEDFileFieldStar1()# generates Pyfile63.med
fs4=MEDFileFields("Pyfile63.med")
ms4=MEDFileMeshes("Pyfile63.med")
self.assertTrue(isinstance(fs4[0],MEDFileIntFieldMultiTS))
- st=cPickle.dumps(fs4[0],cPickle.HIGHEST_PROTOCOL)
- fmts5=cPickle.loads(st)
+ st=pickle.dumps(fs4[0],pickle.HIGHEST_PROTOCOL)
+ fmts5=pickle.loads(st)
self.assertEqual(len(fs4[0]),len(fmts5))
self.assertTrue(isinstance(fmts5,MEDFileIntFieldMultiTS))
self.assertTrue(fmts5[0].field(ms4[0]).isEqual((fs4[0][0]).field(ms4[0]),1e-12,1e-12))
# MEDFileIntField1TS
- st=cPickle.dumps(fs4[0][0],cPickle.HIGHEST_PROTOCOL)
- f1ts6=cPickle.loads(st)
+ st=pickle.dumps(fs4[0][0],pickle.HIGHEST_PROTOCOL)
+ f1ts6=pickle.loads(st)
self.assertTrue(isinstance(f1ts6,MEDFileIntField1TS))
self.assertTrue(f1ts6.field(ms4[0]).isEqual((fs4[0][0]).field(ms4[0]),1e-12,1e-12))
# MEDFileParameters
self.testParameters1()# generates Pyfile56.med
params=MEDFileParameters("Pyfile56.med")
- st=cPickle.dumps(params,cPickle.HIGHEST_PROTOCOL)
- params7=cPickle.loads(st)
+ st=pickle.dumps(params,pickle.HIGHEST_PROTOCOL)
+ params7=pickle.loads(st)
self.assertEqual(len(params),len(params7))
for i in xrange(len(params)):
self.assertTrue(params[i].isEqual(params7[i],1e-12)[0])
tri=MEDCouplingUMesh("tri",2)
tri.allocateCells() ; tri.insertNextCell(NORM_TRI3,[0,1,2])
tri.setCoords(DataArrayDouble([(0.,0.),(0.,1.),(1.,0.)]))
- tris=[tri.deepCopy() for i in xrange(4)]
+ tris = [tri.deepCopy() for i in range(4)]
for i,elt in enumerate(tris): elt.translate([i,0])
tris=MEDCouplingUMesh.MergeUMeshes(tris)
quad=MEDCouplingUMesh("quad",2)
quad.allocateCells() ; quad.insertNextCell(NORM_QUAD4,[0,1,2,3])
quad.setCoords(DataArrayDouble([(0.,0.),(0.,1.),(1.,1.),(1.,0.)]))
- quads=[quad.deepCopy() for i in xrange(5)]
+ quads = [quad.deepCopy() for i in range(5)]
for i,elt in enumerate(quads): elt.translate([5+i,0])
quads=MEDCouplingUMesh.MergeUMeshes(quads)
m=MEDCouplingUMesh.MergeUMeshes(tris,quads)
mml=fcscp.buildFromScratchDataSetSupport(0,fields)
mml2=mml.prepare()
self.assertTrue(isinstance(mml2,MEDUMeshMultiLev))
- for i in xrange(1,5):
+ for i in range(1, 5):
self.assertTrue(fcscp.isDataSetSupportEqualToThePreviousOne(i,fields))
pass
ncc,a0,a1,a2,a3,a4,a5=mml2.buildVTUArrays()
self.assertTrue(a8.isEqual(DataArrayInt([120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,100,101,102,103,104,105,106,107,108])))
self.assertTrue(not a9)
self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None)
- for i in xrange(5):
+ for i in range(5):
fsst=MEDFileField1TSStructItem.BuildItemFrom(fields[0][i],mst)
fields[0][i].loadArraysIfNecessary()
tmpMem=fields.getHeapMemorySize()
tri=MEDCouplingUMesh("tri",2)
tri.allocateCells() ; tri.insertNextCell(NORM_TRI3,[0,1,2])
tri.setCoords(DataArrayDouble([(0.,0.),(0.,1.),(1.,0.)]))
- tris=[tri.deepCopy() for i in xrange(4)]
+ tris = [tri.deepCopy() for i in range(4)]
for i,elt in enumerate(tris): elt.translate([i,0])
tris=MEDCouplingUMesh.MergeUMeshes(tris)
quad=MEDCouplingUMesh("quad",2)
quad.allocateCells() ; quad.insertNextCell(NORM_QUAD4,[0,1,2,3])
quad.setCoords(DataArrayDouble([(0.,0.),(0.,1.),(1.,1.),(1.,0.)]))
- quads=[quad.deepCopy() for i in xrange(5)]
+ quads = [quad.deepCopy() for i in range(5)]
for i,elt in enumerate(quads): elt.translate([5+i,0])
quads=MEDCouplingUMesh.MergeUMeshes(quads)
m=MEDCouplingUMesh.MergeUMeshes(tris,quads)
mml=fcscp.buildFromScratchDataSetSupport(0,fields)
mml2=mml.prepare()
assert isinstance(mml2,MEDUMeshMultiLev)
- for i in xrange(1,5):
+ for i in range(1, 5):
self.assertTrue(fcscp.isDataSetSupportEqualToThePreviousOne(i,fields))
pass
ncc,a0,a1,a2,a3,a4,a5=mml2.buildVTUArrays()
self.assertTrue(a5 is None)
self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None)
# for cells
- for i in xrange(5):
+ for i in range(5):
f=allFMTSLeavesPerCommonSupport[0][0][0][i]
fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst)# Second 0 is for cells
f.loadArraysIfNecessary()
vExp=DataArrayDouble([200.,201.,202.,203.,204.,205.,206.,207.,208.,209.,210.,211.,212.,213.,214.,215.,216.,217.,218.,219.,220.,221.,222.,223.,224.,225.,226.,227.,228.,229.,230.,231.,232.,233.,234.,235.,236.,237.,238.,239.,240.,241.,242.,243.,244.,245.,246.,247.,248.,249.,250.,251.,252.,253.,254.,255.,256.,257.,258.,259.,260.,261.,262.,263.,100.,101.,102.,103.,104.,105.,106.,107.,108.,109.,110.,111.,112.,113.,114.,115.,116.,117.],41,2) ; vExp.setInfoOnComponents(['Comp1 [m]','Com2 [s^2]']) ; vExp+=i*1000
self.assertTrue(v.isEqual(vExp,1e-12))
pass
- for i in xrange(5):
+ for i in range(5):
f=allFMTSLeavesPerCommonSupport[0][0][1][i]
fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst)# Second 0 is for cells
f.loadArraysIfNecessary()
tri=MEDCouplingUMesh("tri",2)
tri.allocateCells() ; tri.insertNextCell(NORM_TRI3,[0,1,2])
tri.setCoords(DataArrayDouble([(0.,0.),(0.,1.),(1.,0.)]))
- tris=[tri.deepCopy() for i in xrange(4)]
+ tris = [tri.deepCopy() for i in range(4)]
for i,elt in enumerate(tris): elt.translate([i,0])
tris=MEDCouplingUMesh.MergeUMeshes(tris)
quad=MEDCouplingUMesh("quad",2)
quad.allocateCells() ; quad.insertNextCell(NORM_QUAD4,[0,1,2,3])
quad.setCoords(DataArrayDouble([(0.,0.),(0.,1.),(1.,1.),(1.,0.)]))
- quads=[quad.deepCopy() for i in xrange(5)]
+ quads = [quad.deepCopy() for i in range(5)]
for i,elt in enumerate(quads): elt.translate([5+i,0])
quads=MEDCouplingUMesh.MergeUMeshes(quads)
m=MEDCouplingUMesh.MergeUMeshes(tris,quads)
mml=fcscp.buildFromScratchDataSetSupport(0,fields)
mml2=mml.prepare()
self.assertTrue(isinstance(mml2,MEDUMeshMultiLev))
- for i in xrange(1,3):
+ for i in range(1, 3):
self.assertTrue(fcscp.isDataSetSupportEqualToThePreviousOne(i,fields))
pass
ncc,a0,a1,a2,a3,a4,a5=mml2.buildVTUArrays()
assert a5 is None
self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None)
# for cells
- for i in xrange(3):
+ for i in range(3):
f=allFMTSLeavesPerCommonSupport[0][0][0][i]
fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst)# Second 0 is for cells
f.loadArraysIfNecessary()
mml=fcscp.buildFromScratchDataSetSupport(0,fields)
mml2=mml.prepare()
self.assertTrue(isinstance(mml2,MEDUMeshMultiLev))
- for i in xrange(1,2):
+ for i in range(1, 2):
self.assertTrue(fcscp.isDataSetSupportEqualToThePreviousOne(i,fields))
pass
ncc,a0,a1,a2,a3,a4,a5=mml2.buildVTUArrays()
self.assertTrue(a4 is None)
self.assertTrue(a5 is None)
self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None)
- for i in xrange(2):
+ for i in range(2):
f=allFMTSLeavesPerCommonSupport[0][0][0][i]
fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst)# Second 0 is for cells
f.loadArraysIfNecessary()
tri=MEDCouplingUMesh("tri",2)
tri.allocateCells() ; tri.insertNextCell(NORM_TRI3,[0,1,2])
tri.setCoords(DataArrayDouble([(0.,0.),(0.,1.),(1.,0.)]))
- tris=[tri.deepCopy() for i in xrange(4)]
+ tris = [tri.deepCopy() for i in range(4)]
for i,elt in enumerate(tris): elt.translate([i,0])
tris=MEDCouplingUMesh.MergeUMeshes(tris)
quad=MEDCouplingUMesh("quad",2)
quad.allocateCells() ; quad.insertNextCell(NORM_QUAD4,[0,1,2,3])
quad.setCoords(DataArrayDouble([(0.,0.),(0.,1.),(1.,1.),(1.,0.)]))
- quads=[quad.deepCopy() for i in xrange(5)]
+ quads = [quad.deepCopy() for i in range(5)]
for i,elt in enumerate(quads): elt.translate([5+i,0])
quads=MEDCouplingUMesh.MergeUMeshes(quads)
m=MEDCouplingUMesh.MergeUMeshes(tris,quads)
mml=fcscp.buildFromScratchDataSetSupport(0,fields)
mml2=mml.prepare()
self.assertTrue(isinstance(mml2,MEDUMeshMultiLev))
- for i in xrange(1,5):
+ for i in range(1, 5):
self.assertTrue(fcscp.isDataSetSupportEqualToThePreviousOne(i,fields))
pass
ncc,a0,a1,a2,a3,a4,a5=mml2.buildVTUArrays()
self.assertTrue(a5 is None)
self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None)
# test all the time steps of the 1/1 time step serie, on field 1
- for i in xrange(5):
+ for i in range(5):
f=allFMTSLeavesPerCommonSupport[0][0][0][i]
fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst)
f.loadArraysIfNecessary()
self.assertTrue(v.isEqual(vExp,1e-12))
pass
# test all the time steps of the 1/1 time step serie, on field 2
- for i in xrange(5):
+ for i in range(5):
f=allFMTSLeavesPerCommonSupport[0][0][1][i]
fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst)
f.loadArraysIfNecessary()
self.assertTrue(v.isEqual(vExp,1e-12))
pass
# test all the time steps of the 1/1 time step serie, on field 3
- for i in xrange(5):
+ for i in range(5):
f=allFMTSLeavesPerCommonSupport[0][0][2][i]
fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst)
f.loadArraysIfNecessary()
fieldName3="zeField3" ; pfl3=DataArrayInt([0,1,2,3,4,5,9,10]) ; pfl3.setName("pfl3") # on cells but different support
fs1=MEDFileFieldMultiTS() ; fs2=MEDFileFieldMultiTS() ; fs3=MEDFileFieldMultiTS()
#
- for i in xrange(5):
+ for i in range(5):
f=MEDFileField1TS()
fNode=MEDCouplingFieldDouble(ON_CELLS) ; fNode.setTime(float(i),i,0)
fNode.setName(fieldName1)
mml=fcscp.buildFromScratchDataSetSupport(0,fields)
mml2=mml.prepare()
self.assertTrue(isinstance(mml2,MEDUMeshMultiLev))
- for i in xrange(1,5):
+ for i in range(1, 5):
self.assertTrue((fcscp.isDataSetSupportEqualToThePreviousOne(i,fields)))
pass
ncc,a0,a1,a2,a3,a4,a5=mml2.buildVTUArrays()
self.assertTrue(a8.isEqual(DataArrayInt([100,101,102,103,104,105])))
self.assertTrue(not a9)
self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None)
- for i in xrange(5):
+ for i in range(5):
nbOfT=[6,8]
fieldNames=[fieldName1,fieldName2]
- for j in xrange(2):
+ for j in range(2):
m={"i":j}
f=allFMTSLeavesPerCommonSupport[0][0][j][i]
fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst)
mml=fcscp.buildFromScratchDataSetSupport(0,fields)
mml2=mml.prepare()
self.assertTrue(isinstance(mml2,MEDUMeshMultiLev))
- for i in xrange(1,5):
+ for i in range(1, 5):
self.assertTrue(fcscp.isDataSetSupportEqualToThePreviousOne(i,fields))
pass
ncc,a0,a1,a2,a3,a4,a5=mml2.buildVTUArrays()
self.assertTrue(a8.isEqual(DataArrayInt([100,101,102,103,104,105,109,110])))
self.assertTrue(not a9)
self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None)
- for i in xrange(5):
+ for i in range(5):
f=allFMTSLeavesPerCommonSupport[1][0][0][i]
fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst)
f.loadArraysIfNecessary()
fieldName4="zeField4" ;# on nodes
fs0=MEDFileFieldMultiTS() ; fs1=MEDFileFieldMultiTS() ; fs2=MEDFileFieldMultiTS() ; fs3=MEDFileFieldMultiTS() ; fs4=MEDFileFieldMultiTS()
#
- for i in xrange(5):
+ for i in range(5):
f=MEDFileField1TS()
fNode=MEDCouplingFieldDouble(ON_CELLS) ; fNode.setTime(float(i),i,0)
fNode.setName(fieldName0) ; fNode.setMesh(m)
self.assertTrue(a.isEqual(coordsX,1e-12))
self.assertTrue(b.isEqual(coordsY,1e-12))
self.assertTrue(isinstance(mml2,MEDCMeshMultiLev))
- for i in xrange(1,5):
+ for i in range(1, 5):
self.assertTrue((fcscp.isDataSetSupportEqualToThePreviousOne(i,fields)))
pass
a6,a7=mml2.retrieveFamilyIdsOnCells()
self.assertTrue(a10.isEqual(DataArrayInt([200,201,202,203,204,205,206,207,208,209,210,211,212,213,214])))
self.assertTrue(a11) # True because no copy
self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None)
- for i in xrange(5):
+ for i in range(5):
f=allFMTSLeavesPerCommonSupport[0][0][0][i]
fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst)
f.loadArraysIfNecessary()
self.assertTrue(a10.isEqual(DataArrayInt([202,203,204,207,208,209,212,213,214])))
self.assertTrue(not a11) # False because copy
self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None)
- for i in xrange(1,5):
+ for i in range(1, 5):
self.assertTrue((fcscp.isDataSetSupportEqualToThePreviousOne(i,fields)))
pass
- for i in xrange(5):
+ for i in range(5):
f=allFMTSLeavesPerCommonSupport[1][0][0][i]
fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst)
f.loadArraysIfNecessary()
self.assertTrue(a8.isEqual(DataArrayInt([102,103,105,107])))
self.assertTrue(not a9) # False because copy
self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None)
- for i in xrange(5):
+ for i in range(5):
f=allFMTSLeavesPerCommonSupport[2][0][0][i]
fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst)
f.loadArraysIfNecessary()
fieldName4="zeField4" ;# on nodes
fs0=MEDFileFieldMultiTS() ; fs1=MEDFileFieldMultiTS() ; fs2=MEDFileFieldMultiTS() ; fs3=MEDFileFieldMultiTS() ; fs4=MEDFileFieldMultiTS()
#
- for i in xrange(5):
+ for i in range(5):
f=MEDFileField1TS()
fNode=MEDCouplingFieldDouble(ON_CELLS) ; fNode.setTime(float(i),i,0)
fNode.setName(fieldName0) ; fNode.setMesh(m)
self.assertTrue(a8.isEqual(DataArrayInt([100,101,102,103,104,105,106,107])))
self.assertTrue(a9) # True because no copy
self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None)
- for i in xrange(1,5):
+ for i in range(1, 5):
self.assertTrue((fcscp.isDataSetSupportEqualToThePreviousOne(i,fields)))
pass
- for i in xrange(5):
+ for i in range(5):
f=allFMTSLeavesPerCommonSupport[0][0][0][i]
fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst)
f.loadArraysIfNecessary()
self.assertTrue(a8.isEqual(DataArrayInt([102,103,106,107])))
self.assertTrue(not a9) # False because copy
self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None)
- for i in xrange(1,5):
+ for i in range(1, 5):
self.assertTrue((fcscp.isDataSetSupportEqualToThePreviousOne(i,fields)))
pass
- for i in xrange(5):
+ for i in range(5):
f=allFMTSLeavesPerCommonSupport[1][0][0][i]
fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst)
f.loadArraysIfNecessary()
self.assertTrue(a8.isEqual(DataArrayInt([102,103,105,107])))
self.assertTrue(not a9) # False because copy
self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None)
- for i in xrange(5):
+ for i in range(5):
f=allFMTSLeavesPerCommonSupport[2][0][0][i]
fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst)
f.loadArraysIfNecessary()
fieldName2="zeField2"
fieldName3="zeField3"
fs0=MEDFileFieldMultiTS() ; fs1=MEDFileFieldMultiTS() ; fs2=MEDFileFieldMultiTS() ; fs3=MEDFileFieldMultiTS()
- for i in xrange(5):
+ for i in range(5):
f=MEDFileField1TS()
fNode=MEDCouplingFieldDouble(ON_GAUSS_NE) ; fNode.setTime(float(i),i,0)
fNode.setName(fieldName0) ; fNode.setMesh(m)
self.assertTrue(a4 is None)
self.assertTrue(a5 is None)
self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None)
- for i in xrange(1,5):
+ for i in range(1, 5):
self.assertTrue((fcscp.isDataSetSupportEqualToThePreviousOne(i,fields)))
pass
- for i in xrange(5):
+ for i in range(5):
f=allFMTSLeavesPerCommonSupport[0][0][0][i]
fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst)
f.loadArraysIfNecessary()
pfl1=DataArrayInt([0,1,7,9,10]) ; pfl1.setName("pfl1") # on cells
pfl2=DataArrayInt([1,2,3,6,7,8,11,12,13]) ; pfl2.setName("pfl2") # on nodes
fs0=MEDFileFieldMultiTS() ; fs1=MEDFileFieldMultiTS() ; fs2=MEDFileFieldMultiTS() ; fs3=MEDFileFieldMultiTS()
- for i in xrange(5):
+ for i in range(5):
f=MEDFileField1TS()
fNode=MEDCouplingFieldDouble(ON_GAUSS_NE) ; fNode.setTime(float(i),i,0)
fNode.setName(fieldName0)
self.assertTrue(a4 is None)
self.assertTrue(a5 is None)
self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None)
- for i in xrange(1,5):
+ for i in range(1, 5):
self.assertTrue((fcscp.isDataSetSupportEqualToThePreviousOne(i,fields)))
pass
- for i in xrange(5):
+ for i in range(5):
f=allFMTSLeavesPerCommonSupport[0][0][0][i]
fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst)
f.loadArraysIfNecessary()
fieldName2="zeField2"
pfl1=DataArrayInt([1,2,3,6,7,8,11,12,13]) ; pfl1.setName("pfl1") # on nodes
fs0=MEDFileFieldMultiTS() ; fs1=MEDFileFieldMultiTS() ; fs2=MEDFileFieldMultiTS()
- for i in xrange(5):
+ for i in range(5):
f=MEDFileField1TS()
fNode=MEDCouplingFieldDouble(ON_NODES) ; fNode.setTime(float(i),i,0)
fNode.setName(fieldName0)
self.assertTrue(a4 is None)
self.assertTrue(a5 is None)
self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None)
- for i in xrange(1,5):
+ for i in range(1, 5):
self.assertTrue((fcscp.isDataSetSupportEqualToThePreviousOne(i,fields)))
pass
- for i in xrange(5):
+ for i in range(5):
f=allFMTSLeavesPerCommonSupport[0][0][0][i]
fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst)
f.loadArraysIfNecessary()
#
fieldName0="zeField0"
fs0=MEDFileFieldMultiTS()
- for i in xrange(5):
+ for i in range(5):
f=MEDFileField1TS()
fNode=MEDCouplingFieldDouble(ON_GAUSS_PT) ; fNode.setTime(float(i),i,0)
fNode.setName(fieldName0) ; fNode.setMesh(m)
self.assertTrue(a4 is None)
self.assertTrue(a5 is None)
self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None)
- for i in xrange(1,5):
+ for i in range(1, 5):
self.assertTrue((fcscp.isDataSetSupportEqualToThePreviousOne(i,fields)))
pass
- for i in xrange(5):
+ for i in range(5):
f=allFMTSLeavesPerCommonSupport[0][0][0][i]
fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst)
f.loadArraysIfNecessary()
fieldName0="zeField0"
fieldName1="zeField1"
fs0=MEDFileFieldMultiTS() ; fs1=MEDFileFieldMultiTS()
- for i in xrange(5):
+ for i in range(5):
f=MEDFileField1TS()
fNode=MEDCouplingFieldDouble(ON_GAUSS_PT) ; fNode.setTime(float(i),i,0)
fNode.setName(fieldName0) ; fNode.setMesh(m)
self.assertTrue(a4 is None)
self.assertTrue(a5 is None)
self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None)
- for i in xrange(1,5):
+ for i in range(1, 5):
self.assertTrue((fcscp.isDataSetSupportEqualToThePreviousOne(i,fields)))
pass
- for i in xrange(5):
+ for i in range(5):
f=allFMTSLeavesPerCommonSupport[0][0][0][i]
fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst)
f.loadArraysIfNecessary()
fieldName1="zeField1"
fieldName2="zeField2" ; pfl1=DataArrayInt([2,3]) ; pfl1.setName("pfl1")
fieldName3="zefield3" ; pfl2=DataArrayInt([2,3,4]) ; pfl2.setName("pfl2")
- for i in xrange(5):
+ for i in range(5):
f=MEDFileField1TS()
fNode=MEDCouplingFieldDouble(ON_CELLS) ; fNode.setTime(float(i),i,0)
fNode.setName(fieldName0) ; fNode.setMesh(m)
self.assertTrue(a4.isEqual(DataArrayInt([-1,-1,0,31,62])))
self.assertTrue(a5.isEqual(DataArrayInt([6,4,3,2,8,9,4,15,21,20,14,4,3,15,14,2,4,2,14,20,8,4,8,20,21,9,4,9,21,15,3,6,4,4,3,9,10,4,16,22,21,15,4,4,16,15,3,4,3,15,21,9,4,9,21,22,10,4,10,22,16,4,6,4,5,4,10,11,4,17,23,22,16,4,5,17,16,4,4,4,16,22,10,4,10,22,23,11,4,11,23,17,5])))
self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None)
- for i in xrange(1,5):
+ for i in range(1, 5):
self.assertTrue((fcscp.isDataSetSupportEqualToThePreviousOne(i,fields)))
pass
pass
- for i in xrange(5):
+ for i in range(5):
f=allFMTSLeavesPerCommonSupport[0][0][0][i]
fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst)
f.loadArraysIfNecessary()
self.assertTrue(a4.isEqual(DataArrayInt([0,31])))
self.assertTrue(a5.isEqual(DataArrayInt([6,4,3,2,8,9,4,15,21,20,14,4,3,15,14,2,4,2,14,20,8,4,8,20,21,9,4,9,21,15,3,6,4,4,3,9,10,4,16,22,21,15,4,4,16,15,3,4,3,15,21,9,4,9,21,22,10,4,10,22,16,4])))
self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None)
- for i in xrange(1,5):
+ for i in range(1, 5):
self.assertTrue((fcscp.isDataSetSupportEqualToThePreviousOne(i,fields)))
pass
pass
- for i in xrange(5):
+ for i in range(5):
f=allFMTSLeavesPerCommonSupport[1][0][0][i]
fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst)
f.loadArraysIfNecessary()
self.assertTrue(a3.isEqual(DataArrayInt([8,2,3,8,9,14,15,20,21,8,3,4,9,10,15,16,21,22,8,4,5,10,11,16,17,22,23])))
self.assertTrue(a4.isEqual(DataArrayInt([0,31,62])))
self.assertTrue(a5.isEqual(DataArrayInt([6,4,3,2,8,9,4,15,21,20,14,4,3,15,14,2,4,2,14,20,8,4,8,20,21,9,4,9,21,15,3,6,4,4,3,9,10,4,16,22,21,15,4,4,16,15,3,4,3,15,21,9,4,9,21,22,10,4,10,22,16,4,6,4,5,4,10,11,4,17,23,22,16,4,5,17,16,4,4,4,16,22,10,4,10,22,23,11,4,11,23,17,5])))
- for i in xrange(1,5):
+ for i in range(1, 5):
self.assertTrue((fcscp.isDataSetSupportEqualToThePreviousOne(i,fields)))
pass
pass
- for i in xrange(5):
+ for i in range(5):
f=allFMTSLeavesPerCommonSupport[2][0][0][i]
fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst)
f.loadArraysIfNecessary()
fs0=MEDFileFieldMultiTS() ; fs1=MEDFileFieldMultiTS()
fieldName0="zeField0"
fieldName1="zeField1"
- for i in xrange(5):
+ for i in range(5):
f=MEDFileField1TS()
fNode=MEDCouplingFieldDouble(ON_CELLS) ; fNode.setTime(float(i),i,0)
fNode.setName(fieldName0) ; fNode.setMesh(m)
self.assertTrue(a4.isEqual(DataArrayInt([0,31,62])))
self.assertTrue(a5.isEqual(DataArrayInt([6,4,3,2,8,9,4,15,21,20,14,4,3,15,14,2,4,2,14,20,8,4,8,20,21,9,4,9,21,15,3,6,4,4,3,9,10,4,16,22,21,15,4,4,16,15,3,4,3,15,21,9,4,9,21,22,10,4,10,22,16,4,6,4,5,4,10,11,4,17,23,22,16,4,5,17,16,4,4,4,16,22,10,4,10,22,23,11,4,11,23,17,5])))
self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None)
- for i in xrange(1,5):
+ for i in range(1, 5):
self.assertTrue((fcscp.isDataSetSupportEqualToThePreviousOne(i,fields)))
pass
a6,a7=mml2.retrieveFamilyIdsOnCells()
a8,a9=mml2.retrieveNumberIdsOnCells()
self.assertTrue(a8 is None)
self.assertTrue(a9)
- for i in xrange(5):
+ for i in range(5):
f=allFMTSLeavesPerCommonSupport[0][0][0][i]
fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst)
f.loadArraysIfNecessary()
self.assertTrue(a8.isEqual(DataArrayInt([0,1])))
self.assertTrue(a9) # no copy here
self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None)
- for i in xrange(1,2):
+ for i in range(1, 2):
self.assertTrue((fcscp.isDataSetSupportEqualToThePreviousOne(i,fields)))
pass
vExp0=[DataArrayDouble([7.,11.]),DataArrayDouble([11.,7.])]
vExp1=[DataArrayDouble([3.,5.,7.,6.,2.,3.,11.,8.]),DataArrayDouble([7.,6.,3.,5.,11.,8.,2.,3.])]
- for i in xrange(2):
+ for i in range(2):
f=allFMTSLeavesPerCommonSupport1[0][0][0][i]
fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst)
f.loadArraysIfNecessary()
self.assertTrue(a8.isEqual(DataArrayInt([0,1])))
self.assertTrue(a9) # no copy here
self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None)
- for i in xrange(1,2):
+ for i in range(1, 2):
self.assertTrue((fcscp.isDataSetSupportEqualToThePreviousOne(i,fields)))
pass
vExp0=[DataArrayDouble([7.,11.]),DataArrayDouble([11.,7.])]
vExp1=[DataArrayDouble([3.,5.,4.,6.]),DataArrayDouble([5.,3.,6.,4.])]
- for i in xrange(2):
+ for i in range(2):
f=allFMTSLeavesPerCommonSupport1[0][0][0][i]
fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst)
f.loadArraysIfNecessary()
self.assertTrue(a8.isEqual(DataArrayInt([0,1])))
self.assertTrue(a9) # no copy here
self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None)
- for i in xrange(1,2):
+ for i in range(1, 2):
self.assertTrue((fcscp.isDataSetSupportEqualToThePreviousOne(i,fields)))
pass
vExp0=[DataArrayDouble([7.,11.]),DataArrayDouble([11.,7.])]
vExp1=[DataArrayDouble([3.,5.,4.,6.]),DataArrayDouble([5.,3.,6.,4.])]
- for i in xrange(2):
+ for i in range(2):
f=allFMTSLeavesPerCommonSupport1[0][0][0][i]
fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst) # no load needed here
v=mml.buildDataArray(fsst,fields,f.getUndergroundDataArray())
self.assertTrue(not a12)
self.assertTrue(a13) # no copy here
self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None)
- for i in xrange(1,2):
+ for i in range(1, 2):
self.assertTrue((fcscp.isDataSetSupportEqualToThePreviousOne(i,fields)))
pass
- for i in xrange(2):
+ for i in range(2):
f=allFMTSLeavesPerCommonSupport1[0][0][0][i]
fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst)
f.loadArraysIfNecessary()
self.assertTrue(a12.isEqual(DataArrayInt([0,10,20,30,40,50,60,70,80,90,100,110,120,130,140,150,160,170,180,190,200,210,220,230,240])))
self.assertTrue(a13) # no copy here
self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None)
- for i in xrange(1,2):
+ for i in range(1, 2):
self.assertTrue((fcscp.isDataSetSupportEqualToThePreviousOne(i,fields)))
pass
- for i in xrange(2):
+ for i in range(2):
f=allFMTSLeavesPerCommonSupport1[0][0][0][i]
fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst)
f.loadArraysIfNecessary()
self.assertTrue(a12.isEqual(DataArrayInt([50,60,70,100,110,120,150,160,170,200,210,220])))
self.assertTrue(not a13) # copy here
self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None)
- for i in xrange(2):
+ for i in range(2):
f=allFMTSLeavesPerCommonSupport1[1][0][0][i]
fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst)
f.loadArraysIfNecessary()
self.assertTrue(b.isEqual(arr1,1e-12))
self.assertTrue(c.isEqual(arr2,1e-12))
self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None)
- for i in xrange(2):
+ for i in range(2):
f=allFMTSLeavesPerCommonSupport[0][0][0][i]
fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst)
f.loadArraysIfNecessary()
self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None)
self.assertEqual(v.getHiddenCppPointer(),ffGauss.getUndergroundDataArray().getHiddenCppPointer())
self.assertEqual(ffGauss.getName(),"fGauss")
- self.assertTrue(v.isEqual(arrGauss,1e-12)) ; self.assertTrue(v.isEqualWithoutConsideringStr(DataArrayDouble(range(27)),1e-12)) ; self.assertEqual(v.getInfoOnComponents(),["gaussc"])
+ self.assertTrue(v.isEqual(arrGauss, 1e-12)) ; self.assertTrue(v.isEqualWithoutConsideringStr(DataArrayDouble(list(range(27))), 1e-12)) ; self.assertEqual(v.getInfoOnComponents(), ["gaussc"])
ffGauss=allFMTSLeavesPerCommonSupport1[0][0][1][0]
pass
#
fmts0=MEDFileFieldMultiTS()
fmts1=MEDFileFieldMultiTS()
- for i in xrange(30):
+ for i in range(30):
f1ts=MEDFileField1TS()
fFaces=MEDCouplingFieldDouble(ON_CELLS) ; fFaces.setName("FieldOnFaces")
arr=DataArrayDouble(98) ; arr.iota() ; arr[i]=100.
self.assertTrue(b.isEqual(arrY,1e-12))
self.assertTrue(c.isEqual(arrZ,1e-12))
self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None)
- for i in xrange(30):
+ for i in range(30):
ffCell=allFMTSLeavesPerCommonSupport1[0][0][0][i]
fsst=MEDFileField1TSStructItem.BuildItemFrom(ffCell,mst)
ffCell.loadArraysIfNecessary()
self.assertTrue(a3.isEqual(DataArrayInt([4,0,12,15,3,4,12,24,27,15,4,24,36,39,27,4,36,48,51,39,4,3,15,18,6,4,15,27,30,18,4,27,39,42,30,4,39,51,54,42,4,6,18,21,9,4,18,30,33,21,4,30,42,45,33,4,42,54,57,45,4,1,13,16,4,4,13,25,28,16,4,25,37,40,28,4,37,49,52,40,4,4,16,19,7,4,16,28,31,19,4,28,40,43,31,4,40,52,55,43,4,7,19,22,10,4,19,31,34,22,4,31,43,46,34,4,43,55,58,46,4,2,14,17,5,4,14,26,29,17,4,26,38,41,29,4,38,50,53,41,4,5,17,20,8,4,17,29,32,20,4,29,41,44,32,4,41,53,56,44,4,8,20,23,11,4,20,32,35,23,4,32,44,47,35,4,44,56,59,47,4,0,12,13,1,4,12,24,25,13,4,24,36,37,25,4,36,48,49,37,4,1,13,14,2,4,13,25,26,14,4,25,37,38,26,4,37,49,50,38,4,3,15,16,4,4,15,27,28,16,4,27,39,40,28,4,39,51,52,40,4,4,16,17,5,4,16,28,29,17,4,28,40,41,29,4,40,52,53,41,4,6,18,19,7,4,18,30,31,19,4,30,42,43,31,4,42,54,55,43,4,7,19,20,8,4,19,31,32,20,4,31,43,44,32,4,43,55,56,44,4,9,21,22,10,4,21,33,34,22,4,33,45,46,34,4,45,57,58,46,4,10,22,23,11,4,22,34,35,23,4,34,46,47,35,4,46,58,59,47,4,0,1,4,3,4,3,4,7,6,4,6,7,10,9,4,1,2,5,4,4,4,5,8,7,4,7,8,11,10,4,12,13,16,15,4,15,16,19,18,4,18,19,22,21,4,13,14,17,16,4,16,17,20,19,4,19,20,23,22,4,24,25,28,27,4,27,28,31,30,4,30,31,34,33,4,25,26,29,28,4,28,29,32,31,4,31,32,35,34,4,36,37,40,39,4,39,40,43,42,4,42,43,46,45,4,37,38,41,40,4,40,41,44,43,4,43,44,47,46,4,48,49,52,51,4,51,52,55,54,4,54,55,58,57,4,49,50,53,52,4,52,53,56,55,4,55,56,59,58])))
self.assertTrue(a4 is None)
self.assertTrue(a5 is None)
- for i in xrange(30):
+ for i in range(30):
ffCell=allFMTSLeavesPerCommonSupport1[1][0][0][i]
fsst=MEDFileField1TSStructItem.BuildItemFrom(ffCell,mst)
ffCell.loadArraysIfNecessary()
fmts0=MEDFileFieldMultiTS()
fmts1=MEDFileFieldMultiTS()
pfl=DataArrayInt(11) ; pfl.iota() ; pfl.setName("PflOnHECA8")
- for i in xrange(30):
+ for i in range(30):
f1ts=MEDFileField1TS()
fFaces=MEDCouplingFieldDouble(ON_CELLS) ; fFaces.setName("FieldOnCells")
arr=DataArrayDouble(11) ; arr.iota() ; arr[i%11]=100.
self.assertTrue(a3.isEqual(DataArrayInt([8,1,0,3,4,13,12,15,16,8,2,1,4,5,14,13,16,17,8,4,3,6,7,16,15,18,19,8,5,4,7,8,17,16,19,20,8,7,6,9,10,19,18,21,22,8,8,7,10,11,20,19,22,23,8,13,12,15,16,25,24,27,28,8,14,13,16,17,26,25,28,29,8,16,15,18,19,28,27,30,31,8,17,16,19,20,29,28,31,32,8,19,18,21,22,31,30,33,34])))
self.assertTrue(a4 is None)
self.assertTrue(a5 is None)
- for i in xrange(30):
+ for i in range(30):
ffCell=allFMTSLeavesPerCommonSupport1[0][0][0][i]
fsst=MEDFileField1TSStructItem.BuildItemFrom(ffCell,mst)
ffCell.loadArraysIfNecessary()
fmts0=MEDFileFieldMultiTS()
fmts1=MEDFileFieldMultiTS()
pfl=DataArrayInt(31) ; pfl.iota() ; pfl.setName("PflOnQUAD4")
- for i in xrange(30):
+ for i in range(30):
f1ts=MEDFileField1TS()
fFaces=MEDCouplingFieldDouble(ON_CELLS) ; fFaces.setName("FieldOnFaces")
arr=DataArrayDouble(31) ; arr.iota() ; arr[i]=100.
self.assertTrue(b.isEqual(arrY,1e-12))
self.assertTrue(c.isEqual(arrZ,1e-12))
self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None)
- for i in xrange(30):
+ for i in range(30):
ffCell=allFMTSLeavesPerCommonSupport1[0][0][0][i]
fsst=MEDFileField1TSStructItem.BuildItemFrom(ffCell,mst)
ffCell.loadArraysIfNecessary()
a6,a7=mml2.retrieveFamilyIdsOnCells()
self.assertTrue(a6 is None)
self.assertTrue(a7)
- for i in xrange(30):
+ for i in range(30):
ffCell=allFMTSLeavesPerCommonSupport1[1][0][0][i]
fsst=MEDFileField1TSStructItem.BuildItemFrom(ffCell,mst)
ffCell.loadArraysIfNecessary()
mm=MEDFileUMesh()
mm.setMeshAtLevel(0,m)
mm.write(fname,2)
- for i in xrange(15):
+ for i in range(15):
fCell0=MEDCouplingFieldDouble(ON_CELLS) ; fCell0.setTime(float(i)+0.1,i,0)
fCell0.setName(fieldName) ; fCell0.setMesh(m)
arr=DataArrayDouble(m.getNumberOfCells()) ; arr.iota(0) ; arr[i%10]=100.
self.assertTrue(a4 is None)
self.assertTrue(a5 is None)
self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None)
- for i in xrange(15):
+ for i in range(15):
ffCell=allFMTSLeavesPerCommonSupport1[0][0][0][i]
fsst=MEDFileField1TSStructItem.BuildItemFrom(ffCell,mst)
ffCell.loadArraysIfNecessary()
fieldName0="zeField0"
fieldName1="zeField1"
fs0=MEDFileFieldMultiTS() ; fs1=MEDFileFieldMultiTS()
- for i in xrange(5):
+ for i in range(5):
f=MEDFileField1TS()
fNode=MEDCouplingFieldDouble(ON_GAUSS_PT) ; fNode.setTime(float(i),i,0)
fNode.setName(fieldName0) ; fNode.setMesh(m)
self.assertEqual(len(allFMTSLeavesPerTimeSeries[0]),5)
allFMTSLeavesPerCommonSupport=MEDFileAnyTypeFieldMultiTS.SplitPerCommonSupport(allFMTSLeavesPerTimeSeries[0],ms[ms.getMeshesNames()[0]])
self.assertEqual(len(allFMTSLeavesPerCommonSupport),5)
- for i in xrange(5):
+ for i in range(5):
self.assertEqual(len(allFMTSLeavesPerCommonSupport[i][0]),1)
#
mst=MEDFileMeshStruct.New(ms[0])
self.assertTrue(a4 is None)
self.assertTrue(a5 is None)
self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None)
- for i in xrange(1,5):
+ for i in range(1, 5):
self.assertTrue((fcscp.isDataSetSupportEqualToThePreviousOne(i,fields)))
pass
- for i in xrange(5):
+ for i in range(5):
f=allFMTSLeavesPerCommonSupport[0][0][0][i]
fsst=MEDFileField1TSStructItem.BuildItemFrom(f,mst)
f.loadArraysIfNecessary()
self.assertTrue(a4 is None)
self.assertTrue(a5 is None)
self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None)
- for i in xrange(1):
+ for i in range(1):
ffCell=allFMTSLeavesPerCommonSupport1[0][0][0][i]
fsst=MEDFileField1TSStructItem.BuildItemFrom(ffCell,mst)
ffCell.loadArraysIfNecessary()
self.assertTrue(a4 is None)
self.assertTrue(a5 is None)
self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None)
- for i in xrange(1):
+ for i in range(1):
ffCell=allFMTSLeavesPerCommonSupport1[1][0][0][i]
fsst=MEDFileField1TSStructItem.BuildItemFrom(ffCell,mst)
ffCell.loadArraysIfNecessary()
self.assertTrue(a.isEqual(ref_a,1e-14))
self.assertEqual(b,[3,4,5])
self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None)
- for i in xrange(1):
+ for i in range(1):
ffCell=allFMTSLeavesPerCommonSupport1[0][0][0][i]
fsst=MEDFileField1TSStructItem.BuildItemFrom(ffCell,mst)
ffCell.loadArraysIfNecessary()
self.assertTrue(a.isEqual(ref_a,1e-14))
self.assertEqual(b,[3,4,5])
self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None)
- for i in xrange(1):
+ for i in range(1):
ffCell=allFMTSLeavesPerCommonSupport1[0][0][0][i]
fsst=MEDFileField1TSStructItem.BuildItemFrom(ffCell,mst)
ffCell.loadArraysIfNecessary()
ref_a.setInfoOnComponents(comps)
self.assertTrue(a0.isEqual(ref_a,1e-14))#<- Test is here
self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None)
- for i in xrange(1):
+ for i in range(1):
ffCell=allFMTSLeavesPerCommonSupport1[0][0][0][i]
fsst=MEDFileField1TSStructItem.BuildItemFrom(ffCell,mst)
ffCell.loadArraysIfNecessary()
self.assertTrue(a.isEqual(ref_a,1e-14))#<- Test is here
self.assertEqual(b,[3,4,5])
self.assertTrue(mml2.retrieveGlobalNodeIdsIfAny() is None)
- for i in xrange(1):
+ for i in range(1):
ffCell=allFMTSLeavesPerCommonSupport1[0][0][0][i]
fsst=MEDFileField1TSStructItem.BuildItemFrom(ffCell,mst)
ffCell.loadArraysIfNecessary()
static void converPyListToVecString(PyObject *pyLi, std::vector<std::string>& v)
{
+ static const char msg0[]="In list passed in argument some elements are NOT strings ! Expected a list containing only strings !";
+ static const char msg1[]="In tuple passed in argument some elements are NOT strings ! Expected a list containing only strings !";
+ static const char msg2[]="Unrecognized python argument : expected a list of string or tuple of string or string !";
if(PyList_Check(pyLi))
{
int size=PyList_Size(pyLi);
for(int i=0;i<size;i++)
{
PyObject *o=PyList_GetItem(pyLi,i);
- if(!PyString_Check(o))
- throw INTERP_KERNEL::Exception("In list passed in argument some elements are NOT strings ! Expected a list containing only strings !");
- const char *st=PyString_AsString(o);
- v[i]=std::string(st);
+ v[i]=convertPyObjectToStr(o,msg0);
}
+ return ;
}
else if(PyTuple_Check(pyLi))
{
for(int i=0;i<size;i++)
{
PyObject *o=PyTuple_GetItem(pyLi,i);
- if(!PyString_Check(o))
- throw INTERP_KERNEL::Exception("In tuple passed in argument some elements are NOT strings ! Expected a tuple containing only strings !");
- const char *st=PyString_AsString(o);
- v[i]=std::string(st);
+ v[i]=convertPyObjectToStr(o,msg1);
}
+ return ;
}
- else if(PyString_Check(pyLi))
- {
- v.resize(1);
- v[0]=std::string((const char *)PyString_AsString(pyLi));
- }
- else
- {
- throw INTERP_KERNEL::Exception("Unrecognized python argument : expected a list of string or tuple of string or string !");
- }
+ v.resize(1);
+ v[0]=convertPyObjectToStr(pyLi,msg2);
}
static PyObject *convertFieldDoubleVecToPy(const std::vector<MEDCoupling::MEDCouplingFieldDouble *>& li)
if(size2!=2)
throw INTERP_KERNEL::Exception(msg);
PyObject *o0=PyTuple_GetItem(o,0);
- if(PyString_Check(o0))
- p.first=std::string(PyString_AsString(o0));
- else
- throw INTERP_KERNEL::Exception(msg);
+ p.first=convertPyObjectToStr(o0,msg);
PyObject *o1=PyTuple_GetItem(o,1);
- if(PyString_Check(o1))
- p.second=std::string(PyString_AsString(o1));
- else
- throw INTERP_KERNEL::Exception(msg);
+ p.second=convertPyObjectToStr(o1,msg);
ret[i]=p;
}
else
for(int j=0;j<size3;j++)
{
PyObject *o0j=PyList_GetItem(o0,j);
- if(PyString_Check(o0j))
- {
- p.first[j]=std::string(PyString_AsString(o0j));
- }
- else
- throw INTERP_KERNEL::Exception(msg);
+ p.first[j]=convertPyObjectToStr(o0j,msg);
}
}
else
throw INTERP_KERNEL::Exception(msg);
PyObject *o1=PyTuple_GetItem(o,1);
- if(PyString_Check(o1))
- p.second=std::string(PyString_AsString(o1));
- else
- throw INTERP_KERNEL::Exception(msg);
+ p.second=convertPyObjectToStr(o1,msg);
ret[i]=p;
}
else
*/
int MEDFileFieldsgetitemSingleTS__(const MEDFileFields *self, PyObject *obj) throw(INTERP_KERNEL::Exception)
{
+ static const char msg[]="MEDFileFields::__getitem__ : only integer or string with fieldname supported !";
if(PyInt_Check(obj))
{
return InterpreteNegativeInt((int)PyInt_AS_LONG(obj),self->getNumberOfFields());
}
- else if(PyString_Check(obj))
- {
- return self->getPosFromFieldName(PyString_AsString(obj));
- }
- else
- throw INTERP_KERNEL::Exception("MEDFileFields::__getitem__ : only integer or string with fieldname supported !");
+ return self->getPosFromFieldName(convertPyObjectToStr(obj,msg));
}
void convertToMapIntDataArrayInt(PyObject *pyMap, std::map<int, MCAuto<DataArrayInt> >& cppMap)
#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) )
self._tmp=3
return
if name=="PDataArray":
- if self._tmp in self._data_array.keys():
+ if self._tmp in self._data_array:
self._data_array[self._tmp](attrs)
pass
return
except self.NormalException as e:
isOK=True
fd.seek(0)
- for i in xrange(e.getLineNb()): fd.readline()
+ for i in range(e.getLineNb()): fd.readline()
ref=fd.tell()+5
pass
if not isOK:
def __init__(self,fileName,tim=(0.,0)):
msg="The time specified in constructor as 2nd arg should be a tuple containing 2 values 1 float and 1 int !"
- if type(tim)!=tuple:
+ if not isinstance(tim, tuple):
raise Exception(msg)
if len(tim)!=2:
raise Exception(msg)
- if type(tim[0])!=float or type(tim[1])!=int:
+ if not isinstance(tim[0], float) or not isinstance(tim[1], int):
raise Exception(msg)
self._fileName=fileName
self._time=tim
def convert(file_in, driver_in, driver_out, format=1, file_out=None):
#
- print file_in
+ print(file_in)
#
if file_out is None:
file_out = file_in
msg = "Driver out %s is unknown"%(driver_out)
raise NotImplementedError(msg)
pass
- print file_out
+ print(file_out)
#
if driver_in == "GIBI":
sr = SauvReader.New(file_in)
ADD_DEFINITIONS(${PYTHON_DEFINITIONS} ${HDF5_DEFINITIONS} ${MEDFILE_DEFINITIONS} ${NUMPY_DEFINITIONS} ${SCIPY_DEFINITIONS})
SET_SOURCE_FILES_PROPERTIES(MEDPartitioner.i PROPERTIES CPLUSPLUS ON)
-SET_SOURCE_FILES_PROPERTIES(MEDPartitioner.i PROPERTIES SWIG_DEFINITIONS "-shadow")
+IF ("${PYTHON_VERSION_MAJOR}" STREQUAL "3")
+ SET_SOURCE_FILES_PROPERTIES(MEDPartitioner.i PROPERTIES SWIG_FLAGS "-py3")
+ELSE()
+ SET_SOURCE_FILES_PROPERTIES(MEDPartitioner.i PROPERTIES SWIG_DEFINITIONS "-shadow")
+ENDIF()
SET(SWIG_MODULE_MEDPartitioner_EXTRA_FLAGS "${NUMPY_DEFINITIONS};${SCIPY_DEFINITIONS};-DWITHOUT_AUTOFIELD")
SET (MEDPartitioner_SWIG_DPYS_FILES
self.assertEqual( 2, joints.getJointAtPos(1).getStepAtPos(0).getNumberOfCorrespondences())
self.assertEqual( 1, joints.getJointAtPos(2).getStepAtPos(0).getNumberOfCorrespondences())
found=0
- for ii in xrange(joints.getJointAtPos(0).getStepAtPos(0).getNumberOfCorrespondences()):
+ for ii in range(joints.getJointAtPos(0).getStepAtPos(0).getNumberOfCorrespondences()):
correspond=joints.getJointAtPos(0).getStepAtPos(0).getCorrespondenceAtPos(ii)
#VSR (10/05/2016): changed to work with metis 5.1... to be confirmed!
#if correspond.getCorrespondence().isEqual(DataArrayInt([1,3,2,4])):
INCLUDE(${SWIG_USE_FILE})
SET_SOURCE_FILES_PROPERTIES(ParaMEDMEM.i PROPERTIES CPLUSPLUS ON)
-SET_SOURCE_FILES_PROPERTIES(ParaMEDMEM.i PROPERTIES SWIG_DEFINITIONS "-shadow")
+IF ("${PYTHON_VERSION_MAJOR}" STREQUAL "3")
+ SET_SOURCE_FILES_PROPERTIES(ParaMEDMEM.i PROPERTIES SWIG_FLAGS "-py3")
+ELSE()
+ SET_SOURCE_FILES_PROPERTIES(ParaMEDMEM.i PROPERTIES SWIG_DEFINITIONS "-shadow")
+ENDIF()
SET(SWIG_MODULE_ParaMEDMEM_EXTRA_FLAGS "${NUMPY_DEFINITIONS};${SCIPY_DEFINITIONS}")
SET (ParaMEDMEM_SWIG_DPYS_FILES
SWIG_ADD_MODULE(ParaMEDMEM python ParaMEDMEM.i)
SWIG_LINK_LIBRARIES(ParaMEDMEM ${PYTHON_LIBRARIES} paramedmem medloader)
-SET_SOURCE_FILES_PROPERTIES(ParaMEDMEM.i PROPERTIES CPLUSPLUS ON)
-SET_SOURCE_FILES_PROPERTIES(ParaMEDMEM.i PROPERTIES SWIG_DEFINITIONS "-shadow")
-
INSTALL(TARGETS _ParaMEDMEM DESTINATION ${MEDCOUPLING_INSTALL_PYTHON})
INSTALL(FILES ParaMEDMEM.i DESTINATION ${MEDCOUPLING_INSTALL_HEADERS})
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/ParaMEDMEM.py test_InterpKernelDEC.py test_NonCoincidentDEC.py test_StructuredCoincidentDEC.py DESTINATION ${MEDCOUPLING_INSTALL_SCRIPT_PYTHON})
char** aStrs = (char **) malloc((aSize+1)*sizeof(char *));
for (i = 0; i < aSize; i++) {
PyObject *s = PyList_GetItem($input,i);
- if (!PyString_Check(s)) {
+ if (PyString_Check(s))
+ aStrs[i] = PyString_AsString(s);
+%#if PY_VERSION_HEX >= 0x03000000
+ else if (PyUnicode_Check(s))
+ aStrs[i] = PyUnicode_AsUTF8(s);
+%#endif
+ else {
free(aStrs);
PyErr_SetString(PyExc_ValueError, "List items must be strings");
return NULL;
}
- aStrs[i] = PyString_AsString(s);
}
aStrs[i] = 0;
$2 = &aStrs;
size = MPI_Comm_size(MPI_COMM_WORLD)
rank = MPI_Comm_rank(MPI_COMM_WORLD)
if size != 5:
- raise RuntimeError, "Expect MPI_COMM_WORLD size == 5"
- print rank
+ raise RuntimeError("Expect MPI_COMM_WORLD size == 5")
+ print(rank)
nproc_source = 3
- procs_source = range( nproc_source )
- procs_target = range( size - nproc_source + 1, size)
+ procs_source = list(range(nproc_source))
+ procs_target = list(range(size - nproc_source + 1, size))
interface = CommInterface()
target_group = MPIProcessorGroup(interface, procs_target)
dec.sendData()
dec.recvData()
field_after_int=parafield.getVolumeIntegral(0,True);
- self.failUnless(math.fabs(field_after_int-field_before_int)<1e-8)
+ self.assertTrue(math.fabs(field_after_int-field_before_int)<1e-8)
pass
else:
dec.synchronize()
size = MPI_Comm_size(MPI_COMM_WORLD)
rank = MPI_Comm_rank(MPI_COMM_WORLD)
if size != 5:
- raise RuntimeError, "Expect MPI_COMM_WORLD size == 5"
+ raise RuntimeError("Expect MPI_COMM_WORLD size == 5")
nproc_source = 3
-procs_source = range( nproc_source )
-procs_target = range( size - nproc_source + 1, size)
+procs_source = list(range(nproc_source))
+procs_target = list(range(size - nproc_source + 1, size))
interface = CommInterface()
field_before_int = [parafield.getVolumeIntegral(1)]
MPI_Bcast(field_before_int, 1, MPI_DOUBLE, 0, MPI_COMM_WORLD);
dec.synchronize()
- print "DEC usage"
+ print("DEC usage")
dec.setForcedRenormalization(False)
dec.sendData()
epsilon = 1e-6
if abs(field_before_int[0] - field_after_int[0]) > epsilon:
- print "Field before is not equal field after: %s != %s"%\
- (field_before_int[0],field_after_int[0])
+ print("Field before is not equal field after: %s != %s"%\
+ (field_before_int[0],field_after_int[0]))
pass
MPI_Barrier(MPI_COMM_WORLD)
MPI_Finalize()
-print "# End of testNonCoincidentDEC"
+print("# End of testNonCoincidentDEC")
rank = MPI_Comm_rank(MPI_COMM_WORLD)
#
if size < 4:
- raise RuntimeError, "Expect MPI_COMM_WORLD size >= 4"
+ raise RuntimeError("Expect MPI_COMM_WORLD size >= 4")
#
interface = CommInterface()
#
for i in range(nb_local):
first=comptopo.firstLocalComponent()
for icomp in range(comptopo.nbLocalComponents()):
- self.failUnless(math.fabs(recv_value[i*comptopo.nbLocalComponents()+icomp]-
+ self.assertTrue(math.fabs(recv_value[i*comptopo.nbLocalComponents()+icomp]-
(float)(i*6+icomp+first))<1e-12)
pass
pass
source_group = 0
MPI_Barrier(MPI_COMM_WORLD)
MPI_Finalize()
- print "End of test StructuredCoincidentDEC"
+ print("End of test StructuredCoincidentDEC")
pass
ADD_DEFINITIONS(${PYTHON_DEFINITIONS} ${NUMPY_DEFINITIONS} ${SCIPY_DEFINITIONS})
SET_SOURCE_FILES_PROPERTIES(MEDRenumber.i PROPERTIES CPLUSPLUS ON)
-SET_SOURCE_FILES_PROPERTIES(MEDRenumber.i PROPERTIES SWIG_DEFINITIONS "-shadow")
+IF ("${PYTHON_VERSION_MAJOR}" STREQUAL "3")
+ SET_SOURCE_FILES_PROPERTIES(MEDRenumber.i PROPERTIES SWIG_FLAGS "-py3")
+ELSE()
+ SET_SOURCE_FILES_PROPERTIES(MEDRenumber.i PROPERTIES SWIG_DEFINITIONS "-shadow")
+ENDIF()
SET(SWIG_MODULE_MEDRenumber_EXTRA_FLAGS "${NUMPY_DEFINITIONS};${SCIPY_DEFINITIONS};-DWITHOUT_AUTOFIELD")
IF(Boost_FOUND)
import os
__filename=os.environ.get('PYTHONSTARTUP')
if __filename and os.path.isfile(__filename):
- execfile(__filename)
+ exec(open(__filename).read())
pass
%}
dirs=["MEDCoupling","MEDCoupling/Test","MEDLoader","MEDLoader/Swig","MEDLoader/Test","MEDPartitioner","MEDPartitioner/Test","MEDPartitioner_Swig","RENUMBER","RENUMBER_Swig","INTERP_KERNELTest","ParaMEDMEM","ParaMEDLoader","ParaMEDMEMTest","ParaMEDMEM_Swig","doc/user/doxygen/fakesources","doc/user/doxygen/doxy2swig","doc/user/doxygen/doxfiles","/home/H87074/salome/DEV/modules/src/MED/src/MEDCouplingCorba","/home/H87074/salome/DEV/modules/src/MED/src/MEDCouplingCorba/Client","/home/H87074/salome/DEV/modules/src/MED/src/MEDCouplingCorba/Test","/home/H87074/salome/DEV/modules/src/MED/src/MEDCalc/cmp","/home/H87074/salome/DEV/modules/src/MED/src/MEDCalculator","/home/H87074/salome/DEV/modules/src/MED/src/MEDCalculator/Swig","/home/H87074/salome/DEV/modules/src/MED/src/MEDCalculator/Test","/home/H87074/salome/DEV/modules/src/PARAVIS/src/Plugins/MEDReader/IO"]
dirname=dirs[-1]
i=0
-print rep1(dirname,rep)
+print(rep1(dirname,rep))
"""for r,dirs,fis in os.walk(dirname):
for fi in fis:
if os.path.splitext(fi)[1] not in [".dox",".doxy"]:
# Skip this script!
if fileName == __myName:
if not quiet:
- print "!!! Skipping script %s !!!" % __myName
+ print("!!! Skipping script %s !!!" % __myName)
continue
ok = False
if fileName[-28:] != "MEDCouplingNatureOfFieldEnum":
else:
ok = True
if not ok: continue # skip file
- if not quiet: print "Handling %s ..." % fileName
+ if not quiet: print("Handling %s ..." % fileName)
for line in fileinput.input(fileName, inplace=1, backup='.bak'):
for before, after in REPLACEMENTS:
line = re.sub("(\W|^)(%s)(\W|$)" % before, r"\1%s\3" % after, line.rstrip('\r\n'))