From 1cb2a5c49ae9ea5f61609279fbc5711dc5445d85 Mon Sep 17 00:00:00 2001 From: lukashergt Date: Thu, 19 Sep 2024 13:14:42 +0200 Subject: [PATCH 1/5] stop warning about `logL<=logL_birth` when both are `-inf`, just silently drop those samples --- anesthetic/samples.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/anesthetic/samples.py b/anesthetic/samples.py index d0dee2b1..44c81076 100644 --- a/anesthetic/samples.py +++ b/anesthetic/samples.py @@ -1302,15 +1302,17 @@ def recompute(self, logL_birth=None, inplace=False): n_bad = invalid.sum() n_equal = (samples.logL == samples.logL_birth).sum() if n_bad: - warnings.warn("%i out of %i samples have logL <= logL_birth," - "\n%i of which have logL == logL_birth." - "\nThis may just indicate numerical rounding " - "errors at the peak of the likelihood, but " - "further investigation of the chains files is " - "recommended." - "\nDropping the invalid samples." % - (n_bad, len(samples), n_equal), - RuntimeWarning) + n_inf = ((samples.logL == samples.logL_birth) & + (samples.logL == -np.inf)).sum() + if n_bad > n_inf: + warnings.warn( + "%i out of %i samples have logL <= logL_birth,\n" + "%i of which have logL == logL_birth.\n" + "This may just indicate numerical rounding errors at " + "the peak of the likelihood, but further " + "investigation of the chains files is recommended.\n" + "Dropping the invalid samples." + % (n_bad, len(samples), n_equal), RuntimeWarning) samples = samples[~invalid].reset_index(drop=True) samples.sort_values('logL', inplace=True) From f6b3bb7afe3c9a0487147615f5973b31cc3ef2bc Mon Sep 17 00:00:00 2001 From: lukashergt Date: Thu, 19 Sep 2024 17:32:24 +0200 Subject: [PATCH 2/5] version bump to 2.8.15 --- README.rst | 2 +- anesthetic/_version.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index 5e4e2096..5acc5279 100644 --- a/README.rst +++ b/README.rst @@ -2,7 +2,7 @@ anesthetic: nested sampling post-processing =========================================== :Authors: Will Handley and Lukas Hergt -:Version: 2.8.14 +:Version: 2.8.15 :Homepage: https://github.com/handley-lab/anesthetic :Documentation: http://anesthetic.readthedocs.io/ diff --git a/anesthetic/_version.py b/anesthetic/_version.py index 965b8c85..7cdefb37 100644 --- a/anesthetic/_version.py +++ b/anesthetic/_version.py @@ -1 +1 @@ -__version__ = '2.8.14' +__version__ = '2.8.15' From f88ef2dc244e927be496cf04ad4e87749d1a58f0 Mon Sep 17 00:00:00 2001 From: lukashergt Date: Thu, 19 Sep 2024 18:37:01 +0200 Subject: [PATCH 3/5] fix test for warning after having relaxed its eagerness --- tests/test_samples.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_samples.py b/tests/test_samples.py index f49aed3d..0dfdf4c8 100644 --- a/tests/test_samples.py +++ b/tests/test_samples.py @@ -1133,6 +1133,7 @@ def test_beta(): def test_beta_with_logL_infinities(): ns = read_chains("./tests/example_data/pc") ns.loc[:10, ('logL', r'$\ln\mathcal{L}$')] = -np.inf + ns.loc[1000, ('logL', r'$\ln\mathcal{L}$')] = -np.inf with pytest.warns(RuntimeWarning): ns.recompute(inplace=True) assert (ns.logL == -np.inf).sum() == 0 From 1ec76dd2f73853ed747ee5327edfddc87945cb75 Mon Sep 17 00:00:00 2001 From: Lukas Hergt Date: Thu, 26 Sep 2024 17:08:23 -0700 Subject: [PATCH 4/5] Update README.rst --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 5acc5279..5e28cce7 100644 --- a/README.rst +++ b/README.rst @@ -2,7 +2,7 @@ anesthetic: nested sampling post-processing =========================================== :Authors: Will Handley and Lukas Hergt -:Version: 2.8.15 +:Version: 2.8.16 :Homepage: https://github.com/handley-lab/anesthetic :Documentation: http://anesthetic.readthedocs.io/ From f098b86564f4d78f9c569c82445e744c7a75f99f Mon Sep 17 00:00:00 2001 From: Lukas Hergt Date: Thu, 26 Sep 2024 17:08:48 -0700 Subject: [PATCH 5/5] Update _version.py --- anesthetic/_version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/anesthetic/_version.py b/anesthetic/_version.py index 7cdefb37..f8f5d150 100644 --- a/anesthetic/_version.py +++ b/anesthetic/_version.py @@ -1 +1 @@ -__version__ = '2.8.15' +__version__ = '2.8.16'