def ed(binWidth, entries, contentType, bins, nanflow, origin):
"""Create a SparselyBin that is only capable of being added.
Parameters:
binWidth (float): the width of a bin.
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 int to :doc:`Container <histogrammar.defs.Container>`): the non-empty bin indexes and their values.
nanflow (:doc:`Container <histogrammar.defs.Container>`): the filled nanflow bin.
origin (float): the left edge of the bin whose index is zero.
"""
if not isinstance(binWidth, numbers.Real):
raise TypeError("binWidth ({0}) must be a number".format(binWidth))
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 isinstance(bins, dict) or not all(isinstance(k, (int, long)) and isinstance(v, Container) for k, v in bins.items()):
raise TypeError("bins ({0}) must be a map from 64-bit integers to Containers".format(bins))
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 entries < 0.0:
raise ValueError("entries ({0}) cannot be negative".format(entries))
if binWidth <= 0.0:
raise ValueError("binWidth ({0}) must be greater than zero".format(binWidth))
out = SparselyBin(binWidth, None, None, nanflow, origin)
out.entries = float(entries)
out.contentType = contentType
out.bins = bins
return out.specialize()
评论列表
文章目录