def to_prefix(x):
    """
    Peak assignments with characters that are not compatible lmfit model naming
    are converted to lmfit "safe" names.

    :param x: Peak assignment to be used as prefix for lmfit model
    :type x: str

    :returns: lmfit model prefix (_Peak_assignment_)
    :rtype: str

    """
    if type(x) != str:
        x = str(x)
    prefix = '_' + x
    to_replace = [['.', '_'], [' ', ''], ['{', '_'], ['}', '_'], ['[', '_'],
        [']', '_'], ['-', ''], ['/', 'or'], ['?', 'maybe'], ['\\', ''], [
        '(', '_'], [')', '_']]
    for p in to_replace:
        prefix = prefix.replace(*p)
    return prefix + '_'
