Skip to content

Add joint multidimensional histograms, frequency views, and marginals - #109

Merged
jmh530 merged 16 commits into
libmir:masterfrom
jmh530:codex/histogram-followups
Sep 16, 2026
Merged

jmh530 merged 16 commits into
libmir:masterfrom
jmh530:codex/histogram-followups

Conversation

@jmh530

@jmh530 jmh530 commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Replace independent per-axis counting with joint multidimensional histograms. For example, put(temperature, pressure) now increments one bin representing that coordinate pair.

Changes

  • Support N-dimensional counting and merging with rectangular built-in arrays and Mir slices, including strided layouts.
  • Unify count storage across dimensions, including enabled underflow/overflow bins.
  • Extend frequency accumulation and bin views to joint histograms.
  • Add optional traversal of all stored bins, with per-axis ordinary, underflow, and overflow classification.
  • Add marginal!(axes...)() to both accumulators, producing independent reference-counted counts by summing over discarded axes.
  • Support reductions over read-only count storage.
  • Add documentation examples and regression, attribute, and lifetime tests.

API changes

  • counts includes enabled underflow/overflow bins in each dimension.
  • With multiple axes, put(x, y, ...) records one joint observation. One-axis variadic insertion continues to record separate observations.
  • Bin entries expose per-axis indices and descriptions through index!dimension and bin!dimension, defaulting to dimension zero.
  • bins() returns descriptions and counts; frequencyBins() also returns relative frequencies. Both default to ordinary bins and support BinCoverage.all.

Marginals include underflow/overflow counts from discarded axes and preserve the selected axes in the requested order. Count storage is independently owned; borrowed axis boundaries remain borrowed.

Validation

  • DMD and LDC default and DIP1000 test suites.
  • Optimized release suites during implementation.
  • Strict DMD documentation checks and verification of generated example placement.

Add a docs-check build type that treats documentation warnings as errors. Run it in a dedicated Ubuntu job using stable DMD.

AI-Assisted-By: Codex (GPT-6 Astra Medium)
Change two-axis insertion from updating separate marginal counts to
incrementing one joint bin. Support rectangular built-in arrays and
rank-2 ndslices, validate storage shape, and resolve both coordinates
before updating counts.

Preserve one-axis behavior and reject unsupported joint flow bins,
merging, and higher-dimensional configurations.

Add documentation examples and regression coverage for storage ownership,
strided slices, mixed coordinate types, and invalid inputs.

AI-Assisted-By: Codex (GPT-6 Astra Medium)
Store enabled underflow/overflow bins alongside ordinary joint counts,
preserving both coordinates for edge and corner observations. Validate
expanded storage dimensions and resolve both coordinates before updating
counts.

Add axis-specific underflow and overflow member functions that sum current
joint counts, including the other axis's underflow/overflow bins. Preserve
existing one-axis storage and accessors.

Add documentation and regression coverage for underflow/overflow bin
combinations, strided storage, boundary handling, invalid inputs, and
const access.

AI-Assisted-By: Codex (GPT-6 Astra Medium)
Prefer DMD and focused tests during routine development, starting with
the affected configuration for compiler-specific issues. Run the required
compiler/build matrix once edits stabilize and reuse valid test results.

AI-Assisted-By: Codex (GPT-6 Astra Medium)
Support joint counting in ndslices and nested built-in arrays with one
storage dimension per axis. Validate every dimension and resolve all
coordinates before incrementing a count.

Extend axis-specific underflow/overflow totals across the remaining
dimensions while preserving storage strides and one-axis behavior.

Add three-dimensional documentation examples and regression coverage
for higher ranks, malformed storage, mixed coordinate types, and
shared storage ownership.

AI-Assisted-By: Codex (GPT-6 Astra Medium)
Merge corresponding ordinary and underflow/overflow bins in N-dimensional
histograms with matching axes and counter types. Validate axes and both
storage shapes before changing counts.

Support const sources and different built-in array and ndslice layouts
without allocation. Preserve one-axis behavior and document the storage
overlap contract.

Add documentation and regression coverage for cross-layout merging,
invalid shapes, self-merging, and read-only sources.

AI-Assisted-By: Codex (GPT-6 Astra Medium)
Generalize HistogramBin and HistogramBinView to expose per-axis indices
and descriptions through index!dimension and bin!dimension, defaulting
to axis zero.

Traverse ordinary joint bins with the last axis advancing fastest,
preserving storage strides, live counts, and original coordinates
through slicing and independent cursors.

