# histogrammar.defs.Container¶

class histogrammar.defs.Container[source]

Bases: object

Interface for classes that contain aggregated data, such as “Count” or “Bin”.

Containers are monoids: they have a neutral element (zero) and an associative operator (+). Thus, partial sums aggregated in parallel can be combined arbitrarily.

__add__(other)

Add two containers of the same type. The originals are unaffected.

__init__

x.__init__(...) initializes x; see help(type(x)) for signature

children

List of sub-aggregators, to make it possible to walk the tree.

copy()

Copy this container, making a clone with no reference to the original.

factory

Reference to the container’s factory for runtime reflection.

fill(datum, weight=1.0)

Increment the aggregator by providing one datum to the fill rule with a given weight.

Usually all containers in a collection of histograms take the same input data by passing it recursively through the tree. Quantities to plot are specified by the individual container’s lambda functions.

The container is changed in-place.

name

Name of the concrete Factory as a string; used to label the container type in JSON.

plot(httpServer=None, **parameters)

Generate a VEGA visualization and serve it via HTTP.

toImmutable()

Return a copy of this container as though it was created by the ed function or from JSON (the “immutable form” in languages that support it, not Python).

toJson()

Convert this container to dicts and lists representing JSON (dropping its fill method).

Note that the dicts and lists can be turned into a string with json.dumps.

toJsonFragment(suppressName)

Used internally to convert the container to JSON without its "type" header.

zero()

Create an empty container with the same parameters as this one. The original is unaffected.