# AUTOGENERATED! DO NOT EDIT! File to edit: 04_generate_coordinate.ipynb (unless otherwise specified).

__all__ = ['randomCoordinates', 'generateRandCoord']

# Cell
from pathlib import Path
import random
import pandas as pd


def randomCoordinates(file_csv:Path) -> list:
    """
        Select andomly a coordinate from a sequence of coordinates.
        The sequence of coordinates are created from data points stored in a "csv" format file.
        Data columns: "init_pto_x", "init_pto_y", "expand_x", expand_y"
    """

    df = pd.read_csv(file_csv, index_col=0)
    index = df.index
    init_pto_x = df['init_pto_x']
    init_pto_y = df['init_pto_y']
    expand_x = df['expand_x']
    expand_y = df['expand_y']
    _index_names = []
    _random_ptos = []
    for i in range(len(init_pto_x)):
        index_names = index[i]
        expand_x_coord = [[init_pto_x[i] + r, init_pto_y[i]] for r in range(expand_x[i])]
        expand_y_coord = [[init_pto_x[i], init_pto_y[i] + r] for r in range(expand_y[i])]
        random_x = random.choice(expand_x_coord)
        random_y = random.choice(expand_y_coord)
        # One random coordinates for each data point
        _random_ptos.append(random.choice([random_x] + [random_y]))
        _index_names.append(index_names)
    return _index_names, _random_ptos

# Todo: amplify this to general use.
def generateRandCoord(generate_size:int, axis:str, init_x:int, init_y:int) -> tuple:
    if generate_size > 0:
        if axis=="x":
            _coordinate = [[init_x + i, init_y] for i in range(generate_size)]
        elif axis == "y":
            _coordinate = [[init_x, init_y + 1] for i in range(generate_size)]
        else:
            print('Error, parameter axis must be either "x" or "y".')
    else:
        print(f'Please retry, generate_size parameter must have a min value of 1.')

    return tuple(random.choice(_coordinate))
# AUTOGENERATED! DO NOT EDIT! File to edit: 04_generate_coordinate.ipynb (unless otherwise specified).

__all__ = ['randomCoordinates', 'generateRandCoord']

# Cell
from pathlib import Path
import random
import pandas as pd


def randomCoordinates(file_csv:Path) -> list:
    """
        Select andomly a coordinate from a sequence of coordinates.
        The sequence of coordinates are created from data points stored in a "csv" format file.
        Data columns: "init_pto_x", "init_pto_y", "expand_x", expand_y"
    """

    df = pd.read_csv(file_csv, index_col=0)
    index = df.index
    init_pto_x = df['init_pto_x']
    init_pto_y = df['init_pto_y']
    expand_x = df['expand_x']
    expand_y = df['expand_y']
    _index_names = []
    _random_ptos = []
    for i in range(len(init_pto_x)):
        index_names = index[i]
        expand_x_coord = [[init_pto_x[i] + r, init_pto_y[i]] for r in range(expand_x[i])]
        expand_y_coord = [[init_pto_x[i], init_pto_y[i] + r] for r in range(expand_y[i])]
        random_x = random.choice(expand_x_coord)
        random_y = random.choice(expand_y_coord)
        # One random coordinates for each data point
        _random_ptos.append(random.choice([random_x] + [random_y]))
        _index_names.append(index_names)
    return _index_names, _random_ptos

# Todo: amplify this to general use.
def generateRandCoord(generate_size:int, axis:str, init_x:int, init_y:int) -> tuple:
    if generate_size > 0:
        if axis=="x":
            _coordinate = [[init_x + i, init_y] for i in range(generate_size)]
        elif axis == "y":
            _coordinate = [[init_x, init_y + 1] for i in range(generate_size)]
        else:
            print('Error, parameter axis must be either "x" or "y".')
    else:
        print(f'Please retry, generate_size parameter must have a min value of 1.')

    return tuple(random.choice(_coordinate))
# AUTOGENERATED! DO NOT EDIT! File to edit: 04_generate_coordinate.ipynb (unless otherwise specified). # Cell Select andomly a coordinate from a sequence of coordinates.         The sequence of coordinates are created from data points stored in a "csv" format file.         Data columns: "init_pto_x", "init_pto_y", "expand_x", expand_y" # One random coordinates for each data point # Todo: amplify this to general use.