Skip to content

Type public results as TypedDicts; bump to 1.1.0 - #78

Merged
OVVO-Financial merged 1 commit into
mainfrom
typed-results
Jul 5, 2026
Merged

Type public results as TypedDicts; bump to 1.1.0#78
OVVO-Financial merged 1 commit into
mainfrom
typed-results

Conversation

@gitRasheed

Copy link
Copy Markdown
Collaborator

Replaces the dict[str, Any] result aliases with real TypedDicts. Results stay plain dicts at runtime — no behavior change, verified against the committed R cache with no regeneration.

What users get

  • RegResult, MRegResult, StackResult, BoostResult, VarResult, MebootResult, SeasonalityResult (plus the inner shapes: RegFitted, RegPoints, RegPredInt, DerivativeTable, RegEquation, RegXStar, MRegPredInt, SeasonalityTable) — exported from nns so pipelines can annotate.
  • Autocomplete on R-style keys ("Fitted.xy", "Point.est") and mypy-caught typos, in user code and inside the library: nns_stack/nns_boost's consumption of nns_reg results is now actually type-checked.
  • Conditional shapes are finally written down: NotRequired marks the point_only/features_only/h=0 partial forms; docstrings state when equation, x.star, pred.int, and conf.int.* appear.

Design decisions

  • nns_reg is overloaded on multivariate_call: the internal True contract returns bare RegPoints; the public form returns RegResult | MRegResult (2-D x dispatches to nns_m_reg, matching R).
  • Functional TypedDict syntax for dotted R key names, same as the existing part.py precedent; class syntax elsewhere.
  • Two shapes stay dynamic on purpose: nns_arma's percent-labelled pred-int keys ("Lower 2.5% pred.int") are runtime-computed R names, and m-reg fit tables key columns V1..Vn — both remain dict[str, NDArray] with the format documented.
  • Typing surfaced facts now recorded in the types: Fitted.xy gains conf.int.* columns when confidence_interval is set; boost's feature.frequency is float64 (R numeric); meboot's degenerate inputs return partial dicts.

Release setup

Bumps version to 1.1.0 in pyproject/__init__/README (check_version_consistency passes) per the batched-release plan for the next PyPI push.

Verification

  • Full suite, NNS_R_CACHE_ONLY=1 (existing cache, no regeneration): 2202 passed; the 3 test_practical_examples failures are the known stale-local-extension issue, green in CI.
  • mypy --strict and ruff clean; runtime smoke confirms results are unchanged plain dicts.

Note: until #77 (numpy<2.5 pin) merges, this PR's CI rolls the numpy-2.5.1 runner lottery — a cache-miss failure on 3.12/3.13 would be that, not this change.

Replace the dict[str, Any] result aliases with real TypedDicts so mypy
checks result access for users and internal consumers alike:

- regression: RegResult (plus RegPoints, RegFitted, RegPredInt,
  DerivativeTable, RegEquation, RegXStar). nns_reg is overloaded on
  multivariate_call: the internal True contract returns bare RegPoints;
  the public form returns RegResult | MRegResult (2-D x dispatches to
  nns_m_reg, as in R). Conditional fields use NotRequired or documented
  None defaults; typing revealed and now records that Fitted.xy gains
  conf.int.* columns when confidence_interval is set.
- multivariate_regression: MRegResult / MRegPredInt / MRegFitted
  (fit-table keys stay dynamic V1..Vn by design).
- stack: StackResult; boost: BoostResult (features_only form via
  NotRequired); var: VarResult (h=0 form via NotRequired); meboot:
  MebootResult; seasonality: SeasonalityTable/SeasonalityResult
  replacing dict[str, object].
- Export the result types from nns.__init__ so callers can annotate.
- Internal cleanups the checker forced: dim-red call sites in stack
  and boost narrow to RegResult explicitly; redundant casts dropped in
  core interval code and tests; nns_arma's percent-labelled pred-int
  dict keys are runtime-computed R names and stay dict[str, NDArray].

Results remain plain dicts at runtime; no behavior change. Full suite
passes against the committed R cache without regeneration.

Bump version to 1.1.0 (pyproject, __init__, README) per the batched
release plan; refresh uv.lock.
@OVVO-Financial
OVVO-Financial merged commit 2124a09 into main Jul 5, 2026
8 checks passed
@OVVO-Financial
OVVO-Financial deleted the typed-results branch July 5, 2026 15:26
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