{"id":3912,"library":"boost-histogram","title":"Boost-histogram","description":"Boost-histogram is a high-performance Python library providing bindings for the C++14 Boost.Histogram library, designed for fast, multi-dimensional generalized histogramming. It treats histograms as first-class objects, enabling easy filling, manipulation, slicing, and projection. The library is currently at version 1.7.2 and maintains an active release cadence with frequent updates and new features, often driven by the Scikit-HEP project.","status":"active","version":"1.7.2","language":"en","source_language":"en","source_url":"https://github.com/scikit-hep/boost-histogram","tags":["histogram","data analysis","physics","scikit-hep","performance"],"install":[{"cmd":"pip install boost-histogram","lang":"bash","label":"Install with pip"},{"cmd":"conda install -c conda-forge boost-histogram","lang":"bash","label":"Install with Conda"}],"dependencies":[{"reason":"Used for efficient array operations, histogram views, and for multithreaded builds. Integrated for data input and output views.","package":"numpy"}],"imports":[{"symbol":"boost_histogram","correct":"import boost_histogram as bh"},{"note":"The common pattern is to import `boost_histogram` as `bh` and then access `Histogram` and axis types through `bh.Histogram` and `bh.axis.*`.","wrong":"from boost_histogram import Histogram","symbol":"Histogram","correct":"bh.Histogram(...)"},{"symbol":"axis.Regular","correct":"bh.axis.Regular(...)"}],"quickstart":{"code":"import boost_histogram as bh\nimport numpy as np\n\n# Create a 1D histogram with 10 bins from 0 to 1\nhist = bh.Histogram(bh.axis.Regular(10, 0, 1))\n\n# Fill the histogram with data\ndata = np.random.rand(1000)\nhist.fill(data)\n\n# Access histogram values (counts)\ncounts = hist.view()\nprint(f\"Histogram counts: {counts[:5]}...\")\n\n# Access axis centers\ncenters = hist.axes[0].centers\nprint(f\"Axis centers: {centers[:5]}...\")","lang":"python","description":"This quickstart demonstrates how to create a 1D histogram using a regular axis, fill it with random data, and then access its bin counts and axis centers."},"warnings":[{"fix":"Ensure your Python environment is 3.10 or newer when using `boost-histogram` version `1.7.0` or later. For older `boost-histogram` versions, check the specific Python requirements.","message":"Python version support has significantly changed across recent versions. Python 3.7 support was removed in `1.5.0`, Python 3.8 support was dropped after `1.5.2` (meaning `1.6.0` and later do not support 3.8), and Python 3.10+ is now required as of `1.7.0`.","severity":"breaking","affected_versions":">=1.5.0, >=1.6.0, >=1.7.0"},{"fix":"Avoid direct reliance on `_storage_type` and use documented API for storage interaction if available, or upgrade to a more recent version and check alternatives if this was for advanced use cases.","message":"The internal `_storage_type` attribute changed from a `PendingDeprecationWarning` to a full `DeprecationWarning`.","severity":"deprecated","affected_versions":">=1.4.0"},{"fix":"When filling axes designed for integers (e.g., `bh.axis.Integer`), ensure your input data are actual integers or integer-like values, not floats. Cast floats to integers explicitly if needed.","message":"Filling integer-based axes with floating-point arrays (or single floats) is now explicitly disallowed to prevent rounding issues around 0.","severity":"gotcha","affected_versions":">=1.4.0"},{"fix":"Ensure that the `boost-histogram` version used for saving and loading histograms is consistent. If upgrading, re-save any critical histograms after the upgrade, or verify compatibility with the `uhi` library for unified serialization.","message":"Serialization behavior and format have seen several fixes and changes across versions, particularly around metadata and complex storages. This could lead to issues when loading histograms saved with older versions or in different environments.","severity":"breaking","affected_versions":">=1.6.0, >=1.6.1"},{"fix":"If you are using a type checker with strictness enabled, you might need to adjust your type annotations, e.g., using `Hist[Any]` instead of `Hist` for more flexible typing where the specific storage type is not known or needs to be generic.","message":"With the introduction of `MultiCell` storage and generic histogram types, advanced type checking might require updating type hints. Histograms are now generic, meaning `Hist` may need to be `Hist[Any]` in strict type-checked code.","severity":"gotcha","affected_versions":">=1.7.1"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}