Salome HOME
Minor source update for OM compatibility
[modules/adao.git] / src / daComposant / daCore / Interfaces.py
index a901e7734b8e7c3c0b0bac1629b0a199c46f8639..abc4f516272c10944f1764bcbb841305756b589b 100644 (file)
@@ -37,6 +37,7 @@ from daCore import PlatformInfo
 from daCore import Templates
 from daCore import Reporting
 from daCore import version
+lpi = PlatformInfo.PlatformInfo()
 
 # ==============================================================================
 class GenericCaseViewer(object):
@@ -70,11 +71,12 @@ class GenericCaseViewer(object):
     def _initialize(self, __multilines):
         "Permet des pré-conversions automatiques simples de commandes ou clés"
         __translation = {
-            "Study_name"          : "StudyName",                  # noqa: E203
-            "Study_repertory"     : "StudyRepertory",             # noqa: E203
-            "MaximumNumberOfSteps": "MaximumNumberOfIterations",
-            "FunctionDict"        : "ScriptWithSwitch",           # noqa: E203
-            "FUNCTIONDICT_FILE"   : "SCRIPTWITHSWITCH_FILE",      # noqa: E203
+            "Study_name"           : "StudyName",                  # noqa: E203
+            "Study_repertory"      : "StudyRepertory",             # noqa: E203
+            "MaximumNumberOfSteps" : "MaximumNumberOfIterations",  # noqa: E203
+            "EnableMultiProcessing": "EnableWiseParallelism",
+            "FunctionDict"         : "ScriptWithSwitch",           # noqa: E203
+            "FUNCTIONDICT_FILE"    : "SCRIPTWITHSWITCH_FILE",      # noqa: E203
         }
         for k, v in __translation.items():
             __multilines = __multilines.replace(k, v)
@@ -136,6 +138,7 @@ class _TUIViewer(GenericCaseViewer):
         GenericCaseViewer.__init__(self, __name, __objname, __content, __object)
         self._addLine("# -*- coding: utf-8 -*-")
         self._addLine("#\n# Python script using ADAO TUI\n#")
+        self._addLine("import numpy as np")
         self._addLine("from numpy import array, matrix")
         self._addLine("from adao import adaoBuilder")
         self._addLine("%s = adaoBuilder.New('%s')"%(self._objname, self._name))
@@ -161,11 +164,13 @@ class _TUIViewer(GenericCaseViewer):
                 __v = __local[k]
                 if __v is None: continue                                # noqa: E701
                 if   k == "Checked"              and not __v: continue  # noqa: E241,E271,E272,E701
-                if   k == "Stored"               and not __v: continue  # noqa: E241,E271,E272,E701
                 if   k == "ColMajor"             and not __v: continue  # noqa: E241,E271,E272,E701
+                if   k == "CrossObs"             and not __v: continue  # noqa: E241,E271,E272,E701
+                if   k == "SyncObs"              and     __v: continue  # noqa: E241,E271,E272,E701
                 if   k == "InputFunctionAsMulti" and not __v: continue  # noqa: E241,E271,E272,E701
-                if   k == "nextStep"             and not __v: continue  # noqa: E241,E271,E272,E701
                 if   k == "PerformanceProfile"   and     __v: continue  # noqa: E241,E271,E272,E701
+                if   k == "Stored"               and not __v: continue  # noqa: E241,E271,E272,E701
+                if   k == "nextStep"             and not __v: continue  # noqa: E241,E271,E272,E701
                 if   k == "noDetails":                        continue  # noqa: E241,E271,E272,E701
                 if isinstance(__v, Persistence.Persistence):
                     __v = __v.values()
@@ -212,6 +217,7 @@ class _COMViewer(GenericCaseViewer):
         self._observerIndex = 0
         self._addLine("# -*- coding: utf-8 -*-")
         self._addLine("#\n# Python script using ADAO COMM\n#")
+        self._addLine("import numpy as np")
         self._addLine("from numpy import array, matrix")
         self._addLine("#")
         self._addLine("%s = {}"%__objname)
@@ -553,10 +559,10 @@ class _SCDViewer(GenericCaseViewer):
                     __text += "%s_config['Data'] = %s\n"%(__command, __v)
                     __text = __text.replace("''", "'")
                     __vectorIsScript = True
-                elif __k in ('Stored', 'Checked', 'ColMajor', 'InputFunctionAsMulti', 'nextStep'):
+                elif __k in ('Stored', 'Checked', 'ColMajor', 'CrossObs', 'InputFunctionAsMulti', 'nextStep'):
                     if bool(__v):
                         __text += "%s_config['%s'] = '%s'\n"%(__command, __k, int(bool(__v)))
