Skip to content

fix: DynestyDynamic OverflowError when run without an output path - #1658

Open
samlange04 wants to merge 2 commits into
PyAutoLabs:mainfrom
samlange04:fix/dynesty-dynamic-nullpaths-overflow
Open

samlange04 wants to merge 2 commits into
PyAutoLabs:mainfrom
samlange04:fix/dynesty-dynamic-nullpaths-overflow

Conversation

@samlange04

Copy link
Copy Markdown

Summary

Discussion: https://github.com/orgs/PyAutoLabs/discussions/28

DynestyDynamic crashed with OverflowError: Python int too large to convert to C long whenever the search had no output path (NullPaths, i.e. created without a name). AbstractDynesty.iterations_from returned int(1e99) as the "unbounded" per-chunk maxcall budget in that case. dynesty's dynamic sampler computes maxcall - ncall with a numpy int64 ncall, which cannot handle a 99-digit Python int. The static sampler only compares against maxcall in pure Python, so it was unaffected.

This PR returns sys.maxsize instead, the same sentinel dynesty substitutes for maxcall=None. The branch where maxcall is set is unchanged. A comment at the site records why the value matters.

API Changes

  • None. iterations_from is internal and the NullPaths return value changes from int(1e99) to sys.maxsize. Both mean "no limit". No downstream code reads this value.

Test Plan

  • New test__null_paths_iteration_budget_fits_c_long, parametrised over DynestyStatic and DynestyDynamic: asserts the budget is sys.maxsize, that subtracting a np.int64 from it works, and that an explicit maxcall is still returned unchanged. Fails red on main (int(1e99) != sys.maxsize).
  • End to end: the reproducer in the discussion (a 3-parameter Gaussian fit with a nameless DynestyDynamic) now runs to completion, with and without n_effective. Fitting with a named search before and after the change gives the same sample counts and effective sample sizes.
  • test_autofit/non_linear/search/nest/: 40 passed, 13 skipped, on macOS / Python 3.13.7 / dynesty 2.1.5. Run with the conftest's set_start_method stubbed because of the macOS import-time bug fixed separately in fix: do not fix the multiprocessing start method at import time on macOS #1657.

🤖 Generated with Claude Code

samlange04 and others added 2 commits October 3, 2026 20:58
…tput path

With `NullPaths` (a search created without a `name`), `iterations_from`
returned `int(1e99)` as the "unbounded" per-chunk budget. dynesty's
dynamic sampler computes `maxcall - ncall` with a numpy int64 `ncall`,
and a 99-digit Python int cannot be converted to a C long, raising
`OverflowError: Python int too large to convert to C long`. The static
sampler only compares against `maxcall`, so it was unaffected.

Use `sys.maxsize`, which is the sentinel dynesty itself uses for
`maxcall=None`.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…C long

Regression test for the OverflowError raised by dynesty's dynamic sampler
when a search is run without an output path.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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.

1 participant