fix(spec): use safe default sampler with cores=1 in VAR.fit()#44
Open
armorbreak001 wants to merge 3 commits into
Open
fix(spec): use safe default sampler with cores=1 in VAR.fit()#44armorbreak001 wants to merge 3 commits into
armorbreak001 wants to merge 3 commits into
Conversation
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 Report✅ All modified and coverable lines are covered by tests. ❌ 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. 🚀 New features to boost your workflow:
|
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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When no sampler is passed to
VAR.fit(), the previous code created a bareNUTSSampler()withcores=None, which auto-detects CPU cores and enablesmultiprocessing. This can cause segfaults on macOS and other platforms (as
documented in CLAUDE.md).
Changes
_default_sampler()static method onVARthat returnsNUTSSampler(cores=1, chains=4)sampler is Nonebranch through this method instead of callingNUTSSampler()directlyThis matches the pattern already used by
StochasticVolatility.fit()(seethe SV Layer 1 plan, Task 6).
Fixes #43