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
Enable unpacking of tuples in DataArrays.
[tools/medcoupling.git]
/
src
/
MEDCoupling_Swig
/
MEDCouplingNumPyTest.py
diff --git
a/src/MEDCoupling_Swig/MEDCouplingNumPyTest.py
b/src/MEDCoupling_Swig/MEDCouplingNumPyTest.py
index 3af053fe1a89d74c050855deee7300ec0eafb0f5..6a622128587bb747640f3fa0981484d0a941c01d 100644
(file)
--- a/
src/MEDCoupling_Swig/MEDCouplingNumPyTest.py
+++ b/
src/MEDCoupling_Swig/MEDCouplingNumPyTest.py
@@
-1,10
+1,10
@@
# -*- coding: iso-8859-1 -*-
# -*- coding: iso-8859-1 -*-
-# Copyright (C) 2007-201
3
CEA/DEN, EDF R&D
+# Copyright (C) 2007-201
4
CEA/DEN, EDF R&D
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
-# version 2.1 of the License.
+# version 2.1 of the License
, or (at your option) any later version
.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
@@
-17,7
+17,6
@@
#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
-#
from MEDCoupling import *
from MEDCoupling import *
@@
-25,13
+24,14
@@
if MEDCouplingHasNumPyBindings():
from numpy import *
pass
from numpy import *
pass
+from platform import architecture
from sys import getrefcount
import os,gc,weakref,unittest
class MEDCouplingNumPyTest(unittest.TestCase):
from sys import getrefcount
import os,gc,weakref,unittest
class MEDCouplingNumPyTest(unittest.TestCase):
-
#
@unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
+ @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
def test1(self):
sz=20
a=array(0,dtype=int32)
def test1(self):
sz=20
a=array(0,dtype=int32)
@@
-39,6
+39,7
@@
class MEDCouplingNumPyTest(unittest.TestCase):
a[:]=4
self.assertEqual(getrefcount(a),2)
a=a.cumsum(dtype=int32)
a[:]=4
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[:]=2
self.assertEqual(getrefcount(a),2)
d=DataArrayInt(a)
d[:]=2
@@
-50,7
+51,7
@@
class MEDCouplingNumPyTest(unittest.TestCase):
self.assertTrue(d.isEqual(e))
pass
self.assertTrue(d.isEqual(e))
pass
-
#
@unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
+ @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
def test2(self):
sz=20
a=array(0,dtype=int32)
def test2(self):
sz=20
a=array(0,dtype=int32)
@@
-66,7
+67,7
@@
class MEDCouplingNumPyTest(unittest.TestCase):
self.assertTrue(d.isEqual(e))
pass
self.assertTrue(d.isEqual(e))
pass
-
#
@unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
+ @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
def test3(self):
sz=10
a=array(0,dtype=int32)
def test3(self):
sz=10
a=array(0,dtype=int32)
@@
-87,14
+88,14
@@
class MEDCouplingNumPyTest(unittest.TestCase):
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])))
pass
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])))
pass
-
#
@unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
+ @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
def test4(self):
a=zeros(20,dtype=int32)
b = a[::-1]
self.assertRaises(InterpKernelException,DataArrayInt.New,b) # b is not contiguous in memory
pass
def test4(self):
a=zeros(20,dtype=int32)
b = a[::-1]
self.assertRaises(InterpKernelException,DataArrayInt.New,b) # b is not contiguous in memory
pass
-
#
@unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
+ @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
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)
@@
-114,7
+115,7
@@
class MEDCouplingNumPyTest(unittest.TestCase):
self.assertTrue(DataArrayInt(a).isUniform(4))
pass
self.assertTrue(DataArrayInt(a).isUniform(4))
pass
-
#
@unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
+ @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
def test6(self):
a=arange(20,dtype=int32)
d=DataArrayInt(a) # d owns data of a
def test6(self):
a=arange(20,dtype=int32)
d=DataArrayInt(a) # d owns data of a
@@
-132,7
+133,7
@@
class MEDCouplingNumPyTest(unittest.TestCase):
self.assertTrue(not e.isAllocated())
pass
self.assertTrue(not e.isAllocated())
pass
-
#
@unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
+ @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
def test7(self):
a=array(0,dtype=int32) ; a.resize(10,2)
b=a.reshape(20)
def test7(self):
a=array(0,dtype=int32) ; a.resize(10,2)
b=a.reshape(20)
@@
-168,7
+169,7
@@
class MEDCouplingNumPyTest(unittest.TestCase):
self.assertTrue(not f.isAllocated())
pass
self.assertTrue(not f.isAllocated())
pass
-
#
@unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
+ @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
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"])
@@
-180,7
+181,7
@@
class MEDCouplingNumPyTest(unittest.TestCase):
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
-
#
@unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
+ @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
def test9(self):
sz=20
a=array(0,dtype=float64)
def test9(self):
sz=20
a=array(0,dtype=float64)
@@
-199,7
+200,7
@@
class MEDCouplingNumPyTest(unittest.TestCase):
self.assertTrue(d.isEqual(e,1e-14))
pass
self.assertTrue(d.isEqual(e,1e-14))
pass
-
#
@unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
+ @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
def test10(self):
sz=20
a=array(0,dtype=float64)
def test10(self):
sz=20
a=array(0,dtype=float64)
@@
-215,7
+216,7
@@
class MEDCouplingNumPyTest(unittest.TestCase):
self.assertTrue(d.isEqual(e,1e-14))
pass
self.assertTrue(d.isEqual(e,1e-14))
pass
-
#
@unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
+ @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
def test11(self):
sz=10
a=array(0,dtype=float64)
def test11(self):
sz=10
a=array(0,dtype=float64)
@@
-236,14
+237,14
@@
class MEDCouplingNumPyTest(unittest.TestCase):
self.assertTrue(d.isEqual(DataArrayDouble([0,0,0,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10]),1e-14))
pass
self.assertTrue(d.isEqual(DataArrayDouble([0,0,0,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10]),1e-14))
pass
-
#
@unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
+ @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
def test12(self):
a=zeros(20,dtype=float64)
b = a[::-1]
self.assertRaises(InterpKernelException,DataArrayDouble.New,b) # b is not contiguous in memory
pass
def test12(self):
a=zeros(20,dtype=float64)
b = a[::-1]
self.assertRaises(InterpKernelException,DataArrayDouble.New,b) # b is not contiguous in memory
pass
-
#
@unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
+ @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
def test13(self):
a=arange(20,dtype=float64)
self.assertEqual(weakref.getweakrefcount(a),0)
def test13(self):
a=arange(20,dtype=float64)
self.assertEqual(weakref.getweakrefcount(a),0)
@@
-263,7
+264,7
@@
class MEDCouplingNumPyTest(unittest.TestCase):
self.assertTrue(DataArrayDouble(a).isUniform(4,1e-14))
pass
self.assertTrue(DataArrayDouble(a).isUniform(4,1e-14))
pass
-
#
@unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
+ @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
def test14(self):
a=arange(20,dtype=float64)
d=DataArrayDouble(a) # d owns data of a
def test14(self):
a=arange(20,dtype=float64)
d=DataArrayDouble(a) # d owns data of a
@@
-281,7
+282,7
@@
class MEDCouplingNumPyTest(unittest.TestCase):
self.assertTrue(not e.isAllocated())
pass
self.assertTrue(not e.isAllocated())
pass
-
#
@unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
+ @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
def test15(self):
a=array(0,dtype=float64) ; a.resize(10,2)
b=a.reshape(20)
def test15(self):
a=array(0,dtype=float64) ; a.resize(10,2)
b=a.reshape(20)
@@
-317,7
+318,7
@@
class MEDCouplingNumPyTest(unittest.TestCase):
self.assertTrue(not f.isAllocated())
pass
self.assertTrue(not f.isAllocated())
pass
-
#
@unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
+ @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
def test16(self):
a=arange(20,dtype=float64)
self.assertTrue(a.flags["OWNDATA"])
def test16(self):
a=arange(20,dtype=float64)
self.assertTrue(a.flags["OWNDATA"])
@@
-329,7
+330,7
@@
class MEDCouplingNumPyTest(unittest.TestCase):
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
-
#
@unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
+ @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
def test17(self):
d=DataArrayInt.Range(0,20,1)
a=d.toNumPyArray()
def test17(self):
d=DataArrayInt.Range(0,20,1)
a=d.toNumPyArray()
@@
-355,7
+356,7
@@
class MEDCouplingNumPyTest(unittest.TestCase):
self.assertTrue(d.isEqual(DataArrayInt([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,200,200,200,200],10,2)))
pass
self.assertTrue(d.isEqual(DataArrayInt([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,200,200,200,200],10,2)))
pass
-
#
@unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
+ @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
def test18(self):
d=DataArrayInt.Range(0,20,1)
d=d.convertToDblArr()
def test18(self):
d=DataArrayInt.Range(0,20,1)
d=d.convertToDblArr()
@@
-382,7
+383,7
@@
class MEDCouplingNumPyTest(unittest.TestCase):
self.assertTrue(d.isEqual(DataArrayDouble([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,200,200,200,200],10,2),1e-14))
pass
self.assertTrue(d.isEqual(DataArrayDouble([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,200,200,200,200],10,2),1e-14))
pass
-
#
@unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
+ @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
def test19(self):
sz=20
a=array(0,dtype=int32)
def test19(self):
sz=20
a=array(0,dtype=int32)
@@
-401,7
+402,7
@@
class MEDCouplingNumPyTest(unittest.TestCase):
self.assertRaises(InterpKernelException,DataArrayInt.New,b) # b has not dimension in [0,1] !
pass
self.assertRaises(InterpKernelException,DataArrayInt.New,b) # b has not dimension in [0,1] !
pass
-
#
@unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
+ @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
def test20(self):
sz=20
a=array(0,dtype=float64)
def test20(self):
sz=20
a=array(0,dtype=float64)
@@
-420,7
+421,7
@@
class MEDCouplingNumPyTest(unittest.TestCase):
self.assertRaises(InterpKernelException,DataArrayDouble.New,b) # b has not dimension in [0,1] !
pass
self.assertRaises(InterpKernelException,DataArrayDouble.New,b) # b has not dimension in [0,1] !
pass
-
#
@unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
+ @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
def test21(self):
#tests that only DataArray*(npArray) contructor is available
a=array(0,dtype=int32)
def test21(self):
#tests that only DataArray*(npArray) contructor is available
a=array(0,dtype=int32)
@@
-435,7
+436,7
@@
class MEDCouplingNumPyTest(unittest.TestCase):
self.assertRaises(InterpKernelException,DataArrayDouble.New,a,20,1)
pass
self.assertRaises(InterpKernelException,DataArrayDouble.New,a,20,1)
pass
-
#
@unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
+ @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
def test22(self):
d=DataArrayDouble(10)
d.iota()
def test22(self):
d=DataArrayDouble(10)
d.iota()
@@
-456,7
+457,7
@@
class MEDCouplingNumPyTest(unittest.TestCase):
self.assertEqual(a.tolist(),[0,1,2,3,4,5,6,7,8,9])
pass
self.assertEqual(a.tolist(),[0,1,2,3,4,5,6,7,8,9])
pass
-
#
@unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
+ @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
def test23(self):
d=DataArrayDouble(10)
d.iota()
def test23(self):
d=DataArrayDouble(10)
d.iota()
@@
-499,7
+500,7
@@
class MEDCouplingNumPyTest(unittest.TestCase):
self.assertEqual(c.tolist(),[0,1,2,3,4,5,6,7,8,9])
pass
self.assertEqual(c.tolist(),[0,1,2,3,4,5,6,7,8,9])
pass
-
#
@unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
+ @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
def test24(self):
d=DataArrayDouble(10)
d.iota()
def test24(self):
d=DataArrayDouble(10)
d.iota()
@@
-556,7
+557,7
@@
class MEDCouplingNumPyTest(unittest.TestCase):
self.assertTrue(not b.flags["OWNDATA"])
pass
self.assertTrue(not b.flags["OWNDATA"])
pass
-
#
@unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
+ @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
def test25(self):
a=arange(10,dtype=int32)
b=DataArrayInt(a)
def test25(self):
a=arange(10,dtype=int32)
b=DataArrayInt(a)
@@
-631,7
+632,7
@@
class MEDCouplingNumPyTest(unittest.TestCase):
self.assertTrue(not c.isAllocated())
pass
self.assertTrue(not c.isAllocated())
pass
-
#
@unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
+ @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
def test26(self):
d=DataArrayInt(15) ; d.iota()
d.rearrange(3)
def test26(self):
d=DataArrayInt(15) ; d.iota()
d.rearrange(3)