import copy


def replace_in(arr, replacement_dict, inplace=False):
    """Replace the keys found in `arr` with the values from
    the `replacement_dict`.
    """
    if inplace:
        new_arr = arr
    else:
        new_arr = copy.deepcopy(arr)
    for k, v in replacement_dict.items():
        new_arr[arr == k] = v
    return new_arr