Skip to content

Add rewrites for inv(diag(x)) and inv(eye) #898

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 30, 2024

Conversation

tanish1729
Copy link
Contributor

@tanish1729 tanish1729 commented Jul 7, 2024

Description

Added rewrites for inv(diag(x)) = 1/x and rewrites inv(eye) -> eye

Related Issue

Checklist

Type of change

  • New feature / enhancement
  • Bug fix
  • Documentation
  • Maintenance
  • Other (please specify):

@tanish1729 tanish1729 changed the title added rewrites for inv(diag(x)) and inv(orthonormal(x)) added rewrites for inv(diag(x)) Jul 30, 2024
@tanish1729 tanish1729 changed the title added rewrites for inv(diag(x)) added rewrites for inv(diag(x)) and inv(eye) Jul 30, 2024
Copy link

codecov bot commented Aug 5, 2024

Codecov Report

Attention: Patch coverage is 94.59459% with 2 lines in your changes missing coverage. Please review.

Project coverage is 81.70%. Comparing base (b65d08c) to head (370f2d8).
Report is 132 commits behind head on main.

Files with missing lines Patch % Lines
pytensor/tensor/rewriting/linalg.py 94.59% 1 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #898   +/-   ##
=======================================
  Coverage   81.69%   81.70%           
=======================================
  Files         182      182           
  Lines       47585    47626   +41     
  Branches    11584    11601   +17     
=======================================
+ Hits        38875    38913   +38     
- Misses       6520     6521    +1     
- Partials     2190     2192    +2     
Files with missing lines Coverage Δ
pytensor/tensor/rewriting/linalg.py 91.66% <94.59%> (+0.38%) ⬆️

... and 4 files with indirect coverage changes

Copy link
Member

@jessegrabowski jessegrabowski left a comment

Choose a reason for hiding this comment

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

Getting close! Can you also add a test of cases that should not be rewritten, for example eye with k!=0. Check the different off-ramps in the rewrites and make sure they happen.

@@ -3,6 +3,7 @@
from typing import cast

from pytensor import Variable
from pytensor import tensor as pt
Copy link
Member

Choose a reason for hiding this comment

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

Import what you need directly from the various packages within pytensor.tensor, it makes the code easier to follow for people in the future

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah that makes sense. i'll do that from next time cuz the test file has way too many uses of pt rn 😓

Copy link
Member

@jessegrabowski jessegrabowski left a comment

Choose a reason for hiding this comment

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

Small change, then I think this is ready

@jessegrabowski jessegrabowski merged commit 1a1c62b into pymc-devs:main Aug 30, 2024
59 of 60 checks passed
@ricardoV94 ricardoV94 changed the title added rewrites for inv(diag(x)) and inv(eye) Add rewrites for inv(diag(x)) and inv(eye) Oct 3, 2024
@ricardoV94 ricardoV94 added enhancement New feature or request graph rewriting linalg Linear algebra labels Oct 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request graph rewriting linalg Linear algebra
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants