stdlib: Add SparseHist to PyStats

This is inclusive of tests to ensure they have implemented correctly.

Change-Id: I5c84d5ffdb7b914936cfd86ca012a7b141eeaf42
This commit is contained in:
Bobby R. Bruce
2024-03-27 10:06:16 -07:00
parent b5e8804cd4
commit 178679cbfd
9 changed files with 251 additions and 0 deletions

View File

@@ -78,6 +78,7 @@ cast_stat_info(const statistics::Info *info)
TRY_CAST(statistics::VectorInfo);
TRY_CAST(statistics::Vector2dInfo);
TRY_CAST(statistics::DistInfo);
TRY_CAST(statistics::SparseHistInfo);
return py::cast(info);
@@ -195,6 +196,15 @@ pybind_init_stats(py::module_ &m_native)
.def_readonly("value", &statistics::Vector2dInfo::cvec)
;
py::class_<statistics::SparseHistInfo, statistics::Info,
std::unique_ptr<statistics::SparseHistInfo, py::nodelete>>(
m, "SparseHistInfo")
.def_property_readonly("values", //A Dict[float, int] of sample & count
[](const statistics::SparseHistInfo &info) {
return info.data.cmap;
})
;
py::class_<statistics::FormulaInfo, statistics::VectorInfo,
std::unique_ptr<statistics::FormulaInfo, py::nodelete>>(
m, "FormulaInfo")