pymc-devs / pymc-devs/pytensor

`params_broadcast_shapes` logic is wrong

Open
#564 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug random variables
Dominant language
Python
Stars
644
Forks
208
Avg merge
2d 14h
Merged PRs (30d)
16

Description

This helper uses max to broadcast dimensions, but this is wrong because a dim of length 1 should broadcasted to length 0 if that's the length of the other dim

https://github.com/pymc-devs/pytensor/blob/9cf2d181f07dc99bbd2e7c9e2b4a3e1b0aeff034/pytensor/tensor/random/utils.py#L25-L71

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in pytensor/tensor/random/utils.py at the linked params_broadcast_shapes helper and inspect how it combines dimensions with max. Reproduce the case where one dimension is 1 and the other is 0, then verify that the resulting broadcast shape follows the issue’s expected behavior and that existing broadcasting cases remain correct.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.