1 # -*- coding: utf-8 -*-
3 # Copyright (C) 2008-2019 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
25 from daCore import BasicObjects
27 # ==============================================================================
28 class ElementaryAlgorithm(BasicObjects.Algorithm):
30 BasicObjects.Algorithm.__init__(self, "INPUTVALUESTEST")
31 self.defineRequiredParameter(
32 name = "NumberOfPrintedDigits",
35 message = "Nombre de chiffres affichés pour les impressions de réels",
38 self.defineRequiredParameter(
39 name = "PrintValuesFor",
42 message = "Liste de vecteurs dont les valeurs sont à imprimer",
49 self.defineRequiredParameter(
53 message = "Activation du mode debug lors de l'exécution",
55 self.requireInputArguments(
59 def run(self, Xb=None, Y=None, U=None, HO=None, EM=None, CM=None, R=None, B=None, Q=None, Parameters=None):
60 self._pre_run(Parameters, Xb, Y, R, B, Q)
62 _p = self._parameters["NumberOfPrintedDigits"]
63 numpy.set_printoptions(precision=_p)
65 def __buildPrintableVectorProperties( __name, __vector ):
66 if __vector is None: return ""
67 if len(__vector) == 0: return ""
68 if hasattr(__vector,"name") and __name != __vector.name():
71 __title = "Information for %svector:"%(str(__name)+" ",)
73 msgs += ("===> "+__title+"\n")
74 msgs += (" "+("-"*len(__title))+"\n")
75 msgs += (" Main characteristics of the vector:\n")
76 if hasattr(__vector,"basetype"):
77 msgs += (" Python base type..........: %s\n")%( __vector.basetype(), )
78 msgs += (" Shape of data.............: %s\n")%( __vector.shape(), )
80 msgs += (" Python base type..........: %s\n")%type( __vector )
81 msgs += (" Shape of serie of vectors.: %s\n")%( __vector.shape, )
83 msgs += (" Number of data............: %s\n")%( len(__vector), )
85 if hasattr(__vector,"mins"):
86 msgs += (" Serie of minimum values...: %s\n")%numpy.array(__vector.mins())
88 msgs += (" Minimum of vector.........: %12."+str(_p)+"e\n")%__vector.min()
89 if hasattr(__vector,"means"):
90 msgs += (" Serie of mean values......: %s\n")%numpy.array(__vector.means())
92 msgs += (" Mean of vector............: %12."+str(_p)+"e\n")%__vector.mean()
93 if hasattr(__vector,"maxs"):
94 msgs += (" Serie of maximum values...: %s\n")%numpy.array(__vector.maxs())
96 msgs += (" Maximum of vector.........: %12."+str(_p)+"e\n")%__vector.max()
97 if self._parameters["SetDebug"] or __name in self._parameters["PrintValuesFor"]:
99 msgs += (" Printing all values :\n")
100 msgs += ("%s"%(__vector,))
104 __buildPrintableVectorProperties( "Background", Xb )
105 __buildPrintableVectorProperties( "CheckingPoint", Xb )
106 __buildPrintableVectorProperties( "Observation", Y )
111 # ==============================================================================
112 if __name__ == "__main__":
113 print('\n AUTODIAGNOSTIC\n')