Skip to content

Commit

Permalink
black formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
aradermacher committed Dec 18, 2024
1 parent 5487765 commit 4c20182
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
2 changes: 1 addition & 1 deletion docs/examples/bias.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class LinearModel(ForwardModelBase):
def __init__(self, name):
super().__init__(name)
self.pce_order = 1

def interface(self):
self.parameters = ["a", "b"]
self.input_sensors = Sensor("x")
Expand Down
9 changes: 6 additions & 3 deletions probeye/inference/bias/solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@
from probeye.subroutines import stream_to_logger
from probeye.subroutines import print_dict_in_rows

from multiprocessing import Pool #pickling problem
#from multiprocessing.pool import ThreadPool as Pool # no pickling needed but no time effect
from multiprocessing import Pool # pickling problem

# from multiprocessing.pool import ThreadPool as Pool # no pickling needed but no time effect
import os

os.environ["OMP_NUM_THREADS"] = "1"


Expand Down Expand Up @@ -261,6 +263,7 @@ def run(
# Pre-process #
# ............................................................................ #
global logprob

def logprob(x):
# Skip loglikelihood evaluation if logprior is equal
# to negative infinity
Expand All @@ -281,7 +284,7 @@ def logprob(x):
log_prob_fn=logprob,
pool=pool,
**kwargs,
)
)

if self.seed is not None:
random.seed(self.seed)
Expand Down
19 changes: 10 additions & 9 deletions probeye/inference/emcee/solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@
from probeye.subroutines import print_dict_in_rows
from probeye.subroutines import extract_true_values

from multiprocessing import Pool #pickling problem
#from multiprocessing.pool import ThreadPool as Pool # no pickling needed but no time effect
from multiprocessing import Pool # pickling problem

# from multiprocessing.pool import ThreadPool as Pool # no pickling needed but no time effect
import os

os.environ["OMP_NUM_THREADS"] = "1"


Expand Down Expand Up @@ -218,8 +220,8 @@ def run(
# Pre-process #
# ............................................................................ #


global logprob

def logprob(x):
# Skip loglikelihood evaluation if logprior is equal
# to negative infinity
Expand All @@ -231,8 +233,7 @@ def logprob(x):
return logprior + self.loglike(x)

logger.debug("Setting up EnsembleSampler")



with Pool(processes=n_processes) as pool:
logger.info(f"parallel sampling using multiprocessing with {pool}")
sampler = emcee.EnsembleSampler(
Expand Down Expand Up @@ -260,9 +261,9 @@ def logprob(x):
)
sampler.reset()

# ............................................................................ #
# Sampling of the posterior #
# ............................................................................ #
# ............................................................................ #
# Sampling of the posterior #
# ............................................................................ #
sampler.run_mcmc(
initial_state=state, nsteps=n_steps, progress=self.show_progress
)
Expand All @@ -287,5 +288,5 @@ def logprob(x):
# translate the results to a common data structure and return it
var_names = self.problem.get_theta_names(tex=True, components=True)
inference_data = az.from_emcee(sampler, var_names=var_names)

return inference_data

0 comments on commit 4c20182

Please sign in to comment.