@@ -56,7 +56,7 @@ def __init__(
5656 self ,
5757 gate : Gate ,
5858 radixes : Sequence [int ] | int ,
59- level_maps : Sequence [int ] | Sequence [Sequence [int ]],
59+ level_maps : None | Sequence [int ] | Sequence [Sequence [int ]] = None ,
6060 ) -> None :
6161 """
6262 Construct an EmbeddedGate.
@@ -71,21 +71,24 @@ def __init__(
7171 if `radixes = 3`, then the gate will be embedded into a
7272 qutrit gate.
7373
74- level_maps (Sequence[int] | Sequence[Sequence[int]]): The level
75- map for the embedding for each qudit. If a sequence of
76- integers is given, then the level map is assumed to be
77- the same for all qudits. For example, if `radixes = 3`
78- and `level_maps = [0, 2]`, then the gate will be
79- embedded into a qutrit gate by mapping the qubit levels
80- 0 and 1 to the qutrit levels 0 and 2, respectively. If a
81- sequence of sequences is given, then the level map is
82- assumed to be different for each qudit. For example, if
83- `radixes = [3, 3]` and `level_maps = [[0, 2], [1, 2]]`,
84- then the gate will be embedded into a two-qudit gate by
85- mapping the first qubit's 0 and 1 levels to the first
86- qutrit's 0 and 2 levels, respectively, and by mapping
87- the second qubit's 0 and 1 levels to the second qutrit's
88- 1 and 2 levels, respectively.
74+ level_maps (None | Sequence[int] | Sequence[Sequence[int]]):
75+ The level map for the embedding for each qudit. If a
76+ sequence of integers is given, then the level map is
77+ assumed to be the same for all qudits. For example, if
78+ `radixes = 3` and `level_maps = [0, 2]`, then the gate
79+ will be embedded into a qutrit gate by mapping the qubit
80+ levels 0 and 1 to the qutrit levels 0 and 2,
81+ respectively. If a sequence of sequences is given, then
82+ the level map is assumed to be different for each qudit.
83+ For example, if `radixes = [3, 3]` and `level_maps =
84+ [[0, 2], [1, 2]]`, then the gate will be embedded into a
85+ two-qudit gate by mapping the first qubit's 0 and 1
86+ levels to the first qutrit's 0 and 2 levels,
87+ respectively, and by mapping the second qubit's 0 and 1
88+ levels to the second qutrit's 1 and 2 levels,
89+ respectively. This can also be set to `None`, which will
90+ embed the lower dimension gate in the lowest levels of
91+ the new radixes.
8992
9093 Raises:
9194
@@ -138,6 +141,9 @@ def __init__(
138141 f' to be greater than 2, got { radixes = } .' ,
139142 )
140143
144+ if level_maps is None :
145+ level_maps = [list (range (levels )) for levels in gate .radixes ]
146+
141147 if not is_sequence (level_maps ):
142148 raise TypeError (
143149 'Expected level_maps to be a sequence of integers or a '
@@ -193,7 +199,7 @@ def __init__(
193199 )
194200
195201 self .gate = gate
196- self .level_maps = [ list (lmap ) for lmap in level_maps ]
202+ self .level_maps = tuple ([ tuple ( list (lmap )) for lmap in level_maps ])
197203 self ._num_qudits = gate ._num_qudits
198204 self ._name = 'Embedded(%s)' % self .gate .name # TODO: include radixes and level maps # noqa: E501
199205 self ._num_params = self .gate ._num_params
0 commit comments