# Path: pyti/catch_errors.py
# def check_for_period_error(data, period):
# def check_for_input_len_diff(*args):
# 
# Path: pyti/function_helper.py
# def fill_for_noncomputable_vals(input_data, result_data):
#     non_computable_values = np.repeat(
#         np.nan, len(input_data) - len(result_data)
#         )
#     filled_result_data = np.append(non_computable_values, result_data)
#     return filled_result_data
# 
# Path: pyti/simple_moving_average.py
# def simple_moving_average(data, period):
#     """
#     Simple Moving Average.
# 
#     Formula:
#     SUM(data / N)
#     """
#     catch_errors.check_for_period_error(data, period)
#     # Mean of Empty Slice RuntimeWarning doesn't affect output so it is
#     # supressed
#     with warnings.catch_warnings():
#         warnings.simplefilter("ignore", category=RuntimeWarning)
#         sma = [np.mean(data[idx-(period-1):idx+1]) for idx in range(0, len(data))]
#     sma = fill_for_noncomputable_vals(data, sma)
#     return sma


import numpy as np
from pyti import catch_errors
from pyti.function_helper import fill_for_noncomputable_vals
from pyti.simple_moving_average import (
    simple_moving_average as sma
    )
from six.moves import range
                 lower_bollinger_band(data, period, std)) /
                 middle_bollinger_band(data, period, std)
                 )

    return bandwidth


def bb_range(data, period, std=2.0):
    """
    Range.

    Formula:
    bb_range = u_bb - l_bb
    """
    catch_errors.check_for_period_error(data, period)

    period = int(period)
    bb_range = (upper_bollinger_band(data, period, std) -
                lower_bollinger_band(data, period, std)
                )
    return bb_range


def percent_bandwidth(data, period, std=2.0):
    """
    Percent Bandwidth.

    Formula:
    %_bw = data() - l_bb() / bb_range()
    """

# Path: pyti/catch_errors.py
# def check_for_period_error(data, period):
# def check_for_input_len_diff(*args):
# 
# Path: pyti/function_helper.py
# def fill_for_noncomputable_vals(input_data, result_data):
#     non_computable_values = np.repeat(
#         np.nan, len(input_data) - len(result_data)
#         )
#     filled_result_data = np.append(non_computable_values, result_data)
#     return filled_result_data
# 
# Path: pyti/simple_moving_average.py
# def simple_moving_average(data, period):
#     """
#     Simple Moving Average.
# 
#     Formula:
#     SUM(data / N)
#     """
#     catch_errors.check_for_period_error(data, period)
#     # Mean of Empty Slice RuntimeWarning doesn't affect output so it is
#     # supressed
#     with warnings.catch_warnings():
#         warnings.simplefilter("ignore", category=RuntimeWarning)
#         sma = [np.mean(data[idx-(period-1):idx+1]) for idx in range(0, len(data))]
#     sma = fill_for_noncomputable_vals(data, sma)
#     return sma


# Path: pyti/bollinger_bands.py
import numpy as np
from pyti import catch_errors
from pyti.function_helper import fill_for_noncomputable_vals
from pyti.simple_moving_average import (
    simple_moving_average as sma
    )
from six.moves import range

                 lower_bollinger_band(data, period, std)) /
                 middle_bollinger_band(data, period, std)
                 )

    return bandwidth


def bb_range(data, period, std=2.0):
    """
    Range.

    Formula:
    bb_range = u_bb - l_bb
    """
    catch_errors.check_for_period_error(data, period)

    period = int(period)
    bb_range = (upper_bollinger_band(data, period, std) -
                lower_bollinger_band(data, period, std)
                )
    return bb_range


def percent_bandwidth(data, period, std=2.0):
    """
    Percent Bandwidth.

    Formula:
    %_bw = data() - l_bb() / bb_range()
    """

    catch_errors.check_for_period_error(data, period)