import click


def _cb_res(ctx, param, value):

    """
    Click callback to validate and transform `--res`.  Forces all values to be
    positive.  If `--res` is only given once then the value is used for both
    X and Y.

    Returns
    -------
    tuple
        Element 0 is X res and element 1 is y res.
    """

    value = tuple(map(abs, value))

    # If no values are given still return the value.  There is an error check
    # later that ensures --res OR --shape are given.
    if len(value) is 2 or len(value) is 0:
        return value
    elif len(value) is 1:
        return value[0], value[0]
    else:
        raise click.BadParameter('specified too many times.')