pymc-devs / pymc-devs/pytensor
Implement equivalent to `np.diag_indices` and `np.diag_indices_from`
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 644
- Forks
- 208
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 16
Description
Description
Shoud be simple, just use pt.arange to allow symbolic inputs: https://github.com/numpy/numpy/blob/e7a123b2d3eca9897843791dd698c1803d9a39c2/numpy/lib/_index_tricks_impl.py#L1010-L1011
And for diag_indices_from:
https://github.com/numpy/numpy/blob/e7a123b2d3eca9897843791dd698c1803d9a39c2/numpy/lib/_index_tricks_impl.py#L1062-L1069
I would perhaps use pt.max(arr.shape) instead, and let indexing fail at runtime if it was not all square?
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 reading the linked NumPy implementations of np.diag_indices and np.diag_indices_from, then locate the corresponding array-indexing entry points in PyTensor. Implement equivalent behavior using symbolic inputs and resolve how nonsquare shapes should be handled. Done means both operations work with symbolic shapes and match the intended NumPy behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- numpy, python
- Domain
- data
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100