From 8be778a08fc511d7268fef1c06ccd969ea98f738 Mon Sep 17 00:00:00 2001 From: Jean-Philippe ARGAUD Date: Fri, 9 Oct 2020 15:43:36 +0200 Subject: [PATCH] Precision support management to fix linalg float128 support (Fedora32) --- .../daAlgorithms/EnsembleKalmanFilter.py | 6 +++--- src/daComposant/daCore/Persistence.py | 15 ++++++--------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/daComposant/daAlgorithms/EnsembleKalmanFilter.py b/src/daComposant/daAlgorithms/EnsembleKalmanFilter.py index 8905c21..1660d06 100644 --- a/src/daComposant/daAlgorithms/EnsembleKalmanFilter.py +++ b/src/daComposant/daAlgorithms/EnsembleKalmanFilter.py @@ -189,8 +189,8 @@ class ElementaryAlgorithm(BasicObjects.Algorithm): # --- > Par principe, M = Id, Q = 0 Xn_predicted = Xn # - Xfm = numpy.asmatrix(numpy.ravel(Xn_predicted.mean(axis=1, dtype=mfp))).T - Hfm = numpy.asmatrix(numpy.ravel(HX_predicted.mean(axis=1, dtype=mfp))).T + Xfm = numpy.asmatrix(numpy.ravel(Xn_predicted.mean(axis=1, dtype=mfp).astype('float'))).T + Hfm = numpy.asmatrix(numpy.ravel(HX_predicted.mean(axis=1, dtype=mfp).astype('float'))).T # PfHT, HPfHT = 0., 0. for i in range(__m): @@ -207,7 +207,7 @@ class ElementaryAlgorithm(BasicObjects.Algorithm): ri = numpy.asmatrix(numpy.random.multivariate_normal(numpy.zeros(__p), Rn, (1,1,1))).T Xn[:,i] = Xn_predicted[:,i] + K * (Ynpu + ri - HX_predicted[:,i]) # - Xa = Xn.mean(axis=1, dtype=mfp) + Xa = Xn.mean(axis=1, dtype=mfp).astype('float') # if self._parameters["StoreInternalVariables"] \ or self._toStore("CostFunctionJ") \ diff --git a/src/daComposant/daCore/Persistence.py b/src/daComposant/daCore/Persistence.py index ecaa304..66d3eef 100644 --- a/src/daComposant/daCore/Persistence.py +++ b/src/daComposant/daCore/Persistence.py @@ -280,7 +280,7 @@ class Persistence(object): élémentaires numpy. """ try: - return [numpy.mean(item, dtype=mfp) for item in self.__values] + return [numpy.mean(item, dtype=mfp).astype('float') for item in self.__values] except: raise TypeError("Base type is incompatible with numpy") @@ -295,9 +295,9 @@ class Persistence(object): """ try: if numpy.version.version >= '1.1.0': - return [numpy.array(item).std(ddof=ddof) for item in self.__values] + return [numpy.array(item).std(ddof=ddof, dtype=mfp).astype('float') for item in self.__values] else: - return [numpy.array(item).std() for item in self.__values] + return [numpy.array(item).std(dtype=mfp).astype('float') for item in self.__values] except: raise TypeError("Base type is incompatible with numpy") @@ -472,10 +472,7 @@ class Persistence(object): les types élémentaires numpy. """ try: - if self.__basetype in [int, float]: - return float( numpy.mean(self.__values, dtype=mfp) ) - else: - return numpy.mean(self.__values, axis=0, dtype=mfp) + return numpy.mean(self.__values, axis=0, dtype=mfp).astype('float') except: raise TypeError("Base type is incompatible with numpy") @@ -490,9 +487,9 @@ class Persistence(object): """ try: if numpy.version.version >= '1.1.0': - return numpy.array(self.__values).std(ddof=ddof,axis=0) + return numpy.array(self.__values).std(ddof=ddof,axis=0).astype('float') else: - return numpy.array(self.__values).std(axis=0) + return numpy.array(self.__values).std(axis=0).astype('float') except: raise TypeError("Base type is incompatible with numpy") -- 2.39.2