refactor: Simplify combine_metadata#2836
Merged
MarcoGorelli merged 2 commits intomainfrom Jul 17, 2025
Merged
Conversation
combine_metadata
Comment on lines
+552
to
+564
| result_expansion_kind = ( | ||
| result_expansion_kind & expansion_kind | ||
| if i > 0 | ||
| else expansion_kind | ||
| ) | ||
|
|
||
| if metadata.has_windows: | ||
| result_has_windows = True | ||
| result_has_windows |= metadata.has_windows | ||
| result_n_orderable_ops += metadata.n_orderable_ops | ||
| if metadata.preserves_length: | ||
| result_preserves_length = True | ||
| if not metadata.is_elementwise: | ||
| result_is_not_elementwise = True | ||
| if not metadata.is_scalar_like: | ||
| result_is_not_scalar_like = True | ||
| if not metadata.is_literal: | ||
| result_is_not_literal = True | ||
| if metadata.is_filtration: | ||
| n_filtrations += 1 | ||
| result_preserves_length |= metadata.preserves_length | ||
| result_is_elementwise &= metadata.is_elementwise | ||
| result_is_scalar_like &= metadata.is_scalar_like | ||
| result_is_literal &= metadata.is_literal | ||
| n_filtrations += int(metadata.is_filtration) |
Member
There was a problem hiding this comment.
I'm pretty impressed by this 🥳
I hadn't seen a real world use-case for __iand__ before, but this looks like it!
MarcoGorelli
approved these changes
Jul 17, 2025
Member
MarcoGorelli
left a comment
There was a problem hiding this comment.
thanks @FBruzzesi !
i remembered some previous discussion where someone had brought up that this was less efficient, but i'm not bothered enough about the difference, and this is clearer anyway, so let's ship it 🚢
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.

What type of PR is this? (check all applicable)
Related issues
Checklist
If you have comments or can explain your changes, please do so below
Overall, this is not a real change. What this PR achieves: