def safemax(data, default=0):
    """ Return maximum of array with default value for empty array

    Args:
        data (array or list ): data to return the maximum
        default (obj): default value
    Returns:
        object: maximum value in the array or the default value
    """

    if isinstance(data, list):
        if len(data) == 0:
            maximum_value = default
        else:
            maximum_value = max(data)
        return maximum_value
    if data.size == 0:
        maximum_value = default
    else:
        maximum_value = data.max()
    return maximum_value