subsetdims: support full coordinate permutations (p == d)#369
Merged
Conversation
Relax the `@assert p < d` in subsetdims to `p <= d`, so a non-identity permutation of all d coordinates returns the reordered copula. The identity `dims == 1:d` still short-circuits to C and `p == 1` to a Uniform, so the only newly-allowed case is a genuine permutation; p>d, duplicate, and out-of-range dims are still rejected. Per-family specializations already handle p==d (elliptical Σ[dims,dims] reindex; Archimedean exchangeability; generic _cdf/_logpdf/_rand!). Adds test/Subsetting.jl: the regression plus a correctness check on an asymmetric Gaussian where the permutation is non-trivial. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #369 +/- ##
=======================================
Coverage 78.28% 78.28%
=======================================
Files 84 84
Lines 5106 5106
=======================================
Hits 3997 3997
Misses 1109 1109 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Owner
|
Work for me, thanks for the catch :) |
thisiscam
added a commit
to thisiscam/Copulas.jl
that referenced
this pull request
Jun 2, 2026
…upports p==d via lrnv#369) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
subsetdims(C, dims)currently assertsp < d, so adimsthat is a non-identity permutation of alldcoordinates throws — even though it is a well-defined reordering. (This came up in the #367 review, re: thep == dreordering case.)This relaxes the assert to
p <= d. The identitydims == 1:dstill short-circuits toC, andp == 1to aUniform, so the only newly-allowed case is a genuine permutation. Invalid inputs (p > d, duplicate dims, out-of-range dims) are still rejected by the remaining asserts.The generic
SubsetCopulamachinery and the per-family specializations already handlep == d:Gaussian/T): reindexΣ[dims, dims]— respects the permutation;_cdfsaturates 0 dims (just permutes),_logpdfreduces to the full density,_rand!permutes a parent draw.Adds
test/Subsetting.jl: the regression (p == dno longer throws) plus a correctness check on an asymmetric Gaussian where the permutation is non-trivial (subsetdims(C, perm).Σ == Σ[perm, perm], andcdf/logpdfmatch the permuted parent).🤖 Generated with Claude Code