sparselybin.py 文件源码

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

项目:Eskapade 作者: KaveIO 项目源码 文件源码
def __init__(self, binWidth, quantity, value=Count(), nanflow=Count(), origin=0.0):
        """Create a SparselyBin that is capable of being filled and added.

        Parameters:
            binWidth (float): the width of a bin; must be strictly greater than zero.
            quantity (function returning float): computes the quantity of interest from the data.
            value (:doc:`Container <histogrammar.defs.Container>`): generates sub-aggregators to put in each bin.
            nanflow (:doc:`Container <histogrammar.defs.Container>`): a sub-aggregator to use for data whose quantity is NaN.
            origin (float): the left edge of the bin whose index is 0.

        Other parameters:
            entries (float): the number of entries, initially 0.0.
            bins (dict from int to :doc:`Container <histogrammar.defs.Container>`): the map, probably a hashmap, to fill with values when their `entries` become non-zero.
        """
        if not isinstance(binWidth, numbers.Real):
            raise TypeError("binWidth ({0}) must be a number".format(binWidth))
        if value is not None and not isinstance(value, Container):
            raise TypeError("value ({0}) must be a Container".format(value))
        if not isinstance(nanflow, Container):
            raise TypeError("nanflow ({0}) must be a Container".format(nanflow))
        if not isinstance(origin, numbers.Real):
            raise TypeError("origin ({0}) must be a number".format(origin))
        if binWidth <= 0.0:
            raise ValueError("binWidth ({0}) must be greater than zero".format(binWidth))

        self.binWidth = binWidth
        self.entries = 0.0
        self.quantity = serializable(quantity)
        self.value = value
        if value is not None:
            self.contentType = value.name
        self.bins = {}
        self.nanflow = nanflow.copy()
        self.origin = origin
        super(SparselyBin, self).__init__()
        self.specialize()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号