def harmean(vals):
    """Compute the harmonic mean of list-like vals. Special case for presence of 0: return 0."""
    try:
        s = sum((1.0 / x for x in vals))
    except ZeroDivisionError:
        return 0.0
    return len(vals) / s