Salome HOME
Minor source update for OM compatibility
[modules/adao.git] / src / daComposant / daCore / NumericObjects.py
index cafe15d95abe94f76ee6fb794f8ad2c362717152..5903cddbced50da59c738fa77ad20e791ad116ec 100644 (file)
@@ -25,7 +25,8 @@ __doc__ = """
 """
 __author__ = "Jean-Philippe ARGAUD"
 
-import os, copy, types, sys, logging, math, numpy, scipy, itertools
+import os, copy, types, sys, logging, math, numpy, scipy, itertools, warnings
+import scipy.linalg  # Py3.6
 from daCore.BasicObjects import Operator, Covariance, PartialAlgorithm
 from daCore.PlatformInfo import PlatformInfo, vt, vfloat
 mpr = PlatformInfo().MachinePrecision()
@@ -643,7 +644,6 @@ def EnsembleErrorCovariance( __Ensemble, __Quick = False ):
 def SingularValuesEstimation( __Ensemble, __Using = "SVDVALS"):
     "Renvoie les valeurs singulières de l'ensemble et leur carré"
     if __Using == "SVDVALS":  # Recommandé
-        import scipy
         __sv   = scipy.linalg.svdvals( __Ensemble )
         __svsq = __sv**2
     elif __Using == "SVD":
@@ -1385,7 +1385,6 @@ def BuildComplexSampleList(
         sampleList = itertools.product(*coordinatesList)
     # ---------------------------
     elif len(__SampleAsMinMaxLatinHyperCube) > 0:
-        import scipy, warnings
         if vt(scipy.version.version) <= vt("1.7.0"):
             __msg = "In order to use Latin Hypercube sampling, you must at least use Scipy version 1.7.0 (and you are presently using Scipy %s). A void sample is then generated."%scipy.version.version
             warnings.warn(__msg, FutureWarning, stacklevel=50)
@@ -1404,7 +1403,6 @@ def BuildComplexSampleList(
             sampleList = scipy.stats.qmc.scale(__sample, __l_bounds, __u_bounds)
     # ---------------------------
     elif len(__SampleAsMinMaxSobolSequence) > 0:
-        import scipy, warnings
         if vt(scipy.version.version) <= vt("1.7.0"):
             __msg = "In order to use Latin Hypercube sampling, you must at least use Scipy version 1.7.0 (and you are presently using Scipy %s). A void sample is then generated."%scipy.version.version
             warnings.warn(__msg, FutureWarning, stacklevel=50)
@@ -1503,12 +1501,11 @@ def multiXOsteps(
             if __CovForecast:
                 Mt = EM["Tangent"].asMatrix(Xn)
                 Mt = Mt.reshape(Xn.size, Xn.size)  # ADAO & check shape
-            if __CovForecast:
                 Ma = EM["Adjoint"].asMatrix(Xn)
                 Ma = Ma.reshape(Xn.size, Xn.size)  # ADAO & check shape
                 Pn_predicted = Q + Mt @ (Pn @ Ma)
-            M  = EM["Direct"].appliedControledFormTo
-            Xn_predicted = M( (Xn, Un) ).reshape((-1, 1))
+            Mm = EM["Direct"].appliedControledFormTo
+            Xn_predicted = Mm( (Xn, Un) ).reshape((-1, 1))
             if CM is not None and "Tangent" in CM and Un is not None:  # Attention : si Cm est aussi dans M, doublon !
                 Cm = CM["Tangent"].asMatrix(Xn_predicted)
                 Cm = Cm.reshape(Xn.size, Un.size)  # ADAO & check shape