Update kron tests to explicitly cover static and dynamic shapes #1912
Open
ayulockedin wants to merge 2 commits intopymc-devs:mainfrom
Open
Update kron tests to explicitly cover static and dynamic shapes #1912ayulockedin wants to merge 2 commits intopymc-devs:mainfrom
ayulockedin wants to merge 2 commits intopymc-devs:mainfrom
Conversation
Contributor
Author
|
@ricardoV94 can u take a look at it |
ricardoV94
requested changes
Feb 24, 2026
tests/tensor/test_nlinalg.py
Outdated
| [(0, (2, 3), (6, 7)), (1, (2, 3), (4, 3, 5)), (2, (2, 4, 3), (4, 3, 5))], | ||
| ) | ||
| def test_kron_commutes_with_inv(self, i, shp0, shp1): | ||
| def test_kron_commutes_with_inv(self, static_shape, i, shp0, shp1): |
Member
There was a problem hiding this comment.
no reason to touch this test
tests/tensor/test_nlinalg.py
Outdated
Comment on lines
768
to
772
| # Adjusting the assertion because a non-static tensor won't have integer dimensions in type.shape | ||
| if static_shape: | ||
| assert kron_xy.type.shape == np_val.shape | ||
| else: | ||
| assert len(kron_xy.type.shape) == len(np_val.shape) |
Member
There was a problem hiding this comment.
define a shape_out like you did shape_x and shape_y, and assert immediately after you define kron_xy that it matches. In the non static shape case it will be (None, None)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This updates the test suite for
pt.linalg.kronto explicitly test both static and non-static shapes. Following reviewer feedback, I added astatic_shapeparameterization totest_performandtest_kron_commutes_with_inv. This ensures that the operation does not accidentally rely onx.type.shapeinternally, which would mask bugs and cause silent failures with dynamic shapes in the future. The regression assertions have also been updated to handle tuple lengths dynamically when static shapes are not provided.Related Issue
Checklist
Type of change