HDembinski · GitHub

henryiii added a commit to henryiii/boost-histogram that referenced this pull request

@henryiii

Add a hash-map backed `DoubleSparse` storage that only allocates filled
cells, making histograms over very large or high-dimensional axis spaces
feasible. Backed by `storage_adaptor<unordered_map<size_t, double>>`.
Scoped to `double` only for now: accumulator-backed sparse storages need
boostorg/histogram#421, which ships in Boost 1.92 (the repo vendors 1.90).
Data access is COO-first and deliberately not a full drop-in:
- `.view()` raises (no contiguous buffer to view into).
- `Histogram.to_coo(flow=False)` returns the filled cells as
  `(per-axis index tuple, values)`, numpy-nonzero style.
- The copying accessors `values()`/`variances()`/`counts()` and
  `np.asarray(h)` densify into a fresh array, so they keep working.
- `at()` reads, slicing, projection, sum and histogram addition stay sparse.
Serialization: pickle round-trips via free save/load on `double_sparse`
(COO key/value arrays); UHI to_uhi/from_uhi store COO under a `"sparse"`
payload plus writer_info, reconstructed via a C++ `_from_coo` bulk setter.
Assisted-by: ClaudeCode:claude-opus-4.8

Read the original on github.com ↗