Repository navigation
Add caller-provided, RC, and custom storage for sorted quantile results - #311
Merged
Merged
Conversation
Write quantiles from ascending observations directly into the caller's output buffer in probability order. Accept read-only observations and use the output element type to determine result precision. Share the batch loop with quantileAssumeSorted so both entry points use the same rank lookup and interpolation. Test strided observations and output, including that elements outside the output view retain their values. AI-Assisted-By: Codex (GPT-6.2 Astra Medium)
Add rcquantileAssumeSorted for reference-counted batch results and makeQuantileAssumeSorted for results owned by the caller's allocator. Scalar queries allocate nothing. Batch queries allocate only the result and fill it through the shared sorted output loop. Test that an RC result outlives its input and that custom allocation occurs only for batch results. Verify that a probability read throwing partway through a batch releases the custom result allocation. AI-Assisted-By: Codex (GPT-6.2 Astra Medium)
… quantileInto Recognize a random-access Phobos SortedRange with a length and the default ascending predicate. Route rcquantile and makeQuantile to their sorted variants, preserving the requested result ownership. Route three-argument quantileInto to quantileAssumeSortedInto so it can read ordered observations and write directly to the caller's output. Document the dispatch rule and test all three entry points with a SortedRange over read-only strided observations. AI-Assisted-By: Codex (GPT-6.2 Astra Medium)
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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.
PR #310 added
quantileAssumeSortedfor ascending observations. This change extends the same direct rank lookup to callers who supply their own output buffer, use reference counting, or manage allocations with a custom allocator.quantileAssumeSortedInto(values, probabilities, output)accepts read-only observations and writes results in probability order. The output element type determines result precision. The call requires no allocation or partition scratch.rcquantileAssumeSortedreturns a reference-counted batch result that can outlive the input.makeQuantileAssumeSortedallocates the batch result with the caller’s allocator and releases it if evaluation throws before the result is returned.Scalar RC and custom-allocator calls allocate nothing. All owning batch variants allocate only their result and share the output loop with
quantileAssumeSortedInto.rcquantile,makeQuantile, and three-argumentquantileIntoforward a random-access PhobosSortedRangewith a length and the default ascending predicate to the corresponding sorted path.Tests
Each of the three commits passed all 42 imported modules under Windows DMD with DIP1000. Focused tests cover read-only strided observations, writes through a strided output view, RC result lifetime, custom allocation counts, cleanup after a probability read throws, and forwarding from the existing entry points.
AI-Assisted-By: Codex (GPT-6.2 Astra Medium)