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

Ignore sampler warnigns caused by paramters outside the parameter limits #137

Merged
merged 1 commit into from
Sep 8, 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ All notable changes to this project will be documented in this file.
### Changed

- Raised required amici version to 0.26.1
- Ignoring sampler warnings caused by parameters outside the parameter limits

### Fixed

Expand Down
33 changes: 22 additions & 11 deletions eulerpi/core/sampling.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"""

import typing
import warnings
from multiprocessing import get_context
from os import path

Expand Down Expand Up @@ -181,17 +182,27 @@ def run_emcee_sampling(
)

# Run the sampler.
sampler_results, final_walker_positions = run_emcee_once(
model,
data,
data_transformation,
data_stdevs,
slice,
initial_walker_positions,
num_walkers,
num_steps,
num_processes,
)
with warnings.catch_warnings():
# This warning is raised when the model returned a -inf value for the log probability, e.g. because the parameters are out of bounds.
# We want to ignore this warning, because the sampler will handle this case correctly.
# NaN values and other errors are not affected by this.
warnings.filterwarnings(
"ignore",
module="red_blue",
category=RuntimeWarning,
message="invalid value encountered in scalar subtract",
)
sampler_results, final_walker_positions = run_emcee_once(
model,
data,
data_transformation,
data_stdevs,
slice,
initial_walker_positions,
num_walkers,
num_steps,
num_processes,
)

result_manager.save_run(
model, slice, run, sampler_results, final_walker_positions
Expand Down
Loading