Skip to content

Support consumed dims in Prior for distributions like Categorical#675

Open
williambdean wants to merge 4 commits intopymc-devs:mainfrom
williambdean:feat/consumed-dims-prior
Open

Support consumed dims in Prior for distributions like Categorical#675
williambdean wants to merge 4 commits intopymc-devs:mainfrom
williambdean:feat/consumed-dims-prior

Conversation

@williambdean
Copy link
Copy Markdown
Collaborator

Fixes #499.

Distributions like Categorical(p)->() consume a parameter dimension entirely without re-emitting it in the output. Prior previously raised UnsupportedShapeError for these cases.

Changes

  • Add _get_dist_param_names and _get_consumed_dims helpers using rv_op metadata
  • Fix _param_dims_work to exclude consumed dims from the subset check
  • Fix handle_dims to preserve consumed dims as trailing axes for the distribution op
  • Auto-compute core_dims from rv_op when not explicitly set

Tests

8 new tests in TestConsumedDims covering Categorical, Interpolated, MvNormal cov, and a guard for non-consumed incompatible dims.

Distributions such as Categorical(p)->() consume the parameter dimension
entirely without re-emitting it in the output. Prior previously raised
UnsupportedShapeError for these cases.

- Add _get_dist_param_names and _get_consumed_dims helpers
- Fix _param_dims_work to exclude consumed dims from subset check
- Fix handle_dims to append core dim indices and handle all-consumed case
- Auto-compute core_dims from rv_op metadata when not explicitly set
- Fix xdist path to pass core_dims=None (not ()) when absent
- Add TestConsumedDims with 8 tests covering Categorical, Interpolated,
  MvNormal cov, and the guard for non-consumed incompatible dims

Closes pymc-devs#499
@ricardoV94
Copy link
Copy Markdown
Member

I assume this was not a problem at all with xdist=True?

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.

Prior support for "consumed" dims

2 participants