1 #-*-coding:iso-8859-1-*-
3 # Copyright (C) 2008-2016 EDF R&D
5 # This library is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Lesser General Public
7 # License as published by the Free Software Foundation; either
8 # version 2.1 of the License.
10 # This library is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # Lesser General Public License for more details.
15 # You should have received a copy of the GNU Lesser General Public
16 # License along with this library; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 # Author: Jean-Philippe Argaud, jean-philippe.argaud@edf.fr, EDF R&D
22 "Test de fonctionnement et de performances de Numpy et Scipy"
24 # ==============================================================================
26 numpy.set_printoptions(precision=5)
29 print " Les caracteristiques des applications et outils systeme :"
30 import sys ; v=sys.version.split() ; print " - Python systeme....: %s"%v[0]
31 import numpy ; print " - Numpy.............: %s"%numpy.version.version
33 import scipy ; print " - Scipy.............: %s"%scipy.version.version
35 print " - Scipy.............: %s"%("absent",)
37 import numpy.distutils.system_info as sysinfo ; la = sysinfo.get_info('lapack') ; print " - Lapack............: %s/lib%s.so"%(la['library_dirs'][0],la['libraries'][0])
39 print " - Lapack............: %s"%("absent",)
43 def testNumpy01(dimension = 3, precision = 1.e-17, repetitions = 10):
46 print " Taille du test..................................: %.0e"%__d
48 A = numpy.array([numpy.arange(dimension)+1.,]*__d)
49 x = numpy.arange(__d)+1.
50 print " La duree elapsed moyenne de l'initialisation est: %4.1f s"%(time.time()-t_init)
53 for i in range(repetitions):
55 print " La duree elapsed pour %3i produits est de.......: %4.1f s"%(repetitions, time.time()-t_init)
56 r = [__d*(__d+1.)*(2.*__d+1.)/6.,]*__d
57 if max(abs(b-r)) > precision:
58 raise ValueError("Resultat du test errone (1)")
60 print " Test correct, erreur maximale inferieure a %s"%precision
64 def testNumpy02(dimension = 3, precision = 1.e-17, repetitions = 100):
67 print " Taille du test..................................: %.0e"%__d
69 A = numpy.random.normal(0.,1.,size=(__d,__d))
70 x = numpy.random.normal(0.,1.,size=(__d,))
71 print " La duree elapsed moyenne de l'initialisation est: %4.1f s"%(time.time()-t_init)
74 for i in range(repetitions):
76 print " La duree elapsed pour %3i produits est de.......: %4.1f s"%(repetitions, time.time()-t_init)
80 # ==============================================================================
81 if __name__ == "__main__":
82 print '\n AUTODIAGNOSTIC \n'
84 numpy.random.seed(1000)
85 testNumpy01(dimension = 1.e4)
86 testNumpy02(dimension = 3.e3)