Add fermion arrow. - #17
Conversation
There was a problem hiding this comment.
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
_arrowattribute 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, ...] |
There was a problem hiding this comment.
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.
| _arrow: tuple[bool, ...] | |
| _arrow: tuple[bool, ...] = () |
| """ | ||
| 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}." |
There was a problem hiding this comment.
[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.
| 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}." |
No description provided.