]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
LOT4: merge fixes from agy/LOT4_feedback
authoreap <eap@opencascade.com>
Thu, 5 Dec 2019 13:12:49 +0000 (16:12 +0300)
committereap <eap@opencascade.com>
Thu, 5 Dec 2019 13:12:49 +0000 (16:12 +0300)
src/MEDCoupling_Swig/MEDCouplingBasicsTest4.py
src/MEDCoupling_Swig/MEDCouplingBasicsTest5.py
src/MEDCoupling_Swig/MEDCouplingCommon.i
src/MEDCoupling_Swig/MEDCouplingNumPyTest.py

index 3bca65eeba86a804964cc5f63323d4232a3679e4..cea4720db7abdd3762e08a1f1a56bcd4e442e639 100644 (file)
@@ -2809,7 +2809,7 @@ class MEDCouplingBasicsTest4(unittest.TestCase):
 
     @unittest.skipUnless(checkFreeMemory((223456789*16)/(1024)), "Not enough memory")
     def testSwig2BigMem(self):
-        if MEDCouplingSizeOfVoidStar()==64:
+        if MEDCouplingSizeOfVoidStar()==64 and MEDCouplingSizeOfIDs()==32:
             d=DataArrayAsciiChar(223456789,16)
             self.assertTrue(d.getNumberOfTuples(),223456789)
             self.assertTrue(d.getNumberOfComponents(),16)
index f8cb7ca8ffbfb3057ab4ea399687b99a6c2f1a6c..b1dc1d3bd514540fd329b5c3f778990fb39ef1ca 100644 (file)
@@ -606,7 +606,7 @@ class MEDCouplingBasicsTest5(unittest.TestCase):
         m=MEDCoupling1SGTUMesh("m",NORM_QUAD4)
         mem_m=m.getHeapMemorySize()
         m.allocateCells(5)
