From 0c677ec9045e85aff261786eee5ceae9a15485dc Mon Sep 17 00:00:00 2001 From: Gregory Ashton <gregory.ashton@ligo.org> Date: Tue, 30 Apr 2019 23:40:38 -0500 Subject: [PATCH] Adds pvalue return to the pp plot generation script Useful if the pvalues needs to be logged elsewhere from a script --- bilby/core/result.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/bilby/core/result.py b/bilby/core/result.py index 42cf236e1..4cd0c30ef 100644 --- a/bilby/core/result.py +++ b/bilby/core/result.py @@ -1469,8 +1469,9 @@ def make_pp_plot(results, filename=None, save=True, confidence_interval=0.9, Returns ------- - fig: - matplotlib figure + fig, pvals: + matplotlib figure and a NamedTuple with attributes `combined_pvalue`, + `pvalues`, and `names`. """ credible_levels = pd.DataFrame() @@ -1519,9 +1520,13 @@ def make_pp_plot(results, filename=None, save=True, confidence_interval=0.9, filename = 'outdir/pp.png' fig.savefig(filename, dpi=500) + Pvals = namedtuple('pvals', ['combined_pvalue', 'pvalues', 'names']) + pvals = Pvals(combined_pvalue=scipy.stats.combine_pvalues(pvalues)[1], + pvalues=pvalues, + names=list(credible_levels.keys())) logger.info( - "Combined p-value: {}".format(scipy.stats.combine_pvalues(pvalues)[1])) - return fig + "Combined p-value: {}".format(pvals.combined_pvalue)) + return fig, pvals class ResultError(Exception): -- GitLab