|
13 | 13 | # limitations under the License. |
14 | 14 |
|
15 | 15 | from functools import cached_property |
16 | | -from typing import Dict, Iterable, Iterator, List, Sequence, Set, TYPE_CHECKING, Union |
| 16 | +from typing import Dict, Iterable, Iterator, List, Sequence, Set, Tuple, TYPE_CHECKING, Union |
17 | 17 |
|
18 | 18 | import attrs |
19 | 19 | import cirq |
@@ -599,14 +599,14 @@ def _t_complexity_(self) -> 'TComplexity': |
599 | 599 | # See: https://github.com/quantumlib/Qualtran/issues/217 |
600 | 600 | return t_complexity(LessThanEqual(self.a_bitsize, self.b_bitsize)) |
601 | 601 |
|
602 | | - def wire_symbol(self, soq: Soquet) -> WireSymbol: |
603 | | - if soq.reg.name == 'a': |
| 602 | + def wire_symbol(self, reg: Register, idx: Tuple[int, ...] = tuple()) -> WireSymbol: |
| 603 | + if reg.name == 'a': |
604 | 604 | return TextBox("In(a)") |
605 | | - if soq.reg.name == 'b': |
| 605 | + if reg.name == 'b': |
606 | 606 | return TextBox("In(b)") |
607 | | - elif soq.reg.name == 'target': |
| 607 | + elif reg.name == 'target': |
608 | 608 | return TextBox("⨁(a > b)") |
609 | | - raise ValueError(f'Unknown register name {soq.reg.name}') |
| 609 | + raise ValueError(f'Unknown register name {reg.name}') |
610 | 610 |
|
611 | 611 | def build_call_graph(self, ssa: 'SympySymbolAllocator') -> Set['BloqCountT']: |
612 | 612 | # TODO Determine precise clifford count and/or ignore. |
@@ -677,7 +677,6 @@ def on_classical_vals( |
677 | 677 | def build_composite_bloq( |
678 | 678 | self, bb: 'BloqBuilder', a: Soquet, b: Soquet, target: SoquetT |
679 | 679 | ) -> Dict[str, 'SoquetT']: |
680 | | - |
681 | 680 | # Base Case: Comparing two qubits. |
682 | 681 | # Signed doesn't matter because we can't represent signed integers with 1 qubit. |
683 | 682 | if self.bitsize == 1: |
@@ -831,12 +830,12 @@ def _t_complexity_(self) -> TComplexity: |
831 | 830 | def short_name(self) -> str: |
832 | 831 | return f"x > {self.val}" |
833 | 832 |
|
834 | | - def wire_symbol(self, soq: Soquet) -> WireSymbol: |
835 | | - if soq.reg.name == 'x': |
| 833 | + def wire_symbol(self, reg: Register, idx: Tuple[int, ...] = tuple()) -> WireSymbol: |
| 834 | + if reg.name == 'x': |
836 | 835 | return TextBox("In(x)") |
837 | | - elif soq.reg.name == 'target': |
| 836 | + elif reg.name == 'target': |
838 | 837 | return TextBox(f"⨁(x > {self.val})") |
839 | | - raise ValueError(f'Unknown register symbol {soq.reg.name}') |
| 838 | + raise ValueError(f'Unknown register symbol {reg.name}') |
840 | 839 |
|
841 | 840 | def build_call_graph(self, ssa: 'SympySymbolAllocator') -> Set['BloqCountT']: |
842 | 841 | # TODO Determine precise clifford count and/or ignore. |
@@ -884,12 +883,12 @@ def _t_complexity_(self) -> 'TComplexity': |
884 | 883 | def short_name(self) -> str: |
885 | 884 | return f"x == {self.val}" |
886 | 885 |
|
887 | | - def wire_symbol(self, soq: Soquet) -> WireSymbol: |
888 | | - if soq.reg.name == 'x': |
| 886 | + def wire_symbol(self, reg: Register, idx: Tuple[int, ...] = tuple()) -> WireSymbol: |
| 887 | + if reg.name == 'x': |
889 | 888 | return TextBox("In(x)") |
890 | | - elif soq.reg.name == 'target': |
| 889 | + elif reg.name == 'target': |
891 | 890 | return TextBox(f"⨁(x = {self.val})") |
892 | | - raise ValueError(f'Unknown register symbol {soq.reg.name}') |
| 891 | + raise ValueError(f'Unknown register symbol {reg.name}') |
893 | 892 |
|
894 | 893 | def build_call_graph(self, ssa: 'SympySymbolAllocator') -> Set['BloqCountT']: |
895 | 894 | # See: https://github.com/quantumlib/Qualtran/issues/219 |
|
0 commit comments