Skip to content

Handle zero-variance covariance dimensions in sampling - #147

Open
sylvesterkaczmarek wants to merge 1 commit into
llnl:mainfrom
sylvesterkaczmarek:fix/zero-variance-covariance
Open

sylvesterkaczmarek wants to merge 1 commit into
llnl:mainfrom
sylvesterkaczmarek:fix/zero-variance-covariance

Conversation

@sylvesterkaczmarek

Copy link
Copy Markdown
Contributor

Handle zero marginal variances when normalizing covariance matrices in sample_points() and sigma_points(). Valid positive-semidefinite covariances can have deterministic coordinates, but the current normalization divides their zero rows/columns by zero, producing NaNs and LinAlgError: SVD did not converge.

Use a unit denominator for those zero scale products while retaining the original zero marginal factors. Fixed coordinates therefore remain exactly at their means. Positive-variance behavior, sigma-point scaling, the sqrt=True path, and caller-owned covariance arrays are unchanged.

Validation

Python 3.12, NumPy 2.5.3, SciPy 1.18.1 on macOS arm64:

  • New tests on unchanged main (8bb784c): 10 failed, 2 passed. With the fix: all 12 passed.
  • Cases cover zero variance in each coordinate, correlated nonzero dimensions, all-zero covariance, singular positive-diagonal controls, explicit fixed dimensions, and a linear unscented transform.
  • Deterministic draws verify the resulting means/covariances without statistical tolerances. Divide-by-zero and invalid warnings are promoted to errors.
  • Focused utility tests: 42 passed.
  • Full suite: 340 passed, 2 skipped, 35 subtests passed.
  • New tests pass Flake8; no additional Flake8 findings in utils.py. Syntax checks and git diff --check pass.

No native code or public API changes. Other operating systems were not tested locally.

@codecov-commenter

codecov-commenter commented Sep 19, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.39%. Comparing base (45730dc) to head (fa926f0).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #147   +/-   ##
=======================================
  Coverage   97.39%   97.39%           
=======================================
  Files          17       17           
  Lines        5897     5899    +2     
=======================================
+ Hits         5743     5745    +2     
  Misses        154      154           
Flag Coverage Δ
unittests 97.39% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
ssapy/utils.py 99.74% <100.00%> (+<0.01%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sylvesterkaczmarek
sylvesterkaczmarek marked this pull request as ready for review September 19, 2026 20:50
@sylvesterkaczmarek
sylvesterkaczmarek force-pushed the fix/zero-variance-covariance branch from 1b2880f to fa926f0 Compare October 1, 2026 07:04
@sylvesterkaczmarek

Copy link
Copy Markdown
Contributor Author

Rebased onto current main today; the branch is now 0 behind, mergeable, and the fresh SSAPy matrix is green. The rewritten head is GitHub Verified. Could a maintainer review it when convenient?

This branch has not been deployed

No deployments
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