-
Notifications
You must be signed in to change notification settings - Fork 171
refactor: Simplify combine_metadata
#2836
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
Conversation
combine_metadata
| 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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm pretty impressed by this 🥳
I hadn't seen a real world use-case for __iand__ before, but this looks like it!
MarcoGorelli
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 🚢

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: