Salome HOME
Get classification
[modules/adao.git] / src / daComposant / daCore / Persistence.py
index 43c18965cd6860bcd12bba63770886e998609e75..ecaa30405a19dfea13b726bcce618b72b75c94c0 100644 (file)
@@ -1,6 +1,6 @@
 # -*- coding: utf-8 -*-
 #
-# Copyright (C) 2008-2018 EDF R&D
+# Copyright (C) 2008-2020 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
@@ -31,7 +31,8 @@ import os, sys, numpy, copy
 import gzip, bz2
 
 from daCore.PlatformInfo import PathManagement ; PathManagement()
-from daCore.PlatformInfo import has_gnuplot
+from daCore.PlatformInfo import has_gnuplot, PlatformInfo
+mfp = PlatformInfo().MaximumPrecision()
 if has_gnuplot:
     import Gnuplot
 
@@ -146,6 +147,9 @@ class Persistence(object):
         "x.__len__() <==> len(x)"
         return len(self.__values)
 
+    def name(self):
+        return self.__name
+
     def __getitem__(self, index=None ):
         "x.__getitem__(y) <==> x[y]"
         return copy.copy(self.__values[index])
@@ -276,7 +280,7 @@ class Persistence(object):
         élémentaires numpy.
         """
         try:
-            return [numpy.matrix(item).mean() for item in self.__values]
+            return [numpy.mean(item, dtype=mfp) for item in self.__values]
         except:
             raise TypeError("Base type is incompatible with numpy")
 
@@ -291,9 +295,9 @@ class Persistence(object):
         """
         try:
             if numpy.version.version >= '1.1.0':
-                return [numpy.matrix(item).std(ddof=ddof) for item in self.__values]
+                return [numpy.array(item).std(ddof=ddof) for item in self.__values]
             else:
-                return [numpy.matrix(item).std() for item in self.__values]
+                return [numpy.array(item).std() for item in self.__values]
         except:
             raise TypeError("Base type is incompatible with numpy")
 
@@ -304,7 +308,7 @@ class Persistence(object):
         numpy.
         """
         try:
-            return [numpy.matrix(item).sum() for item in self.__values]
+            return [numpy.array(item).sum() for item in self.__values]
         except:
             raise TypeError("Base type is incompatible with numpy")
 
@@ -315,7 +319,7 @@ class Persistence(object):
         numpy.
         """
         try:
-            return [numpy.matrix(item).min() for item in self.__values]
+            return [numpy.array(item).min() for item in self.__values]
         except:
             raise TypeError("Base type is incompatible with numpy")
 
@@ -326,7 +330,7 @@ class Persistence(object):
         numpy.
         """
         try:
-            return [numpy.matrix(item).max() for item in self.__values]
+            return [numpy.array(item).max() for item in self.__values]
         except:
             raise TypeError("Base type is incompatible with numpy")
 
@@ -460,6 +464,7 @@ class Persistence(object):
             eval(input('Please press return to continue...\n'))
 
     # ---------------------------------------------------------
+    # On pourrait aussi utiliser d'autres attributs d'un "array" comme "tofile"
     def mean(self):
         """
         Renvoie la moyenne sur toutes les valeurs sans tenir compte de la
@@ -468,9 +473,9 @@ class Persistence(object):
         """
         try:
             if self.__basetype in [int, float]:
-                return float( numpy.array(self.__values).mean() )
+                return float( numpy.mean(self.__values, dtype=mfp) )
             else:
-                return numpy.array(self.__values).mean(axis=0)
+                return numpy.mean(self.__values, axis=0, dtype=mfp)
         except:
             raise TypeError("Base type is incompatible with numpy")
 
@@ -535,9 +540,6 @@ class Persistence(object):
         except:
             raise TypeError("Base type is incompatible with numpy")
 
-    # On pourrait aussi utiliser les autres attributs d'une "matrix", comme
-    # "tofile", "min"...
-
     def plot(self,
              steps    = None,
              title    = "",
@@ -926,4 +928,4 @@ class CompositePersistence(object):
 
 # ==============================================================================
 if __name__ == "__main__":
-    print('\n AUTODIAGNOSTIC \n')
+    print('\n AUTODIAGNOSTIC\n')