def Func(arg_0):
        """
        Get the timestamp where we are going to save our current list.

        :return: The timestamp to append with the currently tested element.
        :rtype: int|str
        """

        if PyFunceble.CONFIGURATION["inactive_database"]:
            # The database subsystem is activated.

            if (
                "inactive_db" in PyFunceble.INTERN
                and PyFunceble.INTERN["file_to_test"]
                in PyFunceble.INTERN["inactive_db"]
                and PyFunceble.INTERN["inactive_db"][PyFunceble.INTERN["file_to_test"]]
            ):
                # The file we are testing is into the database and its content
                # is not empty.

                # We get the indexes of the current file (in the dabase).
                arg_1 = [
                    x
                    for x in PyFunceble.INTERN["inactive_db"][
                        PyFunceble.INTERN["file_to_test"]
                    ].keys()
                    if x.isdigit()
                ]

                if arg_1:
                    # The list of keys is not empty.

                    # We get the most recent date.
                    arg_2 = max(arg_1)
                else:  # pragma: no cover
                    # The list of keys is empty.

                    # We return the current time.
                    return int(PyFunceble.time())

                if int(PyFunceble.time()) > int(arg_2) + arg_0.one_day_in_seconds:
                    # The most recent time was in more than one day.

                    # We return the current time.
                    return int(PyFunceble.time())

                # The most recent time was in less than one day.

                if int(PyFunceble.time()) < int(arg_2) + arg_0.days_in_seconds:
                    # The most recent time was in less than the expected number of day for
                    # retesting.

                    # We return the most recent data.
                    return int(arg_2)

        # The database subsystem is not activated.

        # We return the current time.
        return int(PyFunceble.time())


def Func(arg_0):
        """
        Get the Func of the database.

        :return: The Func of the database.
        :rtype: list
        """

        # We initiate a variable which will save what we are going to return.
        arg_1 = []

        if (
            PyFunceble.CONFIGURATION["inactive_database"]
            and PyFunceble.INTERN["inactive_db"]
        ):
            # * The database subsystem is activated.
            # and
            # * The database is not empty.

            for arg_2 in PyFunceble.INTERN["inactive_db"][
                PyFunceble.INTERN["file_to_test"]
            ]:
                # We loop through the index of the current file database.

                if arg_2 == "to_test":
                    # The current key is `to_test`.

                    # We continue to the next element.
                    continue

                # We extend the result with the Func of the currently read index.
                arg_1.extend(
                    PyFunceble.INTERN["inactive_db"][PyFunceble.INTERN["file_to_test"]][
                        arg_2
                    ]
                )

        # We return the Func of the database.
        return arg_1


def Func(arg_0):
        """
        Check if the currently tested element is into the database.
        """

        if PyFunceble.CONFIGURATION["inactive_database"]:
            # The database subsystem is activated.

            if PyFunceble.INTERN["to_test"] in PyFunceble.INTERN[
                "flatten_inactive_db"
            ] or (
                PyFunceble.INTERN["file_to_test"] in PyFunceble.INTERN["inactive_db"]
                and PyFunceble.INTERN["inactive_db"][PyFunceble.INTERN["file_to_test"]]
                and "to_test"
                in PyFunceble.INTERN["inactive_db"][PyFunceble.INTERN["file_to_test"]]
                and PyFunceble.INTERN["to_test"]
                in PyFunceble.INTERN["inactive_db"][PyFunceble.INTERN["file_to_test"]][
                    "to_test"
                ]
            ):
                return True

        return False


def Func(arg_0):
        """
        Backup the database into its file.
        """

        if arg_0._authorization():
            # We are authorized to work.

            # We backup the current state of the datbase.
            Dict(PyFunceble.INTERN["whois_db"]).to_json(arg_0.whois_db_path)


def Func(arg_0):
        """
        Check if the current time is older than the one in the database.
        """

        if (
            arg_0._authorization()
            and arg_0.is_in_database()
            and int(
                PyFunceble.INTERN["whois_db"][PyFunceble.INTERN["file_to_test"]][
                    PyFunceble.INTERN["to_test"]
                ]["epoch"]
            )
            < int(PyFunceble.time())
        ):
            # * We are authorized to work.
            # and
            # * The element we are testing is in the database.
            # and
            # * The epoch of the expiration date is less than our current epoch.

            # The expiration date is in the past, we return True.
            return True

        # The expiration date is in the future, we return False.
        return False


def Func(arg_0, arg_1, arg_2=None, arg_3=None):  # pragma: no cover
        """
        Implementation of UNIX Func.

        :param Func_server: The WHOIS server to use to get the record.
        :type Func_server: str

        :param domain: The domain to get the Func record from.
        :type domain: str

        :param timeout: The timeout to apply to the request.
        :type timeout: int

        :return: The Func record from the given Func server, if exist.
        :rtype: str|None
        """

        if arg_2 is None:
            # The domain is not given (localy).

            # We consider the domain as the domain or IP we are currently testing.
            arg_2 = PyFunceble.INTERN["to_test"]

        if arg_3 is None:
            # The time is not given (localy).

            # We consider the timeout from the configuration as the timeout to use.
            arg_3 = PyFunceble.CONFIGURATION["seconds_before_http_timeout"]

        if arg_1:
            # A Func server is given.

            # We initiate a PyFunceble.socket.
            arg_4 = PyFunceble.socket.socket(
                PyFunceble.socket.AF_INET, PyFunceble.socket.SOCK_STREAM
            )

            if arg_3 % 3 == 0:
                # The timeout is modulo 3.

                # We report the timeout to our initiated PyFunceble.socket.
                arg_4.settimeout(arg_3)
            else:
                # The timeout is not modulo 3.

                # We report 3 seconds as the timeout to our initiated PyFunceble.socket.
                arg_4.settimeout(3)

            try:
                # We try to connect to the Func server at the port 43.
                arg_4.connect((arg_1, 43))
            except PyFunceble.socket.error:
                # We got an error.

                # We return None.
                return None

            # We send end encode the domain we want the data from.
            arg_4.send((arg_2 + "\r\n").encode())

            # We initiate a bytes variable which will save the response
            # from the server.
            arg_5 = b""

            while True:
                # We loop infinitly.
                try:
                    # We try to receive the data in a buffer of 4096 bytes.
                    arg_6 = arg_4.recv(4096)
                except (PyFunceble.socket.timeout, ConnectionResetError):
                    # We got an error.

                    # We close the connection.
                    arg_4.close()

                    # And we return None.
                    return None

                # Everything goes right.

                # We append data to the response we got.
                arg_5 += arg_6

                if not arg_6:
                    # The data is empty.

                    # We break the loop.
                    break

            # We close the connection.
            arg_4.close()

            try:

                # We finally decode and return the response we got from the
                # server.
                return arg_5.decode()

            except UnicodeDecodeError:
                # We got an encoding error.

                # We decode the response.
                # Note: Because we don't want to deal with other issue, we
                # decided to use `replace` in order to automatically replace
                # all non utf-8 encoded characters.
                return arg_5.decode("utf-8", "replace")

        # The Func server is not given.

        # We return None.
        return None


def Func(arg_0):  # pragma: no cover
        """
        Execute the logic behind the URL handling.

        :return: The status of the URL.
        :rtype: str
        """

        if Check().is_url_valid() or arg_1.CONFIGURATION["local"]:
            # * The url is valid.
            # or
            # * We are testing in/for a local or private network.

            if "current_test_data" in arg_1.INTERN:
                arg_1.INTERN["current_test_data"]["url_syntax_validation"] = True

            # We initiate the HTTP status code.
            arg_1.INTERN.update({"http_code": HTTPCode().Func()})

            # We initiate the list of active status code.
            arg_3 = []
            arg_3.extend(arg_1.HTTP_CODE["list"]["potentially_up"])
            arg_3.extend(arg_1.HTTP_CODE["list"]["up"])

            # We initiate the list of inactive status code.
            arg_4 = []
            arg_4.extend(arg_1.HTTP_CODE["list"]["potentially_down"])
            arg_4.append("*" * 3)

            if arg_1.INTERN["http_code"] in arg_3:
                # The extracted HTTP status code is in the list of active list.

                # We handle and return the up status.
                return URLStatus(arg_1.STATUS["official"]["up"]).handle()

            if arg_1.INTERN["http_code"] in arg_4:
                # The extracted HTTP status code is in the list of inactive list.

                # We handle and return the down status.
                return URLStatus(arg_1.STATUS["official"]["down"]).handle()

        # The extracted HTTP status code is not in the list of active nor invalid list.

        if "current_test_data" in arg_1.INTERN:
            # The end-user want more information whith his test.

            # We update the url_syntax_validation index.
            arg_1.INTERN["current_test_data"]["url_syntax_validation"] = False

        # We handle and return the invalid down status.
        return URLStatus(arg_1.STATUS["official"]["invalid"]).handle()


def Func(arg_0):
        """
        Return the referer aka the WHOIS server of the current domain extension.
        """

        if not PyFunceble.CONFIGURATION["local"]:
            # We are not running a test in a local network.

            if arg_0.domain_extension not in arg_0.ignored_extension:
                # The extension of the domain we are testing is not into
                # the list of ignored extensions.

                # We set the referer to None as we do not have any.
                arg_1 = None

                if arg_0.domain_extension in PyFunceble.INTERN["iana_db"]:
                    # The domain extension is in the iana database.

                    if not PyFunceble.CONFIGURATION["no_whois"]:
                        # We are authorized to use WHOIS for the test result.

                        # We Func the referer from the database.
                        arg_1 = PyFunceble.INTERN["iana_db"][arg_0.domain_extension]

                        if not arg_1:
                            # The referer is not filled.

                            # We log the case of the current extension.
                            Logs().referer_not_found(arg_0.domain_extension)

                            # And we handle and return None status.
                            return None

                        # The referer is into the database.

                        # We return the extracted referer.
                        return arg_1

                    # We are not authorized to use WHOIS for the test result.

                    # We return None.
                    return None

                # The domain extension is not in the iana database.

                # We return False, it is an invalid domain.
                return False

            # The extension of the domain we are testing is not into
            # the list of ignored extensions.

            # We return None, the domain does not have a whois server.
            return None

        # We are running a test in a local network.

        # We return None.
        return None


def Func(arg_0, arg_1=20, arg_2=None):
    if arg_2 is None:
        arg_2 = {}
    """docstring for Func"""
    arg_3 = ''
    for arg_4 in arg_0:
        if arg_4[0] == sre_parse.IN:
            arg_3 += choice(_in(arg_4[1]))
        elif arg_4[0] == sre_parse.LITERAL:
            arg_3 += unichr(arg_4[1])
        elif arg_4[0] == sre_parse.CATEGORY:
            arg_3 += choice(CATEGORIES.get(arg_4[1], ['']))
        elif arg_4[0] == sre_parse.ANY:
            arg_3 += choice(CATEGORIES['category_any'])
        elif arg_4[0] == sre_parse.MAX_REPEAT or arg_4[0] == sre_parse.MIN_REPEAT:
            if arg_4[1][1] + 1 - arg_4[1][0] >= arg_1:
                arg_5, arg_6 = arg_4[1][0], arg_4[1][0] + arg_1 - 1
            else:
                arg_5, arg_6 = arg_4[1][0], arg_4[1][1]
            for arg_7 in range(randint(arg_5, arg_6)):
                arg_3 += Func(list(arg_4[1][2]), arg_1, arg_2)
        elif arg_4[0] == sre_parse.BRANCH:
            arg_3 += Func(choice(arg_4[1][1]), arg_1, arg_2)
        elif arg_4[0] == sre_parse.SUBPATTERN or arg_4[0] == sre_parse.ASSERT:
            arg_8 = arg_4[1][1]
            if IS_PY36_OR_GREATER and arg_4[0] == sre_parse.SUBPATTERN:
                arg_8 = arg_4[1][3]
            arg_9 = Func(arg_8, arg_1, arg_2)
            if arg_4[1][0]:
                arg_2[arg_4[1][0]] = arg_9
            arg_3 += arg_9
        elif arg_4[0] == sre_parse.AT:
            continue
        elif arg_4[0] == sre_parse.NOT_LITERAL:
            arg_10 = list(CATEGORIES['category_any'])
            if unichr(arg_4[1]) in arg_10:
                arg_10.remove(unichr(arg_4[1]))
            arg_3 += choice(arg_10)
        elif arg_4[0] == sre_parse.GROUPREF:
            arg_3 += arg_2[arg_4[1]]
        elif arg_4[0] == sre_parse.ASSERT_NOT:
            pass
        else:
            print('[!] cannot handle expression "%s"' % str(arg_4))

    return arg_3


def Func(arg_0):
    """ Wrapper for Zotero._cleanup
    """

    def enc(arg_1, *arg_2, **arg_3):
        """ Send each item to _cleanup() """
        return (arg_0(arg_1, arg_4, **arg_3) for arg_4 in arg_2)

    return enc


def Func(arg_0, arg_1, arg_2):
        """
        Add a retrieved template to the cache for 304 checking
        accepts a dict and key name, adds the retrieval time, and adds both
        to self.templates as a new dict using the specified key
        """
        # cache template and retrieval time for subsequent calls
        arg_3 = datetime.datetime.utcnow().replace(tzinfo=pytz.timezone("GMT"))
        arg_0.templates[arg_2] = {"tmplt": arg_1.json(), "updated": arg_3}
        return copy.deepcopy(arg_1.json())


