pymc-devs / pymc-devs/pytensor
TensorType.shape is a mutable plain attribute
Open
Beginner friendly
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 644
- Forks
- 208
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 16
Description
Reproduction
import pytensor.tensor as pt
x = pt.scalar("x")
x.type.shape = (3,)
Expected behavior
shape should be a read-only property. Mutating it should raise AttributeError.
Actual behavior
shape is a plain instance attribute. Unlike XTensorType, TensorType has no derived attribute that goes out of sync when shape changes, so no observable corruption occurs. This is a consistency issue rather than a bug.
Environment
pytensor 3.2.4
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the Python definition of TensorType and compare its shape handling with XTensorType. Add or update the relevant test so assigning to shape raises AttributeError, then run that focused test to confirm the attribute is read-only.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- machine-learning
- Issue type
- Refactor
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 76/100