Skip to content

Deprecate central-tendency APIs and remove internal statistics dependencies - #498

Open
jmh530 wants to merge 3 commits into
libmir:masterfrom
jmh530:codex/deprecate-central-tendency
Open

jmh530 wants to merge 3 commits into
libmir:masterfrom
jmh530:codex/deprecate-central-tendency

Conversation

@jmh530

@jmh530 jmh530 commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

Direct users of the central-tendency APIs in mir.math.stat to mir-stat while preserving the legacy implementations and defaults. Prepare for these deprecations by removing statistics dependencies from product type deduction and documentation examples.

Changes

  • Move statType and its existing tests into mir.math.internal.stat_type, register the module in Meson, and update product type deduction to import it directly. Preserve the old package-visible import through mir.math.stat.
  • Update the moving-average example to use Summator directly and the ndslice examples to calculate averages through summation and element counts.
  • Deprecate all overloads of mean, hmean, gmean, median, and center, along with MeanAccumulator and GMeanAccumulator.

The changes are organized into three commits covering helper extraction, example cleanup, and deprecation.

Migration and compatibility

Use the corresponding exports from mir.stat.descriptive for means, their accumulators, and median. Use mir.stat for center.

Existing implementations and defaults remain unchanged, but callers treating deprecations as errors (-de) will need to migrate. Mir-stat includes numerical fixes, so extreme-input results can differ. Accumulator types from the two packages are distinct; interacting declarations should be migrated together.

simpleLinearRegression and the module itself remain undeprecated. This PR adds no dependency on mir-stat and is independent of the variance deprecations in #496.

Validation

  • Windows DMD 2.113 and LDC 1.43 each passed the final 43-module harness with mir_test and mir_ndslice_test enabled.
  • A focused check verified that the old package-visible statType import resolves to the extracted helper and that product calculations compile and run with -de.
  • Confirmed that simpleLinearRegression and its tests are unchanged.
  • Branch whitespace checks passed.

The full repository suite and Meson builds were not run locally.

AI-Assisted-By: Codex (GPT-6 Astra Medium)

Move statType and its existing tests into mir.math.internal.stat_type.
Update product type deduction to import the helper directly, removing
its dependency on mir.math.stat.

Preserve the package-visible statType import through mir.math.stat
and register the new internal module in the Meson source list.

AI-Assisted-By: Codex (GPT-6 Astra Medium)
Use Summator directly in the moving-average example, deriving the
observation count from its fixed-size circular buffer.

Define local averages using summation and element counts in the
ndslice examples. Preserve their demonstrations and expected results
without importing the statistics APIs planned for deprecation.

AI-Assisted-By: Codex (GPT-6 Astra Medium)
Deprecate mean, hmean, gmean, MeanAccumulator, GMeanAccumulator,
median, and center while preserving their implementations and defaults.

Direct callers to mir.stat.descriptive for means and median, and
mir.stat for center. Document the dependency and replacement imports,
numerical differences, and distinct accumulator types.

Leave simpleLinearRegression and the module itself undeprecated.

AI-Assisted-By: Codex (GPT-6 Astra Medium)
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.

1 participant