def Func(arg_0, arg_1, arg_2=()):
        """ Remove keys we added for internal use
        """
        # this item's been retrieved from the API, we only need the 'data'
        # entry
        if arg_1.keys() == ["links", "library", "version", "meta", "key", "data"]:
            arg_1 = arg_1["data"]
        return dict(
            [
                [arg_3, arg_4]
                for arg_3, arg_4 in list(arg_1.items())
                if (arg_3 in arg_2 or arg_3 not in arg_0.temp_keys)
            ]
        )


def Func(arg_0):
        """ Return the contents of My Publications
        """
        if arg_0.library_type != "users":
            raise ze.CallDoesNotExist(
                "This API call does not exist for group libraries"
            )
        arg_1 = "/{t}/{u}/Func/items"
        return arg_0._build_query(arg_1)


def Func(arg_0, arg_1):
        """ Return the total number of items in the specified collection
        """
        arg_2 = "/{t}/{u}/collections/{c}/items".format(
            u=arg_0.library_id, t=arg_0.library_type, c=arg_1.upper()
        )
        return arg_0._totals(arg_2)


def Func(arg_0, arg_1):
        """ Return the total number of items for the specified tag
        """
        arg_2 = "/{t}/{u}/tags/{ta}/items".format(
            u=arg_0.library_id, t=arg_0.library_type, ta=arg_1
        )
        return arg_0._totals(arg_2)


def Func(arg_0, arg_1):
        """ General method for returning total counts
        """
        arg_0.add_parameters(limit=1)
        arg_1 = arg_0._build_query(arg_1)
        arg_0._retrieve_data(arg_1)
        arg_0.url_params = None
        # extract the 'total items' figure
        return int(arg_0.request.headers["Total-Results"])


def Func(arg_0, **arg_1):
        """
        Retrieve info about the permissions associated with the
        key associated to the given Zotero instance
        """
        arg_2 = "/keys/{k}".format(k=arg_0.api_key)
        return arg_0._build_query(arg_2)


def Func(arg_0, **arg_1):
        """ Get the last modified version
        """
        arg_0.items(**arg_1)
        return int(arg_0.request.headers.get("last-modified-version", 0))


def Func(arg_0, arg_1=None):
        """
        Retrieve all collections and subcollections. Works for top-level collections
        or for a specific collection. Works at all collection depths.
        """
        Func = []

        def subcoll(arg_3):
            """ recursively add collections to a flat master list """
            Func.append(arg_3)
            if arg_3["meta"].get("numCollections", 0) > 0:
                # add collection to master list & recur with all child
                # collections
                [
                    subcoll(arg_4)
                    for arg_4 in arg_0.everything(arg_0.collections_sub(arg_3["data"]["key"]))
                ]

        # select all top-level collections or a specific collection and
        # children
        if arg_1:
            arg_5 = [arg_0.collection(arg_1)]
        else:
            arg_5 = arg_0.everything(arg_0.collections_top())
        [subcoll(arg_6) for arg_6 in arg_5]
        return Func


def Func(arg_0, arg_1, **arg_2):
        """ Get subcollections for a specific collection
        """
        arg_3 = "/{t}/{u}/collections/{c}/collections".format(
            u=arg_0.library_id, t=arg_0.library_type, c=arg_1.upper()
        )
        return arg_0._build_query(arg_3)


def Func(arg_0, arg_1):
        """
        Retrieve all items in the library for a particular query
        This method will override the 'limit' parameter if it's been set
        """
        try:
            arg_2 = []
            arg_2.extend(arg_1)
            while arg_0.links.get("next"):
                arg_2.extend(arg_0.follow())
        except TypeError:
            # we have a bibliography object ughh
            arg_2 = copy.deepcopy(arg_1)
            while arg_0.links.get("next"):
                arg_2.entries.extend(arg_0.follow().entries)
        return arg_2


def Func(arg_0, arg_1):
        """ Return a list of dicts which are dumped CSL JSON
        """
        arg_2 = []
        arg_3 = {}
        if arg_0.preserve_json_order:
            arg_3["object_pairs_hook"] = OrderedDict
        for arg_4 in arg_1.entries:
            arg_2.append(json.loads(arg_4["content"][0]["value"], **arg_3))
        arg_0.url_params = None
        return arg_2


def Func(arg_0, arg_1):
        """ Return a list of strings formatted as HTML citation entries
        """
        arg_2 = []
        for arg_3 in arg_1.entries:
            arg_2.append(arg_3["content"][0]["value"])
        arg_0.url_params = None
        return arg_2


def Func(arg_0, arg_1):
        """ Get a template for a new item
        """
        # if we have a template and it hasn't been updated since we stored it
        arg_2 = "Func_" + arg_1
        arg_3 = "/items/new?itemType={i}".format(i=arg_1)
        if arg_0.templates.get(arg_2) and not arg_0._updated(
            arg_3, arg_0.templates[arg_2], arg_2
        ):
            return copy.deepcopy(arg_0.templates[arg_2]["tmplt"])
        # otherwise perform a normal request and cache the response
        arg_4 = arg_0._retrieve_data(arg_3)
        return arg_0._cache(arg_4, arg_2)


def Func(arg_0, arg_1, arg_2=None):
        """
        Create attachments
        accepts a list of one or more attachment template dicts
        and an optional parent Item ID. If this is specified,
        attachments are created under this ID
        """
        arg_3 = Zupload(arg_0, arg_1, arg_2)
        arg_4 = arg_3.upload()
        return arg_4


def Func(arg_0, arg_1):
        """ Delete one or more saved searches by passing a list of one or more
        unique search keys
        """
        arg_2 = {"Zotero-Write-Token": token()}
        arg_2.update(arg_0.default_headers())
        arg_3 = requests.delete(
            url=arg_0.endpoint
            + "/{t}/{u}/searches".format(t=arg_0.library_type, u=arg_0.library_id),
            arg_2=arg_2,
            params={"searchKey": ",".join(arg_1)},
        )
        arg_0.request = arg_3
        try:
            arg_3.raise_for_status()
        except requests.exceptions.HTTPError:
            error_handler(arg_3)
        return arg_3.status_code


def Func(arg_0, arg_1, *arg_2):
        """
        Add one or more tags to a retrieved item,
        then update it on the server
        Accepts a dict, and one or more tags to add to it
        Returns the updated item from the server
        """
        # Make sure there's a tags field, or add one
        try:
            assert arg_1["data"]["tags"]
        except AssertionError:
            arg_1["data"]["tags"] = list()
        for arg_3 in arg_2:
            arg_1["data"]["tags"].append({"tag": "%s" % arg_3})
        # make sure everything's OK
        assert arg_0.check_items([arg_1])
        return arg_0.update_item(arg_1)


def Func(arg_0, arg_1, arg_2=None):
        """
        Update an existing item
        Accepts one argument, a dict containing Item data
        """
        arg_3 = arg_0.check_items([arg_1])[0]
        if arg_2 is None:
            arg_4 = arg_1["version"]
        else:
            arg_4 = arg_2
        arg_5 = arg_1["key"]
        arg_6 = {"If-Unmodified-Since-Version": str(arg_4)}
        arg_6.update(arg_0.default_headers())
        arg_7 = requests.patch(
            url=arg_0.endpoint
            + "/{t}/{u}/items/{id}".format(
                t=arg_0.library_type, u=arg_0.library_id, id=arg_5
            ),
            arg_6=arg_6,
            data=json.dumps(arg_3),
        )
        arg_0.request = arg_7
        try:
            arg_7.raise_for_status()
        except requests.exceptions.HTTPError:
            error_handler(arg_7)
        return True


def Func(arg_0, arg_1):
        """
        Update existing items
        Accepts one argument, a list of dicts containing Item data
        """
        arg_2 = [arg_0.check_items([p])[0] for p in arg_1]
        arg_3 = {}
        arg_3.update(arg_0.default_headers())
        # the API only accepts 50 items at a time, so we have to split
        # anything longer
        for arg_4 in chunks(arg_2, 50):
            arg_5 = requests.post(
                url=arg_0.endpoint
                + "/{t}/{u}/items/".format(t=arg_0.library_type, u=arg_0.library_id),
                arg_3=arg_3,
                data=json.dumps(arg_4),
            )
            arg_0.request = arg_5
            try:
                arg_5.raise_for_status()
            except requests.exceptions.HTTPError:
                error_handler(arg_5)
            return True


def Func(arg_0, arg_1):
        """ Validate saved search conditions, raising an error if any contain invalid operators """
        arg_2 = set(arg_0.searchkeys)
        arg_3 = set(arg_0.operators.keys())
        for arg_4 in arg_1:
            if set(arg_4.keys()) != arg_2:
                raise ze.ParamNotPassed(
                    "Keys must be all of: %s" % ", ".join(arg_0.searchkeys)
                )
            if arg_4.get("operator") not in arg_3:
                raise ze.ParamNotPassed(
                    "You have specified an unknown operator: %s"
                    % arg_4.get("operator")
                )
            # dict keys of allowed operators for the current condition
            arg_5 = arg_0.conditions_operators.get(
                arg_4.get("condition")
            )
            # transform these into values
            arg_6 = set(
                [arg_0.operators.get(op) for op in arg_5]
            )
            if arg_4.get("operator") not in arg_6:
                raise ze.ParamNotPassed(
                    "You may not use the '%s' operator when selecting the '%s' condition. \nAllowed operators: %s"
                    % (
                        arg_4.get("operator"),
                        arg_4.get("condition"),
                        ", ".join(list(arg_6)),
                    )
                )


def Func(arg_0):
    """Split a multiline string into a list, excluding blank lines."""
    return [arg_1 for arg_1 in (arg_2.strip() for arg_2 in arg_0.split('\n'))
            if arg_1]


def Func(arg_0):
    """Split a string with comma or space-separated elements into a list."""
    arg_1 = [v.strip() for v in arg_0.split(',')]
    if len(arg_1) == 1:
        arg_1 = arg_0.split()
    return arg_1


def Func(arg_0):
    """Evaluate environment markers."""
    def Func_str(arg_0):
        arg_1 = arg_0.split(';')
        if len(arg_1) < 2:
            return arg_0
        arg_2 = arg_1[1].lstrip()
        if not re.match("^((\\w+(\\.\\w+)?|'.*?'|\".*?\")\\s+"
                        '(in|==|!=|not in)\\s+'
                        "(\\w+(\\.\\w+)?|'.*?'|\".*?\")"
                        '(\\s+(or|and)\\s+)?)+$', arg_2):
            raise ValueError('bad environment marker: %r' % arg_2)
        arg_2 = re.sub(r"(platform\.\w+)", r"\1()", arg_2)
        return arg_1[0] if eval(arg_2) else ''

    if isinstance(arg_0, list):
        arg_3 = []
        for arg_4 in arg_0:
            arg_4 = Func_str(arg_4)
            if arg_4:
                arg_3.append(arg_4)
    elif isinstance(arg_0, str):
        arg_3 = Func_str(arg_0)
    else:
        arg_3 = arg_0

    return arg_3


def Func(arg_0, arg_1, arg_2):
    """Get configuration value."""
    try:
        arg_3 = arg_0[arg_1][arg_2]
    except KeyError:
        if (arg_1, arg_2) in MULTI_OPTIONS:
            return []
        else:
            return ''
    if (arg_1, arg_2) in MULTI_OPTIONS:
        arg_3 = split_multiline(arg_3)
    if (arg_1, arg_2) in ENVIRON_OPTIONS:
        arg_3 = eval_environ(arg_3)
    return arg_3


def Func(arg_0, arg_1, arg_2, arg_3):
    """Set configuration value."""
    if isinstance(arg_3, list):
        arg_3 = '\n'.join(arg_3)
    arg_0[arg_1][arg_2] = arg_3


def Func(arg_0):
    """Compatibility helper to use setup.cfg in setup.py."""
    arg_1 = {}
    arg_2 = {
        'metadata': [
            ('name', 'name'),
            ('author', 'author'),
            ('author-email', 'author_email'),
            ('maintainer', 'maintainer'),
            ('maintainer-email', 'maintainer_email'),
            ('home-page', 'url'),
            ('summary', 'description'),
            ('description', 'long_description'),
            ('download-url', 'download_url'),
            ('classifier', 'classifiers'),
            ('platform', 'platforms'),
            ('license', 'license'),
            ('keywords', 'keywords'),
        ],
        'files': [
            ('packages_root', 'package_dir'),
            ('packages', 'packages'),
            ('modules', 'py_modules'),
            ('scripts', 'scripts'),
            ('package_data', 'package_data'),
            ('data_files', 'data_files'),
        ],
    }

    arg_2['metadata'].append(('requires-dist', 'install_requires'))
    if IS_PY2K and not which('3to2'):
        arg_1['setup_requires'] = ['3to2']
    arg_1['zip_safe'] = False

    for arg_3 in arg_2:
        for arg_4, arg_5 in arg_2[arg_3]:
            arg_6 = get_cfg_value(arg_0, arg_3, arg_4)
            if arg_6:
                arg_1[arg_5] = arg_6

    if 'long_description' not in arg_1:
        arg_1['long_description'] = read_description_file(arg_0)

    if 'package_dir' in arg_1:
        arg_1['package_dir'] = {'': arg_1['package_dir']}

    if 'keywords' in arg_1:
        arg_1['keywords'] = split_elements(arg_1['keywords'])

    if 'package_data' in arg_1:
        arg_1['package_data'] = get_package_data(arg_1['package_data'])

    if 'data_files' in arg_1:
        arg_1['data_files'] = get_data_files(arg_1['data_files'])

    arg_1['version'] = get_version()

    if not IS_PY2K:
        arg_1['test_suite'] = 'test'

    return arg_1


