def train_and_test_partition(inputs, targets, train_part, test_part):
    """
    Splits a data matrix (or design matrix) and associated targets into train
    and test parts.

    parameters
    ----------
    inputs - a 2d numpy array whose rows are the data points, or can be a design
        matrix, where rows are the feature vectors for data points.
    targets - a 1d numpy array whose elements are the targets.
    train_part - A list (or 1d array) of N booleans, where N is the number of
        data points. If the ith element is true, then the ith data point will be
        added to the training data.
    test_part - (like train_part), but specifying the test points.

    returns
    -------     
    train_inputs - the training input matrix
    train_targets - the training targets
    test_inputs - the test input matrix
    test_targets - the test targets
    """

    # getting the indices of the train and test portion
    if len(inputs.shape) == 1:
        # if inputs is a sequence of scalars, we should reshape into a matrix
        inputs = inputs.reshape((inputs.size, 1))

    # getting the indices of the train and test portion
    train_inputs = inputs[train_part, :]
    test_inputs = inputs[test_part, :]
    train_targets = targets[train_part]
    test_targets = targets[test_part]

    return train_inputs, train_targets, test_inputs, test_targets