Skip to content

Add fermion arrow. - #17

Merged
hzhangxyz merged 1 commit into
mainfrom
dev/add-arrow
Jul 31, 2025
Merged

Add fermion arrow.#17
hzhangxyz merged 1 commit into
mainfrom
dev/add-arrow

Conversation

@hzhangxyz

Copy link
Copy Markdown
Member

No description provided.

@hzhangxyz
hzhangxyz requested a review from Copilot July 31, 2025 01:59

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 fermion arrow functionality to the ParityTensor class to track the order of fermion operators. The arrow is represented as a tuple of booleans indicating the direction/order of fermion operators for each tensor dimension.

  • Adds _arrow attribute to store fermion operator ordering information
  • Implements arrow property getter and validation logic
  • Updates permutation operations to preserve arrow information

Each dimension of the tensor is composed of an even and an odd part, represented as a pair of integers.
"""

_arrow: tuple[bool, ...]

Copilot AI Jul 31, 2025

Copy link

Choose a reason for hiding this comment

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

The _arrow attribute is declared without a default value, but other attributes like _parity and _mask have default values of None. This inconsistency could cause initialization issues if arrow is not provided during object creation.

Suggested change
_arrow: tuple[bool, ...]
_arrow: tuple[bool, ...] = ()

Copilot uses AI. Check for mistakes.
"""
Validate that the edges of two ParityTensor instances are compatible for arithmetic operations.
"""
assert self._arrow == other.arrow, f"Arrows must match for arithmetic operations. Got {self._arrow} and {other.arrow}."

Copilot AI Jul 31, 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 assertion accesses other.arrow (property) while comparing to self._arrow (private attribute). For consistency, either use other._arrow or self.arrow to maintain symmetry in the comparison.

Suggested change
assert self._arrow == other.arrow, f"Arrows must match for arithmetic operations. Got {self._arrow} and {other.arrow}."
assert self.arrow == other.arrow, f"Arrows must match for arithmetic operations. Got {self.arrow} and {other.arrow}."

Copilot uses AI. Check for mistakes.
@hzhangxyz
hzhangxyz merged commit 802673d into main Jul 31, 2025
6 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