def Func():
    """Get LanguageTool version."""
    arg_0 = _get_attrib().get('version')
    if not arg_0:
        arg_1 = re.search(r"LanguageTool-?.*?(\S+)$", get_directory())
        if arg_1:
            arg_0 = arg_1.group(1)
    return arg_0


def Func() -> set:
    """Get supported languages."""
    try:
        arg_0 = arg_1['languages']
    except KeyError:
        arg_0 = LanguageTool._Func()
        arg_1['languages'] = arg_0
    return arg_0


def Func(arg_0=None):
    """Set LanguageTool directory."""
    arg_1 = get_directory()
    terminate_server()
    arg_2.clear()
    if arg_0:
        arg_2['language_check_dir'] = arg_0
        try:
            get_jar_info()
        except Error:
            arg_2['language_check_dir'] = arg_1
            raise


def Func(arg_0, arg_1: arg_2, arg_3=None) -> [Match]:
        """Match text against enabled rules."""
        arg_4 = arg_0._get_root(arg_0._url, arg_0._encode(arg_1, arg_3))
        return [Match(arg_5.attrib) for arg_5 in arg_4 if arg_5.tag == 'error']


def Func():
    """Return newest compatible version.

    >>> version = Func()
    >>> version in [JAVA_6_COMPATIBLE_VERSION,
    ...             JAVA_7_COMPATIBLE_VERSION,
    ...             LATEST_VERSION]
    True

    """
    arg_0 = find_executable('java')
    if not arg_0:
        # Just ignore this and assume an old version of Java. It might not be
        # found because of a PATHEXT-related issue
        # (https://bugs.python.org/issue2200).
        return JAVA_6_COMPATIBLE_VERSION

    arg_1 = subprocess.check_output([arg_0, '-version'],
                                     stderr=subprocess.STDOUT,
                                     universal_newlines=True)

    arg_2 = parse_java_version(arg_1)

    if arg_2 >= (1, 8):
        return LATEST_VERSION
    elif arg_2 >= (1, 7):
        return JAVA_7_COMPATIBLE_VERSION
    elif arg_2 >= (1, 6):
        warn('language-check would be able to use a newer version of '
             'LanguageTool if you had Java 7 or newer installed')
        return JAVA_6_COMPATIBLE_VERSION
    else:
        raise SystemExit(
            'You need at least Java 6 to use language-check')


def Func(arg_0):
    """Get common directory in a zip file if any."""
    arg_1 = arg_0.namelist()
    if arg_1 and all(arg_2.startswith(arg_1[0]) for arg_2 in arg_1[1:]):
        return arg_1[0]
    return None


def Func(*arg_0):
    """Make a Qt async slot run on asyncio loop."""
    def outer_decorator(arg_1):
        @Slot(*arg_0)
        @functools.wraps(arg_1)
        def wrapper(*arg_0, **arg_2):
            asyncio.ensure_future(arg_1(*arg_0, **arg_2))
        return wrapper
    return outer_decorator


def Func(arg_0):
    """Class decorator to add a logger to a class."""
    arg_1 = '_logger'
    arg_2 = arg_0.__qualname__
    arg_3 = arg_0.__module__
    if arg_3 is not None:
        arg_2 = arg_3 + '.' + arg_2
    else:
        raise AssertionError
    setattr(arg_0, arg_1, logging.getLogger(arg_2))
    return arg_0


def Func(arg_0, arg_1, arg_2):
        """Selector has delivered us an event."""
        arg_0._logger.debug('Processing event with key {} and mask {}'.format(arg_1, arg_2))
        arg_3, (arg_4, arg_5) = arg_1.fileobj, arg_1.data
        if arg_2 & selectors.EVENT_READ and arg_4 is not None:
            if arg_4._cancelled:
                arg_0.remove_reader(arg_3)
            else:
                arg_0._logger.debug('Invoking reader callback: {}'.format(arg_4))
                arg_4._run()
        if arg_2 & selectors.EVENT_WRITE and arg_5 is not None:
            if arg_5._cancelled:
                arg_0.remove_writer(arg_3)
            else:
                arg_0._logger.debug('Invoking writer callback: {}'.format(arg_5))
                arg_5._run()


def Func(arg_0, *arg_1):
        """Add more ASN.1 MIB source repositories.

        MibCompiler.compile will invoke each of configured source objects
        in order of their addition asking each to fetch MIB module specified
        by name.

        Args:
            sources: reader object(s)

        Returns:
            reference to itself (can be used for call chaining)

        """
        arg_0._sources.extend(arg_1)

        debug.logger & debug.flagCompiler and debug.logger(
            'current MIB source(s): %s' % ', '.join([str(arg_2) for arg_2 in arg_0._sources]))

        return arg_0


def Func(arg_0, *arg_1):
        """Add more transformed MIBs repositories to borrow MIBs from.

        Whenever MibCompiler.compile encounters MIB module which neither of
        the *searchers* can find or fetched ASN.1 MIB module can not be
        parsed (due to syntax errors), these *borrowers* objects will be
        invoked in order of their addition asking each if already transformed
        MIB can be fetched (borrowed).

        Args:
            borrowers: borrower object(s)

        Returns:
            reference to itself (can be used for call chaining)

        """
        arg_0._borrowers.extend(arg_1)

        debug.logger & debug.flagCompiler and debug.logger(
            'current MIB borrower(s): %s' % ', '.join([str(arg_2) for arg_2 in arg_0._borrowers]))

        return arg_0


def Func(arg_0):
        """Get current object.
        This is useful if you want the real
        object behind the proxy at a time for performance reasons or because
        you want to pass the object into a different context.
        """
        arg_1 = object.__getattribute__(arg_0, '_Proxy__local')
        if not hasattr(arg_1, '__release_local__'):
            return arg_1(*arg_0.__args, **arg_0.__kwargs)
        try:  # pragma: no cover
            # not sure what this is about
            return getattr(arg_1, arg_0.__name__)
        except AttributeError:  # pragma: no cover
            raise RuntimeError('no object bound to {0.__name__}'.format(arg_0))


def Func(arg_0, arg_1, arg_2):
    r"""Kullback information criterion

    .. math:: Func(k) = log(\rho_k) + 3 \frac{k+1}{N}

    :validation: double checked versus octave.
    """
    from numpy import log, array
    arg_3 = log(arg_1) + 3. * (arg_2+1.) /float(arg_0)
    return arg_3


def Func(arg_0, arg_1, arg_2):
    r"""approximate corrected Kullback information

    .. math:: Func(k) = log(rho_k) + \frac{p}{N*(N-k)} + (3-\frac{k+2}{N})*\frac{k+1}{N-k-2}

    """
    from numpy import log, array
    arg_3 = arg_2
    arg_4 = log(arg_1) + arg_3/arg_0/(arg_0-arg_3) + (3.-(arg_3+2.)/arg_0) * (arg_3+1.) / (arg_0-arg_3-2.)
    return arg_4


def Func(arg_0,arg_1, arg_2=None):
    r"""Final prediction error criterion

    .. math:: Func(k) = \frac{N + k + 1}{N - k - 1} \rho_k

    :validation: double checked versus octave.

    """
    #k #todo check convention. agrees with octave
    arg_3 = arg_1 * (arg_0 + arg_2 + 1.) / (arg_0- arg_2 -1)
    return arg_3


def Func(arg_0, arg_1, arg_2):
    r"""Minimum Description Length

    .. math:: Func(k) = N log \rho_k + p \log N

    :validation: results
    """
    from numpy import log
    #p = arange(1, len(rho)+1)
    arg_3 = arg_0* log(arg_1) + arg_2 * log(arg_0)
    return arg_3


def Func(arg_0):
    """Generate the Main examples gallery reStructuredText

    Start the sphinx-gallery configuration and recursively scan the examples
    directories in order to populate the examples gallery
    """
    try:
        arg_1 = eval(arg_0.builder.config.plot_gallery)
    except TypeError:
        arg_1 = bool(arg_0.builder.config.plot_gallery)

    gallery_conf.update(arg_0.config.sphinx_gallery_conf)
    gallery_conf.update(arg_1=arg_1)
    gallery_conf.update(abort_on_example_error=arg_0.builder.config.abort_on_example_error)

    # this assures I can call the config in other places
    arg_0.config.sphinx_gallery_conf = gallery_conf
    arg_0.config.html_static_path.append(glr_path_static())

    clean_gallery_out(arg_0.builder.outdir)

    arg_4 = gallery_conf['examples_dirs']
    arg_5 = gallery_conf['gallery_dirs']

    if not isinstance(arg_4, list):
        arg_4 = [arg_4]
    if not isinstance(arg_5, list):
        arg_5 = [arg_5]

    arg_6 = os.path.relpath(gallery_conf['mod_example_dir'],
                                       arg_0.builder.srcdir)
    arg_7 = set()

    for arg_8, arg_9 in zip(arg_4, arg_5):
        arg_8 = os.path.relpath(arg_8,
                                       arg_0.builder.srcdir)
        arg_9 = os.path.relpath(arg_9,
                                      arg_0.builder.srcdir)

        for arg_10 in [arg_8, arg_9, arg_6]:
            if not os.path.exists(arg_10):
                os.makedirs(arg_10)

        # we create an index.rst with all examples
        arg_11 = open(os.path.join(arg_9, 'index.rst'), 'w')
        # Here we don't use an os.walk, but we recurse only twice: flat is
        # better than nested.
        arg_11.write(generate_dir_rst(arg_8, arg_9, gallery_conf,
                                       arg_7))
        for arg_12 in sorted(os.listdir(arg_8)):
            if os.path.isdir(os.path.join(arg_8, arg_12)):
                arg_13 = os.path.join(arg_8, arg_12)
                arg_14 = os.path.join(arg_9, arg_12)
                arg_11.write(generate_dir_rst(arg_13, arg_14,
                                               gallery_conf,
                                               arg_7))
        arg_11.flush()


def Func(arg_0):
    """Setup sphinx-gallery sphinx extension"""
    arg_0.add_config_value('plot_gallery', True, 'html')
    arg_0.add_config_value('abort_on_example_error', False, 'html')
    arg_0.add_config_value('sphinx_gallery_conf', gallery_conf, 'html')
    arg_0.add_stylesheet('gallery.css')

    arg_0.connect('builder-inited', generate_gallery_rst)

    arg_0.connect('build-finished', embed_code_links)


def Func(arg_0, arg_1=None, arg_2=None, arg_3='unbiased'):
    r"""Correlation function

    This function should give the same results as :func:`xcorr` but it
    returns the positive lags only. Moreover the algorithm does not use
    FFT as compared to other algorithms.

    :param array x: first data array of length N
    :param array y: second data array of length N. If not specified, computes the
        autocorrelation.
    :param int maxlags: compute cross correlation between [0:maxlags]
        when maxlags is not specified, the range of lags is [0:maxlags].
    :param str norm: normalisation in ['biased', 'unbiased', None, 'coeff']

        * *biased*   correlation=raw/N,
        * *unbiased* correlation=raw/(N-`|lag|`)
        * *coeff*    correlation=raw/(rms(x).rms(y))/N
        * None       correlation=raw

    :return:
        * a numpy.array correlation sequence,  r[1,N]
        * a float for the zero-lag correlation,  r[0]

    The *unbiased* correlation has the form:

    .. math::

        \hat{r}_{xx} = \frac{1}{N-m}T \sum_{n=0}^{N-m-1} x[n+m]x^*[n] T

    The *biased* correlation differs by the front factor only:

    .. math::

        \check{r}_{xx} = \frac{1}{N}T \sum_{n=0}^{N-m-1} x[n+m]x^*[n] T

    with :math:`0\leq m\leq N-1`.

    .. doctest::

        >>> from spectrum import Func
        >>> x = [1,2,3,4,5]
        >>> res = Func(x,x, maxlags=0, norm='biased')
        >>> res[0]
        11.0

    .. note:: this function should be replaced by :func:`xcorr`.

    .. seealso:: :func:`xcorr`
    """
    assert arg_3 in ['unbiased','biased', 'coeff', None]
    #transform lag into list if it is an integer
    arg_0 = np.array(arg_0)
    if arg_1 is None:
        arg_1 = arg_0
    else:
        arg_1 = np.array(arg_1)

    # N is the max of x and y
    arg_4 = max(len(arg_0), len(arg_1))
    if len(arg_0) < arg_4:
        arg_0 = arg_1.copy()
        arg_0.resize(arg_4)
    if len(arg_1) < arg_4:
        arg_1 = arg_1.copy()
        arg_1.resize(arg_4)

    #default lag is N-1
    if arg_2 is None:
        arg_2 = arg_4 - 1
    assert arg_2 < arg_4, 'lag must be less than len(x)'

    arg_5 = np.isrealobj(arg_0) and np.isrealobj(arg_1)
    #create an autocorrelation array with same length as lag
    if arg_5 == True:
        arg_6 = np.zeros(arg_2, dtype=float)
    else:
        arg_6 = np.zeros(arg_2, dtype=complex)

    if arg_3 == 'coeff':
        arg_7 = pylab_rms_flat(arg_0)
        arg_8 = pylab_rms_flat(arg_1)

    for arg_9 in range(0, arg_2+1):
        arg_10 = arg_4 - arg_9 - 1

        if arg_5 == True:
            arg_11 = 0
            for arg_12 in range(0, arg_10+1):
                arg_11 = arg_11 + arg_0[arg_12+arg_9] * arg_1[arg_12]
        else:
            arg_11 = 0. + 0j
            for arg_12 in range(0, arg_10+1):
                arg_11 = arg_11 + arg_0[arg_12+arg_9] * arg_1[arg_12].conjugate()
        if arg_9 == 0:
            if arg_3 in ['biased', 'unbiased']:
                arg_13 = arg_11/float(arg_4)
            elif arg_3 is None:
                arg_13 = arg_11
            else:
                arg_13 =  1.
        else:
            if arg_3 == 'unbiased':
                arg_6[arg_9-1] = arg_11 / float(arg_4-arg_9)
            elif arg_3 == 'biased':
                arg_6[arg_9-1] = arg_11 / float(arg_4)
            elif arg_3 is None:
                arg_6[arg_9-1] = arg_11
            elif arg_3 == 'coeff':
                arg_6[arg_9-1] =  arg_11/(arg_7*arg_8)/float(arg_4)

    arg_6 = np.insert(arg_6, 0, arg_13)
    return arg_6


