Skip to content

Fix bug in AdvancedSubtensor infer_shape #101

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 2 commits into from
Dec 10, 2022

Conversation

ricardoV94
Copy link
Member

The underlying utility indexed_result_shape was off by 1 in terms of when do the advanced index operations have to be brought to the front of the array.

Closes #98

The underlying utility `indexed_result_shape` was off by 1 in terms of when do the advanced index operations have to be brought to the front of the array.
Copy link
Member

@aseyboldt aseyboldt left a comment

Choose a reason for hiding this comment

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

Looks good, apart from the possible parenthesis nitpick :-)

@@ -489,8 +489,10 @@ def indexed_result_shape(array_shape, indices, indices_are_shapes=False):
remaining_dims = range(pytensor.tensor.basic.get_vector_length(array_shape))
idx_groups = group_indices(indices)

if len(idx_groups) > 2 or len(idx_groups) > 1 and not idx_groups[0][0]:
# Bring adv. index groups to the front and merge each group
if len(idx_groups) > 3 or len(idx_groups) == 3 and not idx_groups[0][0]:
Copy link
Member

Choose a reason for hiding this comment

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

I had to look up operator precedence for and and or here. :-)
Turns out and has higher precedence, which I think is correct here.
Is that just me, or should we maybe add parenthesis here to make it obvious?

Copy link
Member Author

Choose a reason for hiding this comment

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

Always in favor of parenthesis. Brings us closer to lisp!

@ricardoV94 ricardoV94 merged commit d159f06 into pymc-devs:main Dec 10, 2022
@ricardoV94 ricardoV94 deleted the fix_advanced_index_shape_bug branch December 10, 2022 05:40
Copy link

codecov bot commented Aug 28, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 74.26%. Comparing base (220442a) to head (3404d43).
Report is 630 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #101      +/-   ##
==========================================
- Coverage   80.42%   74.26%   -6.17%     
==========================================
  Files         170      175       +5     
  Lines       45376    48929    +3553     
  Branches    11082    10395     -687     
==========================================
- Hits        36495    36335     -160     
- Misses       6654    10291    +3637     
- Partials     2227     2303      +76     
Files with missing lines Coverage Δ
pytensor/tensor/subtensor.py 89.44% <100.00%> (-0.20%) ⬇️

... and 152 files with indirect coverage changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working shape problem
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Wrong shape inference in AdvancedSubtensor
2 participants