-
Notifications
You must be signed in to change notification settings - Fork 0
Add reshape function. #39
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
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
0c0222c to
aa4004f
Compare
aa4004f to
85dff0f
Compare
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2a05108 to
d15b150
Compare
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.
Pull Request Overview
This PR adds a reshape function to the GrassmannTensor class that allows reshaping of Grassmann tensors while handling the complex requirements of splitting and merging edges with proper parity sign calculations.
- Adds a new
_reorder_indiceshelper method for calculating edge reordering and parity signs - Implements the main
reshapemethod that can split or merge tensor dimensions while preserving Grassmann algebra properties - Handles complex logic for maintaining arrow consistency and applying appropriate signs during tensor transformations
| cursor_self += 1 | ||
| cursor_plan = new_cursor_plan | ||
|
|
||
| if cursor_plan == len(new_shape) and cursor_self == self.tensor.dim(): |
Copilot
AI
Aug 9, 2025
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.
The loop termination condition is placed after potential IndexError scenarios. If either cursor exceeds bounds during the loop iterations, the function will crash before reaching this check.
| if cursor_plan == len(new_shape) and cursor_self == self.tensor.dim(): |
|
|
||
| splitting_parity = functools.reduce( | ||
| torch.logical_xor, | ||
| (self._unsqueeze(sign, index, self.tensor.dim()) for index, sign in splitting_sign if self.arrow[index]), |
Copilot
AI
Aug 9, 2025
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.
The condition self.arrow[index] uses the original tensor's arrow, but index refers to positions in the original tensor during splitting. After tensor reshaping, the dimensions may not correspond correctly.
| (self._unsqueeze(sign, index, self.tensor.dim()) for index, sign in splitting_sign if self.arrow[index]), | |
| (self._unsqueeze(sign, index, self.tensor.dim()) for index, sign in splitting_sign if arrow[index]), |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
No description provided.