Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stop warning when logL==logL_birth==-inf #395

Merged
merged 6 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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/

Expand Down
2 changes: 1 addition & 1 deletion anesthetic/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '2.8.15'
__version__ = '2.8.16'
20 changes: 11 additions & 9 deletions anesthetic/samples.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions tests/test_samples.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading