# 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


import numpy as np
from impyute.ops import matrix
from impyute.ops import wrapper
            left_i = max(0, y_i-wside_left)
            right_i = min(len(data), y_i+wside_right+1)
            window = data[x_i, left_i: right_i]
            window_not_null = window[~np.isnan(window)]

            if len(window_not_null) > 0:
                try:
                    data[x_i][y_i] = func(window_not_null)
                    continue
                except Exception as e:
                    if errors == "raise":
                        raise e

            if errors == "coerce":
                # If either the window has a length of 0 or the aggregate function fails somehow,
                # do a fallback of just trying the best we can by using it as the middle and trying
                # to recalculate. Use temporary wside_left/wside_right, for only the calculation of
                # this specific problamatic value
                wside_left_tmp = wsize // 2
                wside_right_tmp = wside_left_tmp

                left_i_tmp = max(0, y_i-wside_left_tmp)
                right_i_tmp = min(len(data), y_i+wside_right_tmp+1)

                window = data[x_i, left_i_tmp:right_i_tmp]
                window_not_null = window[~np.isnan(window)]
                try:
                    data[x_i][y_i] = func(window_not_null)
                except Exception as e:
                    print("Exception:", e)

# 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/imputation/ts/moving_window.py
import numpy as np
from impyute.ops import matrix
from impyute.ops import wrapper

            left_i = max(0, y_i-wside_left)
            right_i = min(len(data), y_i+wside_right+1)
            window = data[x_i, left_i: right_i]
            window_not_null = window[~np.isnan(window)]

            if len(window_not_null) > 0:
                try:
                    data[x_i][y_i] = func(window_not_null)
                    continue
                except Exception as e:
                    if errors == "raise":
                        raise e

            if errors == "coerce":
                # If either the window has a length of 0 or the aggregate function fails somehow,
                # do a fallback of just trying the best we can by using it as the middle and trying
                # to recalculate. Use temporary wside_left/wside_right, for only the calculation of
                # this specific problamatic value
                wside_left_tmp = wsize // 2
                wside_right_tmp = wside_left_tmp

                left_i_tmp = max(0, y_i-wside_left_tmp)
                right_i_tmp = min(len(data), y_i+wside_right_tmp+1)

                window = data[x_i, left_i_tmp:right_i_tmp]
                window_not_null = window[~np.isnan(window)]
                try:
                    data[x_i][y_i] = func(window_not_null)
                except Exception as e:
                    print("Exception:", e)

        if n_nan_prev == len(matrix.nan_indices(data)):