1 # -*- coding: utf-8 -*-
3 # Copyright (C) 2008-2020 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 = "PrintAllValuesFor",
42 message = "Liste de noms de vecteurs dont les valeurs détaillées sont à imprimer",
49 self.defineRequiredParameter(
50 name = "ShowInformationOnlyFor",
51 default = ["Background", "CheckingPoint", "Observation"],
53 message = "Liste de noms de vecteurs dont les informations synthétiques sont à imprimer",
60 self.defineRequiredParameter(
64 message = "Activation du mode debug lors de l'exécution",
66 self.requireInputArguments(
69 self.setAttributes(tags=(
73 def run(self, Xb=None, Y=None, U=None, HO=None, EM=None, CM=None, R=None, B=None, Q=None, Parameters=None):
74 self._pre_run(Parameters, Xb, Y, U, HO, EM, CM, R, B, Q)
76 _p = self._parameters["NumberOfPrintedDigits"]
77 numpy.set_printoptions(precision=_p)
79 def __buildPrintableVectorProperties( __name, __vector ):
80 if __vector is None: return ""
81 if len(__vector) == 0: return ""
82 if hasattr(__vector,"name") and __name != __vector.name(): return ""
83 if __name not in self._parameters["ShowInformationOnlyFor"]: return ""
85 if hasattr(__vector,"mins"):
86 __title = "Information for %svector series:"%(str(__name)+" ",)
88 __title = "Information for %svector:"%(str(__name)+" ",)
90 msgs += ("===> "+__title+"\n")
91 msgs += (" "+("-"*len(__title))+"\n")
92 msgs += (" Main characteristics of the vector:\n")
93 if hasattr(__vector,"basetype"):
94 msgs += (" Python base type..........: %s\n")%( __vector.basetype(), )
95 msgs += (" Shape of data.............: %s\n")%( __vector.shape(), )
97 msgs += (" Python base type..........: %s\n")%type( __vector )
98 msgs += (" Shape of serie of vectors.: %s\n")%( __vector.shape, )
100 msgs += (" Number of data............: %s\n")%( len(__vector), )
102 if hasattr(__vector,"mins"):
103 msgs += (" Serie of minimum values...: %s\n")%numpy.array(__vector.mins())
105 msgs += (" Minimum of vector.........: %12."+str(_p)+"e\n")%__vector.min()
106 if hasattr(__vector,"means"):
107 msgs += (" Serie of mean values......: %s\n")%numpy.array(__vector.means())
109 msgs += (" Mean of vector............: %12."+str(_p)+"e\n")%__vector.mean()
110 if hasattr(__vector,"maxs"):
111 msgs += (" Serie of maximum values...: %s\n")%numpy.array(__vector.maxs())
113 msgs += (" Maximum of vector.........: %12."+str(_p)+"e\n")%__vector.max()
114 if self._parameters["SetDebug"] or __name in self._parameters["PrintAllValuesFor"]:
116 msgs += (" Printing all values :\n")
117 msgs += ("%s"%(__vector,))
121 __buildPrintableVectorProperties( "Background", Xb )
122 __buildPrintableVectorProperties( "CheckingPoint", Xb )
123 __buildPrintableVectorProperties( "Observation", Y )
128 # ==============================================================================
129 if __name__ == "__main__":
130 print('\n AUTODIAGNOSTIC\n')