Repository navigation
Fix DimensionMismatch in DataDrivenSolution for empty bases (#514) - #689
Conversation
Independent review (Codex CLI 0.166.0 / gpt-6.1-sol), session 01a1975f-0acf-7dc2-985a-b2b93af6fbc0, reviewed head 7e09643
Review written by the reviewer named above in a session other than the PR author's, and copied here by the posting agent without change to its findings. The posting agent did not re-run the reviewer's commands. Summary: Treats an empty recovered basis as a zero predictor for residual sums and summary statistics. The added regression fails on base and passes at head; only comment cleanup is requested. Blast radius: DataDrivenSolution construction, rss-derived information criteria, and StatsBase.summarystats for empty predictions; nonempty prediction calculations remain unchanged. Evidence: Blind L6 assessment sealed before author context; expanded analysis of the single-target path raises the final rating to ML1. The PR test file passes 26/26 at head and fails on the merge-base with DimensionMismatch after 23 passing assertions. An independent head probe passes 33/33 assertions for hand-calculated residual statistics, information criteria, and sparse recovery. No PR CI checks are reported. Blocking findingsNone. Non-blocking findings
What I ran
What I did not verifyThe supplemental full-constructor single-target check did not execute on base because of the probe import ambiguity; its old zero-RSS behavior is inferred from the inspected broadcast and empty-residual branch. No whole-package or downstream suite, GPU, AD, MPI, alternate Julia version, or Windows execution was performed; the change adds no such specialized paths. Implicit-model recovery and no-observation datasets were not exercised. The issue's exact SR3/normalization/batching example was not reproduced; the end-to-end sparse check used STLSQ. No PR CI results are available. 🤖 Posted by an AI agent — harness: Claude Code · model: claude-sonnet-5-5 |
Resolves #514
When sparsity thresholds zero out all basis coefficients (e.g. SR3 with strong regularization), __construct_basis filters out all equations, leaving an empty basis whose prediction Ŷ = b(prob) has 0 rows. Attempting residuals = Y .- Ŷ resulted in a DimensionMismatch between (n, T) and (0, T).
This PR:
Checks isempty(Ŷ) in DataDrivenSolution and assigns rss = sum(abs2, Y) (the residual of "no model" being the data itself).
Safely handles isempty(Ŷ) in StatsBase.summarystats(sol).
Adds regression tests in test/Core/solution.jl.