if not ignore_nan and (any(numpy.isnan(values)) or any(numpy.isnan(weights))):
        return numpy.nan