def convert_single_elem_array_to_scalar(obj, keepdims=False):
    """
    Convert array with single element to scalar
    """

    if (obj.ndim > 0) and (obj.size == 1) and (keepdims is False):
        return obj.dtype.type(obj[0])

    return obj