# - Generated by tools/entrypoint_compiler.py: do not edit by hand
"""
TimeSeriesProcessing.PercentileThresholdTransform
"""

import numbers

from ..utils.entrypoints import EntryPoint
from ..utils.utils import try_set, unlist


def timeseriesprocessing_percentilethresholdtransform(
        source,
        data,
        name,
        output_data=None,
        model=None,
        percentile=1.0,
        window_size=1,
        **params):
    """
    **Description**
        Detects the values of time-series that are in the top percentile of
        the sliding window.

    :param source: The name of the source column (inputs).
    :param data: Input dataset (inputs).
    :param name: The name of the new column (inputs).
    :param percentile: The percentile value for thresholding in the
        range [0, 100] (inputs).
    :param window_size: The size of the sliding window for computing
        the percentile threshold. The default value is set to 1.
        (inputs).
    :param output_data: Transformed dataset (outputs).
    :param model: Transform model (outputs).
    """

    entrypoint_name = 'TimeSeriesProcessing.PercentileThresholdTransform'
    inputs = {}
    outputs = {}

    if source is not None:
        inputs['Source'] = try_set(
            obj=source,
            none_acceptable=False,
            is_of_type=str,
            is_column=True)
    if data is not None:
        inputs['Data'] = try_set(
            obj=data,
            none_acceptable=False,
            is_of_type=str)
    if name is not None:
        inputs['Name'] = try_set(
            obj=name,
            none_acceptable=False,
            is_of_type=str,
            is_column=True)
    if percentile is not None:
        inputs['Percentile'] = try_set(
            obj=percentile,
            none_acceptable=True,
            is_of_type=numbers.Real)
    if window_size is not None:
        inputs['WindowSize'] = try_set(
            obj=window_size,
            none_acceptable=True,
            is_of_type=numbers.Real)
    if output_data is not None:
        outputs['OutputData'] = try_set(
            obj=output_data,
            none_acceptable=False,
            is_of_type=str)
    if model is not None:
        outputs['Model'] = try_set(
            obj=model,
            none_acceptable=False,
            is_of_type=str)

    input_variables = {
        x for x in unlist(inputs.values())
        if isinstance(x, str) and x.startswith("$")}
    output_variables = {
        x for x in unlist(outputs.values())
        if isinstance(x, str) and x.startswith("$")}

    entrypoint = EntryPoint(
        name=entrypoint_name, inputs=inputs, outputs=outputs,
        input_variables=input_variables,
        output_variables=output_variables)
    return entrypoint
