Skip to content

subsetdims: support full coordinate permutations (p == d)#369

Merged
lrnv merged 1 commit into
lrnv:mainfrom
thisiscam:subsetdims-full-permutation
Jun 1, 2026
Merged

subsetdims: support full coordinate permutations (p == d)#369
lrnv merged 1 commit into
lrnv:mainfrom
thisiscam:subsetdims-full-permutation

Conversation

@thisiscam

Copy link
Copy Markdown
Contributor

subsetdims(C, dims) currently asserts p < d, so a dims that is a non-identity permutation of all d coordinates throws — even though it is a well-defined reordering. (This came up in the #367 review, re: the p == d reordering case.)

This relaxes the assert to p <= d. 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. Invalid inputs (p > d, duplicate dims, out-of-range dims) are still rejected by the remaining asserts.

The generic SubsetCopula machinery and the per-family specializations already handle p == d:

  • elliptical (Gaussian/T): reindex Σ[dims, dims] — respects the permutation;
  • Archimedean: exchangeable, so any permutation yields the same copula;
  • generic: _cdf saturates 0 dims (just permutes), _logpdf reduces to the full density, _rand! permutes a parent draw.

Adds test/Subsetting.jl: the regression (p == d no longer throws) plus a correctness check on an asymmetric Gaussian where the permutation is non-trivial (subsetdims(C, perm).Σ == Σ[perm, perm], and cdf/logpdf match the permuted parent).

🤖 Generated with Claude Code

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

codecov Bot commented Jun 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.28%. Comparing base (5cd3d24) to head (a56e231).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@lrnv

lrnv commented Jun 1, 2026

Copy link
Copy Markdown
Owner

Work for me, thanks for the catch :)

@lrnv lrnv merged commit 73649fe into lrnv:main Jun 1, 2026
5 checks passed
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants