-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Equality check between
Sum
types (#1422)
`Sum`, `Tuple` and `UnitSum` can represent the same type, but the equality fn checked the specific subclasses.
- Loading branch information
Showing
2 changed files
with
20 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from __future__ import annotations | ||
|
||
from hugr.tys import Bool, Qubit, Sum, Tuple, UnitSum | ||
|
||
|
||
def test_sums(): | ||
assert Sum([[Bool, Qubit]]) == Tuple(Bool, Qubit) | ||
assert Tuple(Bool, Qubit) == Sum([[Bool, Qubit]]) | ||
assert Sum([[Bool, Qubit]]).as_tuple() == Sum([[Bool, Qubit]]) | ||
|
||
assert Tuple() == Sum([[]]) | ||
assert UnitSum(0) == Sum([]) | ||
assert UnitSum(1) == Tuple() | ||
assert UnitSum(4) == Sum([[], [], [], []]) |