def Func(arg_0, arg_1=None, arg_2=None, arg_3='biased'):
    """Cross-correlation using numpy.correlate

    Estimates the cross-correlation (and autocorrelation) sequence of a random
    process of length N. By default, there is no normalisation and the output
    sequence of the cross-correlation has a length 2*N+1.

    :param array x: first data array of length N
    :param array y: second data array of length N. If not specified, computes the
        autocorrelation.
    :param int maxlags: compute cross correlation between [-maxlags:maxlags]
        when maxlags is not specified, the range of lags is [-N+1:N-1].
    :param str option: normalisation in ['biased', 'unbiased', None, 'coeff']

    The true cross-correlation sequence is

    .. math:: r_{xy}[m] = E(x[n+m].y^*[n]) = E(x[n].y^*[n-m])

    However, in practice, only a finite segment of one realization of the
    infinite-length random process is available.

    The correlation is estimated using numpy.correlate(x,y,'full').
    Normalisation is handled by this function using the following cases:

        * 'biased': Biased estimate of the cross-correlation function
        * 'unbiased': Unbiased estimate of the cross-correlation function
        * 'coeff': Normalizes the sequence so the autocorrelations at zero
           lag is 1.0.

    :return:
        * a numpy.array containing the cross-correlation sequence (length 2*N-1)
        * lags vector

    .. note:: If x and y are not the same length, the shorter vector is
        zero-padded to the length of the longer vector.

    .. rubric:: Examples

    .. doctest::

        >>> from spectrum import Func
        >>> x = [1,2,3,4,5]
        >>> c, l = Func(x,x, maxlags=0, norm='biased')
        >>> c
        array([ 11.])

    .. seealso:: :func:`CORRELATION`.
    """
    arg_4 = len(arg_0)
    if arg_1 is None:
        arg_1 = arg_0
    assert len(arg_0) == len(arg_1), 'x and y must have the same length. Add zeros if needed'

    if arg_2 is None:
        arg_2 = arg_4-1
        arg_5 = np.arange(0, 2*arg_4-1)
    else:
        assert arg_2 <= arg_4, 'maxlags must be less than data length'
        arg_5 = np.arange(arg_4-arg_2-1, arg_4+arg_2)

    arg_6 = np.correlate(arg_0, arg_1, mode='full')

    if arg_3 == 'biased':
        arg_7 = float(arg_4)
        arg_6 = arg_6[arg_5] / float(arg_4)    # do not use /= !!
    elif arg_3 == 'unbiased':
        arg_6 = arg_6[arg_5] / (float(arg_4)-abs(np.arange(-arg_4+1, arg_4)))[arg_5]
    elif arg_3 == 'coeff':
        arg_7 = float(arg_4)
        arg_8 = pylab_rms_flat(arg_0) * pylab_rms_flat(arg_1)
        arg_6 = arg_6[arg_5] / arg_8 / arg_7
    else:
        arg_6 = arg_6[arg_5]

    arg_5 = np.arange(-arg_2, arg_2+1)
    return arg_6, arg_5


def Func(arg_0, arg_1, arg_2):
    """Finds the minimum eigenvalue of a Hermitian Toeplitz matrix

    The classical power method is used together with a  fast  Toeplitz
    equation solution routine.  The eigenvector is normalized to unit length.

    :param T0: Scalar corresponding to real matrix element t(0)
    :param T: Array of  M  complex matrix elements t(1),...,t(M) C            from the left column of the Toeplitz matrix
    :param TOL: Real scalar tolerance; routine exits when [ EVAL(k) - EVAL(k-1) ]/EVAL(k-1) < TOL , where the index k denotes the iteration number.

    :return:
        * EVAL - Real scalar denoting the minimum eigenvalue of matrix
        * EVEC - Array of  M  complex eigenvector elements associated

    .. note::
     * External array T must be dimensioned >= M
     * array EVEC must be >= M+1
     *  Internal array E must be dimensioned >= M+1 .

     * **dependencies**
        *  :meth:`spectrum.toeplitz.HERMTOEP`
    """
    arg_3 = len(arg_1)
    arg_4 = 10
    arg_5 = 1
    arg_6  = numpy.zeros(arg_3+1, dtype=complex)
    for arg_7 in range(0,arg_3+1):
        arg_6[arg_7] = 1+0j
    arg_8=0
    #print 'initialisation',T0, T, eigval, eigvec
    arg_9 = 15
    while abs(arg_5-arg_4)>arg_2*arg_5 and arg_8<arg_9:
        arg_8=arg_8+1
        arg_5 = arg_4
        #print 'iteration ',it, 'eigvalold=',eigvalold, 'eigval=', eigval

        arg_10 = toeplitz.HERMTOEP(arg_0, arg_1, arg_6)
        arg_11 = 0
        arg_12 =0.+0j
        for arg_7 in range(0, arg_3+1):
            arg_11 = arg_11 + arg_10[arg_7].real**2+arg_10[arg_7].imag**2
            arg_12 = arg_12 +arg_10[arg_7]*arg_6[arg_7].conjugate()
        arg_11=1./arg_11
        arg_4 = arg_12.real*arg_11
        for arg_7 in range(0,arg_3+1):
            arg_6[arg_7] = arg_11 * arg_10[arg_7]
    if arg_8==arg_9:
        print('warning reached max number of iteration (%s)' % arg_9)
    return arg_4, arg_6


def Func(arg_0, arg_1, arg_2):
    r"""Generate the Morlet waveform

    The Morlet waveform is defined as follows:

    .. math:: w[x] = \cos{5x}  \exp^{-x^2/2}

    :param lb: lower bound
    :param ub: upper bound
    :param int n: waveform data samples

    .. plot::
        :include-source:
        :width: 80%

        from spectrum import Func
        from pylab import plot
        plot(Func(0,10,100))

    """
    if arg_2 <= 0:
        raise ValueError("n must be strictly positive")

    arg_3 = numpy.linspace(arg_0, arg_1, arg_2)
    arg_4 = numpy.cos(5*arg_3) * numpy.exp(-arg_3**2/2.)
    return arg_4


def Func(arg_0, arg_1=None):
    """convert reflection coefficients to prediction filter polynomial

    :param k: reflection coefficients

    """
    # Initialize the recursion
    from .levinson import levup
    arg_2 = len(arg_0)              #% p is the order of the prediction polynomial.
    arg_3 = numpy.array([1, arg_0[0]])           #% a is a true polynomial.
    arg_4 = numpy.zeros(len(arg_0))

    if arg_1 is None:
        arg_5 = 0
    else:
        arg_5 = arg_1

    arg_4[0] = arg_5 * (1. - numpy.conj(numpy.conjugate(arg_0[0])*arg_0[0]))

    # Continue the recursion for k=2,3,...,p, where p is the order of the
    # prediction polynomial.

    for arg_6 in range(1, arg_2):
        [arg_3, arg_4[arg_6]] = levup(arg_3, arg_0[arg_6], arg_4[arg_6-1])

    arg_7 = arg_4[-1]
    return arg_3, arg_7


def Func(arg_0):
    """Convert reflection coefficients to log area ratios.

    :param k: reflection coefficients
    :return: inverse sine parameters

    The log area ratio is defined by G = log((1+k)/(1-k)) , where the K
    parameter is the reflection coefficient.

    .. seealso:: :func:`lar2rc`, :func:`rc2poly`, :func:`rc2ac`, :func:`rc2ic`.

    :References:
       [1] J. Makhoul, "Linear Prediction: A Tutorial Review," Proc. IEEE, Vol.63, No.4, pp.561-580, Apr 1975.

    """
    assert numpy.isrealobj(arg_0), 'Log area ratios not defined for complex reflection coefficients.'
    if max(numpy.abs(arg_0)) >= 1:
        raise ValueError('All reflection coefficients should have magnitude less than unity.')

    # Use the relation, atanh(x) = (1/2)*log((1+k)/(1-k))
    return -2 * numpy.arctanh(-numpy.array(arg_0))


def Func(arg_0):
    """Convert log area ratios to reflection coefficients.

    :param g:  log area ratios
    :returns: the reflection coefficients

    .. seealso: :func:`rc2lar`, :func:`poly2rc`, :func:`ac2rc`, :func:`is2rc`.

    :References:
       [1] J. Makhoul, "Linear Prediction: A Tutorial Review," Proc. IEEE,  Vol.63, No.4, pp.561-580, Apr 1975.

    """
    assert numpy.isrealobj(arg_0), 'Log area ratios not defined for complex reflection coefficients.'
    # Use the relation, tanh(x) = (1-exp(2x))/(1+exp(2x))
    return -numpy.tanh(-numpy.array(arg_0)/2)


def Func(arg_0):
    """Convert line spectral frequencies to prediction filter coefficients

    returns a vector a containing the prediction filter coefficients from a vector lsf of line spectral frequencies.

    .. doctest::

        >>> from spectrum import Func
        >>> lsf = [0.7842 ,   1.5605  ,  1.8776 ,   1.8984,    2.3593]
        >>> a = Func(lsf)

    # array([  1.00000000e+00,   6.14837835e-01,   9.89884967e-01,
    # 9.31594056e-05,   3.13713832e-03,  -8.12002261e-03 ])

    .. seealso:: poly2lsf, rc2poly, ac2poly, rc2is
    """
    #   Reference: A.M. Kondoz, "Digital Speech: Coding for Low Bit Rate Communications
    #   Systems" John Wiley & Sons 1994 ,Chapter 4

    # Line spectral frequencies must be real.

    arg_0 = numpy.array(arg_0)

    if max(arg_0) > numpy.pi or min(arg_0) < 0:
        raise ValueError('Line spectral frequencies must be between 0 and pi.')

    arg_1 = len(arg_0) # model order

    # Form zeros using the LSFs and unit amplitudes
    arg_2  = numpy.exp(1.j * arg_0)

    # Separate the zeros to those belonging to P and Q
    arg_3 = arg_2[0::2]
    arg_4 = arg_2[1::2]

    # Include the conjugates as well
    arg_3 = numpy.concatenate((arg_3, arg_3.conjugate()))
    arg_4 = numpy.concatenate((arg_4, arg_4.conjugate()))

    # Form the polynomials P and Q, note that these should be real
    arg_5  = numpy.poly(arg_3);
    arg_6  = numpy.poly(arg_4);

    # Form the sum and difference filters by including known roots at z = 1 and
    # z = -1

    if arg_1%2:
        # Odd order: z = +1 and z = -1 are roots of the difference filter, P1(z)
        arg_7 = numpy.convolve(arg_6, [1, 0, -1])
        arg_8 = arg_5
    else:
        # Even order: z = -1 is a root of the sum filter, Q1(z) and z = 1 is a
        # root of the difference filter, P1(z)
        arg_7 = numpy.convolve(arg_6, [1, -1])
        arg_8 = numpy.convolve(arg_5, [1,  1])

    # Prediction polynomial is formed by averaging P1 and Q1

    arg_9 = .5 * (arg_7+arg_8)
    return arg_9[0:-1:1]


