Skip to content

Conversation

@hzhangxyz
Copy link
Member

No description provided.

@hzhangxyz hzhangxyz mentioned this pull request Aug 7, 2025
13 tasks
@codecov
Copy link

codecov bot commented Aug 7, 2025

Codecov Report

❌ Patch coverage is 3.50877% with 110 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
grassmann_tensor/tensor.py 3.50% 110 Missing ⚠️

📢 Thoughts on this report? Let us know!

@hzhangxyz hzhangxyz marked this pull request as ready for review August 8, 2025 06:37
@hzhangxyz hzhangxyz requested a review from Copilot August 8, 2025 07:15

This comment was marked as outdated.

hzhangxyz and others added 2 commits August 8, 2025 15:19
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@hzhangxyz hzhangxyz requested a review from Copilot August 8, 2025 07:19

This comment was marked as outdated.

@hzhangxyz hzhangxyz requested a review from Copilot August 9, 2025 04:58

This comment was marked as outdated.

@hzhangxyz hzhangxyz requested a review from Copilot August 9, 2025 05:23

This comment was marked as outdated.

@hzhangxyz hzhangxyz requested a review from Copilot August 9, 2025 05:39
Copy link
Contributor

Copilot AI left a 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_indices helper method for calculating edge reordering and parity signs
  • Implements the main reshape method 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():
Copy link

Copilot AI Aug 9, 2025

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.

Suggested change
if cursor_plan == len(new_shape) and cursor_self == self.tensor.dim():

Copilot uses AI. Check for mistakes.

splitting_parity = functools.reduce(
torch.logical_xor,
(self._unsqueeze(sign, index, self.tensor.dim()) for index, sign in splitting_sign if self.arrow[index]),
Copy link

Copilot AI Aug 9, 2025

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.

Suggested change
(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]),

Copilot uses AI. Check for mistakes.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@hzhangxyz hzhangxyz requested a review from Copilot August 9, 2025 05:53
@hzhangxyz hzhangxyz merged commit c05e37b into main Aug 9, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants