Skip to content

Propagate triangularity through matrix transpose#2174

Merged
jessegrabowski merged 2 commits into
pymc-devs:mainfrom
jessegrabowski:triangular-transpose
May 30, 2026
Merged

Propagate triangularity through matrix transpose#2174
jessegrabowski merged 2 commits into
pymc-devs:mainfrom
jessegrabowski:triangular-transpose

Conversation

@jessegrabowski
Copy link
Copy Markdown
Member

The following was not being correctly propagated:

x = assume(pt.dmatrix('x'), upper_triangular=True)
y = x.T
y.dprint(print_assumptions=True) # Expected: y is lower_triangular

This was just an oversight, so I added it.

Replace the dead _dimshuffle_left_expand_dims rule (shadowed by the
default DimShuffle handler) with cross-key inference: a matrix-transpose
DimShuffle now flips lower<->upper, so downstream rewrites can see
triangular structure through .T / .mT.
Copy link
Copy Markdown
Member

@ricardoV94 ricardoV94 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bit more work but you can propagate False if the input triangularity is false (not just unknown)

@jessegrabowski jessegrabowski merged commit 32a372c into pymc-devs:main May 30, 2026
66 checks passed
@jessegrabowski jessegrabowski deleted the triangular-transpose branch May 30, 2026 15:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants