Skip to content

Wire plot=True on compute functions to render via nns.plotting - #13

Merged
OVVO-Financial merged 2 commits into
mainfrom
claude/relaxed-sagan-17a4g9
Jun 14, 2026
Merged

Wire plot=True on compute functions to render via nns.plotting#13
OVVO-Financial merged 2 commits into
mainfrom
claude/relaxed-sagan-17a4g9

Conversation

@OVVO-Financial

Copy link
Copy Markdown
Owner

Summary

Follow-up to #12 (already merged). #12 landed the nns.plotting package, but the
compute functions still del'd their R-compatible plot= arguments, so
plot=True produced nothing. This PR wires plot=True to actually render a
Matplotlib figure — as a side effect — through the nns.plotting layer, while
the value-only return contract (which the parity suite depends on) is
unchanged.

These two commits were pushed to the branch after #12 was merged, so they need
this separate PR to reach main.

What's wired

Function plot=True renders Extra flag
nns_reg plot_nns_reg residual_plot=True → residual scatter
nns_m_reg R's residual plot — actual y (steelblue open circles) + fitted ŷ (red line) + pink CI band residual_plot=True (R default) → same figure
nns_arma plot_nns_arma
nns_arma_optim plot_nns_arma_optim
nns_cdf (univariate) plot_nns_cdf
nns_seas plot_nns_seas

Guarantees

  • plot=True creates a figure for all of the above and returns the identical
    value to plot=False.
  • Default plot=False opens no figure — computation never plots on its own,
    so the parity/invariant suites are unaffected (761 passed locally).
  • Multivariate CDF has no faithful single-axis R plot, so it stays a no-op (by
    design).

Tests / checks

  • New tests/plotting/test_compute_plot_flag.py asserts plot=True creates a
    figure and returns the same value as plot=False, including the m_reg
    steelblue-actual / red-fitted residual-plot colors.
  • mypy clean (168 files), ruff clean, 33 plotting tests pass.

https://claude.ai/code/session_01B2z9DRMNCydHrpRQUA6HBW


Generated by Claude Code

claude added 2 commits June 14, 2026 03:15
Previously the compute functions accepted R-compatible plot arguments and
immediately `del`'d them, so `plot=True` produced nothing — a strict validator
expecting a figure would fail. Now `plot=True` renders a Matplotlib figure as a
side effect through the nns.plotting layer while the value-only return contract
(which the parity suite depends on) is unchanged.

Wired:
- nns_reg: plot / plot_regions -> plot_nns_reg; residual_plot -> residual scatter
- nns_m_reg: plot -> fitted-vs-actual; residual_plot -> residual scatter
- nns_arma / nns_arma_optim -> plot_nns_arma / plot_nns_arma_optim
- nns_cdf (univariate) -> plot_nns_cdf
- nns_seas -> plot_nns_seas (compute split into _nns_seas_compute)

Rendering only fires for results that carry the needed series, and default
plot=False opens no figure (verified). Adds tests/plotting/test_compute_plot_flag.py
asserting plot=True creates a figure and returns the same value as plot=False.
Updates the plot-parity policy and README.
R's NNS.M.reg plot output is its residual plot (Multivariate_Regression.R:367-377):
actual y over the observation index as steelblue open circles, fitted y.hat as a
red line, with a pink (alpha 0.375) confidence band when present. The previous
fitted-vs-actual scatter / residuals-about-zero scatter did not match R.

Both plot=True and residual_plot=True now render this single faithful figure.
Strengthens the m_reg plot test to assert the steelblue-actual / red-fitted colors.
@OVVO-Financial
OVVO-Financial merged commit 67e98ca into main Jun 14, 2026
4 checks passed
@OVVO-Financial
OVVO-Financial deleted the claude/relaxed-sagan-17a4g9 branch June 14, 2026 04:50
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