# Path: pyglm/models/model_factory.py
# def make_model(template, N=None, dt=None):
#     """ Construct a model from a template and update the specified parameters
#     """
#     if isinstance(template, str):
#         # Create the specified model
#         if template.lower() == 'standard_glm' or \
#            template.lower() == 'standardglm':
#             model = copy.deepcopy(StandardGlm)
#         elif template.lower() == 'spatiotemporal_glm':
#             model = copy.deepcopy(SpatiotemporalGlm)
#         elif template.lower() == 'shared_tuning_curve':
#             model = copy.deepcopy(SharedTuningCurveGlm)
#         elif template.lower() == 'simple_weighted_model' or \
#              template.lower() == 'simpleweightedmodel':
#             model = copy.deepcopy(SimpleWeightedModel)
#         elif template.lower() == 'simple_sparse_model' or \
#              template.lower() == 'simplesparsemodel':
#             model = copy.deepcopy(SimpleSparseModel)
#         elif template.lower() == 'sparse_weighted_model' or \
#              template.lower() == 'sparseweightedmodel':
#             model = copy.deepcopy(SparseWeightedModel)
#         elif template.lower() == 'sbm_weighted_model' or \
#              template.lower() == 'sbmweightedmodel':
#             model = copy.deepcopy(SbmWeightedModel)
#         elif template.lower() == 'distance_weighted_model' or \
#              template.lower() == 'distanceweightedmodel':
#             model = copy.deepcopy(DistanceWeightedModel)
#         else:
#             raise Exception("Unrecognized template model: %s!" % template)
#     elif isinstance(template, dict):
#         model = copy.deepcopy(template)
#     else:
#         raise Exception("Unrecognized template model!")
# 
#     # Override template model parameters
#     if N is not None:
#         model['N'] = N
# 
#     if dt is not None:
#         model['dt'] = dt
# 
#     # # Update other parameters as necessary
#     # if template.lower() == 'distance_weighted_model' or \
#     #    template.lower() == 'distanceweightedmodel':
#     #     #model['network']['graph']['location_prior']['sigma'] = N/2.0/3.0
#     #     model['network']['graph']['location_prior']['mu'] = \
#     #         np.tile(np.arange(N).reshape((N,1)),
#     #                 [1,model['network']['graph']['N_dims']]).ravel()
# 
#     return model


import cPickle
from IPython.parallel import Client
from synth_harness import parse_cmd_line_args
from pyglm.models.model_factory import make_model
from population import Population

    return data

def load_imports_on_client(dview):
    """ Import required modules on client
    """
    dview.execute('from population import Population')
    dview.execute('popn = None')

def initialize_client(model, data):
    """ Initialize a population objsect on the client
    """
    # Initialize a model with N neurons
    print "Initializing GLM"
    global popn
    popn = Population(model)

    # Initialize the GLM with the data
    popn.set_data(data)

def run_parallel_map():
    """ Run a test with synthetic data and MCMC inference
    """
    # Parse command line args
    (options, args) = parse_cmd_line_args()

    # Load the data
    data = load_data(options)
    # Get a model for the data
    model_type = 'standard_glm'

# Path: pyglm/models/model_factory.py
# def make_model(template, N=None, dt=None):
#     """ Construct a model from a template and update the specified parameters
#     """
#     if isinstance(template, str):
#         # Create the specified model
#         if template.lower() == 'standard_glm' or \
#            template.lower() == 'standardglm':
#             model = copy.deepcopy(StandardGlm)
#         elif template.lower() == 'spatiotemporal_glm':
#             model = copy.deepcopy(SpatiotemporalGlm)
#         elif template.lower() == 'shared_tuning_curve':
#             model = copy.deepcopy(SharedTuningCurveGlm)
#         elif template.lower() == 'simple_weighted_model' or \
#              template.lower() == 'simpleweightedmodel':
#             model = copy.deepcopy(SimpleWeightedModel)
#         elif template.lower() == 'simple_sparse_model' or \
#              template.lower() == 'simplesparsemodel':
#             model = copy.deepcopy(SimpleSparseModel)
#         elif template.lower() == 'sparse_weighted_model' or \
#              template.lower() == 'sparseweightedmodel':
#             model = copy.deepcopy(SparseWeightedModel)
#         elif template.lower() == 'sbm_weighted_model' or \
#              template.lower() == 'sbmweightedmodel':
#             model = copy.deepcopy(SbmWeightedModel)
#         elif template.lower() == 'distance_weighted_model' or \
#              template.lower() == 'distanceweightedmodel':
#             model = copy.deepcopy(DistanceWeightedModel)
#         else:
#             raise Exception("Unrecognized template model: %s!" % template)
#     elif isinstance(template, dict):
#         model = copy.deepcopy(template)
#     else:
#         raise Exception("Unrecognized template model!")
# 
#     # Override template model parameters
#     if N is not None:
#         model['N'] = N
# 
#     if dt is not None:
#         model['dt'] = dt
# 
#     # # Update other parameters as necessary
#     # if template.lower() == 'distance_weighted_model' or \
#     #    template.lower() == 'distanceweightedmodel':
#     #     #model['network']['graph']['location_prior']['sigma'] = N/2.0/3.0
#     #     model['network']['graph']['location_prior']['mu'] = \
#     #         np.tile(np.arange(N).reshape((N,1)),
#     #                 [1,model['network']['graph']['N_dims']]).ravel()
# 
#     return model


# Path: test/parallel_map.py
import cPickle
from IPython.parallel import Client
from synth_harness import parse_cmd_line_args
from pyglm.models.model_factory import make_model
from population import Population


    return data

def load_imports_on_client(dview):
    """ Import required modules on client
    """
    dview.execute('from population import Population')
    dview.execute('popn = None')

def initialize_client(model, data):
    """ Initialize a population objsect on the client
    """
    # Initialize a model with N neurons
    print "Initializing GLM"
    global popn
    popn = Population(model)

    # Initialize the GLM with the data
    popn.set_data(data)

def run_parallel_map():
    """ Run a test with synthetic data and MCMC inference
    """
    # Parse command line args
    (options, args) = parse_cmd_line_args()

    # Load the data
    data = load_data(options)
    # Get a model for the data
    model_type = 'standard_glm'

    model = make_model(model_type, N=data['N'])