-        self.assertIn(m.getHeapMemorySize() - mem_m, list(range(5 * 4 * 4, 5 * 4 * 4 + 32)))
+        self.assertIn(m.getHeapMemorySize() - mem_m, list(range(5 * 4 * MEDCouplingSizeOfIDs()//8, 5 * 4 * MEDCouplingSizeOfIDs()//8 + 32)))
         self.assertEqual(m.getNodalConnectivity().getNbOfElemAllocated(),20)
         m.setCoords(um.getCoords())
         m.insertNextCell([1,0,6,7])
@@ -1019,7 +1019,7 @@ class MEDCouplingBasicsTest5(unittest.TestCase):
         self.assertEqual(d.getInfoOnComponents(),["aa","bbb"])
         ref=d.getHeapMemorySize()
         d.desallocate()
-        self.assertEqual(ref-d.getHeapMemorySize(),6*4)
+        self.assertEqual(ref-d.getHeapMemorySize(),6*MEDCouplingSizeOfIDs()//8)
         self.assertTrue(not d.isAllocated())
         self.assertEqual(d.getInfoOnComponents(),["aa","bbb"])
         self.assertRaises(InterpKernelException,d.checkAllocated)
@@ -3885,9 +3885,9 @@ class MEDCouplingBasicsTest5(unittest.TestCase):
         m.setCoords(arrX,arrX)
         f=MEDCouplingFieldInt(ON_CELLS)
         f.setMesh(m)
-        arr=DataArrayInt(8) ; arr.iota() ;f.setArray(arr)
+        arr=DataArrayInt32(8) ; arr.iota() ;f.setArray(arr)
         self.assertRaises(InterpKernelException,f.checkConsistencyLight)
-        arr=DataArrayInt(9) ; arr.iota() ;f.setArray(arr)
+        arr=DataArrayInt32(9) ; arr.iota() ;f.setArray(arr)
         f.checkConsistencyLight()
         f.setTimeUnit("ms")
         self.assertEqual(f.getTimeUnit(),"ms")
@@ -3935,13 +3935,13 @@ class MEDCouplingBasicsTest5(unittest.TestCase):
         m1=MEDCouplingCMesh() ; m1.setCoords(DataArrayDouble([0,1,2,3]),DataArrayDouble([0,1,2,3,4]))
         m1=m1.buildUnstructured() ; m1.setName("mesh")
         f1=MEDCouplingFieldInt(ON_CELLS) ; f1.setMesh(m1)
-        arr1=DataArrayInt([(0,1),(2,3),(4,5),(6,7),(8,9),(10,11),(12,13),(14,15),(16,17),(18,19),(20,21),(22,23)]) ; arr1.setInfoOnComponents(["aa","bbb"])
+        arr1=DataArrayInt32([(0,1),(2,3),(4,5),(6,7),(8,9),(10,11),(12,13),(14,15),(16,17),(18,19),(20,21),(22,23)]) ; arr1.setInfoOnComponents(["aa","bbb"])
         f1.setArray(arr1) ; f1.setName("f1") ; f1.setTime(2.,3,4)
         #
         m2=MEDCouplingCMesh() ; m2.setCoords(DataArrayDouble([0,1,2,3]),DataArrayDouble([0,1,2,3,4]))
         m2=m2.buildUnstructured() ; m2.setName("mesh")
         f2=MEDCouplingFieldInt(ON_CELLS) ; f2.setMesh(m2)
-        arr2=DataArrayInt([(0,1),(2,3),(4,5),(6,7),(8,9),(10,11),(12,13),(14,15),(16,17),(18,19),(20,21),(22,23)]) ; arr2.setInfoOnComponents(["aa","bbb"])
+        arr2=DataArrayInt32([(0,1),(2,3),(4,5),(6,7),(8,9),(10,11),(12,13),(14,15),(16,17),(18,19),(20,21),(22,23)]) ; arr2.setInfoOnComponents(["aa","bbb"])
         f2.setArray(arr2) ; f2.setName("f1") ; f2.setTime(2.,3,4)
         #
         self.assertTrue(f1.isEqual(f2,1e-12,0))
@@ -3967,7 +3967,7 @@ class MEDCouplingBasicsTest5(unittest.TestCase):
         #
         for fd,expected in ((ON_NODES,False),(ON_CELLS,True)):
             f4=MEDCouplingFieldInt(fd) ; f4.setMesh(m2) ; f4.setTime(2.,3,4)
-            arr4=DataArrayInt([(0,1),(2,3),(4,5),(6,7),(8,9),(10,11),(12,13),(14,15),(16,17),(18,19),(20,21),(22,23)]) ; arr4.setInfoOnComponents(["aa","bbb"])
+            arr4=DataArrayInt32([(0,1),(2,3),(4,5),(6,7),(8,9),(10,11),(12,13),(14,15),(16,17),(18,19),(20,21),(22,23)]) ; arr4.setInfoOnComponents(["aa","bbb"])
             f4.setArray(arr4) ; f4.setName("f1")
             self.assertEqual(f1.isEqual(f4,1e-12,0),expected)
             pass
@@ -4687,14 +4687,14 @@ class MEDCouplingBasicsTest5(unittest.TestCase):
         """Test focused of new wrapped methods for MEDCouplingFieldInt thanks to code factorization."""
         d=DataArrayDouble(7) ; d.iota()
         m=MEDCouplingUMesh.Build1DMeshFromCoords(d)
-        f=MEDCouplingFieldInt(ON_CELLS) ; f.setMesh(m) ; arr=DataArrayInt(6) ; arr.iota() ; f.setArray(arr) ; f.checkConsistencyLight()
+        f=MEDCouplingFieldInt(ON_CELLS) ; f.setMesh(m) ; arr=DataArrayInt32(6) ; arr.iota() ; f.setArray(arr) ; f.checkConsistencyLight()
         f_0=f[::2] # test is here
-        self.assertTrue(f_0.getArray().isEqual(DataArrayInt([0,2,4])))
+        self.assertTrue(f_0.getArray().isEqual(DataArrayInt32([0,2,4])))
         self.assertTrue(f_0.getMesh().isEqual(m[[0,2,4]],1e-12))
         #
-        f2=MEDCouplingFieldInt(ON_NODES) ; f2.setMesh(m) ; arr=DataArrayInt(7) ; arr.iota() ; f2.setArray(arr) ; f2.checkConsistencyLight()
+        f2=MEDCouplingFieldInt(ON_NODES) ; f2.setMesh(m) ; arr=DataArrayInt32(7) ; arr.iota() ; f2.setArray(arr) ; f2.checkConsistencyLight()
         f_1=f2[::2] # test is here
-        self.assertTrue(f_1.getArray().isEqual(DataArrayInt([0,1,2,3,4,5])))
+        self.assertTrue(f_1.getArray().isEqual(DataArrayInt32([0,1,2,3,4,5])))
         m_1=m[[0,2,4]] ; m_1.zipCoords()
         self.assertTrue(f_1.getMesh().isEqual(m_1,1e-12))
         pass
index ca1dd0943343f0de343b0e0dfda6ab3f1a5687a4..f0106b66861373b2de419754bdc800c0996043fc 100644 (file)
@@ -5962,13 +5962,13 @@ def MEDCouplingFieldTemplateReduce(self):
 #
 # Forwarding DataArrayInt functions to MEDCouplingUMesh:
 #
-MEDCouplingUMesh.ExtractFromIndexedArrays           = DataArrayInt32.ExtractFromIndexedArrays
-MEDCouplingUMesh.ExtractFromIndexedArraysSlice      = DataArrayInt32.ExtractFromIndexedArraysSlice
-MEDCouplingUMesh.SetPartOfIndexedArrays             = DataArrayInt32.SetPartOfIndexedArrays
-##MEDCouplingUMesh.SetPartOfIndexedArraysSlice        = DataArrayInt32.SetPartOfIndexedArraysSlice
-MEDCouplingUMesh.SetPartOfIndexedArraysSameIdx      = DataArrayInt32.SetPartOfIndexedArraysSameIdx
-MEDCouplingUMesh.RemoveIdsFromIndexedArrays         = DataArrayInt32.RemoveIdsFromIndexedArrays
-##MEDCouplingUMesh.SetPartOfIndexedArraysSameIdxSlice = DataArrayInt32.SetPartOfIndexedArraysSameIdxSlice
+MEDCouplingUMesh.ExtractFromIndexedArrays           = DataArrayInt.ExtractFromIndexedArrays
+MEDCouplingUMesh.ExtractFromIndexedArraysSlice      = DataArrayInt.ExtractFromIndexedArraysSlice
+MEDCouplingUMesh.SetPartOfIndexedArrays             = DataArrayInt.SetPartOfIndexedArrays
+##MEDCouplingUMesh.SetPartOfIndexedArraysSlice        = DataArrayInt.SetPartOfIndexedArraysSlice
+MEDCouplingUMesh.SetPartOfIndexedArraysSameIdx      = DataArrayInt.SetPartOfIndexedArraysSameIdx
+MEDCouplingUMesh.RemoveIdsFromIndexedArrays         = DataArrayInt.RemoveIdsFromIndexedArrays
+##MEDCouplingUMesh.SetPartOfIndexedArraysSameIdxSlice = DataArrayInt.SetPartOfIndexedArraysSameIdxSlice
 
 %}
 
index a76432a4a1e8167d838b4a6ce45c2fa4241c3fa7..b35f9ecdb94b9d00cc8ed7864e12ff1d673b97ef 100644 (file)
@@ -46,10 +46,10 @@ class MEDCouplingNumPyTest(unittest.TestCase):
         a=a.cumsum(dtype=int32)
         a=array(a,dtype=int64) ; a=array(a,dtype=int32)
         self.assertEqual(getrefcount(a),2)
-        d=DataArrayInt(a)
+        d=DataArrayInt32(a)
         d[:]=2
         #
-        e=DataArrayInt(sz) ; e.fillWithValue(2)
+        e=DataArrayInt32(sz) ; e.fillWithValue(2)
         self.assertTrue(d.isEqual(e))
         #
         a[:]=4 ; e.fillWithValue(4)
@@ -66,9 +66,9 @@ class MEDCouplingNumPyTest(unittest.TestCase):
         self.assertEqual(getrefcount(a),3)
         self.assertEqual(getrefcount(b),2)
         b[:]=5
-        d=DataArrayInt(b)
+        d=DataArrayInt32(b)
         #
-        e=DataArrayInt(sz*2) ; e.fillWithValue(5)
+        e=DataArrayInt32(sz*2) ; e.fillWithValue(5)
         self.assertTrue(d.isEqual(e))
         pass
     
@@ -81,16 +81,16 @@ class MEDCouplingNumPyTest(unittest.TestCase):
         c=a.reshape(2,sz)
         b[:]=6
         b[7:17]=7
-        d=DataArrayInt(b)
-        self.assertTrue(d.isEqual(DataArrayInt([6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,6,6,6])))
+        d=DataArrayInt32(b)
+        self.assertTrue(d.isEqual(DataArrayInt32([6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,6,6,6])))
         #
         a=zeros((10,2),dtype=int32)
         b=a.T
         c=b.view()
         a.shape=20
         a[3:]=10.
-        d=DataArrayInt(a)
-        self.assertTrue(d.isEqual(DataArrayInt([0,0,0,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10])))
+        d=DataArrayInt32(a)
+        self.assertTrue(d.isEqual(DataArrayInt32([0,0,0,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10])))
         pass
     
     @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
@@ -104,7 +104,7 @@ class MEDCouplingNumPyTest(unittest.TestCase):
     def test5(self):
         a=arange(20,dtype=int32)
         self.assertEqual(weakref.getweakrefcount(a),0)
-        d=DataArrayInt(a)
+        d=DataArrayInt32(a)
         self.assertEqual(weakref.getweakrefcount(a),1)
         self.assertTrue(not a.flags["OWNDATA"])
         self.assertTrue(d.isIota(20))
@@ -116,14 +116,14 @@ class MEDCouplingNumPyTest(unittest.TestCase):
         gc.collect()
         self.assertTrue(a.flags["OWNDATA"])
         a[:]=4 # a can be used has usual
-        self.assertTrue(DataArrayInt(a).isUniform(4))
+        self.assertTrue(DataArrayInt32(a).isUniform(4))
         pass
     
     @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
     def test6(self):
         a=arange(20,dtype=int32)
-        d=DataArrayInt(a) # d owns data of a
-        e=DataArrayInt(a) # a not owned -> e only an access to chunk of a 
+        d=DataArrayInt32(a) # d owns data of a
+        e=DataArrayInt32(a) # a not owned -> e only an access to chunk of a 
         self.assertTrue(d.isIota(d.getNumberOfTuples()))
         self.assertTrue(e.isIota(e.getNumberOfTuples()))
         a[:]=6
@@ -142,9 +142,9 @@ class MEDCouplingNumPyTest(unittest.TestCase):
         a=array(0,dtype=int32) ; a.resize(10,2)
         b=a.reshape(20)
         c=a.reshape(2,10)
-        d=DataArrayInt(b) # d owns data of a
-        e=DataArrayInt(b) # a not owned -> e only an access to chunk of a
-        f=DataArrayInt(b) # a not owned -> e only an access to chunk of a
+        d=DataArrayInt32(b) # d owns data of a
+        e=DataArrayInt32(b) # a not owned -> e only an access to chunk of a
+        f=DataArrayInt32(b) # a not owned -> e only an access to chunk of a
         del d # d removed -> a ownes again data
         ##@@ Ensure a pass of the garbage collector so that the de-allocator of d is called 
         import gc
@@ -177,11 +177,11 @@ class MEDCouplingNumPyTest(unittest.TestCase):
     def test8(self):
         a=arange(20,dtype=int32)
         self.assertTrue(a.flags["OWNDATA"])
-        d=DataArrayInt(a) # d owns data of a
+        d=DataArrayInt32(a) # d owns data of a
         self.assertTrue(not a.flags["OWNDATA"])
         d.pushBackSilent(20)# d pushBack so release of chunk of data -> a becomes owner of its data again
         self.assertTrue(a.flags["OWNDATA"])
-        self.assertTrue(d.isEqual(DataArrayInt([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20])))
+        self.assertTrue(d.isEqual(DataArrayInt32([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20])))
         self.assertEqual(a.tolist(),[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19])
         pass
 
@@ -394,13 +394,13 @@ class MEDCouplingNumPyTest(unittest.TestCase):
         a.resize(sz//2,2)
         a[:]=4
         self.assertEqual(getrefcount(a),2)
-        d=DataArrayInt(a)
+        d=DataArrayInt32(a)
         self.assertEqual(10,d.getNumberOfTuples())
         self.assertEqual(2,d.getNumberOfComponents())
         self.assertEqual(sz,d.getNbOfElems())
-        self.assertTrue(d.isEqual(DataArrayInt([(4,4),(4,4),(4,4),(4,4),(4,4),(4,4),(4,4),(4,4),(4,4),(4,4)])))
+        self.assertTrue(d.isEqual(DataArrayInt32([(4,4),(4,4),(4,4),(4,4),(4,4),(4,4),(4,4),(4,4),(4,4),(4,4)])))
         a[:]=7
-        self.assertTrue(d.isEqual(DataArrayInt([(7,7),(7,7),(7,7),(7,7),(7,7),(7,7),(7,7),(7,7),(7,7),(7,7)])))
+        self.assertTrue(d.isEqual(DataArrayInt32([(7,7),(7,7),(7,7),(7,7),(7,7),(7,7),(7,7),(7,7),(7,7),(7,7)])))
         #
         b=a.reshape((2,5,2))
         self.assertRaises(InterpKernelException,DataArrayInt.New,b) # b has not dimension in [0,1] !
@@ -430,7 +430,7 @@ class MEDCouplingNumPyTest(unittest.TestCase):
         #tests that only DataArray*(npArray) constructor is available
         a=array(0,dtype=int32)
         a.resize(20)
-        DataArrayInt(a)
+        DataArrayInt32(a)
         self.assertRaises(InterpKernelException,DataArrayInt.New,a,20)
         self.assertRaises(InterpKernelException,DataArrayInt.New,a,20,1)
         a=array(0,dtype=float64)
@@ -564,9 +564,9 @@ class MEDCouplingNumPyTest(unittest.TestCase):
     @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
     def test25(self):
         a=arange(10,dtype=int32)
-        b=DataArrayInt(a)
-        c=DataArrayInt(a)
-        d=DataArrayInt(a)
+        b=DataArrayInt32(a)
+        c=DataArrayInt32(a)
+        d=DataArrayInt32(a)
         self.assertTrue(b.isIota(10))
         self.assertTrue(c.isIota(10))
         self.assertTrue(d.isIota(10))
@@ -584,8 +584,8 @@ class MEDCouplingNumPyTest(unittest.TestCase):
         self.assertTrue(c.isIota(11))
         #
         a=arange(10,dtype=int32)
-        b=DataArrayInt(a)
-        c=DataArrayInt(a)
+        b=DataArrayInt32(a)
+        c=DataArrayInt32(a)
         self.assertTrue(b.isIota(10))
         self.assertTrue(c.isIota(10))
         b.pushBackSilent(10) # c and a,b are dissociated
@@ -644,9 +644,9 @@ class MEDCouplingNumPyTest(unittest.TestCase):
         self.assertEqual(a.ndim,2)
         self.assertEqual(a.size,15)
         self.assertEqual(a.shape,(5,3))
-        self.assertEqual(a.strides,(12,4))
-        self.assertEqual(a.nbytes,60)
-        self.assertEqual(a.itemsize,4)
+        self.assertEqual(a.strides,(3*MEDCouplingSizeOfIDs()//8,MEDCouplingSizeOfIDs()//8))
+        self.assertEqual(a.nbytes,15*MEDCouplingSizeOfIDs()//8)
+        self.assertEqual(a.itemsize,MEDCouplingSizeOfIDs()//8)
         self.assertEqual(a.tolist(),[[0,1,2],[3,4,5],[6,7,8],[9,10,11],[12,13,14]])
         #
         d2=d.convertToDblArr()