# Path: lib/utils.py
# DTYPE_COORD = np.dtype([('x', np.float), ('y', np.float)])


import math
from lib.utils import DTYPE_COORD
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
'''



def largest_triangle_three_buckets(data, threshold):
    """
    Return a downsampled version of data.

    Parameters
    ----------
    data: list of lists
        data must be formated this way: [[x,y], [x,y], [x,y], ...]
    threshold: int
        threshold must be >= 2 and <= to the len of data

    Returns
    -------
    data, but downsampled using threshold
    """

    # Check if data and threshold are valid
    if not data.dtype == DTYPE_COORD:
        raise Exception("1. incorrect data provided")
    if not isinstance(threshold, int) or threshold <= 2 or threshold >= len(data):
        raise Exception("threshold not well defined: thr=" + str(threshold) + " total=" + str(len(data)))
    for i in data:

# Path: lib/utils.py
# DTYPE_COORD = np.dtype([('x', np.float), ('y', np.float)])


# Path: lib/lttb.py
import math
from lib.utils import DTYPE_COORD

AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
'''



def largest_triangle_three_buckets(data, threshold):
    """
    Return a downsampled version of data.

    Parameters
    ----------
    data: list of lists
        data must be formated this way: [[x,y], [x,y], [x,y], ...]
    threshold: int
        threshold must be >= 2 and <= to the len of data

    Returns
    -------
    data, but downsampled using threshold
    """

    # Check if data and threshold are valid
    if not data.dtype == DTYPE_COORD:
        raise Exception("1. incorrect data provided")
    if not isinstance(threshold, int) or threshold <= 2 or threshold >= len(data):
        raise Exception("threshold not well defined: thr=" + str(threshold) + " total=" + str(len(data)))
    for i in data:

        if not i.dtype == DTYPE_COORD or len(i) != 2: