import traceback
import sampling_functions

from __run_tools import get_logger
logger = get_logger(__name__)
'''
This file provides an interface for using sampling functions.
The sampling scheme should be programmed in such a function by
the user and saved in sampling_functions.py. These are called
through sampling_function defined in get_one, which handles
the arguments and provides the routines that should be replicated
for all sampling functions, currently this is simply converting
them to a runnable form, ie trajectory objects.
'''


def get_one(name_func, **sfkwargs):

    name_backup_func = 'random_sampling_trajectories'

    _sampling_function = getattr(sampling_functions, name_func)
    logger.info("Retrieved sampling function: {}".format(_sampling_function))
    backup_sampling_function = getattr(sampling_functions, name_backup_func)
    logger.info(
        "Backup sampling function: {}".format(backup_sampling_function))

    assert callable(_sampling_function)
    assert callable(backup_sampling_function)

    # Use Sampled Frames to make New Trajectories
    def sampling_function(project, engine, length, number, *args, **skwargs):
Example #2
0
    - use something like the np.choice shown in
      xplor_microstates. here the weights were given
      by a vector with probability for each state i.

 5. Returns these frames
    - these frames are converted to trajectories for execution
      by the sampling interface component, no need to do

'''
from __future__ import print_function

import numpy as np

from __run_tools import get_logger

LOGGER = get_logger(__name__)


oty    = lambda d: d['input']['modeller'].outtype
stride = lambda d: d['input']['modeller'].engine.types[oty(d)].stride
dfti   = lambda d, fi: fi/stride(d)


def long_trajectories(project, number=1, trajectories=None, uselast=True, **kwargs):
    '''
    Continually grow the same trajectories to longer total
    length.
    '''
    #Note -- This currently does not make TrajectoryExtensionTasks
    #        which would be the expected output...
    #TODO -- have this function return or indicate to interface