Skip to content

fix(spec): use safe default sampler with cores=1 in VAR.fit()#44

Open
armorbreak001 wants to merge 3 commits into
thomaspinder:mainfrom
armorbreak001:fix/43-var-default-sampler-cores
Open

fix(spec): use safe default sampler with cores=1 in VAR.fit()#44
armorbreak001 wants to merge 3 commits into
thomaspinder:mainfrom
armorbreak001:fix/43-var-default-sampler-cores

Conversation

@armorbreak001
Copy link
Copy Markdown

Summary

When no sampler is passed to VAR.fit(), the previous code created a bare
NUTSSampler() with cores=None, which auto-detects CPU cores and enables
multiprocessing. This can cause segfaults on macOS and other platforms (as
documented in CLAUDE.md).

Changes

  • Add _default_sampler() static method on VAR that returns
    NUTSSampler(cores=1, chains=4)
  • Route the sampler is None branch through this method instead of calling
    NUTSSampler() directly

This matches the pattern already used by StochasticVolatility.fit() (see
the SV Layer 1 plan, Task 6).

Fixes #43

When no sampler is passed to VAR.fit(), the previous code created a bare
NUTSSampler() with cores=None, which auto-detects CPU cores and enables
multiprocessing. This can cause segfaults on macOS and other platforms.

Route the default through a _default_sampler() static method that pins
cores=1, matching the pattern used by StochasticVolatility.fit().

Fixes thomaspinder#43
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 21, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.7%. Comparing base (891bb51) to head (2deeee9).
⚠️ Report is 1 commits behind head on main.

❌ Your project status has failed because the head coverage (88.7%) is below the target coverage (90.0%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files
@@           Coverage Diff           @@
##            main     #44     +/-   ##
=======================================
+ Coverage   88.4%   88.7%   +0.3%     
=======================================
  Files         17      17             
  Lines        665     669      +4     
  Branches      69      69             
=======================================
+ Hits         588     594      +6     
+ Misses        58      57      -1     
+ Partials      19      18      -1     

☔ 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.

Add two new test cases:
- Verify _default_sampler() returns a callable sampler with .sample()
- Verify each call returns a fresh instance (not cached)

Addresses Codecov patch coverage gap (3 missing lines).
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.

VAR.fit() uses unsafe NUTSSampler defaults when sampler argument is omitted

2 participants