Skip to content

Preserve size=1 vector parameters and add a prior_draw_mode contract - #455

Merged
vhaasteren merged 4 commits into
nanograv:devfrom
vhaasteren:feat/nlt-sampling-api
Jul 15, 2026
Merged

Preserve size=1 vector parameters and add a prior_draw_mode contract#455
vhaasteren merged 4 commits into
nanograv:devfrom
vhaasteren:feat/nlt-sampling-api

Conversation

@vhaasteren

@vhaasteren vhaasteren commented Jul 15, 2026

Copy link
Copy Markdown
Member

Summary

  • Fix PTA.map_params to preserve a size=1 parameter as a length-1 array
    instead of collapsing it to a bare scalar (n = p.size if p.size else 1
    conflated size=None and size=1). A one-dimensional vector parameter
    mapped to a scalar breaks downstream linear algebra (e.g. C @ x on a
    1x1 whitening matrix).
  • Add Parameter.prior_draw_mode (default "component", class-level
    attribute so every existing Parameter subclass inherits it unchanged)
    and UserParameter(..., prior_draw_mode="component"|"joint"), so a
    correlated vector parameter can declare that prior-draw proposals must
    replace it as a whole block rather than one component at a time.
  • Defensive consistency fix: param_names (on Signal, SignalCollection,
    and PTA) now checks p.size is not None instead of the previous truthy
    if p.size: check, for the same size=None vs size=1 distinction
    map_params needed. (param_names already produced the correct indexed
    name for size=1 today; this just makes the two checks consistent.)

Why

Part of implementing nltiming's feature_nltiming_sampling_api.md: a
full-whitening nonlinear-timing block is a correlated joint vector Enterprise
parameter, and when only one timing parameter is sampled that block has
size=1. Without the map_params fix it silently collapsed to a scalar;
without prior_draw_mode, a generic prior-draw proposal (e.g.
enterprise_extensions.JumpProposal.draw_from_prior) has no way to know it
must replace such a block atomically rather than one entry at a time, which
is mathematically invalid for a non-diagonal (correlated) prior.

prior_draw_mode is deliberately generic — no NLT-specific attribute or name
inspection — so it's reusable by any future correlated vector parameter, not
just this one.

Test plan

  • pytest tests/test_parameter.py tests/test_vector_parameter.py — includes
    new TestPriorDrawMode and TestMapParamsVectorShape coverage (25 tests,
    all pass).
  • black --check / flake8 clean on the changed files.
  • Ran the rest of the suite file-by-file (test_likelihood.py,
    test_selections.py, test_set_parameter.py, test_utils.py, etc.) — all
    pass.

Depends on / paired with

Companion PRs on enterprise_extensions (honor prior_draw_mode in
JumpProposal) and nltiming (Enterprise-native timing parameters that use
this contract).

AaronDJohnson and others added 4 commits July 14, 2026 08:20
PTA.map_params collapsed a size=1 vector Parameter to a bare scalar
(conflating size=None and size=1), which breaks matrix ops like C @ x on a
one-dimensional whitened block. Also add Parameter.prior_draw_mode
("component" default, "joint" opt-in via UserParameter) so a correlated
vector parameter can declare that prior-draw proposals must replace it as a
whole block rather than one component at a time.
@codecov

codecov Bot commented Jul 15, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 72.85%. Comparing base (5b3d80c) to head (544a737).
⚠️ Report is 5 commits behind head on dev.

Files with missing lines Patch % Lines
enterprise/signals/signal_base.py 91.66% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##              dev     #455      +/-   ##
==========================================
+ Coverage   72.71%   72.85%   +0.14%     
==========================================
  Files          13       13              
  Lines        3478     3489      +11     
==========================================
+ Hits         2529     2542      +13     
+ Misses        949      947       -2     
Files with missing lines Coverage Δ
enterprise/signals/parameter.py 91.83% <100.00%> (+0.19%) ⬆️
enterprise/signals/signal_base.py 90.92% <91.66%> (+0.06%) ⬆️

Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 26ec116...544a737. Read the comment docs.

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

@vhaasteren
vhaasteren merged commit a9697a8 into nanograv:dev Jul 15, 2026
14 checks passed
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