From 9c705fb3110ece10bba4c598f2c3ba7798227450 Mon Sep 17 00:00:00 2001 From: Antoine CARME Date: Thu, 9 Mar 2023 00:22:09 +0100 Subject: [PATCH] Python 3.11 support #227. Warning hunt. --- pyaf/TS/Perf.py | 2 +- pyaf/TS/Plots.py | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/pyaf/TS/Perf.py b/pyaf/TS/Perf.py index ed6c0fe0a..f6dce3a90 100644 --- a/pyaf/TS/Perf.py +++ b/pyaf/TS/Perf.py @@ -128,7 +128,7 @@ def compute_LnQ(self, signal , estimator): def compute_KS_Kendall_MWU_AUC(self, signal , estimator): from scipy.stats import mannwhitneyu, kendalltau, kstest - lKSTest = kstest(signal, estimator) + lKSTest = kstest(signal, estimator, method='asymp') self.mKS = lKSTest.statistic self.mKS = round( self.mKS , 4 ) lKendallTau_Result = kendalltau(signal, estimator) diff --git a/pyaf/TS/Plots.py b/pyaf/TS/Plots.py index 0c57cc29d..9b71db65d 100644 --- a/pyaf/TS/Plots.py +++ b/pyaf/TS/Plots.py @@ -172,7 +172,11 @@ def quantiles_plot_internal(df, time, signal, estimator, iQuantiles, name = None if(name is not None): plt.switch_backend('Agg') lMin, lMax = df1[lQuantileNames].values.min(), df1[lQuantileNames].values.max() - + # Avoid a warning from matplotlib. + lEps = 0.01 + if((lMax - lMin) < lEps): + lMin, lMax = lMin - lEps, lMax + lEps + # Forecast Quantiles Plots can be improved #225 # Use a more meaningful color map (gradient, Blue = Low, Green = Normal, Red = High) for synchronized histograms. # Blue/Red for lower/higher quartile, decreasing alpha towards ther median. @@ -192,7 +196,10 @@ def quantiles_plot_internal(df, time, signal, estimator, iQuantiles, name = None lIdx = df1.index[h] lTime = df1.loc[lIdx, time] q_values = df1.loc[lIdx, lQuantileNames].tolist() - _, bins1, patches = axs[h].hist(q_values, bins = q_values, weights=[1]*len(lQuantileNames), density = True) + if((max(q_values) - min(q_values)) < lEps): + # Avoid a warning from matplotlib for a constant signal. + q_values = [min(q_values) - lEps] + [max(q_values) + lEps] + _, bins1, patches = axs[h].hist(q_values, bins = q_values, weights=[1]*len(q_values), density = True) for i, p in enumerate(patches): j = (bins1[i] - lMin) / (lMax - lMin) plt.setp(p, 'facecolor', cm(j))