# Path: epistasis/models/utils.py
# def arghandler(method):
#     """Points methods to argument handlers. Assumes each argument has a
#     corresponding method attached to the object named "_{argument}". These
#     methods given default values to arguments.
# 
#     Ignores self and kwargs
#     """
#     @wraps(method)
#     def inner(self, *args, **kwargs):
#         # Get method name
#         name = method.__name__
# 
#         # Inspect function for arguments to update.
#         out = inspect.signature(method)
# 
#         # Construct kwargs from signature.
#         kws = {key: val.default for key, val in out.parameters.items()}
#         kws.pop('self')
# 
#         # Try to remove kwargs.
#         try:
#             kws.pop('kwargs')
#         except:
#             pass
# 
#         # Update kwargs with user specified kwargs.
#         kws.update(**kwargs)
# 
#         # Handle each argument
#         for arg in kws:
#             # Get handler function.
#             handler_name = "_{}".format(arg)
#             handler = getattr(self, handler_name)
#             kws[arg] = handler(data=kws[arg], method=name)
# 
#         return method(self, **kws)
#     return inner


import numpy as np
from ..stats import pearson
from .base import BaseModel
from .utils import arghandler
        X : array
            array of genotypes.

        thetas : array
            array of model parameters.
        """
        # Flatten thetas
        t = []
        idx = 0

        # Break up thetas into lists of lists
        for m in self:
            n = m.num_of_params
            t.append(list(thetas[idx:idx + n]))
            idx += n

        # Predict from last model in the list first.
        model = self[-1]
        thetas = t[-1]
        ypred = model.hypothesis_transform(X=X, thetas=thetas)

        # Then work backwards predicting/transforming until the first model.
        for i in range(-2, -(len(self)+1), -1):
            model = self[i]
            thetas = t[i]
            ypred = model.hypothesis_transform(X=X, y=ypred, thetas=thetas)

        # Return predictions
        return ypred


# Path: epistasis/models/utils.py
# def arghandler(method):
#     """Points methods to argument handlers. Assumes each argument has a
#     corresponding method attached to the object named "_{argument}". These
#     methods given default values to arguments.
# 
#     Ignores self and kwargs
#     """
#     @wraps(method)
#     def inner(self, *args, **kwargs):
#         # Get method name
#         name = method.__name__
# 
#         # Inspect function for arguments to update.
#         out = inspect.signature(method)
# 
#         # Construct kwargs from signature.
#         kws = {key: val.default for key, val in out.parameters.items()}
#         kws.pop('self')
# 
#         # Try to remove kwargs.
#         try:
#             kws.pop('kwargs')
#         except:
#             pass
# 
#         # Update kwargs with user specified kwargs.
#         kws.update(**kwargs)
# 
#         # Handle each argument
#         for arg in kws:
#             # Get handler function.
#             handler_name = "_{}".format(arg)
#             handler = getattr(self, handler_name)
#             kws[arg] = handler(data=kws[arg], method=name)
# 
#         return method(self, **kws)
#     return inner


# Path: epistasis/models/pipeline.py
import numpy as np
from ..stats import pearson
from .base import BaseModel
from .utils import arghandler

        X : array
            array of genotypes.

        thetas : array
            array of model parameters.
        """
        # Flatten thetas
        t = []
        idx = 0

        # Break up thetas into lists of lists
        for m in self:
            n = m.num_of_params
            t.append(list(thetas[idx:idx + n]))
            idx += n

        # Predict from last model in the list first.
        model = self[-1]
        thetas = t[-1]
        ypred = model.hypothesis_transform(X=X, thetas=thetas)

        # Then work backwards predicting/transforming until the first model.
        for i in range(-2, -(len(self)+1), -1):
            model = self[i]
            thetas = t[i]
            ypred = model.hypothesis_transform(X=X, y=ypred, thetas=thetas)

        # Return predictions
        return ypred


    @arghandler