Skip to content

Return a Diagonal from rand of a diagonal uncertainty matrix - #163

Merged
baggepinnen merged 1 commit into
masterfrom
fb/rand-diagonal-uncertainty
Nov 11, 2026
Merged

baggepinnen merged 1 commit into
masterfrom
fb/rand-diagonal-uncertainty

Conversation

@baggepinnen

@baggepinnen baggepinnen commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

rand(D, N) for a diagonal uncertainty matrix D = Δ(n, δc) broadcasts rand over the Diagonal. On Julia 1.10 the broadcast returns a dense Matrix, on Julia 1.13 it preserves the Diagonal structure. The values are identical, but the test test_uncertainty.jl:42, which asserts rand(D, 100) isa Matrix{Complex{Particles{Float64, 100}}}, fails on Julia 1.13.

Changes:

  • Add Base.rand(D::Diagonal{<:δ}, N), which returns a Diagonal on all Julia versions.
  • Update the test to assert a Diagonal result with zero off-diagonal entries.
  • Add Julia 1 to the CI matrix, which previously contained only Julia 1.10.

Verified locally on Julia 1.10.12 and 1.13.2 for complex (δc) and real (δr) uncertainties. The full test suite on Julia 1.13 failed only at this test before the change (apart from the LinearMPC example, see below).

CI resolves MatrixEquations v2 while LinearMPC (a test dependency) restricts it to v2 (see darnstrom/LinearMPC.jl#153).


Host: demeter2, session: MatrixEquations v3 compat PRs (session_01JGy8YZaumSKXZ3ucgmVARB), working directory: /home/baggepinnen/.julia/dev

🤖 Generated with Claude Code

Broadcasting rand over a Diagonal returns a dense Matrix on Julia 1.10
and a Diagonal on Julia 1.13, so the result type of rand(D, N) depended
on the Julia version and test_uncertainty.jl failed on 1.13. A dedicated
method now returns a Diagonal on all versions. Julia 1 is added to the
CI matrix.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov-commenter

codecov-commenter commented Nov 11, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.17%. Comparing base (cd6b095) to head (3e25bd9).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #163      +/-   ##
==========================================
+ Coverage   91.81%   92.17%   +0.35%     
==========================================
  Files          20       20              
  Lines        3128     3130       +2     
==========================================
+ Hits         2872     2885      +13     
+ Misses        256      245      -11     
Flag Coverage Δ
unittests 92.17% <100.00%> (+0.35%) ⬆️

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

☔ View full report in Codecov by Harness.
📢 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.

@baggepinnen
baggepinnen merged commit 09b5449 into master Nov 11, 2026
3 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