Support borrowed views of static-array storage with compiler-dependent
escape checking. Add documentation and regression coverage for mixed
axes, const access, ownership, and invalid shapes.

AI-Assisted-By: Codex (GPT-6 Astra Medium)
Support multiple axes with one total update per joint observation,
ordinary-bin frequency access, and per-axis underflow/overflow
frequencies with selectable output types.

Initialize totals from all storage and support merging compatible
joint accumulators across storage layouts. Keep cumulative methods
and frequency views one-dimensional.

Add a documentation example and regression tests for joint counting,
indexing, merging, and rejected inputs, including @safe/@nogc coverage.

AI-Assisted-By: Codex (GPT-6 Astra Medium)
Support ordinary-bin traversal across multiple axes with per-axis
index and bin access, live counts and frequencies, and selectable
output precision.

Share bin-reading logic with histogram views while preserving
frequency views' accumulator borrowing and DIP1000 protections.

Add documentation and tests for joint traversal, strided storage,
categorical axes, live updates, const cursors, and lifetime checks.

AI-Assisted-By: Codex (GPT-6 Astra Medium)
Store enabled underflow/overflow bins alongside ordinary bins in
one-dimensional histograms, matching the joint histogram layout.
Remove separate counters and consolidate insertion and merging.

Add storageExtent accessors and update reference-counted factories
to allocate the full storage size. Preserve ordinary-bin indexing
in views and frequency access, and account for the unified layout
in totals and cumulative frequencies.

Update documentation and tests for storage sizing, prepopulated
end counts, shared storage, and merges across layouts.

AI-Assisted-By: Codex (GPT-6 Astra Medium)
Add BinCoverage.all to histogram and frequency views, including joint
underflow/overflow combinations and per-axis bin classification.
Keep ordinary-only traversal as the default and guard access to
ordinary-bin indices and descriptions.

Expose count-only bins on FrequencyAccumulator alongside frequencyBins,
preserving storage ownership and borrowing behavior.

Add documentation examples and regression tests for coverage, live
updates, strided storage, and lifetime protections.

AI-Assisted-By: Codex (GPT-6 Astra Medium)
Add marginal!(axes...) to histogram and frequency accumulators,
preserving the selected axis order and summing all discarded-axis
bins, including underflow/overflow bins.

Use a shared internal projection routine for built-in arrays and
strided Mir slices. Allocate independent reference-counted counts
while preserving retained axes' boundary ownership semantics.

Add documentation examples and regression tests for count conservation,
axis selection, independent updates, allocation attributes, and lifetimes.

AI-Assisted-By: Codex (GPT-6 Astra Medium)
Use an unqualified CountType for count values and temporary sums while
preserving const and immutable qualifiers on the underlying storage.

Add regression tests for read-only histogram and frequency reductions,
marginals, cumulative frequencies, and rejection of count mutation.

AI-Assisted-By: Codex (GPT-6 Astra Medium)
Move histogram and frequency marginal documentation tests alongside
their accumulator examples, preserving simple-to-complex ordering.

AI-Assisted-By: Codex (GPT-6 Astra Medium)
Wrap assignment checks in statement blocks within __traits(compiles)
and use named static-array types for .init expressions.

Preserve the existing checks while addressing CircleCI parser errors.

AI-Assisted-By: Codex (GPT-6 Astra Medium)
Pass the source view by ref const to avoid an LDC 1.28.1 compiler
crash and unnecessary reference-count operations. Extend regression
coverage for cursor independence and ownership of saved/sliced views.

AI-Assisted-By: Codex (GPT-6 Astra Medium)
@jmh530
jmh530 marked this pull request as ready for review September 16, 2026 03:53
@codecov-commenter

codecov-commenter commented Sep 16, 2026

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 42.12%. Comparing base (8a8b380) to head (08b7a89).
⚠️ Report is 76 commits behind head on master.
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

❗ There is a different number of reports uploaded between BASE (8a8b380) and HEAD (08b7a89). Click for more details.

HEAD has 6 uploads less than BASE
Flag BASE (8a8b380) HEAD (08b7a89)
8 2
Additional details and impacted files
@@             Coverage Diff              @@
##            master     #109       +/-   ##
============================================
- Coverage   100.00%   42.12%   -57.88%     
============================================
  Files           39        7       -32     
  Lines         6270      235     -6035     
============================================
- Hits          6270       99     -6171     
- Misses           0      136      +136     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jmh530
jmh530 merged commit 1a9a5c3 into libmir:master Sep 16, 2026
10 checks passed
@jmh530
jmh530 deleted the codex/histogram-followups branch September 16, 2026 03:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants