categorize.py 文件源码

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

项目:Eskapade 作者: KaveIO 项目源码 文件源码
def ed(entries, contentType, binsAsDict=None, **bins):
        """Create a Categorize that is only capable of being added.

        Parameters:
            entries (float): the number of entries.
            contentType (str): the value's sub-aggregator type (must be provided to determine type for the case when `bins` is empty).
            bins (dict from str to :doc:`Container <histogrammar.defs.Container>`): the non-empty bin categories and their values.
        """
        if not isinstance(entries, numbers.Real) and entries not in ("nan", "inf", "-inf"):
            raise TypeError("entries ({0}) must be a number".format(entries))
        if not isinstance(contentType, basestring):
            raise TypeError("contentType ({0}) must be a string".format(contentType))
        if not all(isinstance(k, basestring) and isinstance(v, Container) for k, v in bins.items()):
            raise TypeError("bins ({0}) must be a dict from strings to Containers".format(bins))
        if entries < 0.0:
            raise ValueError("entries ({0}) cannot be negative".format(entries))

        out = Categorize(None, None)
        out.entries = float(entries)
        if binsAsDict is None:
            out.bins = {}
        else:
            out.bins = binsAsDict
        out.bins.update(bins)
        out.contentType = contentType
        return out.specialize()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号