Skip to content

Fix find_constants to properly handle discrete observed data#8087

Open
hrideymarwah15 wants to merge 1 commit intopymc-devs:mainfrom
hrideymarwah15:fix/find-constants-7851
Open

Fix find_constants to properly handle discrete observed data#8087
hrideymarwah15 wants to merge 1 commit intopymc-devs:mainfrom
hrideymarwah15:fix/find-constants-7851

Conversation

@hrideymarwah15
Copy link

Fixes #7851

The find_constants function was not properly filtering out observed data when the observation went through a Cast operation (e.g., for discrete distributions like Categorical or Poisson). This caused the observed data to appear in both constant_data and observed_data groups.

The fix computes value_vars ancestors excluding model_vars ancestors, which properly identifies data variables that are used only as observations.

Fixes pymc-devs#7851

The find_constants function was not properly filtering out observed data
when the observation went through a Cast operation (e.g., for discrete
distributions like Categorical or Poisson). This caused the observed data
to appear in both constant_data and observed_data groups.

The fix computes value_vars ancestors excluding model_vars ancestors,
which properly identifies data variables that are used only as observations,
even when they go through Cast or other transformation operations.

This solution was suggested by @ricardoV94 in the issue discussion.
@github-actions github-actions bot added bug trace-backend Traces and ArviZ stuff labels Feb 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug trace-backend Traces and ArviZ stuff

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: find_constants helper function is inconsistent

1 participant