Skip to content

Commit

Permalink
Ignore sampler warnigns caused by paramters outside the parameter limits
Browse files Browse the repository at this point in the history
  • Loading branch information
kaiserls committed Sep 8, 2024
1 parent 85e880d commit c811a09
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 11 deletions.
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

0 comments on commit c811a09

Please sign in to comment.