Skip to content

Drop divergence_message in drop_warning_stat#8334

Open
gaoflow wants to merge 1 commit into
pymc-devs:mainfrom
gaoflow:fix-8321-drop-divergence-message
Open

Drop divergence_message in drop_warning_stat#8334
gaoflow wants to merge 1 commit into
pymc-devs:mainfrom
gaoflow:fix-8321-drop-divergence-message

Conversation

@gaoflow

@gaoflow gaoflow commented Jun 19, 2026

Copy link
Copy Markdown

Description

nutpie can add a string-valued divergence_message variable to sample_stats, which keeps keep_warning_stat=False from producing an InferenceData object that can be serialized cleanly.

This updates drop_warning_stat() to drop divergence_message alongside the existing warning stats, while preserving ordinary sampler stats like diverging. A regression test covers both sample_stats and warmup_sample_stats.

AI assistance was used under my direction.

Related Issue

Checklist

Type of change

  • New feature / enhancement
  • Bug fix
  • Documentation
  • Maintenance
  • Other (please specify):

Local checks

  • uv run --with-editable . --with pytest python -m pytest tests/test_util.py::test_drop_warning_stat tests/test_util.py::test_drop_divergence_message_stat -q
  • uv run --with ruff ruff check pymc/util.py tests/test_util.py
  • uv run --with ruff ruff format --check pymc/util.py tests/test_util.py
  • git diff --check origin/main...HEAD

nutpie emits a string-valued divergence_message variable in sample_stats.
The drop_warning_stat filter only removed warning and sampler_N__warning
variables, so divergence_message survived into idata.sample_stats and made
idata.to_netcdf() fail on the object-dtype array. Include divergence_message
in the set of dropped names, scoped to sample-stats groups as before.

Closes pymc-devs#8321
@gaoflow gaoflow changed the title Drop in Drop divergence_message in drop_warning_stat Jun 19, 2026
@github-actions github-actions Bot added the bug label Jun 19, 2026
@codecov

codecov Bot commented Jun 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.70%. Comparing base (9d24260) to head (2d098fd).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##             main    #8334       +/-   ##
===========================================
+ Coverage   79.80%   91.70%   +11.90%     
===========================================
  Files         125      125               
  Lines       20526    20526               
===========================================
+ Hits        16380    18824     +2444     
+ Misses       4146     1702     -2444     
Files with missing lines Coverage Δ
pymc/util.py 81.09% <ø> (+2.94%) ⬆️

... and 42 files with indirect coverage changes

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

@gaoflow

gaoflow commented Jun 21, 2026

Copy link
Copy Markdown
Author

CI triage note: the current red job looks unrelated to this drop_warning_stat change.

The failing matrix is alternative_backends (cvm, 3.13, tests/distributions/test_random_alternative_backends.py ...), and the only assertion failure shown in the log is:

FAILED tests/distributions/test_random_alternative_backends.py::test_mvstudentt[NUMBA]
Not equal to tolerance rtol=0.1, atol=0
ACTUAL: array([0.999302, 2.002764, 2.680959])
DESIRED: array([1, 2, 3])

The all_tests check then fails only as the aggregate matrix-status step. This PR only changes pymc/util.py and tests/test_util.py to drop the string-valued divergence_message sample stat, so I do not see a code action for this branch from that failure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: keep_warning_stat argument in pm.sample does nothing

1 participant