def get_code ( x, code_out, code_in ):
    """Convert from one coding to another

    :Parameters:
        *x*
            input to be coded
        *code_out*
            desired code of the output
        *code_in*
            code of the input

    :Example:
    >>> code_out = [-1,1]
    >>> code_in  = [0,1]
    >>> get_code ( 1., code_out, code_in )
    1
    >>> get_code ( 0., code_out, code_in )
    -1
    >>> get_code ( 0., code_in, code_in )
    0
    >>> get_code ( 0., code_in, code_out )
    Traceback (most recent call last):
    ...
    ValueError: list.index(x): x not in list

    """
    if isinstance ( code_in, (list,tuple) ):
        return code_out[code_in.index(x)]
    else:
        return code_out[code_in.tolist ().index(x)]