-                elif __k in ('PerformanceProfile', 'noDetails'):
+                elif __k in ('PerformanceProfile', 'SyncObs', 'noDetails'):
                     if not bool(__v):
                         __text += "%s_config['%s'] = '%s'\n"%(__command, __k, int(bool(__v)))
                 else:
@@ -666,10 +672,9 @@ class _YACSViewer(GenericCaseViewer):
             if os.path.isfile(__file) or os.path.islink(__file):
                 os.remove(__file)
         # -----
-        if not PlatformInfo.has_salome or \
-                not PlatformInfo.has_adao:
+        if not lpi.has_salome or not lpi.has_adao:
             raise ImportError(
-                "Unable to get SALOME (%s) or ADAO (%s) environnement for YACS conversion.\n"%(PlatformInfo.has_salome, PlatformInfo.has_adao) + \
+                "Unable to get SALOME (%s) or ADAO (%s) environnement for YACS conversion.\n"%(lpi.has_salome, lpi.has_adao) + \
                 "Please load the right SALOME environnement before trying to use it.")
         else:
             from daYacsSchemaCreator.run import create_schema_from_content
@@ -723,11 +728,13 @@ class _ReportViewer(GenericCaseViewer):
                 __v = __local[k]
                 if __v is None: continue                                # noqa: E701
                 if   k == "Checked"              and not __v: continue  # noqa: E241,E271,E272,E701
-                if   k == "Stored"               and not __v: continue  # noqa: E241,E271,E272,E701
                 if   k == "ColMajor"             and not __v: continue  # noqa: E241,E271,E272,E701
+                if   k == "CrossObs"             and not __v: continue  # noqa: E241,E271,E272,E701
+                if   k == "SyncObs"              and     __v: continue  # noqa: E241,E271,E272,E701
                 if   k == "InputFunctionAsMulti" and not __v: continue  # noqa: E241,E271,E272,E701
-                if   k == "nextStep"             and not __v: continue  # noqa: E241,E271,E272,E701
                 if   k == "PerformanceProfile"   and     __v: continue  # noqa: E241,E271,E272,E701
+                if   k == "Stored"               and not __v: continue  # noqa: E241,E271,E272,E701
+                if   k == "nextStep"             and not __v: continue  # noqa: E241,E271,E272,E701
                 if   k == "noDetails":                        continue  # noqa: E241,E271,E272,E701
                 if   k == "Concept":                          continue  # noqa: E241,E271,E272,E701
                 if   k == "self":                             continue  # noqa: E241,E271,E272,E701
@@ -1069,7 +1076,7 @@ class ImportFromFile(object):
         self.__supportedformats["text/tab-separated-values"] = True
         self.__supportedformats["application/numpy.npy"]     = True
         self.__supportedformats["application/numpy.npz"]     = True
-        self.__supportedformats["application/dymola.sdf"]    = PlatformInfo.has_sdf
+        self.__supportedformats["application/dymola.sdf"]    = lpi.has_sdf
         return self.__supportedformats
 
     def getvalue(self, ColNames=None, ColIndex=None ):
@@ -1110,7 +1117,7 @@ class ImportFromFile(object):
             if __usecols is None:  # Si une variable demandée n'existe pas
                 self._colnames = None
         #
-        elif self._format == "application/dymola.sdf" and PlatformInfo.has_sdf:
+        elif self._format == "application/dymola.sdf" and lpi.has_sdf:
             import sdf
             __content = sdf.load(self._filename)
             __columns = None
@@ -1205,14 +1212,14 @@ class ImportScalarLinesFromFile(ImportFromFile):
             __usecols  = (0, 1, 2, 3)
 
             def __replaceNoneN( s ):
-                if s.strip() == b'None':
-                    return numpy.NINF
+                if s.strip() in (b'None', 'None'):
+                    return -numpy.inf
                 else:
                     return s
 
             def __replaceNoneP( s ):
-                if s.strip() == b'None':
-                    return numpy.PINF
+                if s.strip() in (b'None', 'None'):
+                    return numpy.inf
                 else:
                     return s
             __converters = {2: __replaceNoneN, 3: __replaceNoneP}
@@ -1229,8 +1236,8 @@ class ImportScalarLinesFromFile(ImportFromFile):
             __usecols  = tuple(range(len(HeaderNames)))
 
             def __replaceNone( s ):
-                if s.strip() == b'None':
-                    return numpy.NAN
+                if s.strip() in (b'None', 'None'):
+                    return numpy.nan
                 else:
                     return s
             __converters = dict()