Skip to content

Fix/datatree nan handling - #4876

Open
reachsridhard wants to merge 6 commits into
HypothesisWorks:masterfrom
reachsridhard:fix/datatree-nan-handling
Open

reachsridhard wants to merge 6 commits into
HypothesisWorks:masterfrom
reachsridhard:fix/datatree-nan-handling

Conversation

@reachsridhard

Copy link
Copy Markdown
Contributor

Fix NaN handling in compute_max_children and all_children

Summary

Fixes compute_max_children and all_children ignoring NaN when allow_nan=True, despite choice_permitted correctly treating NaN as valid.

This caused incorrect exhaustion checks, unnecessary force-splitting of float nodes, and prevented the cache-based drawing path from generating NaN.

Changes

  • compute_max_children: Include all valid NaN bit patterns when allow_nan=True.
  • all_children: Yield canonical math.nan and -math.nan values when NaN is allowed.
  • _draw_from_cache: Fall back to random drawing when the cache has no usable candidates.

Updated existing tests to distinguish finite-only cases and added coverage for NaN inclusion/exclusion and permission checks.

@reachsridhard
reachsridhard force-pushed the fix/datatree-nan-handling branch 2 times, most recently from 1e001ec to 0f5652d Compare September 13, 2026 02:24
@reachsridhard
reachsridhard force-pushed the fix/datatree-nan-handling branch from 0f5652d to 26a5160 Compare September 13, 2026 10:38
Under the crosshair backend, the inline f-string in the UnsatisfiedAssumption raise could evaluate to an empty string due to opcode tracing, producing gave_up observations with an empty status_reason. Computing the reason via a helper call keeps it concrete, matching how where and location are produced.
The fallback for an exhausted children cache was uncovered: it only fires for float branches with allow_nan=True, where all_children enumerates only the canonical NaN values but compute_max_children counts every NaN bit pattern.
Downcasting unbounded float64 draws to width=16 rejects the overwhelming majority of inputs, making the filter_too_much health check marginal and flaky (observed failing on Python 3.15 CI).

This branch has not been deployed

No deployments
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