Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@log_call(include_args=[],
include_result=False)
def resample(self, walkers):
# do some initialiation routines and debugging preparations if
# necessary
self._resample_init(walkers=walkers)
## assign/score the walkers, also getting changes in the
## resampler state
assignments, resampler_data = self.assign(walkers)
# make the decisions for the the walkers for only a single
# step
resampling_data = self.decide(delta_walkers=0)
@log_call(
include_args=[
'segment_length',
'cycle_idx',
],
include_result=False,
)
def run_segment(self, walkers, segment_length, cycle_idx):
"""Run a time segment for all walkers using the available workers.
Maps the work for running each segment for each walker using
the work mapper.
Walkers will have the same weights but different states.
Parameters
----------
@log_call(include_args=[],
include_result=False)
def map(self, *args, **kwargs):
"""Map the 'segment_func' to args.
Parameters
----------
*args : list of list
Each element is the argument to one call of 'segment_func'.
Returns
-------
results : list
The results of each call to 'segment_func' in the same order as input.
Examples
--------
@log_call(include_args=[],
include_result=False)
def cleanup(self, **kwargs):
"""Runtime post-simulation tasks.
This is run either at the end of a successful simulation or
upon an error in the main process of the simulation manager
call to `run_cycle`.
The Mapper class performs no actions here and all arguments
are ignored.
"""
# nothing to do
pass
@log_call
def multiply(a, b):
return 0 * b
@log_call(include_args=[],
include_result=False)
def post_cycle(self, **kwargs):
"""Perform post-cycle behavior. run_segment will be called for each
walker so this allows you to perform changes of state on a
per-cycle basis.
Parameters
----------
kwargs : key-word arguments
Key-value pairs to be interpreted by each runner implementation.
"""
# by default just pass since subclasses need not implement this
pass
@log_call
def main_computation():
bag = from_sequence([1, 2, 3])
bag = bag.map(multiply).fold(add)
return compute_with_trace(bag)[0] # instead of dask.compute(bag)
@log_call(include_args=[
'n_segment_steps',
'cycle_idx',
'runner_opts'],
include_result=False)
def run_cycle(self,
walkers,
n_segment_steps,
cycle_idx,
runner_opts=None,
):
"""Run a full cycle of weighted ensemble simulation using each
component.
The order of application of wepy components are:
- runner
@log_call
def multiplysum(a, b, c):
return multiply(add(a, b), c)
@log_call(
include_args=[
'segment_length',
'getState_kwargs',
'platform',
'platform_kwargs',
],
include_result=False,
)
def run_segment(self,
walker,
segment_length,
getState_kwargs=None,
platform=None,
platform_kwargs=None,
**kwargs):
"""Run dynamics for the walker.