Repository navigation
partial moments: co-moments reject empty input and recycled targets - #189
Closed
gitRasheed wants to merge 1 commit into
Closed
gitRasheed wants to merge 1 commit into
gitRasheed wants to merge 1 commit into
Conversation
…R co-moment-fixes) Mirrors the length checks of R Co.LPM/Co.UPM/D.LPM/D.UPM (OVVO-Financial/NNS co-moment-fixes). co_lpm, co_upm, d_lpm and d_upm already raised on unequal x and y. Now one check before the native/pure dispatch also rejects empty x and y, empty targets, and target lengths that are neither equal nor 1, so both backends raise the same ValueError. Before -> after (= R main), native / NNS_DISABLE_NATIVE=1: co_lpm(1, x, x, [0, 1, 2], [0, 1]) recycled / recycled -> ValueError co_lpm(1, x, x, [], 0) ZeroDivisionError / same -> ValueError co_lpm(1, x, x, [], []) [] / [] -> ValueError co_lpm(1, [], [], 0, 0) ValueError / nan -> ValueError The internal callers (var.py, arma.py) pass scalar targets. R's mixed-degree D.UPM fix comes with the NNS-core re-vendor. No cache entry moves.
OVVO-Financial
added a commit
that referenced
this pull request
Nov 6, 2026
This audit retains exactly the previously green workflow files from #189, including pandas test dependencies and pure-Python fallback parity, instead of the older main defaults restored by workflow protection. Workflow change approved for draft audit; do not merge until all R 14.0 gates pass.
This was referenced Nov 6, 2026
Contributor
|
Incorporated through NNS R 14.0 integration #192, merged as |
This was referenced Nov 12, 2026
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.
R's
Co.LPM,Co.UPM,D.LPMandD.UPMcrashed the session on unequal lengths with a vector target, and raised SIGFPE on an empty target. OVVO-Financial/NNS#132 (merged) checks the lengths up front: x and y equal and non-empty, targets non-empty, and target lengths equal or one of them 1. Unequal target lengths used to recycle and now raise. This slice mirrors that half. The other half, D.UPM with one integer and one fractional degree, is in NNS-core and comes with the re-vendor.Stacked on #188; merge with a merge commit.
Changes
_co_moment(co_moments.py) runs one check before the native/pure dispatch, so both backends raise the sameValueError. Unequal x and y already raised. Empty x and y raise "x and y must be non-empty." (the repo's wording, not R's backticked one). Empty targets raise, and so do target lengths that are neither equal nor 1. The native branch'ssize > 0guard is gone, since the check covers it.NNS_DISABLE_NATIVE=1):co_lpm(1, x, x, [0, 1, 2], [0, 1])recycled in both and now raises. An empty target raised ZeroDivisionError in both. Two empty targets returned[].co_lpm(1, [], [], 0, 0)raised natively and returned nan without native. All of these now raise ValueError.co_lpmdocstring change to match.Tests
[0, 1, 2]against[0, 1], and a vector target against a scalar one equal to the elementwise calls. They pass with and without the native kernel and fail on the parent commit in both. I left out R's mixed-degree block, since native D.UPM gives 2.5 instead of 6.5 until the re-vendor.NNS_DISABLE_NATIVE=1: 2936 passed, 29 skipped, 2 xpassed. The 3 xfails are mode: break tied discrete modes by gravity, not their mean (mirrors R #111) #178's strict ones and the 2 xpasses the existing non-strict live-R VAR xfails. tests/parity/test_practical_examples.py against the usual R library: 9 passed, 2 xfailed, as on mode: break tied discrete modes by gravity, not their mean (mirrors R #111) #178. ruff check is clean on every changed file.Mirrors the length checks of OVVO-Financial/NNS#132
Review
GPT-6.1 Sol reviewed the #149 and #132 mirrors together: SHIP, no findings. It checked 198 nonzero-residual meboot cases per backend for bit-identical outputs and RNG state.