distribution.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:endpoints-management-python 作者: cloudendpoints 项目源码 文件源码
def _update_explicit_bucket_count(a_float, dist):
    """Adds `a_float` to `dist`, updating its explicit buckets.

    Args:
      a_float (float): a new value
      dist (:class:`endpoints_management.gen.servicecontrol_v1_messages.Distribution`):
        the Distribution being updated

    Raises:
      ValueError: if `dist` does not already have explict buckets defined
      ValueError: if there are not enough bucket count fields in `dist`
    """
    buckets = dist.explicitBuckets
    if buckets is None:
        raise ValueError(_BAD_UNSET_BUCKETS % (u'explicit buckets'))
    bucket_counts = dist.bucketCounts
    bounds = buckets.bounds
    if len(bucket_counts) < len(bounds) + 1:
        raise ValueError(_BAD_LOW_BUCKET_COUNT)
    bucket_counts[bisect.bisect(bounds, a_float)] += 1
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号