pymc-devs / pymc-devs/pytensor
Document `output_types_preference` in ScalarOp
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 644
- Forks
- 208
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 16
Description
Description
ScalarOps are parametrized by an output_types_preference that determines the output types from the input types in make_node (unless an Op overrides make_node). This is used indirectly via output_types. The design is somewhat convoluted, but meant to make it easier to define ScalarOps (and IIRC to tweak their behavior in the InplaceOptimizer).
The whole logic should be documented, in which process, we may find out it can be simplified. Also, everytime we use it we check whether the outputs from this function are valid, which is costly. Since nobody is really creating new output_types_preference we should just trust them.
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
Read pytensor/scalar/basic.py around lines 1219-1272 and trace how output_types_preference is used by ScalarOp.make_node and output_types, including the override case mentioned in the issue. Document the current logic and its validation checks, and leave the behavior simplified only if the surrounding code confirms that is safe.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend, documentation
- Issue type
- Documentation
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100