# 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


import numpy as np
from pyti import catch_errors
from pyti.function_helper import fill_for_noncomputable_vals
from six.moves import range
from __future__ import absolute_import


def aroon_up(data, period):
    """
    Aroon Up.

    Formula:
    AROONUP = (((PERIOD) - (PERIODS since PERIOD high)) / (PERIOD)) * 100
    """
    catch_errors.check_for_period_error(data, period)
    period = int(period)

    a_up = [((period -
            list(reversed(data[idx+1-period:idx+1])).index(np.max(data[idx+1-period:idx+1]))) /
            float(period)) * 100 for idx in range(period-1, len(data))]
    a_up = fill_for_noncomputable_vals(data, a_up)
    return a_up


def aroon_down(data, period):
    """
    Aroon Down.

    Formula:
    AROONDWN = (((PERIOD) - (PERIODS SINCE PERIOD LOW)) / (PERIOD)) * 100
    """

# 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/aroon.py
import numpy as np
from pyti import catch_errors
from pyti.function_helper import fill_for_noncomputable_vals
from six.moves import range

from __future__ import absolute_import


def aroon_up(data, period):
    """
    Aroon Up.

    Formula:
    AROONUP = (((PERIOD) - (PERIODS since PERIOD high)) / (PERIOD)) * 100
    """
    catch_errors.check_for_period_error(data, period)
    period = int(period)

    a_up = [((period -
            list(reversed(data[idx+1-period:idx+1])).index(np.max(data[idx+1-period:idx+1]))) /
            float(period)) * 100 for idx in range(period-1, len(data))]
    a_up = fill_for_noncomputable_vals(data, a_up)
    return a_up


def aroon_down(data, period):
    """
    Aroon Down.

    Formula:
    AROONDWN = (((PERIOD) - (PERIODS SINCE PERIOD LOW)) / (PERIOD)) * 100
    """

    catch_errors.check_for_period_error(data, period)