Salome HOME
projects
/
tools
/
medcoupling.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix computation height of isocel triangle with base equal zero : NaN
[tools/medcoupling.git]
/
src
/
MEDCoupling_Swig
/
MEDCouplingNumPyTest.py
diff --git
a/src/MEDCoupling_Swig/MEDCouplingNumPyTest.py
b/src/MEDCoupling_Swig/MEDCouplingNumPyTest.py
index a76432a4a1e8167d838b4a6ce45c2fa4241c3fa7..1fc1fbce4126620aae4f1c806ca2d1bb38e28c5c 100644
(file)
--- a/
src/MEDCoupling_Swig/MEDCouplingNumPyTest.py
+++ b/
src/MEDCoupling_Swig/MEDCouplingNumPyTest.py
@@
-1,5
+1,5
@@
# -*- coding: iso-8859-1 -*-
# -*- coding: iso-8859-1 -*-
-# Copyright (C) 2007-20
19 CEA/DEN, EDF R&D
+# Copyright (C) 2007-20
23 CEA, EDF
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
@@
-20,10
+20,7
@@
import sys
import sys
-if sys.platform == "win32":
- from MEDCouplingCompat import *
-else:
- from medcoupling import *
+from medcoupling import *
if MEDCouplingHasNumPyBindings():
from numpy import *
if MEDCouplingHasNumPyBindings():
from numpy import *
@@
-46,10
+43,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)
a=a.cumsum(dtype=int32)
a=array(a,dtype=int64) ; a=array(a,dtype=int32)
self.assertEqual(getrefcount(a),2)
- d=DataArrayInt(a)
+ d=DataArrayInt
32
(a)
d[:]=2
#
d[:]=2
#
- e=DataArrayInt(sz) ; e.fillWithValue(2)
+ e=DataArrayInt
32
(sz) ; e.fillWithValue(2)
self.assertTrue(d.isEqual(e))
#
a[:]=4 ; e.fillWithValue(4)
self.assertTrue(d.isEqual(e))
#
a[:]=4 ; e.fillWithValue(4)
@@
-66,9
+63,9
@@
class MEDCouplingNumPyTest(unittest.TestCase):
self.assertEqual(getrefcount(a),3)
self.assertEqual(getrefcount(b),2)
b[:]=5
self.assertEqual(getrefcount(a),3)
self.assertEqual(getrefcount(b),2)
b[:]=5
- d=DataArrayInt(b)
+ d=DataArrayInt
32
(b)
#
#
- e=DataArrayInt(sz*2) ; e.fillWithValue(5)
+ e=DataArrayInt
32
(sz*2) ; e.fillWithValue(5)
self.assertTrue(d.isEqual(e))
pass
self.assertTrue(d.isEqual(e))
pass
@@
-81,16
+78,16
@@
class MEDCouplingNumPyTest(unittest.TestCase):
c=a.reshape(2,sz)
b[:]=6
b[7:17]=7
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=DataArrayInt
32
(b)
+ self.assertTrue(d.isEqual(DataArrayInt
32
([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.
#
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=DataArrayInt
32
(a)
+ self.assertTrue(d.isEqual(DataArrayInt
32
([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")
pass
@unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
@@
-104,7
+101,7
@@
class MEDCouplingNumPyTest(unittest.TestCase):
def test5(self):
a=arange(20,dtype=int32)
self.assertEqual(weakref.getweakrefcount(a),0)
def test5(self):
a=arange(20,dtype=int32)
self.assertEqual(weakref.getweakrefcount(a),0)
- d=DataArrayInt(a)
+ d=DataArrayInt
32
(a)
self.assertEqual(weakref.getweakrefcount(a),1)
self.assertTrue(not a.flags["OWNDATA"])
self.assertTrue(d.isIota(20))
self.assertEqual(weakref.getweakrefcount(a),1)
self.assertTrue(not a.flags["OWNDATA"])
self.assertTrue(d.isIota(20))
@@
-116,14
+113,14
@@
class MEDCouplingNumPyTest(unittest.TestCase):
gc.collect()
self.assertTrue(a.flags["OWNDATA"])
a[:]=4 # a can be used has usual
gc.collect()
self.assertTrue(a.flags["OWNDATA"])
a[:]=4 # a can be used has usual
- self.assertTrue(DataArrayInt(a).isUniform(4))
+ self.assertTrue(DataArrayInt
32
(a).isUniform(4))
pass
@unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
def test6(self):
a=arange(20,dtype=int32)
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=DataArrayInt
32
(a) # d owns data of a
+ e=DataArrayInt
32
(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
self.assertTrue(d.isIota(d.getNumberOfTuples()))
self.assertTrue(e.isIota(e.getNumberOfTuples()))
a[:]=6
@@
-142,9
+139,9
@@
class MEDCouplingNumPyTest(unittest.TestCase):
a=array(0,dtype=int32) ; a.resize(10,2)
b=a.reshape(20)
c=a.reshape(2,10)
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=DataArrayInt
32
(b) # d owns data of a
+ e=DataArrayInt
32
(b) # a not owned -> e only an access to chunk of a
+ f=DataArrayInt
32
(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
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
+174,11
@@
class MEDCouplingNumPyTest(unittest.TestCase):
def test8(self):
a=arange(20,dtype=int32)
self.assertTrue(a.flags["OWNDATA"])
def test8(self):
a=arange(20,dtype=int32)
self.assertTrue(a.flags["OWNDATA"])
- d=DataArrayInt(a) # d owns data of a
+ d=DataArrayInt
32
(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(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(DataArrayInt
32
([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
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
+391,13
@@
class MEDCouplingNumPyTest(unittest.TestCase):
a.resize(sz//2,2)
a[:]=4
self.assertEqual(getrefcount(a),2)
a.resize(sz//2,2)
a[:]=4
self.assertEqual(getrefcount(a),2)
- d=DataArrayInt(a)
+ d=DataArrayInt
32
(a)
self.assertEqual(10,d.getNumberOfTuples())
self.assertEqual(2,d.getNumberOfComponents())
self.assertEqual(sz,d.getNbOfElems())
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(DataArrayInt
32
([(4,4),(4,4),(4,4),(4,4),(4,4),(4,4),(4,4),(4,4),(4,4),(4,4)])))
a[:]=7
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(DataArrayInt
32
([(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] !
#
b=a.reshape((2,5,2))
self.assertRaises(InterpKernelException,DataArrayInt.New,b) # b has not dimension in [0,1] !
@@
-430,7
+427,7
@@
class MEDCouplingNumPyTest(unittest.TestCase):
#tests that only DataArray*(npArray) constructor is available
a=array(0,dtype=int32)
a.resize(20)
#tests that only DataArray*(npArray) constructor is available
a=array(0,dtype=int32)
a.resize(20)
- DataArrayInt(a)
+ DataArrayInt
32
(a)
self.assertRaises(InterpKernelException,DataArrayInt.New,a,20)
self.assertRaises(InterpKernelException,DataArrayInt.New,a,20,1)
a=array(0,dtype=float64)
self.assertRaises(InterpKernelException,DataArrayInt.New,a,20)
self.assertRaises(InterpKernelException,DataArrayInt.New,a,20,1)
a=array(0,dtype=float64)
@@
-564,9
+561,9
@@
class MEDCouplingNumPyTest(unittest.TestCase):
@unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
def test25(self):
a=arange(10,dtype=int32)
@unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
def test25(self):
a=arange(10,dtype=int32)
- b=DataArrayInt(a)
- c=DataArrayInt(a)
- d=DataArrayInt(a)
+ b=DataArrayInt
32
(a)
+ c=DataArrayInt
32
(a)
+ d=DataArrayInt
32
(a)
self.assertTrue(b.isIota(10))
self.assertTrue(c.isIota(10))
self.assertTrue(d.isIota(10))
self.assertTrue(b.isIota(10))
self.assertTrue(c.isIota(10))
self.assertTrue(d.isIota(10))
@@
-584,8
+581,8
@@
class MEDCouplingNumPyTest(unittest.TestCase):
self.assertTrue(c.isIota(11))
#
a=arange(10,dtype=int32)
self.assertTrue(c.isIota(11))
#
a=arange(10,dtype=int32)
- b=DataArrayInt(a)
- c=DataArrayInt(a)
+ b=DataArrayInt
32
(a)
+ c=DataArrayInt
32
(a)
self.assertTrue(b.isIota(10))
self.assertTrue(c.isIota(10))
b.pushBackSilent(10) # c and a,b are dissociated
self.assertTrue(b.isIota(10))
self.assertTrue(c.isIota(10))
b.pushBackSilent(10) # c and a,b are dissociated
@@
-644,9
+641,9
@@
class MEDCouplingNumPyTest(unittest.TestCase):
self.assertEqual(a.ndim,2)
self.assertEqual(a.size,15)
self.assertEqual(a.shape,(5,3))
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()
self.assertEqual(a.tolist(),[[0,1,2],[3,4,5],[6,7,8],[9,10,11],[12,13,14]])
#
d2=d.convertToDblArr()