1 # -*- coding: utf-8 -*-
3 # Copyright (C) 2008-2024 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
24 from daCore import BasicObjects
26 # ==============================================================================
27 class ElementaryAlgorithm(BasicObjects.Algorithm):
29 BasicObjects.Algorithm.__init__(self, "INPUTVALUESTEST")
30 self.defineRequiredParameter(
31 name = "NumberOfPrintedDigits",
34 message = "Nombre de chiffres affichés pour les impressions de réels",
37 self.defineRequiredParameter(
38 name = "PrintAllValuesFor",
41 message = "Liste de noms de vecteurs dont les valeurs détaillées sont à imprimer",
48 self.defineRequiredParameter(
49 name = "ShowInformationOnlyFor",
50 default = ["Background", "CheckingPoint", "Observation"],
52 message = "Liste de noms de vecteurs dont les informations synthétiques sont à imprimer",
59 self.defineRequiredParameter(
63 message = "Activation du mode debug lors de l'exécution",
65 self.requireInputArguments(
77 def run(self, Xb=None, Y=None, U=None, HO=None, EM=None, CM=None, R=None, B=None, Q=None, Parameters=None):
78 self._pre_run(Parameters, Xb, Y, U, HO, EM, CM, R, B, Q)
80 _p = self._parameters["NumberOfPrintedDigits"]
81 numpy.set_printoptions(precision=_p)
83 def __buildPrintableVectorProperties( __name, __vector ):
86 if len(__vector) == 0:
88 if hasattr(__vector, "name") and __name != __vector.name():
90 if __name not in self._parameters["ShowInformationOnlyFor"]:
93 if hasattr(__vector, "mins"):
94 __title = "Information for %svector series:"%(str(__name) + " ",)
96 __title = "Information for %svector:"%(str(__name) + " ",)
98 msgs += ("===> " + __title + "\n")
99 msgs += (" " + ("-" * len(__title)) + "\n")
100 msgs += (" Main characteristics of the vector:\n")
101 if hasattr(__vector, "basetype"):
102 msgs += (" Python base type..........: %s\n")%( __vector.basetype(), )
103 msgs += (" Shape of data.............: %s\n")%( __vector.shape(), )
105 msgs += (" Python base type..........: %s\n")%type( __vector )
106 msgs += (" Shape of serie of vectors.: %s\n")%( __vector.shape, )
108 msgs += (" Number of data............: %s\n")%( len(__vector), )
111 if hasattr(__vector, "mins"):
112 msgs += (" Serie of minimum values...: %s\n")%numpy.array(__vector.mins())
114 msgs += (" Minimum of vector.........: %12." + str(_p) + "e\n")%__vector.min()
115 if hasattr(__vector, "means"):
116 msgs += (" Serie of mean values......: %s\n")%numpy.array(__vector.means())
118 msgs += (" Mean of vector............: %12." + str(_p) + "e\n")%__vector.mean()
119 if hasattr(__vector, "maxs"):
120 msgs += (" Serie of maximum values...: %s\n")%numpy.array(__vector.maxs())
122 msgs += (" Maximum of vector.........: %12." + str(_p) + "e\n")%__vector.max()
123 if self._parameters["SetDebug"] or __name in self._parameters["PrintAllValuesFor"]:
125 msgs += (" Printing all values :\n")
126 msgs += ("%s"%(__vector,))
130 __buildPrintableVectorProperties( "Background", Xb )
131 __buildPrintableVectorProperties( "CheckingPoint", Xb )
132 __buildPrintableVectorProperties( "Observation", Y )
134 self._post_run(HO, EM)
137 # ==============================================================================
138 if __name__ == "__main__":
139 print("\n AUTODIAGNOSTIC\n")