Skip to content

Add support for reverse. - #29

Merged
hzhangxyz merged 3 commits into
mainfrom
dev/reverse-edge
Aug 7, 2025
Merged

Add support for reverse.#29
hzhangxyz merged 3 commits into
mainfrom
dev/reverse-edge

Conversation

@hzhangxyz

Copy link
Copy Markdown
Member

No description provided.

@hzhangxyz hzhangxyz mentioned this pull request Jul 31, 2025
13 tasks
@codecov

codecov Bot commented Jul 31, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 12.50000% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 37.56%. Comparing base (8f53b1b) to head (bb6f9c4).

Files with missing lines Patch % Lines
parity_tensor/parity_tensor.py 12.50% 7 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #29      +/-   ##
==========================================
- Coverage   38.57%   37.56%   -1.02%     
==========================================
  Files           3        3              
  Lines         197      205       +8     
  Branches       26       26              
==========================================
+ Hits           76       77       +1     
- Misses        121      128       +7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@codecov

codecov Bot commented Aug 7, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 12.50000% with 7 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
grassmann_tensor/tensor.py 12.50% 7 Missing ⚠️

📢 Thoughts on this report? Let us know!

@hzhangxyz
hzhangxyz merged commit 018b484 into main Aug 7, 2025
10 of 11 checks passed
@hzhangxyz
hzhangxyz requested a review from Copilot August 8, 2025 07:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 new reverse method to the GrassmannTensor class that allows reversing specified indices while maintaining proper Grassmann algebra sign conventions.

  • Implements tensor index reversal with automatic sign handling for Grassmann tensors
  • Validates input indices for uniqueness and bounds checking
  • Calculates and applies parity-based sign corrections according to Grassmann algebra rules

assert len(set(indices)) == len(indices), f"Indices must be unique. Got {indices}."
assert all(0 <= i < self.tensor.dim() for i in indices), f"Indices must be within tensor dimensions. Got {indices}."

arrow = tuple(self.arrow[i] ^ i in indices for i in range(self.tensor.dim()))

Copilot AI Aug 8, 2025

Copy link

Choose a reason for hiding this comment

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

[nitpick] The expression i in indices should be parenthesized for clarity. The current precedence could be confusing. Consider: arrow = tuple(self.arrow[i] ^ (i in indices) for i in range(self.tensor.dim()))

Suggested change
arrow = tuple(self.arrow[i] ^ i in indices for i in range(self.tensor.dim()))
arrow = tuple(self.arrow[i] ^ (i in indices) for i in range(self.tensor.dim()))

Copilot uses AI. Check for mistakes.

total_parity = functools.reduce(
torch.logical_xor,
(self._unsqueeze(parity, index, self.tensor.dim()) for index, parity in enumerate(self.parity) if index in indices and self.arrow[index]),

Copilot AI Aug 8, 2025

Copy link

Choose a reason for hiding this comment

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

[nitpick] The condition index in indices and self.arrow[index] should be parenthesized for clarity: (index in indices) and self.arrow[index]

Suggested change
(self._unsqueeze(parity, index, self.tensor.dim()) for index, parity in enumerate(self.parity) if index in indices and self.arrow[index]),
(self._unsqueeze(parity, index, self.tensor.dim()) for index, parity in enumerate(self.parity) if (index in indices and self.arrow[index])),

Copilot uses AI. Check for mistakes.
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