Wire plot=True on compute functions to render via nns.plotting - #13
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to #12 (already merged). #12 landed the
nns.plottingpackage, but thecompute functions still
del'd their R-compatibleplot=arguments, soplot=Trueproduced nothing. This PR wiresplot=Trueto actually render aMatplotlib figure — as a side effect — through the
nns.plottinglayer, whilethe 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
plot=Truerendersnns_regplot_nns_regresidual_plot=True→ residual scatternns_m_regy(steelblue open circles) + fittedŷ(red line) + pink CI bandresidual_plot=True(R default) → same figurenns_armaplot_nns_armanns_arma_optimplot_nns_arma_optimnns_cdf(univariate)plot_nns_cdfnns_seasplot_nns_seasGuarantees
plot=Truecreates a figure for all of the above and returns the identicalvalue to
plot=False.plot=Falseopens no figure — computation never plots on its own,so the parity/invariant suites are unaffected (761 passed locally).
design).
Tests / checks
tests/plotting/test_compute_plot_flag.pyassertsplot=Truecreates afigure and returns the same value as
plot=False, including the m_regsteelblue-actual / red-fitted residual-plot colors.
mypyclean (168 files),ruffclean, 33 plotting tests pass.https://claude.ai/code/session_01B2z9DRMNCydHrpRQUA6HBW
Generated by Claude Code