def Func(arg_0):
    """Prediction polynomial to line spectral frequencies.

    converts the prediction polynomial specified by A,
    into the corresponding line spectral frequencies, LSF.
    normalizes the prediction polynomial by A(1).

    .. doctest::

        >>> from spectrum import Func
        >>> a = [1.0000,  0.6149, 0.9899, 0.0000 ,0.0031, -0.0082]
        >>> lsf = Func(a)
        >>> lsf =  array([0.7842, 1.5605, 1.8776, 1.8984, 2.3593])

    .. seealso:: lsf2poly, poly2rc, poly2qc, rc2is
    """

    #Line spectral frequencies are not defined for complex polynomials.

    # Normalize the polynomial

    arg_0 = numpy.array(arg_0)
    if arg_0[0] != 1:
        arg_0/=arg_0[0]

    if max(numpy.abs(numpy.roots(arg_0))) >= 1.0:
        error('The polynomial must have all roots inside of the unit circle.');

    # Form the sum and differnce filters

    arg_1  = len(arg_0)-1   # The leading one in the polynomial is not used
    arg_2 = numpy.concatenate((arg_0, numpy.array([0])))
    arg_3 = arg_2[-1::-1]
    arg_4 = arg_2 - arg_3        # Difference filter
    arg_5 = arg_2 + arg_3        # Sum Filter

    # If order is even, remove the known root at z = 1 for P1 and z = -1 for Q1
    # If odd, remove both the roots from P1

    if arg_1%2: # Odd order
        arg_6, arg_7 = deconvolve(arg_4,[1, 0 ,-1])
        arg_8 = arg_5
    else:          # Even order
        arg_6, arg_7 = deconvolve(arg_4, [1, -1])
        arg_8, arg_7 = deconvolve(arg_5, [1,  1])

    arg_9  = numpy.roots(arg_6)
    arg_10  = numpy.roots(arg_8)

    arg_11  = numpy.angle(arg_9[1::2])
    arg_12  = numpy.angle(arg_10[1::2])

    arg_13 = sorted(numpy.concatenate((-arg_11,-arg_12)))

    return arg_13


