# Path: impyute/ops/matrix.py
# def nan_indices(data):
# def map_nd(fn, arr):
# def every_nd(fn, arr):
# 
# Path: impyute/ops/wrapper.py
# @wraps(fn)
# def wrapper(*args, **kwargs):
#     postprocess_fn = None
#     ## convert tuple to list so args can be modified
#     args = list(args)
#     ## Either make a copy or use a pointer to the original
#     if kwargs.get('inplace'):
#         args[0] = args[0]
#     else:
#         args[0] = args[0].copy()
# 
#     ## If input data is a dataframe then cast the input to an np.array
#     ## and set an indicator flag before continuing
#     pd_DataFrame = get_pandas_df()
#     if pd_DataFrame and isinstance(args[0], pd_DataFrame):
#         postprocess_fn = pd_DataFrame
#         args[0] = args[0].values
# 
#     ## function invokation
#     results = u.execute_fn_with_args_and_or_kwargs(fn, args, kwargs)
# 
#     ## cast the output back to a DataFrame.
#     if postprocess_fn is not None:
#         results = postprocess_fn(results)
# 
#     return results
# 
# Path: impyute/ops/error.py
# class BadInputError(Exception):
# class BadOutputError(Exception):


import numpy as np
from impyute.ops import matrix
from impyute.ops import wrapper
from impyute.ops import error
@wrapper.wrappers
@wrapper.checks
def locf(data, axis=0):
    """ Last Observation Carried Forward

    For each set of missing indices, use the value of one row before(same
    column). In the case that the missing value is the first row, look one
    row ahead instead. If this next row is also NaN, look to the next row.
    Repeat until you find a row in this column that's not NaN. All the rows
    before will be filled with this value.

    Parameters
    ----------
    data: numpy.ndarray
        Data to impute.
    axis: boolean (optional)
        0 if time series is in row format (Ex. data[0][:] is 1st data point).
        1 if time series is in col format (Ex. data[:][0] is 1st data point).

    Returns
    -------
    numpy.ndarray
        Imputed data.

    """
    if axis == 0:
        data = np.transpose(data)
    elif axis == 1:
        pass
    else:

# Path: impyute/ops/matrix.py
# def nan_indices(data):
# def map_nd(fn, arr):
# def every_nd(fn, arr):
# 
# Path: impyute/ops/wrapper.py
# @wraps(fn)
# def wrapper(*args, **kwargs):
#     postprocess_fn = None
#     ## convert tuple to list so args can be modified
#     args = list(args)
#     ## Either make a copy or use a pointer to the original
#     if kwargs.get('inplace'):
#         args[0] = args[0]
#     else:
#         args[0] = args[0].copy()
# 
#     ## If input data is a dataframe then cast the input to an np.array
#     ## and set an indicator flag before continuing
#     pd_DataFrame = get_pandas_df()
#     if pd_DataFrame and isinstance(args[0], pd_DataFrame):
#         postprocess_fn = pd_DataFrame
#         args[0] = args[0].values
# 
#     ## function invokation
#     results = u.execute_fn_with_args_and_or_kwargs(fn, args, kwargs)
# 
#     ## cast the output back to a DataFrame.
#     if postprocess_fn is not None:
#         results = postprocess_fn(results)
# 
#     return results
# 
# Path: impyute/ops/error.py
# class BadInputError(Exception):
# class BadOutputError(Exception):


# Path: impyute/imputation/ts/locf.py
import numpy as np
from impyute.ops import matrix
from impyute.ops import wrapper
from impyute.ops import error

@wrapper.wrappers
@wrapper.checks
def locf(data, axis=0):
    """ Last Observation Carried Forward

    For each set of missing indices, use the value of one row before(same
    column). In the case that the missing value is the first row, look one
    row ahead instead. If this next row is also NaN, look to the next row.
    Repeat until you find a row in this column that's not NaN. All the rows
    before will be filled with this value.

    Parameters
    ----------
    data: numpy.ndarray
        Data to impute.
    axis: boolean (optional)
        0 if time series is in row format (Ex. data[0][:] is 1st data point).
        1 if time series is in col format (Ex. data[:][0] is 1st data point).

    Returns
    -------
    numpy.ndarray
        Imputed data.

    """
    if axis == 0:
        data = np.transpose(data)
    elif axis == 1:
        pass
    else:

        raise error.BadInputError("Error: Axis value is invalid, please use either 0 (row format) or 1 (column format)")