def _pattern_common(**params):
    """
    Do common preprocessing steps for pattern_match and pattern_count.

    Not really useful on its own.

    Args:
        data (list): values.
        params (kwargs):
            pattern (str or list): the pattern to be sought in data (obligatory)
            metric (str): 'identity' counts identical positions,
                           'euclid' calculates the Euclidean distance (L2 norm),
                           'taxi' calculates the taxicab (Manhattan) distance
                               (L1 norm).
                           'sup' returns maximum distance between positions,
                           'inf' returns minimum distance between positions.
                           Only 'identity' can be used with non-numerical data.
            radius (number): the similarity cutoff (non-negative)

    Returns:
        pattern (list): the pattern to be sought in data as a list.
        patlen (int): length of the pattern.
        metric (str): name of the metric for calculating match similarity.

   Raises:
        NameError when 'pattern' is not given,
        TypeError if 'pattern' is neither string nor list,
        ValueError if 'radius' is negative or unsupported distance method used.
    """

    if 'pattern' in params:
        if isinstance(params['pattern'], list):
            pattern = params['pattern']
        elif isinstance(params['pattern'], str):
            pattern = list(params['pattern'])
        else:
            raise TypeError("The pattern should be either list or a string.")
    else:
        raise NameError("No pattern provided.")

    patlen = len(pattern)

    radius = params['radius'] if 'radius' in params else 0

    if radius < 0:
        raise ValueError("Similarity radius cannot be negative.")

    metric = params['metric'] if 'metric' in params else 'identity'

    if metric not in ['identity', 'taxi', 'euclid', 'sup', 'inf']:
        raise ValueError("Unsupported distance metric.")

    return pattern, patlen, radius, metric