def Func(arg_0):
    """Convert a one-sided PSD to a twosided PSD

    In order to keep the power in the onesided PSD the same
    as in the twosided version, the onesided values are twice
    as much as in the input data (except for the zero-lag value).

    ::

        >>> Func([10, 2,3,3,2,8])
        array([ 10.,   4.,   6.,   8.])

    """
    assert len(arg_0) % 2 == 0
    arg_1 = len(arg_0)
    arg_2 = np.array(arg_0[0:arg_1//2+1]) * 2.
    arg_2[0] /= 2.
    arg_2[-1] = arg_0[-1]
    return arg_2


def Func(arg_0):
    """Convert a two-sided PSD to a one-sided PSD

    In order to keep the power in the twosided PSD the same
    as in the onesided version, the twosided values are 2 times
    lower than the input data (except for the zero-lag and N-lag
    values).

    ::

        >>> twosided_2_onesided([10, 4, 6, 8])
        array([ 10.,   2.,   3.,   3., 2., 8.])

    """
    arg_1 = np.concatenate((arg_0[0:-1], cshift(arg_0[-1:0:-1], -1)))/2.
    arg_1[0] *= 2.
    arg_1[-1] *= 2.
    return arg_1


def Func(arg_0):
    """Convert a two-sided PSD to a center-dc PSD"""
    arg_1 = len(arg_0)
    # could us int() or // in python 3
    arg_2 = np.concatenate((cshift(arg_0[arg_1//2:], 1), arg_0[0:arg_1//2]))
    arg_2[0] = arg_0[-1]
    return arg_2


def Func(arg_0):
    """Convert a center-dc PSD to a twosided PSD"""
    arg_1 = len(arg_0)
    arg_2 = np.concatenate((arg_0[arg_1//2:], (cshift(arg_0[0:arg_1//2], -1))))
    return arg_2


def Func(arg_0=200):
    """A simple test example with two close frequencies

    """
    arg_1 = arange(arg_0)
    arg_2 = cos(0.257*pi*arg_1) + sin(0.2*pi*arg_1) + 0.01*randn(arg_1.size)
    return arg_2


def Func(arg_0, **arg_1):
        """Plot the data set, using the sampling information to set the x-axis
        correctly."""
        from pylab import Func, linspace, xlabel, ylabel, grid
        arg_2 = linspace(1*arg_0.dt, arg_0.N*arg_0.dt, arg_0.N)
        Func(arg_2, arg_0.data, **arg_1)
        xlabel('Time')
        ylabel('Amplitude')
        grid(True)


def Func(arg_0, **arg_1):
    """Returns the autocovariance of signal s at all lags.

    Adheres to the definition
    sxx[k] = E{S[n]S[n+k]} = cov{S[n],S[n+k]}
    where E{} is the expectation operator, and S is a zero mean process
    """
    # only remove the mean once, if needed
    arg_2 = arg_1.pop('debias', True)
    arg_3 = arg_1.get('axis', -1)
    if arg_2:
        arg_0 = _remove_bias(arg_0, arg_3)
    arg_1['debias'] = False
    return _crosscov(arg_0, arg_0, **arg_1)


def Func(arg_0):
    """Separate `filename` content between docstring and the rest

    Strongly inspired from ast.get_docstring.

    Returns
    -------
    docstring: str
        docstring of `filename`
    rest: str
        `filename` content without the docstring
    """
    with open(arg_0) as f:
        arg_1 = f.read()

    arg_2 = ast.parse(arg_1)
    if not isinstance(arg_2, ast.Module):
        raise TypeError("This function only supports modules. "
                        "You provided {0}".format(arg_2.__class__.__name__))
    if arg_2.body and isinstance(arg_2.body[0], ast.Expr) and \
       isinstance(arg_2.body[0].value, ast.Str):
        arg_3 = arg_2.body[0]
        arg_4 = arg_3.value.s
        # This get the content of the file after the docstring last line
        # Note: 'maxsplit' argument is not a keyword argument in python2
        arg_5 = arg_1.split('\n', arg_3.lineno)[-1]
        return arg_4, arg_5
    else:
        raise ValueError(('Could not find docstring in file "{0}". '
                          'A docstring is required by sphinx-gallery')
                         .format(arg_0))


def Func(arg_0):
    """Returns md5sum of file"""

    with open(arg_0, 'r') as src_data:
        arg_1 = src_data.read()

        # data needs to be encoded in python3 before hashing
        if sys.version_info[0] == 3:
            arg_1 = arg_1.encode('utf-8')

        arg_2 = hashlib.md5(arg_1).hexdigest()
    return arg_2


def Func(arg_0):
    """Returns True if src_file has a different md5sum"""

    arg_1 = get_md5sum(arg_0)

    arg_2 = arg_0 + '.md5'
    arg_3 = True
    if os.path.exists(arg_2):
        with open(arg_2, 'r') as file_checksum:
            arg_4 = file_checksum.read()
        if arg_1 == arg_4:
            arg_3 = False

    if arg_3:
        with open(arg_2, 'w') as file_checksum:
            file_checksum.write(arg_1)

    return arg_3


def Func(arg_0, arg_1):
    """Test existence of image file and no change in md5sum of
    example"""

    arg_2 = arg_1.format(1)
    arg_3 = os.path.exists(arg_2)
    arg_4 = check_md5sum_change(arg_0)

    return arg_3 and not arg_4


def Func(arg_0, arg_1, arg_2):
    """Save all open matplotlib figures of the example code-block

    Parameters
    ----------
    image_path : str
        Path where plots are saved (format string which accepts figure number)
    fig_count : int
        Previous figure number count. Figure number add from this number

    Returns
    -------
    list of strings containing the full path to each figure
    """
    arg_3 = []

    arg_4 = matplotlib._pylab_helpers.Gcf.get_all_fig_managers()
    for arg_5 in arg_4:
        # Set the fig_num figure as the current figure as we can't
        # save a figure that's not the current figure.
        arg_6 = plt.figure(arg_5.num)
        arg_7 = {}
        arg_8 = matplotlib.colors.colorConverter.to_rgba
        for arg_9 in ['facecolor', 'edgecolor']:
            arg_10 = getattr(arg_6, 'get_' + arg_9)()
            arg_11 = matplotlib.rcParams['figure.' + arg_9]
            if arg_8(arg_10) != arg_8(arg_11):
                arg_7[arg_9] = arg_10

        arg_12 = arg_0.format(arg_1 + arg_5.num)
        arg_6.savefig(arg_12, **arg_7)
        arg_3.append(arg_12)

    if arg_2.get('find_mayavi_figures', False):
        from mayavi import mlab
        arg_13 = mlab.get_engine()
        arg_14 = len(arg_3)
        arg_15 = arg_14 + len(arg_13.scenes)
        arg_16 = range(arg_14, arg_15)

        for arg_17, arg_18 in zip(arg_13.scenes, arg_16):
            arg_12 = arg_0.format(arg_18)
            mlab.savefig(arg_12, figure=arg_17)
            # make sure the image is not too large
            scale_image(arg_12, arg_12, 850, 999)
            arg_3.append(arg_12)
        mlab.close(all=True)

    return arg_3


def Func(arg_0, arg_1, arg_2):
    """Save the thumbnail image"""
    arg_3 = arg_0.format(1)
    arg_4 = os.path.join(os.path.dirname(arg_3), 'thumb')
    if not os.path.exists(arg_4):
        os.makedirs(arg_4)

    arg_5 = os.path.join(arg_4,
                              'sphx_glr_%s_thumb.png' % arg_1)

    if os.path.exists(arg_3):
        scale_image(arg_3, arg_5, 400, 280)
    elif not os.path.exists(arg_5):
        # create something to replace the thumbnail
        arg_6 = os.path.join(glr_path_static(), 'no_image.png')
        arg_6 = arg_2.get("default_thumb_file",
                                              arg_6)
        scale_image(arg_6, arg_5, 200, 140)


def Func(arg_0, arg_1, arg_2, arg_3,
                   arg_4, arg_5):
    """Executes the code block of the example file"""
    arg_6 = 0
    arg_7 = ''

    # We need to execute the code
    print('plotting code blocks in %s' % arg_4)

    plt.close('all')
    arg_8 = os.getcwd()
    # Redirect output to stdout and
    arg_9 = arg_12.stdout

    try:
        # First cd in the original example dir, so that any file
        # created by the example get created in this directory
        os.chdir(os.path.dirname(arg_4))
        arg_10 = StringIO()
        arg_11 = Tee(arg_12.stdout, arg_10)
        arg_12.stdout = arg_11

        arg_13 = time()
        exec(arg_0, arg_1)
        arg_6 = time() - arg_13

        arg_12.stdout = arg_9

        arg_11 = arg_10.getvalue().strip().expandtabs()
        if arg_11:
            arg_7 = CODE_OUTPUT.format(indent(arg_11, ' ' * 4))
        os.chdir(arg_8)
        arg_14 = save_figures(arg_2, arg_3, arg_5)

        # Depending on whether we have one or more figures, we're using a
        # horizontal list or a single rst call to 'image'.
        arg_15 = ""
        if len(arg_14) == 1:
            arg_16 = arg_14[0]
            arg_15 = SINGLE_IMAGE % arg_16.lstrip('/')
        elif len(arg_14) > 1:
            arg_15 = HLIST_HEADER
            for arg_16 in arg_14:
                arg_15 += HLIST_IMAGE_TEMPLATE % arg_16.lstrip('/')

    except Exception:
        arg_17 = traceback.format_exc()

        print(80 * '_')
        print('%s is not compiling:' % arg_4)
        print(arg_17)
        print(80 * '_')

        arg_14 = []
        arg_15 = codestr2rst(arg_17, lang='pytb')

        # Overrides the output thumbnail in the gallery for easy identification
        arg_18 = os.path.join(glr_path_static(), 'broken_example.png')
        shutil.copyfile(arg_18, os.path.join(arg_8, arg_2.format(1)))
        arg_3 += 1  # raise count to avoid overwriting image

        # Breaks build on first example error

        if arg_5['abort_on_example_error']:
            raise

    finally:
        os.chdir(arg_8)
        arg_12.stdout = arg_9

    print(" - time elapsed : %.2g sec" % arg_6)
    arg_19 = "\n{0}\n\n{1}\n\n".format(arg_15, arg_7)

    return arg_19, arg_6, arg_3 + len(arg_14)


def Func(arg_0, arg_1):
    """This function solve Ax=B directly without taking care of the input
    matrix properties.
    """
    arg_2 = numpy.linalg.solve(arg_0, arg_1)
    return arg_2


def Func(arg_0, arg_1=None, arg_2=True, arg_3=1.,
                   arg_4=True, arg_5='hamming', arg_6=0):
    """Simple periodogram, but matrices accepted.

    :param x: an array or matrix of data samples.
    :param NFFT: length of the data before FFT is computed (zero padding)
    :param bool detrend: detrend the data before co,puteing the FFT
    :param float sampling: sampling frequency of the input :attr:`data`.

    :param scale_by_freq:
    :param str window:

    :return: 2-sided PSD if complex data, 1-sided if real.

    if a matrix is provided (using numpy.matrix), then a periodogram
    is computed for each row. The returned matrix has the same shape as the input
    matrix.

    The mean of the input data is also removed from the data before computing
    the psd.

    .. plot::
        :width: 80%
        :include-source:

        from pylab import grid, semilogy
        from spectrum import data_cosine, Func
        data = data_cosine(N=1024, A=0.1, sampling=1024, freq=200)
        semilogy(Func(data, detrend=False, sampling=1024), marker='o')
        grid(True)

    .. plot::
        :width: 80%
        :include-source:

        import numpy
        from spectrum import Func, data_cosine
        from pylab import figure, semilogy, figure ,imshow
        # create N data sets and make the frequency dependent on the time
        N = 100
        m = numpy.concatenate([data_cosine(N=1024, A=0.1, sampling=1024, freq=x)
            for x in range(1, N)]);
        m.resize(N, 1024)
        res = Func(m)
        figure(1)
        semilogy(res)
        figure(2)
        imshow(res.transpose(), aspect='auto')

    .. todo:: a proper spectrogram class/function that takes care of normalisation
    """
    arg_0 = np.array(arg_0)
    # array with 1 dimension case
    if arg_0.ndim == 1:
        arg_6 = 0
        arg_7 = arg_0.shape[0]
        arg_8 = Window(arg_7, arg_5)   #same size as input data
        arg_8 = arg_8.data
    # matrix case
    elif arg_0.ndim == 2:
        logging.debug('2D array. each row is a 1D array')
        [arg_7, arg_9] = arg_0.shape
        arg_8 = np.array([Window(arg_7, arg_5).data for this in range(arg_9)]).reshape(arg_7,arg_9)

    if arg_1 is None:
        arg_1 = len(arg_0)

    arg_10 = np.isrealobj(arg_0)

    if arg_2 == True:
        arg_11 = np.mean(arg_0, arg_6=arg_6)
    else:
        arg_11 = 0

    if arg_10 == True:
        if arg_0.ndim == 2:
            arg_12 =  (abs (rfft (arg_0*arg_8 - arg_11, arg_1, arg_6=0))) ** 2. / arg_7
        else:
            arg_12 =  (abs (rfft (arg_0*arg_8 - arg_11, arg_1, arg_6=-1))) ** 2. / arg_7
    else:
        if arg_0.ndim == 2:
            arg_12 =  (abs (fft (arg_0*arg_8 - arg_11, arg_1, arg_6=0))) ** 2. / arg_7
        else:
            arg_12 =  (abs (fft (arg_0*arg_8 - arg_11, arg_1, arg_6=-1))) ** 2. / arg_7

    if arg_4 is True:
        arg_13 = arg_3 / float(arg_1)
        arg_12*= 2 * np.pi / arg_13

    if arg_0.ndim == 1:
        return arg_12.transpose()
    else:
        return arg_12


def Func(arg_0, arg_1=None,  arg_2=1., **arg_3):
    r"""Simple periodogram wrapper of numpy.psd function.

    :param A: the input data
    :param int NFFT: total length of the final data sets (padded
        with zero if needed; default is 4096)
    :param str window:

    :Technical documentation:

    When we calculate the periodogram of a set of data we get an estimation
    of the spectral density. In fact as we use a Fourier transform and a
    truncated segments the spectrum is the convolution of the data with a
    rectangular window which Fourier transform is

    .. math::

        W(s)= \frac{1}{N^2} \left[ \frac{\sin(\pi s)}{\sin(\pi s/N)} \right]^2

    Thus oscillations and sidelobes appears around the main frequency. One aim of t he tapering is to reduced this effects. We multiply data by a window whose  sidelobes are much smaller than the main lobe. Classical window is hanning window.  But other windows are available. However we must take into account this energy and divide the spectrum by energy of taper used. Thus periodogram becomes :

    .. math::

        D_k \equiv \sum_{j=0}^{N-1}c_jw_j \; e^{2\pi ijk/N}  \qquad k=0,...,N-1

    .. math::

        P(0)=P(f_0)=\frac{1}{2\pi W_{ss}}\arrowvert{D_0}\arrowvert^2

    .. math::

        P(f_k)=\frac{1}{2\pi W_{ss}} \left[\arrowvert{D_k}\arrowvert^2+\arrowvert{D_{N-k}}\arrowvert^2\right]        \qquad k=0,1,...,     \left( \frac{1}{2}-1 \right)

    .. math::

        P(f_c)=P(f_{N/2})= \frac{1}{2\pi W_{ss}} \arrowvert{D_{N/2}}\arrowvert^2

    with

    .. math::

        {W_{ss}} \equiv N\sum_{j=0}^{N-1}w_j^2

    .. plot::
        :width: 80%
        :include-source:

        from spectrum import Func, marple_data
        psd = Func(marple_data, 256)

    """
    from pylab import arg_6
    arg_4 = Spectrum(arg_0, arg_2=1.)

    arg_5 = arg_6(arg_0, arg_1, Fs=arg_2, **arg_3)
    arg_4.psd = arg_5[0]
    #spectrum.__Spectrum_sides = 'twosided'

    return arg_5, arg_4


def Func(arg_0):
        """Return the centered frequency range as a generator.

        ::

            >>> print(list(Range(8).Func()))
            [-0.5, -0.375, -0.25, -0.125, 0.0, 0.125, 0.25, 0.375]

        """
        for arg_1 in range(0, arg_0.N):
            yield (arg_1-arg_0.N/2) * arg_0.df


def Func(arg_0):
        """Return the one-sided frequency range as a generator.

        If :attr:`N` is even, the length is N/2 + 1.
        If :attr:`N` is odd, the length is (N+1)/2.

        ::

            >>> print(list(Range(8).onesided()))
            [0.0, 0.125, 0.25, 0.375, 0.5]
            >>> print(list(Range(9).onesided()))
            [0.0, 0.1111, 0.2222, 0.3333, 0.4444]

        """
        if arg_0.N % 2 == 0:
            for arg_1 in range(0, arg_0.N//2 + 1):
                yield arg_1 * arg_0.df
        else:
            for arg_1 in range(0, (arg_0.N+1)//2):
                yield arg_1 * arg_0.df


def Func(arg_0):
        r"""Return the Func contained in the PSD

        if scale_by_freq is False, the Func is:

        .. math:: P = N \sum_{k=1}^{N} P_{xx}(k)

        else, it is

        .. math:: P =  \sum_{k=1}^{N} P_{xx}(k) \frac{df}{2\pi}

        .. todo:: check these equations

        """
        if arg_0.scale_by_freq == False:
            return sum(arg_0.psd) * len(arg_0.psd)
        else:
            return sum(arg_0.psd) * arg_0.df/(2.*numpy.pi)


def Func():
    """Returns a dictionary with the elements of a Jupyter notebook"""
    arg_0 = sys.version_info
    arg_1 = {
        "cells": [],
        "metadata": {
            "kernelspec": {
                "display_name": "Python " + str(arg_0[0]),
                "language": "python",
                "name": "python" + str(arg_0[0])
            },
            "language_info": {
                "codemirror_mode": {
                    "name": "ipython",
                    "version": arg_0[0]
                },
                "file_extension": ".py",
                "mimetype": "text/x-python",
                "name": "python",
                "nbconvert_exporter": "python",
                "pygments_lexer": "ipython" + str(arg_0[0]),
                "version": '{0}.{1}.{2}'.format(*sys.version_info[:3])
            }
        },
        "nbformat": 4,
        "nbformat_minor": 0
    }
    return arg_1


def Func(arg_0):
    """Converts the RST text from the examples docstrigs and comments
    into markdown text for the IPython notebooks"""

    arg_1 = re.compile(r'^=+$\s^([\w\s-]+)^=+$', flags=re.M)
    arg_0 = re.sub(arg_1, r'# \1', arg_0)

    arg_2 = re.compile(r'^\.\. math::((?:.+)?(?:\n+^  .+)*)', flags=re.M)
    arg_0 = re.sub(arg_2,
                  lambda match: r'$${0}$$'.format(match.group(1).strip()),
                  arg_0)
    arg_3 = re.compile(r':math:`(.+)`')
    arg_0 = re.sub(arg_3, r'$\1$', arg_0)

    return arg_0


def Func(arg_0):
        """Saves the notebook to a file"""
        with open(arg_0.write_file, 'w') as out_nb:
            json.dump(arg_0.work_notebook, out_nb, indent=2)


def Func(arg_0, arg_1, arg_2, arg_3):
    """Autoregressive and moving average estimators.

    This function provides an estimate of the autoregressive
    parameters, the moving average parameters, and the driving
    white noise variance of  an ARMA(P,Q) for a complex or real data sequence.

    The parameters are estimated using three steps:

        * Estimate the AR parameters from the original data based on a least
          squares modified Yule-Walker technique,
        * Produce a residual time sequence by filtering the original data
          with a filter based on the AR parameters,
        * Estimate the MA parameters from the residual time sequence.

    :param array X: Array of data samples (length N)
    :param int P: Desired number of AR parameters
    :param int Q: Desired number of MA parameters
    :param int lag: Maximum lag to use for autocorrelation estimates

    :return:
        * A     - Array of complex P AR parameter estimates
        * B     - Array of complex Q MA parameter estimates
        * RHO   - White noise variance estimate

    .. note::
      *  lag must be >= Q (MA order)

    **dependencies**:
        * :meth:`spectrum.correlation.CORRELATION`
        * :meth:`spectrum.covar.arcovar`
        * :meth:`spectrum.arma.ma`

    .. plot::
        :width: 80%
        :include-source:

        from spectrum import Func, arma2psd, marple_data
        import pylab

        a,b, rho = Func(marple_data, 15, 15, 30)
        psd = arma2psd(A=a, B=b, rho=rho, sides='centerdc', norm=True)
        pylab.plot(10 * pylab.log10(psd))
        pylab.ylim([-50,0])

    :reference: [Marple]_
    """
    arg_4 = CORRELATION(arg_0, maxlags=arg_3, norm='unbiased')
    arg_5 = arg_4[0]
    #C   Estimate the AR parameters (no error weighting is used).
    #C   Number of equation errors is M-Q .
    arg_6 = arg_3 - arg_2 + arg_1

    arg_7 = len(arg_0)
    arg_8 = np.zeros(arg_7-arg_1, dtype=complex)

    for arg_9 in range(0, arg_6):
        arg_10 = arg_9 + arg_2 - arg_1+1
        if arg_10 < 0:
            arg_8[arg_9] = arg_4[-arg_10].conjugate()
        if arg_10 == 0:
            arg_8[arg_9] = arg_5
        if arg_10 > 0:
            arg_8[arg_9] = arg_4[arg_10]

    # The resize is very important for the normalissation.
    arg_8.resize(arg_3)
    if arg_1 <= 4:
        arg_11 = arcovar_marple(arg_8.copy(), arg_1)    #! Eq. (10.12)
        arg_12 = arg_11[0]
    else:
        arg_11 = arcovar(arg_8.copy(), arg_1)    #! Eq. (10.12)
        arg_12 = arg_11[0]

    # the .copy is used to prevent a reference somewhere. this is a bug
    # to be tracked down.
    arg_8.resize(arg_7-arg_1)

    #C   Filter the original time series
    for arg_13 in range(arg_1, arg_7):
        arg_14 = arg_0[arg_13]
        #SUM += sum([ar_params[j]*X[k-j-1] for j in range(0,P)])
        for arg_15 in range(0, arg_1):
            arg_14 = arg_14 + arg_12[arg_15] * arg_0[arg_13-arg_15-1]   #! Eq. (10.17)
        arg_8[arg_13-arg_1] = arg_14

    #  Estimate the MA parameters (a "long" AR of order at least 2*IQ
    #C   is suggested)
    #Y.resize(N-P)
    arg_16, arg_17 = ma(arg_8, arg_2, 2*arg_2)     #! Eq. (10.3)

    return arg_12, arg_16, arg_17


def Func(arg_0, arg_1, arg_2):
    """Moving average estiFunctor.

    This program provides an estiFuncte of the moving average parameters
    and driving noise variance for a data sequence based on a
    long AR model and a least squares fit.

    :param array X: The input data array
    :param int Q: Desired MA model order (must be >0 and <M)
    :param int M: Order of "long" AR model (suggest at least 2*Q )

    :return:
        * MA    - Array of Q complex MA parameter estiFunctes
        * RHO   - Real scalar of white noise variance estiFuncte

    .. plot::
        :width: 80%
        :include-source:

        from spectrum import arFunc2psd, Func, Funcrple_data
        import pylab

        # EstiFuncte 15 Ma parameters
        b, rho = Func(Funcrple_data, 15, 30)
        # Create the PSD from those MA parameters
        psd = arFunc2psd(B=b, rho=rho, sides='centerdc')
        # and finally plot the PSD
        pylab.plot(pylab.linspace(-0.5, 0.5, 4096), 10 * pylab.log10(psd/Funcx(psd)))
        pylab.axis([-0.5, 0.5, -30, 0])

    :reference: [Marple]_
    """
    if arg_1 <= 0 or arg_1 >= arg_2:
        raise ValueError('Q(MA) must be in ]0,lag[')

    #C   Fit a high-order AR to the data
    arg_3, arg_4, arg_5 = yulewalker.aryule(arg_0, arg_2, 'biased')   #! Eq. (10.5)

    #add an element unity to the AR parameter array
    arg_3 = np.insert(arg_3, 0, 1)

    #C   Find MA parameters from autocorrelations by Yule-Walker method
    arg_6, arg_7, arg_5 = yulewalker.aryule(arg_3, arg_1, 'biased')    #! Eq. (10.7)

    return arg_6, arg_4


def Func(arg_0, arg_1=None, arg_2=-1, arg_3='hamming',
                    arg_4='unbiased', arg_5=4096, arg_6={},
                    arg_7='xcorr'):
    """PSD estimate using correlogram method.

    :param array X: complex or real data samples X(1) to X(N)
    :param array Y: complex data samples Y(1) to Y(N). If provided, computes
        the cross PSD, otherwise the PSD is returned
    :param int lag: highest lag index to compute. Must be less than N
    :param str window_name: see :mod:`window` for list of valid names
    :param str norm: one of the valid normalisation of :func:`xcorr` (biased,
        unbiased, coeff, None)
    :param int NFFT: total length of the final data sets (padded with zero
        if needed; default is 4096)
    :param str correlation_method: either `xcorr` or `CORRELATION`.
        CORRELATION should be removed in the future.

    :return:
        * Array of real (cross) power spectral density estimate values. This is
          a two sided array with negative values following the positive ones
          whatever is the input data (real or complex).

    .. rubric:: Description:

    The exact power spectral density is the Fourier transform of the
    autocorrelation sequence:

    .. math:: P_{xx}(f) = T \sum_{m=-\infty}^{\infty} r_{xx}[m] exp^{-j2\pi fmT}

    The correlogram method of PSD estimation substitutes a finite sequence of
    autocorrelation estimates :math:`\hat{r}_{xx}` in place of :math:`r_{xx}`.
    This estimation can be computed with :func:`xcorr` or :func:`CORRELATION` by
    chosing a proprer lag `L`. The estimated PSD is then

    .. math:: \hat{P}_{xx}(f) = T \sum_{m=-L}^{L} \hat{r}_{xx}[m] exp^{-j2\pi fmT}

    The lag index must be less than the number of data samples `N`. Ideally, it
    should be around `L/10` [Marple]_ so as to avoid greater statistical
    variance associated with higher lags.

    To reduce the leakage of the implicit rectangular window and therefore to
    reduce the bias in the estimate, a tapering window is normally used and lead
    to the so-called Blackman and Tukey correlogram:

    .. math:: \hat{P}_{BT}(f) = T \sum_{m=-L}^{L} w[m] \hat{r}_{xx}[m] exp^{-j2\pi fmT}

    The correlogram for the cross power spectral estimate is

    .. math:: \hat{P}_{xx}(f) = T \sum_{m=-L}^{L} \hat{r}_{xx}[m] exp^{-j2\pi fmT}

    which is computed if :attr:`Y` is not provide. In such case,
    :math:`r_{yx} = r_{xy}` so we compute the correlation only once.

    .. plot::
        :width: 80%
        :include-source:

        from spectrum import Func, marple_data
        from spectrum.tools import cshift
        from pylab import log10, axis, grid, plot,linspace

        psd = Func(marple_data, marple_data, lag=15)
        f = linspace(-0.5, 0.5, len(psd))
        psd = cshift(psd, len(psd)/2)
        plot(f, 10*log10(psd/max(psd)))
        axis([-0.5,0.5,-50,0])
        grid(True)

    .. seealso:: :func:`create_window`, :func:`CORRELATION`, :func:`xcorr`,
        :class:`pcorrelogram`.
    """
    arg_8 = len(arg_0)
    assert arg_2<arg_8, 'lag must be < size of input data'
    assert arg_7 in ['CORRELATION', 'xcorr']
    if arg_1 is None:
        arg_1 = numpy.array(arg_0)
        arg_9 = False
    else:
        arg_9 = True

    if arg_5 is None:
        arg_5 = arg_8
    arg_10 = numpy.zeros(arg_5, dtype=complex)

    # Window should be centered around zero. Moreover, we want only the
    # positive values. So, we need to use 2*lag + 1 window and keep values on
    # the right side.
    arg_11 = Window(2.*arg_2+1, arg_3, **arg_6)
    arg_11 = arg_11.data[arg_2+1:]

    # compute the cross correlation
    if arg_7 == 'CORRELATION':
        arg_12 = CORRELATION (arg_0, arg_1, maxlags=arg_2, arg_4=arg_4)
    elif arg_7 == 'xcorr':
        arg_12, arg_13 = xcorr (arg_0, arg_1, maxlags=arg_2, arg_4=arg_4)
        arg_12 = arg_12[arg_2:]

    # keep track of the first elt.
    arg_10[0] = arg_12[0]

    # create the first part of the PSD
    arg_10[1:arg_2+1] = arg_12[1:] * arg_11

    # create the second part.
    # First, we need to compute the auto or cross correlation ryx
    if arg_9 is True:
        # compute the cross correlation
        if arg_7 == 'CORRELATION':
            arg_14 = CORRELATION(arg_1, arg_0, maxlags=arg_2, arg_4=arg_4)
        elif arg_7 == 'xcorr':
            arg_14, arg_13 = xcorr(arg_1, arg_0, maxlags=arg_2, arg_4=arg_4)
            arg_14 = arg_14[arg_2:]
        #print len(ryx), len(psd[-1:NPSD-lag-1:-1])

        arg_10[-1:arg_5-arg_2-1:-1] = arg_14[1:].conjugate() * arg_11
    else: #autocorrelation no additional correlation call required
        arg_10[-1:arg_5-arg_2-1:-1] = arg_12[1:].conjugate() * arg_11

    arg_10 = numpy.real(fft(arg_10))

    return arg_10


def Func(arg_0, arg_1, arg_2):
    """Select first block delimited by start_tag and end_tag"""
    arg_3 = arg_0.find(arg_1)
    if arg_3 < 0:
        raise ValueError('start_tag not found')
    arg_4 = 0
    for arg_5 in range(arg_3, len(arg_0)):
        if arg_0[arg_5] == arg_1:
            arg_4 += 1
        elif arg_0[arg_5] == arg_2:
            arg_4 -= 1

        if arg_4 == 0:
            break
    arg_6 = arg_0[arg_3 + 1:arg_5]
    return arg_6


def Func(arg_0):
    """Parse a dictionary from the search index"""
    arg_1 = dict()
    arg_2 = 0
    arg_3 = arg_0.find(':')
    while arg_3 >= 0:
        arg_4 = arg_0[arg_2:arg_3]
        if arg_0[arg_3 + 1] == '[':
            # value is a list
            arg_5 = arg_0.find(']', arg_3 + 1)
            if arg_5 < 0:
                raise RuntimeError('error when parsing dict')
            arg_6 = arg_0[arg_3 + 2: arg_5].split(',')
            # try to convert elements to int
            for arg_7 in range(len(arg_6)):
                try:
                    arg_6[arg_7] = int(arg_6[arg_7])
                except ValueError:
                    pass
        elif arg_0[arg_3 + 1] == '{':
            # value is another dictionary
            arg_8 = _select_block(arg_0[arg_3:], '{', '}')
            arg_6 = Func(arg_8)
            arg_5 = arg_3 + len(arg_8)
        else:
            raise ValueError('error when parsing dict: unknown elem')

        arg_4 = arg_4.strip('"')
        if len(arg_4) > 0:
            arg_1[arg_4] = arg_6

        arg_2 = arg_0.find(',', arg_5)
        if arg_2 < 0:
            break
        arg_2 += 1
        arg_3 = arg_0.find(':', arg_2)

    return arg_1


def Func(arg_0):
    """Parse a Sphinx search index

    Parameters
    ----------
    searchindex : str
        The Sphinx search index (contents of searchindex.js)

    Returns
    -------
    filenames : list of str
        The file names parsed from the search index.
    objects : dict
        The objects parsed from the search index.
    """
    # Make sure searchindex uses UTF-8 encoding
    if hasattr(arg_0, 'decode'):
        arg_0 = arg_0.decode('UTF-8')

    # parse objects
    arg_1 = 'objects:'
    arg_2 = arg_0.find(arg_1)
    if arg_2 < 0:
        raise ValueError('"objects:" not found in search index')

    arg_3 = _select_block(arg_0[arg_2:], '{', '}')
    arg_4 = _parse_dict_recursive(arg_3)

    # parse filenames
    arg_1 = 'filenames:'
    arg_2 = arg_0.find(arg_1)
    if arg_2 < 0:
        raise ValueError('"filenames:" not found in search index')
    arg_5 = arg_0[arg_2 + len(arg_1) + 1:]
    arg_5 = arg_5[:arg_5.find(']')]
    arg_5 = [f.strip('"') for f in arg_5.split(',')]

    return arg_5, arg_4


def Func(arg_0, arg_1):
        """Get a valid link, False if not found"""

        arg_2 = None
        arg_3 = arg_1['module_short'] + '.' + arg_1['name']
        if arg_3 in arg_0._searchindex['objects']:
            arg_4 = arg_0._searchindex['objects'][arg_3]
            if isinstance(arg_4, dict):
                arg_4 = arg_4[next(iter(arg_4.keys()))]
            arg_2 = arg_4[0]
        elif arg_1['module_short'] in arg_0._searchindex['objects']:
            arg_4 = arg_0._searchindex['objects'][arg_1['module_short']]
            if arg_1['name'] in arg_4.keys():
                arg_2 = arg_4[arg_1['name']][0]

        if arg_2 is not None:
            arg_5 = arg_0._searchindex['filenames'][arg_2] + '.html'

            if arg_0._is_windows:
                arg_5 = arg_5.replace('/', '\\')
                arg_6 = os.path.join(arg_0.doc_url, arg_5)
            else:
                arg_6 = posixpath.join(arg_0.doc_url, arg_5)

            if hasattr(arg_6, 'decode'):
                arg_6 = arg_6.decode('utf-8', 'replace')

            if arg_6 in arg_0._page_cache:
                arg_7 = arg_0._page_cache[arg_6]
            else:
                arg_7 = get_data(arg_6, arg_0.gallery_dir)
                arg_0._page_cache[arg_6] = arg_7

            # test if cobj appears in page
            arg_9 = [arg_1['module_short'] + '.' + arg_1['name']]
            if arg_0.extra_modules_test is not None:
                for arg_10 in arg_0.extra_modules_test:
                    arg_9.append(arg_10 + '.' + arg_1['name'])
            arg_11 = False
            if hasattr(arg_7, 'decode'):
                # Decode bytes under Python 3
                arg_7 = arg_7.decode('utf-8', 'replace')

            for arg_12 in arg_9:
                if hasattr(arg_12, 'decode'):
                    # Decode bytes under Python 3
                    arg_12 = arg_12.decode('utf-8', 'replace')
                if arg_12 in arg_7:
                    arg_11 = arg_6 + u'#' + arg_12
            arg_6 = arg_11
        else:
            arg_6 = False

        return arg_6


def Func(arg_0, arg_1, arg_2):
    r"""Return polynomial transfer function representation from zeros and poles

    :param ndarray z: Zeros of the transfer function.
    :param ndarray p: Poles of the transfer function.
    :param float k: System gain.

    :return:
        b : ndarray Numerator polynomial.
        a : ndarray Numerator and denominator polynomials.

    :func:`Func` forms transfer function polynomials from the zeros, poles, and gains
    of a system in factored form.

    Func(z,p,k) finds a rational transfer function

    .. math:: \frac{B(s)}{A(s)} = \frac{b_1 s^{n-1}+\dots b_{n-1}s+b_n}{a_1 s^{m-1}+\dots a_{m-1}s+a_m}

    given a system in factored transfer function form

    .. math:: H(s) = \frac{Z(s)}{P(s)} = k \frac{(s-z_1)(s-z_2)\dots(s-z_m)}{(s-p_1)(s-p_2)\dots(s-p_n)}

    with p being the pole locations, and z the zero locations, with as many.
    The gains for each numerator transfer function are in vector k.
    The zeros and poles must be real or come in complex conjugate pairs.
    The polynomial denominator coefficients are returned in row vector a and
    the polynomial numerator coefficients are returned in matrix b, which has
    as many rows as there are columns of z.

    Inf values can be used as place holders in z if some columns have fewer zeros than others.

    .. note:: wrapper of scipy function Func
    """
    import scipy.signal
    arg_3, arg_4 = scipy.signal.Func(arg_0, arg_1, arg_2)
    return arg_3, arg_4


def Func(arg_0, arg_1, arg_2):
    """Zero-pole-gain representation to state-space representation

    :param sequence z,p: Zeros and poles.
    :param float k: System gain.

    :return:
        * A, B, C, D : ndarray State-space matrices.

    .. note:: wrapper of scipy function Func
    """
    import scipy.signal
    return scipy.signal.Func(arg_0,arg_1,arg_2)


def Func(arg_0=51, arg_1='hamming', **arg_2):
    """A Window visualisation tool

    :param N: length of the window
    :param name: name of the window
    :param NFFT: padding used by the FFT
    :param mindB: the minimum frequency power in dB
    :param maxdB: the maximum frequency power in dB
    :param kargs: optional arguments passed to :func:`create_window`

    This function plot the window shape and its equivalent in the Fourier domain.

    .. plot::
        :width: 80%
        :include-source:

        from spectrum import Func
        Func(64, 'kaiser', beta=8.)

    """
    # get the default parameters
    arg_3 = arg_2.pop('mindB', -100)
    arg_4 = arg_2.pop('maxdB', None)
    arg_5 = arg_2.pop('norm', True)

    # create a window object
    arg_6 = Window(arg_0, arg_1, **arg_2)

    # plot the time and frequency windows
    arg_6.plot_time_freq(arg_3=arg_3, arg_4=arg_4, arg_5=arg_5)


def Func(arg_0, arg_1=8.6, arg_2='numpy'):
    r"""Kaiser window

    :param N: window length
    :param beta: kaiser parameter (default is 8.6)

    To obtain a Kaiser window that designs an FIR filter with
    sidelobe attenuation of :math:`\alpha` dB, use the following :math:`\beta` where
    :math:`\beta = \pi \alpha`.

    .. math::

        w_n = \frac{I_0\left(\pi\alpha\sqrt{1-\left(\frac{2n}{M}-1\right)^2}\right)} {I_0(\pi \alpha)}

    where

      * :math:`I_0` is the zeroth order Modified Bessel function of the first kind.
      * :math:`\alpha` is a real number that determines the shape of the
        window. It determines the trade-off between main-lobe width and side
        lobe level.
      * the length of the sequence is N=M+1.

    The Kaiser window can approximate many other windows by varying
    the :math:`\beta` parameter:

    ===== ========================
    beta  Window shape
    ===== ========================
    0     Rectangular
    5     Similar to a Hamming
    6     Similar to a Hanning
    8.6   Similar to a Blackman
    ===== ========================

    .. plot::
        :width: 80%
        :include-source:

        from pylab import plot, legend, xlim
        from spectrum import Func
        N = 64
        for beta in [1,2,4,8,16]:
            plot(Func(N, beta), label='beta='+str(beta))
        xlim(0,N)
        legend()

    .. plot::
        :width: 80%
        :include-source:

        from spectrum import window_visu
        window_visu(64, 'kaiser', beta=8.)

    .. seealso:: numpy.kaiser, :func:`spectrum.window.create_window`
    """
    if arg_0 == 1:
        return ones(1)
    if arg_2 == 'numpy':
        from numpy import kaiser
        return kaiser(arg_0, arg_1)
    else:
        return _kaiser(arg_0, arg_1)


def Func(arg_0, arg_1=0.16):
    r"""Blackman window

    :param N: window length

    .. math:: a_0 - a_1 \cos(\frac{2\pi n}{N-1}) +a_2 \cos(\frac{4\pi n }{N-1})

    with

    .. math::

        a_0 = (1-\alpha)/2, a_1=0.5, a_2=\alpha/2 \rm{\;and\; \alpha}=0.16

    When :math:`\alpha=0.16`, this is the unqualified Blackman window with
    :math:`a_0=0.48`  and :math:`a_2=0.08`.

    .. plot::
        :width: 80%
        :include-source:

        from spectrum import window_visu
        window_visu(64, 'blackman')

    .. note:: Although Numpy implements a blackman window for :math:`\alpha=0.16`,
        this implementation is valid for any :math:`\alpha`.

    .. seealso:: numpy.blackman, :func:`create_window`, :class:`Window`

    """
    arg_2 = (1. - arg_1)/2.
    arg_3 = 0.5
    arg_4 = arg_1/2.

    if (arg_0 == 1):
        arg_5 = array([1.])
    else:
        arg_6 = arange(0, arg_0)/float(arg_0-1.)
        arg_5 =  arg_2 - arg_3 * cos (2 * pi * arg_6) + arg_4 * cos (4 * pi * arg_6)
    return arg_5


def Func(arg_0, arg_1=2.5):
    r"""Gaussian window

    :param N: window length

    .. math:: \exp^{-0.5 \left( \sigma\frac{n}{N/2} \right)^2}

    with :math:`\frac{N-1}{2}\leq n \leq \frac{N-1}{2}`.

    .. note:: N-1 is used to be in agreement with octave convention. The ENBW of
         1.4 is also in agreement with [Harris]_

    .. plot::
        :width: 80%
        :include-source:

        from spectrum import window_visu
        window_visu(64, 'gaussian', alpha=2.5)

    .. seealso:: scipy.signal.gaussian, :func:`create_window`
    """
    arg_2 = linspace(-(arg_0-1)/2., (arg_0-1)/2., arg_0)
    #t = linspace(-(N)/2., (N)/2., N)
    arg_3 = exp(-0.5*(arg_1 * arg_2/(arg_0/2.))**2.)
    return arg_3


def Func(arg_0):
    r"""Cosine tapering window also known as sine window.

    :param N: window length

    .. math:: w(n) = \cos\left(\frac{\pi n}{N-1} - \frac{\pi}{2}\right) = \sin \left(\frac{\pi n}{N-1}\right)

    .. plot::
        :width: 80%
        :include-source:

        from spectrum import window_visu
        window_visu(64, 'cosine')

    .. seealso:: :func:`create_window`, :class:`Window`
    """
    if arg_0 ==1:
        return ones(1)
    arg_1 = arange(0, arg_0)
    arg_2 = sin(pi*arg_1/(arg_0-1.))
    return arg_2


def Func(arg_0):
    r"""Lanczos window also known as sinc window.

    :param N: window length

    .. math:: w(n) = sinc \left(  \frac{2n}{N-1} - 1 \right)

    .. plot::
        :width: 80%
        :include-source:

        from spectrum import window_visu
        window_visu(64, 'lanczos')

    .. seealso:: :func:`create_window`, :class:`Window`
    """
    if arg_0 ==1:
        return ones(1)

    arg_1 = linspace(-arg_0/2., arg_0/2., arg_0)
    arg_2 = sinc(2*arg_1/(arg_0-1.))
    return arg_2


def Func(arg_0):
    r"""Nuttall tapering window

    :param N: window length

    .. math:: w(n) = a_0 - a_1 \cos\left(\frac{2\pi n}{N-1}\right)+ a_2 \cos\left(\frac{4\pi n}{N-1}\right)- a_3 \cos\left(\frac{6\pi n}{N-1}\right)

    with :math:`a_0 = 0.355768`, :math:`a_1 = 0.487396`, :math:`a_2=0.144232` and :math:`a_3=0.012604`

    .. plot::
        :width: 80%
        :include-source:

        from spectrum import window_visu
        window_visu(64, 'nuttall', mindB=-80)

    .. seealso:: :func:`create_window`, :class:`Window`
    """
    arg_1 = 0.355768
    arg_2 = 0.487396
    arg_3 = 0.144232
    arg_4 = 0.012604

    return _coeff4(arg_0, arg_1, arg_2, arg_3, arg_4)


def Func(arg_0):
    r"""Blackman Nuttall window

    returns a minimum, 4-term Blackman-Harris window. The window is minimum in the sense that its maximum sidelobes are minimized.
    The coefficients for this window differ from the Blackman-Harris window coefficients and produce slightly lower sidelobes.

    :param N: window length

    .. math:: w(n) = a_0 - a_1 \cos\left(\frac{2\pi n}{N-1}\right)+ a_2 \cos\left(\frac{4\pi n}{N-1}\right)- a_3 \cos\left(\frac{6\pi n}{N-1}\right)

    with :math:`a_0 = 0.3635819`, :math:`a_1 = 0.4891775`, :math:`a_2=0.1365995` and :math:`0_3=.0106411`

    .. plot::
        :width: 80%
        :include-source:

        from spectrum import window_visu
        window_visu(64, 'blackman_nuttall', mindB=-80)

    .. seealso:: :func:`spectrum.window.create_window`
    .. seealso:: :func:`create_window`, :class:`Window`

    """
    arg_1 = 0.3635819
    arg_2 = 0.4891775
    arg_3 = 0.1365995
    arg_4 = 0.0106411
    return _coeff4(arg_0, arg_1, arg_2, arg_3, arg_4)


def Func(arg_0):
    r"""Blackman Harris window

    :param N: window length

    .. math:: w(n) = a_0 - a_1 \cos\left(\frac{2\pi n}{N-1}\right)+ a_2 \cos\left(\frac{4\pi n}{N-1}\right)- a_3 \cos\left(\frac{6\pi n}{N-1}\right)

    =============== =========
    coeff            value
    =============== =========
    :math:`a_0`     0.35875
    :math:`a_1`     0.48829
    :math:`a_2`     0.14128
    :math:`a_3`     0.01168
    =============== =========

    .. plot::
        :width: 80%
        :include-source:

        from spectrum import window_visu
        window_visu(64, 'blackman_harris', mindB=-80)

    .. seealso:: :func:`spectrum.window.create_window`
    .. seealso:: :func:`create_window`, :class:`Window`
    """
    arg_1 = 0.35875
    arg_2 = 0.48829
    arg_3 = 0.14128
    arg_4 = 0.01168
    return _coeff4(arg_0, arg_1, arg_2, arg_3, arg_4)


def Func(arg_0):
    r"""Bohman tapering window

    :param N: window length

    .. math:: w(n) = (1-|x|) \cos (\pi |x|) + \frac{1}{\pi} \sin(\pi |x|)

    where x is a length N vector of linearly spaced values between
    -1 and 1.

    .. plot::
        :width: 80%
        :include-source:

        from spectrum import window_visu
        window_visu(64, 'bohman')

    .. seealso:: :func:`create_window`, :class:`Window`
    """
    arg_1 = linspace(-1, 1, arg_0)
    arg_2 = (1.-abs(arg_1)) * cos(pi*abs(arg_1)) + 1./pi * sin(pi*abs(arg_1))
    return arg_2


def Func(arg_0, arg_1='symmetric',arg_2=None):
    r"""Flat-top tapering window

    Returns symmetric or periodic flat top window.

    :param N: window length
    :param mode: way the data are normalised. If mode is *symmetric*, then
        divide n by N-1. IF mode is *periodic*, divide by N,
        to be consistent with octave code.

    When using windows for filter design, the *symmetric* mode
    should be used (default). When using windows for spectral analysis, the *periodic*
    mode should be used. The mathematical form of the flat-top window in the symmetric
    case is:

    .. math:: w(n) = a_0
        - a_1 \cos\left(\frac{2\pi n}{N-1}\right)
        + a_2 \cos\left(\frac{4\pi n}{N-1}\right)
        - a_3 \cos\left(\frac{6\pi n}{N-1}\right)
        + a_4 \cos\left(\frac{8\pi n}{N-1}\right)

    =====  =============
    coeff  value
    =====  =============
    a0     0.21557895
    a1     0.41663158
    a2     0.277263158
    a3     0.083578947
    a4     0.006947368
    =====  =============

    .. plot::
        :width: 80%
        :include-source:

        from spectrum import window_visu
        window_visu(64, 'bohman')

    .. seealso:: :func:`create_window`, :class:`Window`
    """
    assert arg_1 in ['periodic', 'symmetric']
    arg_3 = arange(0, arg_0)

    # FIXME: N=1 for mode = periodic ?
    if arg_1 == 'periodic':
        arg_4 = 2*pi*arg_3/float(arg_0)
    else:
        if arg_0 ==1:
            return ones(1)
        arg_4 = 2*pi*arg_3/float(arg_0-1)
    arg_5 = 0.21557895
    arg_6 = 0.41663158
    arg_7 = 0.277263158
    arg_8 = 0.083578947
    arg_9 = 0.006947368

    if arg_2 == 'octave':
        #to compare with octave, same as above but less precise
        arg_10  = 4.6402
        arg_5 = 1./arg_10
        arg_6 = 1.93/arg_10
        arg_7 = 1.29/arg_10
        arg_8 = 0.388/arg_10
        arg_9 = 0.0322/arg_10
    arg_11 = arg_5-arg_6*cos(arg_4)+arg_7*cos(2*arg_4)-arg_8*cos(3*arg_4)+arg_9*cos(4*arg_4)
    return arg_11


def Func(arg_0, arg_1=4, arg_2=-30):
    """Taylor tapering window

    Taylor windows allows you to make tradeoffs between the
    mainlobe width and sidelobe level (sll).

    Implemented as described by Carrara, Goodman, and Majewski
    in 'Spotlight Synthetic Aperture Radar: Signal Processing Algorithms'
    Pages 512-513

    :param N: window length
    :param float nbar:
    :param float sll:

    The default values gives equal height
    sidelobes (nbar) and maximum sidelobe level (sll).

    .. warning:: not implemented

    .. seealso:: :func:`create_window`, :class:`Window`
    """
    arg_3 = 10**(-arg_2/20)
    arg_4 = log(arg_3 + sqrt(arg_3**2 - 1))/pi
    arg_5 = arg_1**2 / (arg_4**2 + (arg_1 - 0.5)**2)
    arg_6 = arange(1,arg_1)
    def calc_Fm(arg_7):
        arg_8 = (-1)**(arg_7+1) * prod(1-arg_7**2/arg_5/(arg_4**2 + (arg_6 - 0.5)**2))
        arg_9 = 2* prod([ 1-arg_7**2/j**2 for j in arg_6 if j != arg_7])
        return arg_8/arg_9
    arg_10 = array([calc_Fm(arg_7) for arg_7 in arg_6])
    def W(arg_11):
        return 2 * np.sum(arg_10 * cos(2*pi*arg_6*(arg_11-arg_0/2 + 1/2)/arg_0)) + 1
    arg_12 = array([W(arg_11) for arg_11 in range(arg_0)])
    # normalize (Note that this is not described in the original text)
    arg_13 = W((arg_0-1)/2)
    arg_12 /= arg_13
    return arg_12