#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
#   Copyright 2016-2026 Blaise Frederick
#
#   Licensed under the Apache License, Version 2.0 (the "License");
#   you may not use this file except in compliance with the License.
#   You may obtain a copy of the License at
#
#       http://www.apache.org/licenses/LICENSE-2.0
#
#   Unless required by applicable law or agreed to in writing, software
#   distributed under the License is distributed on an "AS IS" BASIS,
#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#   See the License for the specific language governing permissions and
#   limitations under the License.
#
#
import matplotlib as mpl
import matplotlib.pyplot as plt
import numpy as np

import rapidtide.fit as tide_fit


def test_funcs(displayplots=False, debug=False):
    xvals = np.linspace(-10, 10, num=500, endpoint=True)

    height = 2.0
    width = 2.0
    loc = 5.0
    baseline = 0.0

    gaussvals = np.zeros_like(xvals)
    sincvals = np.zeros_like(xvals)

    for i in range(len(xvals)):
        gaussvals[i] = tide_fit.gaussfunc(xvals[i], height, loc, width)
        sincvals[i] = tide_fit.sincfunc(xvals[i], height, loc, width, baseline)
    if debug:
        print(xvals)
        print(gaussvals)
        print(sincvals)
    if displayplots:
        legend = []
        plt.figure()
        plt.plot(xvals, gaussvals)
        plt.plot(xvals, sincvals)
        plt.legend(["gauss", "sinc"])
        plt.show()


if __name__ == "__main__":
    mpl.use("TkAgg")
    test_funcs(displayplots=True, debug=True)
