repo stringlengths 7 54 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 20 28.4k | docstring stringlengths 1 46.3k | docstring_tokens listlengths 1 1.66k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 1
value | summary stringlengths 4 350 | obf_code stringlengths 7.85k 764k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
quantumlib/Cirq | cirq/circuits/_block_diagram_drawer.py | BlockDiagramDrawer.mutable_block | def mutable_block(self, x: int, y: int) -> Block:
"""Returns the block at (x, y) so it can be edited."""
if x < 0 or y < 0:
raise IndexError('x < 0 or y < 0')
return self._blocks[(x, y)] | python | def mutable_block(self, x: int, y: int) -> Block:
"""Returns the block at (x, y) so it can be edited."""
if x < 0 or y < 0:
raise IndexError('x < 0 or y < 0')
return self._blocks[(x, y)] | [
"def",
"mutable_block",
"(",
"self",
",",
"x",
":",
"int",
",",
"y",
":",
"int",
")",
"->",
"Block",
":",
"if",
"x",
"<",
"0",
"or",
"y",
"<",
"0",
":",
"raise",
"IndexError",
"(",
"'x < 0 or y < 0'",
")",
"return",
"self",
".",
"_blocks",
"[",
"... | Returns the block at (x, y) so it can be edited. | [
"Returns",
"the",
"block",
"at",
"(",
"x",
"y",
")",
"so",
"it",
"can",
"be",
"edited",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/circuits/_block_diagram_drawer.py#L173-L177 | train | Returns the mutable block at the given position. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/circuits/_block_diagram_drawer.py | BlockDiagramDrawer.set_col_min_width | def set_col_min_width(self, x: int, min_width: int):
"""Sets a minimum width for blocks in the column with coordinate x."""
if x < 0:
raise IndexError('x < 0')
self._min_widths[x] = min_width | python | def set_col_min_width(self, x: int, min_width: int):
"""Sets a minimum width for blocks in the column with coordinate x."""
if x < 0:
raise IndexError('x < 0')
self._min_widths[x] = min_width | [
"def",
"set_col_min_width",
"(",
"self",
",",
"x",
":",
"int",
",",
"min_width",
":",
"int",
")",
":",
"if",
"x",
"<",
"0",
":",
"raise",
"IndexError",
"(",
"'x < 0'",
")",
"self",
".",
"_min_widths",
"[",
"x",
"]",
"=",
"min_width"
] | Sets a minimum width for blocks in the column with coordinate x. | [
"Sets",
"a",
"minimum",
"width",
"for",
"blocks",
"in",
"the",
"column",
"with",
"coordinate",
"x",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/circuits/_block_diagram_drawer.py#L179-L183 | train | Sets a minimum width for blocks in the column with coordinate x. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/circuits/_block_diagram_drawer.py | BlockDiagramDrawer.set_row_min_height | def set_row_min_height(self, y: int, min_height: int):
"""Sets a minimum height for blocks in the row with coordinate y."""
if y < 0:
raise IndexError('y < 0')
self._min_heights[y] = min_height | python | def set_row_min_height(self, y: int, min_height: int):
"""Sets a minimum height for blocks in the row with coordinate y."""
if y < 0:
raise IndexError('y < 0')
self._min_heights[y] = min_height | [
"def",
"set_row_min_height",
"(",
"self",
",",
"y",
":",
"int",
",",
"min_height",
":",
"int",
")",
":",
"if",
"y",
"<",
"0",
":",
"raise",
"IndexError",
"(",
"'y < 0'",
")",
"self",
".",
"_min_heights",
"[",
"y",
"]",
"=",
"min_height"
] | Sets a minimum height for blocks in the row with coordinate y. | [
"Sets",
"a",
"minimum",
"height",
"for",
"blocks",
"in",
"the",
"row",
"with",
"coordinate",
"y",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/circuits/_block_diagram_drawer.py#L185-L189 | train | Sets a minimum height for blocks in the row with coordinate y. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/circuits/_block_diagram_drawer.py | BlockDiagramDrawer.render | def render(self,
*,
block_span_x: Optional[int] = None,
block_span_y: Optional[int] = None,
min_block_width: int = 0,
min_block_height: int = 0) -> str:
"""Outputs text containing the diagram.
Args:
block_span_x: The... | python | def render(self,
*,
block_span_x: Optional[int] = None,
block_span_y: Optional[int] = None,
min_block_width: int = 0,
min_block_height: int = 0) -> str:
"""Outputs text containing the diagram.
Args:
block_span_x: The... | [
"def",
"render",
"(",
"self",
",",
"*",
",",
"block_span_x",
":",
"Optional",
"[",
"int",
"]",
"=",
"None",
",",
"block_span_y",
":",
"Optional",
"[",
"int",
"]",
"=",
"None",
",",
"min_block_width",
":",
"int",
"=",
"0",
",",
"min_block_height",
":",
... | Outputs text containing the diagram.
Args:
block_span_x: The width of the diagram in blocks. Set to None to
default to using the smallest width that would include all
accessed blocks and columns with a specified minimum width.
block_span_y: The height of ... | [
"Outputs",
"text",
"containing",
"the",
"diagram",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/circuits/_block_diagram_drawer.py#L191-L265 | train | Renders the diagram. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | examples/quantum_fourier_transform.py | main | def main():
"""Demonstrates Quantum Fourier transform.
"""
# Create circuit
qft_circuit = generate_2x2_grid_qft_circuit()
print('Circuit:')
print(qft_circuit)
# Simulate and collect final_state
simulator = cirq.Simulator()
result = simulator.simulate(qft_circuit)
print()
prin... | python | def main():
"""Demonstrates Quantum Fourier transform.
"""
# Create circuit
qft_circuit = generate_2x2_grid_qft_circuit()
print('Circuit:')
print(qft_circuit)
# Simulate and collect final_state
simulator = cirq.Simulator()
result = simulator.simulate(qft_circuit)
print()
prin... | [
"def",
"main",
"(",
")",
":",
"# Create circuit",
"qft_circuit",
"=",
"generate_2x2_grid_qft_circuit",
"(",
")",
"print",
"(",
"'Circuit:'",
")",
"print",
"(",
"qft_circuit",
")",
"# Simulate and collect final_state",
"simulator",
"=",
"cirq",
".",
"Simulator",
"(",... | Demonstrates Quantum Fourier transform. | [
"Demonstrates",
"Quantum",
"Fourier",
"transform",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/examples/quantum_fourier_transform.py#L28-L40 | train | Demonstrates Quantum Fourier transform.
| Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/ops/pauli_string_raw_types.py | PauliStringGateOperation.map_qubits | def map_qubits(self: TSelf_PauliStringGateOperation,
qubit_map: Dict[raw_types.Qid, raw_types.Qid]
) -> TSelf_PauliStringGateOperation:
"""Return an equivalent operation on new qubits with its Pauli string
mapped to new qubits.
new_pauli_string = self.pauli_... | python | def map_qubits(self: TSelf_PauliStringGateOperation,
qubit_map: Dict[raw_types.Qid, raw_types.Qid]
) -> TSelf_PauliStringGateOperation:
"""Return an equivalent operation on new qubits with its Pauli string
mapped to new qubits.
new_pauli_string = self.pauli_... | [
"def",
"map_qubits",
"(",
"self",
":",
"TSelf_PauliStringGateOperation",
",",
"qubit_map",
":",
"Dict",
"[",
"raw_types",
".",
"Qid",
",",
"raw_types",
".",
"Qid",
"]",
")",
"->",
"TSelf_PauliStringGateOperation",
":"
] | Return an equivalent operation on new qubits with its Pauli string
mapped to new qubits.
new_pauli_string = self.pauli_string.map_qubits(qubit_map) | [
"Return",
"an",
"equivalent",
"operation",
"on",
"new",
"qubits",
"with",
"its",
"Pauli",
"string",
"mapped",
"to",
"new",
"qubits",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/ops/pauli_string_raw_types.py#L42-L49 | train | Return an equivalent operation on new qubits with its Pauli string
mapped to new qubits. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | dev_tools/prepared_env.py | PreparedEnv.report_status_to_github | def report_status_to_github(self,
state: str,
description: str,
context: str,
target_url: Optional[str] = None):
"""Sets a commit status indicator on github.
If not running fr... | python | def report_status_to_github(self,
state: str,
description: str,
context: str,
target_url: Optional[str] = None):
"""Sets a commit status indicator on github.
If not running fr... | [
"def",
"report_status_to_github",
"(",
"self",
",",
"state",
":",
"str",
",",
"description",
":",
"str",
",",
"context",
":",
"str",
",",
"target_url",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
")",
":",
"if",
"state",
"not",
"in",
"[",
"'error'",... | Sets a commit status indicator on github.
If not running from a pull request (i.e. repository is None), then this
just prints to stderr.
Args:
state: The state of the status indicator.
Must be 'error', 'failure', 'pending', or 'success'.
description: A s... | [
"Sets",
"a",
"commit",
"status",
"indicator",
"on",
"github",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/dev_tools/prepared_env.py#L63-L118 | train | Report the status of the current branch to github. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | dev_tools/prepared_env.py | PreparedEnv.get_changed_files | def get_changed_files(self) -> List[str]:
"""Get the files changed on one git branch vs another.
Returns:
List[str]: File paths of changed files, relative to the git repo
root.
"""
out = shell_tools.output_of(
'git',
'diff',
... | python | def get_changed_files(self) -> List[str]:
"""Get the files changed on one git branch vs another.
Returns:
List[str]: File paths of changed files, relative to the git repo
root.
"""
out = shell_tools.output_of(
'git',
'diff',
... | [
"def",
"get_changed_files",
"(",
"self",
")",
"->",
"List",
"[",
"str",
"]",
":",
"out",
"=",
"shell_tools",
".",
"output_of",
"(",
"'git'",
",",
"'diff'",
",",
"'--name-only'",
",",
"self",
".",
"compare_commit_id",
",",
"self",
".",
"actual_commit_id",
"... | Get the files changed on one git branch vs another.
Returns:
List[str]: File paths of changed files, relative to the git repo
root. | [
"Get",
"the",
"files",
"changed",
"on",
"one",
"git",
"branch",
"vs",
"another",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/dev_tools/prepared_env.py#L120-L135 | train | Get the files changed on one git branch vs another. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/value/duration.py | Duration.create | def create(cls, duration: Union['Duration', timedelta]) -> 'Duration':
"""Creates a Duration from datetime.timedelta if necessary"""
if isinstance(duration, cls):
return duration
elif isinstance(duration, timedelta):
duration_in_picos = duration.total_seconds() * 10**12
... | python | def create(cls, duration: Union['Duration', timedelta]) -> 'Duration':
"""Creates a Duration from datetime.timedelta if necessary"""
if isinstance(duration, cls):
return duration
elif isinstance(duration, timedelta):
duration_in_picos = duration.total_seconds() * 10**12
... | [
"def",
"create",
"(",
"cls",
",",
"duration",
":",
"Union",
"[",
"'Duration'",
",",
"timedelta",
"]",
")",
"->",
"'Duration'",
":",
"if",
"isinstance",
"(",
"duration",
",",
"cls",
")",
":",
"return",
"duration",
"elif",
"isinstance",
"(",
"duration",
",... | Creates a Duration from datetime.timedelta if necessary | [
"Creates",
"a",
"Duration",
"from",
"datetime",
".",
"timedelta",
"if",
"necessary"
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/value/duration.py#L42-L51 | train | Creates a Duration from datetime. timedelta. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/google/sim/mem_manager.py | SharedMemManager._create_array | def _create_array(self, arr: np.ndarray) -> int:
"""Returns the handle of a RawArray created from the given numpy array.
Args:
arr: A numpy ndarray.
Returns:
The handle (int) of the array.
Raises:
ValueError: if arr is not a ndarray or of an unsupported d... | python | def _create_array(self, arr: np.ndarray) -> int:
"""Returns the handle of a RawArray created from the given numpy array.
Args:
arr: A numpy ndarray.
Returns:
The handle (int) of the array.
Raises:
ValueError: if arr is not a ndarray or of an unsupported d... | [
"def",
"_create_array",
"(",
"self",
",",
"arr",
":",
"np",
".",
"ndarray",
")",
"->",
"int",
":",
"if",
"not",
"isinstance",
"(",
"arr",
",",
"np",
".",
"ndarray",
")",
":",
"raise",
"ValueError",
"(",
"'Array is not a numpy ndarray.'",
")",
"try",
":",... | Returns the handle of a RawArray created from the given numpy array.
Args:
arr: A numpy ndarray.
Returns:
The handle (int) of the array.
Raises:
ValueError: if arr is not a ndarray or of an unsupported dtype. If
the array is of an unsupported type, us... | [
"Returns",
"the",
"handle",
"of",
"a",
"RawArray",
"created",
"from",
"the",
"given",
"numpy",
"array",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/google/sim/mem_manager.py#L53-L91 | train | Creates a RawArray from the given numpy array. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/google/sim/mem_manager.py | SharedMemManager._free_array | def _free_array(self, handle: int):
"""Frees the memory for the array with the given handle.
Args:
handle: The handle of the array whose memory should be freed. This
handle must come from the _create_array method.
"""
with self._lock:
if self._arrays[ha... | python | def _free_array(self, handle: int):
"""Frees the memory for the array with the given handle.
Args:
handle: The handle of the array whose memory should be freed. This
handle must come from the _create_array method.
"""
with self._lock:
if self._arrays[ha... | [
"def",
"_free_array",
"(",
"self",
",",
"handle",
":",
"int",
")",
":",
"with",
"self",
".",
"_lock",
":",
"if",
"self",
".",
"_arrays",
"[",
"handle",
"]",
"is",
"not",
"None",
":",
"self",
".",
"_arrays",
"[",
"handle",
"]",
"=",
"None",
"self",
... | Frees the memory for the array with the given handle.
Args:
handle: The handle of the array whose memory should be freed. This
handle must come from the _create_array method. | [
"Frees",
"the",
"memory",
"for",
"the",
"array",
"with",
"the",
"given",
"handle",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/google/sim/mem_manager.py#L102-L112 | train | Frees the memory for the given array with the given handle. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/google/sim/mem_manager.py | SharedMemManager._get_array | def _get_array(self, handle: int) -> np.ndarray:
"""Returns the array with the given handle.
Args:
handle: The handle of the array whose memory should be freed. This
handle must come from the _create_array method.
Returns:
The numpy ndarray with the handle given... | python | def _get_array(self, handle: int) -> np.ndarray:
"""Returns the array with the given handle.
Args:
handle: The handle of the array whose memory should be freed. This
handle must come from the _create_array method.
Returns:
The numpy ndarray with the handle given... | [
"def",
"_get_array",
"(",
"self",
",",
"handle",
":",
"int",
")",
"->",
"np",
".",
"ndarray",
":",
"tup",
"=",
"self",
".",
"_arrays",
"[",
"handle",
"]",
"assert",
"tup",
"is",
"not",
"None",
"c_arr",
",",
"shape",
"=",
"tup",
"with",
"warnings",
... | Returns the array with the given handle.
Args:
handle: The handle of the array whose memory should be freed. This
handle must come from the _create_array method.
Returns:
The numpy ndarray with the handle given from _create_array. | [
"Returns",
"the",
"array",
"with",
"the",
"given",
"handle",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/google/sim/mem_manager.py#L114-L131 | train | Returns the numpy array with the given handle. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/circuits/qasm_output.py | QasmOutput.save | def save(self, path: Union[str, bytes, int]) -> None:
"""Write QASM output to a file specified by path."""
with open(path, 'w') as f:
def write(s: str) -> None:
f.write(s)
self._write_qasm(write) | python | def save(self, path: Union[str, bytes, int]) -> None:
"""Write QASM output to a file specified by path."""
with open(path, 'w') as f:
def write(s: str) -> None:
f.write(s)
self._write_qasm(write) | [
"def",
"save",
"(",
"self",
",",
"path",
":",
"Union",
"[",
"str",
",",
"bytes",
",",
"int",
"]",
")",
"->",
"None",
":",
"with",
"open",
"(",
"path",
",",
"'w'",
")",
"as",
"f",
":",
"def",
"write",
"(",
"s",
":",
"str",
")",
"->",
"None",
... | Write QASM output to a file specified by path. | [
"Write",
"QASM",
"output",
"to",
"a",
"file",
"specified",
"by",
"path",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/circuits/qasm_output.py#L187-L192 | train | Write QASM output to a file specified by path. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/contrib/acquaintance/mutation_utils.py | rectify_acquaintance_strategy | def rectify_acquaintance_strategy(
circuit: circuits.Circuit,
acquaint_first: bool=True
) -> None:
"""Splits moments so that they contain either only acquaintance gates
or only permutation gates. Orders resulting moments so that the first one
is of the same type as the previous one.
... | python | def rectify_acquaintance_strategy(
circuit: circuits.Circuit,
acquaint_first: bool=True
) -> None:
"""Splits moments so that they contain either only acquaintance gates
or only permutation gates. Orders resulting moments so that the first one
is of the same type as the previous one.
... | [
"def",
"rectify_acquaintance_strategy",
"(",
"circuit",
":",
"circuits",
".",
"Circuit",
",",
"acquaint_first",
":",
"bool",
"=",
"True",
")",
"->",
"None",
":",
"if",
"not",
"is_acquaintance_strategy",
"(",
"circuit",
")",
":",
"raise",
"TypeError",
"(",
"'no... | Splits moments so that they contain either only acquaintance gates
or only permutation gates. Orders resulting moments so that the first one
is of the same type as the previous one.
Args:
circuit: The acquaintance strategy to rectify.
acquaint_first: Whether to make acquaintance moment firs... | [
"Splits",
"moments",
"so",
"that",
"they",
"contain",
"either",
"only",
"acquaintance",
"gates",
"or",
"only",
"permutation",
"gates",
".",
"Orders",
"resulting",
"moments",
"so",
"that",
"the",
"first",
"one",
"is",
"of",
"the",
"same",
"type",
"as",
"the",... | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/contrib/acquaintance/mutation_utils.py#L36-L67 | train | Rectifies the acquaintance strategy of the given circuit. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/contrib/acquaintance/mutation_utils.py | replace_acquaintance_with_swap_network | def replace_acquaintance_with_swap_network(
circuit: circuits.Circuit,
qubit_order: Sequence[ops.Qid],
acquaintance_size: Optional[int] = 0,
swap_gate: ops.Gate = ops.SWAP
) -> bool:
"""
Replace every moment containing acquaintance gates (after
rectification) with a g... | python | def replace_acquaintance_with_swap_network(
circuit: circuits.Circuit,
qubit_order: Sequence[ops.Qid],
acquaintance_size: Optional[int] = 0,
swap_gate: ops.Gate = ops.SWAP
) -> bool:
"""
Replace every moment containing acquaintance gates (after
rectification) with a g... | [
"def",
"replace_acquaintance_with_swap_network",
"(",
"circuit",
":",
"circuits",
".",
"Circuit",
",",
"qubit_order",
":",
"Sequence",
"[",
"ops",
".",
"Qid",
"]",
",",
"acquaintance_size",
":",
"Optional",
"[",
"int",
"]",
"=",
"0",
",",
"swap_gate",
":",
"... | Replace every moment containing acquaintance gates (after
rectification) with a generalized swap network, with the partition
given by the acquaintance gates in that moment (and singletons for the
free qubits). Accounts for reversing effect of swap networks.
Args:
circuit: The acquaintance strat... | [
"Replace",
"every",
"moment",
"containing",
"acquaintance",
"gates",
"(",
"after",
"rectification",
")",
"with",
"a",
"generalized",
"swap",
"network",
"with",
"the",
"partition",
"given",
"by",
"the",
"acquaintance",
"gates",
"in",
"that",
"moment",
"(",
"and",... | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/contrib/acquaintance/mutation_utils.py#L70-L115 | train | Replaces all acquaintance gates in the given circuit with a generalized swap network. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/ion/convert_to_ion_gates.py | is_native_ion_gate | def is_native_ion_gate(gate: ops.Gate) -> bool:
"""Check if a gate is a native ion gate.
Args:
gate: Input gate.
Returns:
True if the gate is native to the ion, false otherwise.
"""
return isinstance(gate, (ops.XXPowGate,
ops.MeasurementGate,
... | python | def is_native_ion_gate(gate: ops.Gate) -> bool:
"""Check if a gate is a native ion gate.
Args:
gate: Input gate.
Returns:
True if the gate is native to the ion, false otherwise.
"""
return isinstance(gate, (ops.XXPowGate,
ops.MeasurementGate,
... | [
"def",
"is_native_ion_gate",
"(",
"gate",
":",
"ops",
".",
"Gate",
")",
"->",
"bool",
":",
"return",
"isinstance",
"(",
"gate",
",",
"(",
"ops",
".",
"XXPowGate",
",",
"ops",
".",
"MeasurementGate",
",",
"ops",
".",
"XPowGate",
",",
"ops",
".",
"YPowGa... | Check if a gate is a native ion gate.
Args:
gate: Input gate.
Returns:
True if the gate is native to the ion, false otherwise. | [
"Check",
"if",
"a",
"gate",
"is",
"a",
"native",
"ion",
"gate",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/ion/convert_to_ion_gates.py#L90-L103 | train | Check if a gate is a native ion gate. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/ion/convert_to_ion_gates.py | ConvertToIonGates.convert_one | def convert_one(self, op: ops.Operation) -> ops.OP_TREE:
"""Convert a single (one- or two-qubit) operation
into ion trap native gates
Args:
op: gate operation to be converted
Returns:
the desired operation implemented with ion trap gates
"""
# K... | python | def convert_one(self, op: ops.Operation) -> ops.OP_TREE:
"""Convert a single (one- or two-qubit) operation
into ion trap native gates
Args:
op: gate operation to be converted
Returns:
the desired operation implemented with ion trap gates
"""
# K... | [
"def",
"convert_one",
"(",
"self",
",",
"op",
":",
"ops",
".",
"Operation",
")",
"->",
"ops",
".",
"OP_TREE",
":",
"# Known gate name",
"if",
"not",
"isinstance",
"(",
"op",
",",
"ops",
".",
"GateOperation",
")",
":",
"raise",
"TypeError",
"(",
"\"{!r} i... | Convert a single (one- or two-qubit) operation
into ion trap native gates
Args:
op: gate operation to be converted
Returns:
the desired operation implemented with ion trap gates | [
"Convert",
"a",
"single",
"(",
"one",
"-",
"or",
"two",
"-",
"qubit",
")",
"operation"
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/ion/convert_to_ion_gates.py#L34-L79 | train | Convert a single operation into an ion trap native gates. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/linalg/diagonalize.py | diagonalize_real_symmetric_matrix | def diagonalize_real_symmetric_matrix(
matrix: np.ndarray,
*,
rtol: float = 1e-5,
atol: float = 1e-8) -> np.ndarray:
"""Returns an orthogonal matrix that diagonalizes the given matrix.
Args:
matrix: A real symmetric matrix to diagonalize.
rtol: float = 1e-5,
... | python | def diagonalize_real_symmetric_matrix(
matrix: np.ndarray,
*,
rtol: float = 1e-5,
atol: float = 1e-8) -> np.ndarray:
"""Returns an orthogonal matrix that diagonalizes the given matrix.
Args:
matrix: A real symmetric matrix to diagonalize.
rtol: float = 1e-5,
... | [
"def",
"diagonalize_real_symmetric_matrix",
"(",
"matrix",
":",
"np",
".",
"ndarray",
",",
"*",
",",
"rtol",
":",
"float",
"=",
"1e-5",
",",
"atol",
":",
"float",
"=",
"1e-8",
")",
"->",
"np",
".",
"ndarray",
":",
"# TODO: Determine if thresholds should be pas... | Returns an orthogonal matrix that diagonalizes the given matrix.
Args:
matrix: A real symmetric matrix to diagonalize.
rtol: float = 1e-5,
atol: float = 1e-8
Returns:
An orthogonal matrix P such that P.T @ matrix @ P is diagonal.
Raises:
ValueError: Matrix isn't re... | [
"Returns",
"an",
"orthogonal",
"matrix",
"that",
"diagonalizes",
"the",
"given",
"matrix",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/linalg/diagonalize.py#L24-L49 | train | Returns an orthogonal matrix that diagonalizes the given matrix. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/linalg/diagonalize.py | _contiguous_groups | def _contiguous_groups(
length: int,
comparator: Callable[[int, int], bool]
) -> List[Tuple[int, int]]:
"""Splits range(length) into approximate equivalence classes.
Args:
length: The length of the range to split.
comparator: Determines if two indices have approximately equal it... | python | def _contiguous_groups(
length: int,
comparator: Callable[[int, int], bool]
) -> List[Tuple[int, int]]:
"""Splits range(length) into approximate equivalence classes.
Args:
length: The length of the range to split.
comparator: Determines if two indices have approximately equal it... | [
"def",
"_contiguous_groups",
"(",
"length",
":",
"int",
",",
"comparator",
":",
"Callable",
"[",
"[",
"int",
",",
"int",
"]",
",",
"bool",
"]",
")",
"->",
"List",
"[",
"Tuple",
"[",
"int",
",",
"int",
"]",
"]",
":",
"result",
"=",
"[",
"]",
"star... | Splits range(length) into approximate equivalence classes.
Args:
length: The length of the range to split.
comparator: Determines if two indices have approximately equal items.
Returns:
A list of (inclusive_start, exclusive_end) range endpoints. Each
corresponds to a run of app... | [
"Splits",
"range",
"(",
"length",
")",
"into",
"approximate",
"equivalence",
"classes",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/linalg/diagonalize.py#L52-L74 | train | Splits a range into approximate equivalence classes. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/linalg/diagonalize.py | diagonalize_real_symmetric_and_sorted_diagonal_matrices | def diagonalize_real_symmetric_and_sorted_diagonal_matrices(
symmetric_matrix: np.ndarray,
diagonal_matrix: np.ndarray,
*,
rtol: float = 1e-5,
atol: float = 1e-8,
check_preconditions: bool = True) -> np.ndarray:
"""Returns an orthogonal matrix that diagonalizes both g... | python | def diagonalize_real_symmetric_and_sorted_diagonal_matrices(
symmetric_matrix: np.ndarray,
diagonal_matrix: np.ndarray,
*,
rtol: float = 1e-5,
atol: float = 1e-8,
check_preconditions: bool = True) -> np.ndarray:
"""Returns an orthogonal matrix that diagonalizes both g... | [
"def",
"diagonalize_real_symmetric_and_sorted_diagonal_matrices",
"(",
"symmetric_matrix",
":",
"np",
".",
"ndarray",
",",
"diagonal_matrix",
":",
"np",
".",
"ndarray",
",",
"*",
",",
"rtol",
":",
"float",
"=",
"1e-5",
",",
"atol",
":",
"float",
"=",
"1e-8",
"... | Returns an orthogonal matrix that diagonalizes both given matrices.
The given matrices must commute.
Guarantees that the sorted diagonal matrix is not permuted by the
diagonalization (except for nearly-equal values).
Args:
symmetric_matrix: A real symmetric matrix.
diagonal_matrix: A r... | [
"Returns",
"an",
"orthogonal",
"matrix",
"that",
"diagonalizes",
"both",
"given",
"matrices",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/linalg/diagonalize.py#L77-L142 | train | Returns an orthogonal matrix that diagonalizes both given matrices. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/linalg/diagonalize.py | bidiagonalize_real_matrix_pair_with_symmetric_products | def bidiagonalize_real_matrix_pair_with_symmetric_products(
mat1: np.ndarray,
mat2: np.ndarray,
*,
rtol: float = 1e-5,
atol: float = 1e-8,
check_preconditions: bool = True) -> Tuple[np.ndarray, np.ndarray]:
"""Finds orthogonal matrices that diagonalize both mat1 and m... | python | def bidiagonalize_real_matrix_pair_with_symmetric_products(
mat1: np.ndarray,
mat2: np.ndarray,
*,
rtol: float = 1e-5,
atol: float = 1e-8,
check_preconditions: bool = True) -> Tuple[np.ndarray, np.ndarray]:
"""Finds orthogonal matrices that diagonalize both mat1 and m... | [
"def",
"bidiagonalize_real_matrix_pair_with_symmetric_products",
"(",
"mat1",
":",
"np",
".",
"ndarray",
",",
"mat2",
":",
"np",
".",
"ndarray",
",",
"*",
",",
"rtol",
":",
"float",
"=",
"1e-5",
",",
"atol",
":",
"float",
"=",
"1e-8",
",",
"check_preconditio... | Finds orthogonal matrices that diagonalize both mat1 and mat2.
Requires mat1 and mat2 to be real.
Requires mat1.T @ mat2 to be symmetric.
Requires mat1 @ mat2.T to be symmetric.
Args:
mat1: One of the real matrices.
mat2: The other real matrix.
rtol: Relative numeric error thre... | [
"Finds",
"orthogonal",
"matrices",
"that",
"diagonalize",
"both",
"mat1",
"and",
"mat2",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/linalg/diagonalize.py#L153-L230 | train | This function returns the orthogonalized matrix that diagonalize both mat1 and mat2 and returns the first orthogonal matrix that is symmetric. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/linalg/diagonalize.py | bidiagonalize_unitary_with_special_orthogonals | def bidiagonalize_unitary_with_special_orthogonals(
mat: np.ndarray,
*,
rtol: float = 1e-5,
atol: float = 1e-8,
check_preconditions: bool = True
) -> Tuple[np.ndarray, np.array, np.ndarray]:
"""Finds orthogonal matrices L, R such that L @ matrix @ R is diagonal.
Args:
... | python | def bidiagonalize_unitary_with_special_orthogonals(
mat: np.ndarray,
*,
rtol: float = 1e-5,
atol: float = 1e-8,
check_preconditions: bool = True
) -> Tuple[np.ndarray, np.array, np.ndarray]:
"""Finds orthogonal matrices L, R such that L @ matrix @ R is diagonal.
Args:
... | [
"def",
"bidiagonalize_unitary_with_special_orthogonals",
"(",
"mat",
":",
"np",
".",
"ndarray",
",",
"*",
",",
"rtol",
":",
"float",
"=",
"1e-5",
",",
"atol",
":",
"float",
"=",
"1e-8",
",",
"check_preconditions",
":",
"bool",
"=",
"True",
")",
"->",
"Tupl... | Finds orthogonal matrices L, R such that L @ matrix @ R is diagonal.
Args:
mat: A unitary matrix.
rtol: Relative numeric error threshold.
atol: Absolute numeric error threshold.
check_preconditions: If set, verifies that the input is a unitary matrix
(to the given tolera... | [
"Finds",
"orthogonal",
"matrices",
"L",
"R",
"such",
"that",
"L",
"@",
"matrix",
"@",
"R",
"is",
"diagonal",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/linalg/diagonalize.py#L233-L278 | train | This function uses bidiagonalization to find orthogonal matrices L and R. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/ops/common_channels.py | asymmetric_depolarize | def asymmetric_depolarize(
p_x: float, p_y: float, p_z: float
) -> AsymmetricDepolarizingChannel:
r"""Returns a AsymmetricDepolarizingChannel with given parameter.
This channel evolves a density matrix via
$$
\rho \rightarrow (1 - p_x - p_y - p_z) \rho
+ p_x X \rho X + p_y ... | python | def asymmetric_depolarize(
p_x: float, p_y: float, p_z: float
) -> AsymmetricDepolarizingChannel:
r"""Returns a AsymmetricDepolarizingChannel with given parameter.
This channel evolves a density matrix via
$$
\rho \rightarrow (1 - p_x - p_y - p_z) \rho
+ p_x X \rho X + p_y ... | [
"def",
"asymmetric_depolarize",
"(",
"p_x",
":",
"float",
",",
"p_y",
":",
"float",
",",
"p_z",
":",
"float",
")",
"->",
"AsymmetricDepolarizingChannel",
":",
"return",
"AsymmetricDepolarizingChannel",
"(",
"p_x",
",",
"p_y",
",",
"p_z",
")"
] | r"""Returns a AsymmetricDepolarizingChannel with given parameter.
This channel evolves a density matrix via
$$
\rho \rightarrow (1 - p_x - p_y - p_z) \rho
+ p_x X \rho X + p_y Y \rho Y + p_z Z \rho Z
$$
Args:
p_x: The probability that a Pauli X and no other gat... | [
"r",
"Returns",
"a",
"AsymmetricDepolarizingChannel",
"with",
"given",
"parameter",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/ops/common_channels.py#L90-L110 | train | r Returns an AsymmetricDepolarizingChannel with given parameter. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/ops/common_channels.py | phase_flip | def phase_flip(
p: Optional[float] = None
) -> Union[common_gates.ZPowGate, PhaseFlipChannel]:
r"""
Returns a PhaseFlipChannel that flips a qubit's phase with probability p
if p is None, return a guaranteed phase flip in the form of a Z operation.
This channel evolves a density matrix via:
... | python | def phase_flip(
p: Optional[float] = None
) -> Union[common_gates.ZPowGate, PhaseFlipChannel]:
r"""
Returns a PhaseFlipChannel that flips a qubit's phase with probability p
if p is None, return a guaranteed phase flip in the form of a Z operation.
This channel evolves a density matrix via:
... | [
"def",
"phase_flip",
"(",
"p",
":",
"Optional",
"[",
"float",
"]",
"=",
"None",
")",
"->",
"Union",
"[",
"common_gates",
".",
"ZPowGate",
",",
"PhaseFlipChannel",
"]",
":",
"if",
"p",
"is",
"None",
":",
"return",
"_phase_flip_Z",
"(",
")",
"return",
"_... | r"""
Returns a PhaseFlipChannel that flips a qubit's phase with probability p
if p is None, return a guaranteed phase flip in the form of a Z operation.
This channel evolves a density matrix via:
$$
\rho \rightarrow M_0 \rho M_0^\dagger + M_1 \rho M_1^\dagger
$$
With:
... | [
"r",
"Returns",
"a",
"PhaseFlipChannel",
"that",
"flips",
"a",
"qubit",
"s",
"phase",
"with",
"probability",
"p",
"if",
"p",
"is",
"None",
"return",
"a",
"guaranteed",
"phase",
"flip",
"in",
"the",
"form",
"of",
"a",
"Z",
"operation",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/ops/common_channels.py#L652-L690 | train | r Returns a PhaseFlipChannel that flips a qubit s phase with probability p. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/ops/common_channels.py | bit_flip | def bit_flip(
p: Optional[float] = None
) -> Union[common_gates.XPowGate, BitFlipChannel]:
r"""
Construct a BitFlipChannel that flips a qubit state
with probability of a flip given by p. If p is None, return
a guaranteed flip in the form of an X operation.
This channel evolves a density matrix ... | python | def bit_flip(
p: Optional[float] = None
) -> Union[common_gates.XPowGate, BitFlipChannel]:
r"""
Construct a BitFlipChannel that flips a qubit state
with probability of a flip given by p. If p is None, return
a guaranteed flip in the form of an X operation.
This channel evolves a density matrix ... | [
"def",
"bit_flip",
"(",
"p",
":",
"Optional",
"[",
"float",
"]",
"=",
"None",
")",
"->",
"Union",
"[",
"common_gates",
".",
"XPowGate",
",",
"BitFlipChannel",
"]",
":",
"if",
"p",
"is",
"None",
":",
"return",
"pauli_gates",
".",
"X",
"return",
"_bit_fl... | r"""
Construct a BitFlipChannel that flips a qubit state
with probability of a flip given by p. If p is None, return
a guaranteed flip in the form of an X operation.
This channel evolves a density matrix via
$$
\rho \rightarrow M_0 \rho M_0^\dagger + M_1 \rho M_1^\dagger
$$
... | [
"r",
"Construct",
"a",
"BitFlipChannel",
"that",
"flips",
"a",
"qubit",
"state",
"with",
"probability",
"of",
"a",
"flip",
"given",
"by",
"p",
".",
"If",
"p",
"is",
"None",
"return",
"a",
"guaranteed",
"flip",
"in",
"the",
"form",
"of",
"an",
"X",
"ope... | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/ops/common_channels.py#L792-L831 | train | r Returns a BitFlipChannel that flips a qubit state
with probability of a bit flip given by p. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/schedules/schedule.py | Schedule.query | def query(
self,
*, # Forces keyword args.
time: Timestamp,
duration: Union[Duration, timedelta] = Duration(),
qubits: Iterable[Qid] = None,
include_query_end_time=False,
include_op_end_times=False) -> List[ScheduledOperation]:
... | python | def query(
self,
*, # Forces keyword args.
time: Timestamp,
duration: Union[Duration, timedelta] = Duration(),
qubits: Iterable[Qid] = None,
include_query_end_time=False,
include_op_end_times=False) -> List[ScheduledOperation]:
... | [
"def",
"query",
"(",
"self",
",",
"*",
",",
"# Forces keyword args.",
"time",
":",
"Timestamp",
",",
"duration",
":",
"Union",
"[",
"Duration",
",",
"timedelta",
"]",
"=",
"Duration",
"(",
")",
",",
"qubits",
":",
"Iterable",
"[",
"Qid",
"]",
"=",
"Non... | Finds operations by time and qubit.
Args:
time: Operations must end after this time to be returned.
duration: Operations must start by time+duration to be
returned.
qubits: If specified, only operations touching one of the included
qubits will... | [
"Finds",
"operations",
"by",
"time",
"and",
"qubit",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/schedules/schedule.py#L75-L120 | train | Query the scheduled operations by time and qubit. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/schedules/schedule.py | Schedule.operations_happening_at_same_time_as | def operations_happening_at_same_time_as(
self, scheduled_operation: ScheduledOperation
) -> List[ScheduledOperation]:
"""Finds operations happening at the same time as the given operation.
Args:
scheduled_operation: The operation specifying the time to query.
Returns:
... | python | def operations_happening_at_same_time_as(
self, scheduled_operation: ScheduledOperation
) -> List[ScheduledOperation]:
"""Finds operations happening at the same time as the given operation.
Args:
scheduled_operation: The operation specifying the time to query.
Returns:
... | [
"def",
"operations_happening_at_same_time_as",
"(",
"self",
",",
"scheduled_operation",
":",
"ScheduledOperation",
")",
"->",
"List",
"[",
"ScheduledOperation",
"]",
":",
"overlaps",
"=",
"self",
".",
"query",
"(",
"time",
"=",
"scheduled_operation",
".",
"time",
... | Finds operations happening at the same time as the given operation.
Args:
scheduled_operation: The operation specifying the time to query.
Returns:
Scheduled operations that overlap with the given operation. | [
"Finds",
"operations",
"happening",
"at",
"the",
"same",
"time",
"as",
"the",
"given",
"operation",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/schedules/schedule.py#L140-L154 | train | Finds operations happening at the same time as the given operation. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/schedules/schedule.py | Schedule.include | def include(self, scheduled_operation: ScheduledOperation):
"""Adds a scheduled operation to the schedule.
Args:
scheduled_operation: The operation to add.
Raises:
ValueError:
The operation collided with something already in the schedule.
"""
... | python | def include(self, scheduled_operation: ScheduledOperation):
"""Adds a scheduled operation to the schedule.
Args:
scheduled_operation: The operation to add.
Raises:
ValueError:
The operation collided with something already in the schedule.
"""
... | [
"def",
"include",
"(",
"self",
",",
"scheduled_operation",
":",
"ScheduledOperation",
")",
":",
"collisions",
"=",
"self",
".",
"query",
"(",
"time",
"=",
"scheduled_operation",
".",
"time",
",",
"duration",
"=",
"scheduled_operation",
".",
"duration",
",",
"q... | Adds a scheduled operation to the schedule.
Args:
scheduled_operation: The operation to add.
Raises:
ValueError:
The operation collided with something already in the schedule. | [
"Adds",
"a",
"scheduled",
"operation",
"to",
"the",
"schedule",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/schedules/schedule.py#L156-L174 | train | Adds a scheduled operation to the schedule. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/schedules/schedule.py | Schedule.exclude | def exclude(self, scheduled_operation: ScheduledOperation) -> bool:
"""Omits a scheduled operation from the schedule, if present.
Args:
scheduled_operation: The operation to try to remove.
Returns:
True if the operation was present and is now removed, False if it
... | python | def exclude(self, scheduled_operation: ScheduledOperation) -> bool:
"""Omits a scheduled operation from the schedule, if present.
Args:
scheduled_operation: The operation to try to remove.
Returns:
True if the operation was present and is now removed, False if it
... | [
"def",
"exclude",
"(",
"self",
",",
"scheduled_operation",
":",
"ScheduledOperation",
")",
"->",
"bool",
":",
"try",
":",
"self",
".",
"scheduled_operations",
".",
"remove",
"(",
"scheduled_operation",
")",
"return",
"True",
"except",
"ValueError",
":",
"return"... | Omits a scheduled operation from the schedule, if present.
Args:
scheduled_operation: The operation to try to remove.
Returns:
True if the operation was present and is now removed, False if it
was already not present. | [
"Omits",
"a",
"scheduled",
"operation",
"from",
"the",
"schedule",
"if",
"present",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/schedules/schedule.py#L176-L190 | train | Removes a scheduled operation from the schedule if present. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/schedules/schedule.py | Schedule.to_circuit | def to_circuit(self) -> Circuit:
"""Convert the schedule to a circuit.
This discards most timing information from the schedule, but does place
operations that are scheduled at the same time in the same Moment.
"""
circuit = Circuit(device=self.device)
time = None # type... | python | def to_circuit(self) -> Circuit:
"""Convert the schedule to a circuit.
This discards most timing information from the schedule, but does place
operations that are scheduled at the same time in the same Moment.
"""
circuit = Circuit(device=self.device)
time = None # type... | [
"def",
"to_circuit",
"(",
"self",
")",
"->",
"Circuit",
":",
"circuit",
"=",
"Circuit",
"(",
"device",
"=",
"self",
".",
"device",
")",
"time",
"=",
"None",
"# type: Optional[Timestamp]",
"for",
"so",
"in",
"self",
".",
"scheduled_operations",
":",
"if",
"... | Convert the schedule to a circuit.
This discards most timing information from the schedule, but does place
operations that are scheduled at the same time in the same Moment. | [
"Convert",
"the",
"schedule",
"to",
"a",
"circuit",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/schedules/schedule.py#L192-L208 | train | Convert the schedule to a circuit. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/contrib/acquaintance/gates.py | acquaint_insides | def acquaint_insides(swap_gate: ops.Gate,
acquaintance_gate: ops.Operation,
qubits: Sequence[ops.Qid],
before: bool,
layers: Layers,
mapping: Dict[ops.Qid, int]
) -> None:
"""Acquaints each ... | python | def acquaint_insides(swap_gate: ops.Gate,
acquaintance_gate: ops.Operation,
qubits: Sequence[ops.Qid],
before: bool,
layers: Layers,
mapping: Dict[ops.Qid, int]
) -> None:
"""Acquaints each ... | [
"def",
"acquaint_insides",
"(",
"swap_gate",
":",
"ops",
".",
"Gate",
",",
"acquaintance_gate",
":",
"ops",
".",
"Operation",
",",
"qubits",
":",
"Sequence",
"[",
"ops",
".",
"Qid",
"]",
",",
"before",
":",
"bool",
",",
"layers",
":",
"Layers",
",",
"m... | Acquaints each of the qubits with another set specified by an
acquaintance gate.
Args:
qubits: The list of qubits of which half are individually acquainted
with another list of qubits.
layers: The layers to put gates into.
acquaintance_gate: The acquaintance gate that acquai... | [
"Acquaints",
"each",
"of",
"the",
"qubits",
"with",
"another",
"set",
"specified",
"by",
"an",
"acquaintance",
"gate",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/contrib/acquaintance/gates.py#L84-L128 | train | Acquaints each of the qubits with another set of qubits with another set of qubits. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/contrib/acquaintance/gates.py | acquaint_and_shift | def acquaint_and_shift(parts: Tuple[List[ops.Qid], List[ops.Qid]],
layers: Layers,
acquaintance_size: Optional[int],
swap_gate: ops.Gate,
mapping: Dict[ops.Qid, int]):
"""Acquaints and shifts a pair of lists of qubits. The f... | python | def acquaint_and_shift(parts: Tuple[List[ops.Qid], List[ops.Qid]],
layers: Layers,
acquaintance_size: Optional[int],
swap_gate: ops.Gate,
mapping: Dict[ops.Qid, int]):
"""Acquaints and shifts a pair of lists of qubits. The f... | [
"def",
"acquaint_and_shift",
"(",
"parts",
":",
"Tuple",
"[",
"List",
"[",
"ops",
".",
"Qid",
"]",
",",
"List",
"[",
"ops",
".",
"Qid",
"]",
"]",
",",
"layers",
":",
"Layers",
",",
"acquaintance_size",
":",
"Optional",
"[",
"int",
"]",
",",
"swap_gat... | Acquaints and shifts a pair of lists of qubits. The first part is
acquainted with every qubit individually in the second part, and vice
versa. Operations are grouped into several layers:
* prior_interstitial: The first layer of acquaintance gates.
* prior: The combination of acquaintance gates a... | [
"Acquaints",
"and",
"shifts",
"a",
"pair",
"of",
"lists",
"of",
"qubits",
".",
"The",
"first",
"part",
"is",
"acquainted",
"with",
"every",
"qubit",
"individually",
"in",
"the",
"second",
"part",
"and",
"vice",
"versa",
".",
"Operations",
"are",
"grouped",
... | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/contrib/acquaintance/gates.py#L136-L234 | train | Acquaints and shifts a pair of parts into a single set of layers. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/contrib/qcircuit/qcircuit_pdf.py | circuit_to_pdf_using_qcircuit_via_tex | def circuit_to_pdf_using_qcircuit_via_tex(circuit: circuits.Circuit,
filepath: str,
pdf_kwargs=None,
qcircuit_kwargs=None,
clean_ext=('dvi', 'ps'),
... | python | def circuit_to_pdf_using_qcircuit_via_tex(circuit: circuits.Circuit,
filepath: str,
pdf_kwargs=None,
qcircuit_kwargs=None,
clean_ext=('dvi', 'ps'),
... | [
"def",
"circuit_to_pdf_using_qcircuit_via_tex",
"(",
"circuit",
":",
"circuits",
".",
"Circuit",
",",
"filepath",
":",
"str",
",",
"pdf_kwargs",
"=",
"None",
",",
"qcircuit_kwargs",
"=",
"None",
",",
"clean_ext",
"=",
"(",
"'dvi'",
",",
"'ps'",
")",
",",
"do... | Compiles the QCircuit-based latex diagram of the given circuit.
Args:
circuit: The circuit to produce a pdf of.
filepath: Where to output the pdf.
pdf_kwargs: The arguments to pass to generate_pdf.
qcircuit_kwargs: The arguments to pass to
circuit_to_latex_using_qcircuit... | [
"Compiles",
"the",
"QCircuit",
"-",
"based",
"latex",
"diagram",
"of",
"the",
"given",
"circuit",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/contrib/qcircuit/qcircuit_pdf.py#L27-L60 | train | Compiles the QCircuit - based latex diagram of the given circuit and outputs a PDF of the result. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/linalg/decompositions.py | deconstruct_single_qubit_matrix_into_angles | def deconstruct_single_qubit_matrix_into_angles(
mat: np.ndarray) -> Tuple[float, float, float]:
"""Breaks down a 2x2 unitary into more useful ZYZ angle parameters.
Args:
mat: The 2x2 unitary matrix to break down.
Returns:
A tuple containing the amount to phase around Z, then rotat... | python | def deconstruct_single_qubit_matrix_into_angles(
mat: np.ndarray) -> Tuple[float, float, float]:
"""Breaks down a 2x2 unitary into more useful ZYZ angle parameters.
Args:
mat: The 2x2 unitary matrix to break down.
Returns:
A tuple containing the amount to phase around Z, then rotat... | [
"def",
"deconstruct_single_qubit_matrix_into_angles",
"(",
"mat",
":",
"np",
".",
"ndarray",
")",
"->",
"Tuple",
"[",
"float",
",",
"float",
",",
"float",
"]",
":",
"# Anti-cancel left-vs-right phase along top row.",
"right_phase",
"=",
"cmath",
".",
"phase",
"(",
... | Breaks down a 2x2 unitary into more useful ZYZ angle parameters.
Args:
mat: The 2x2 unitary matrix to break down.
Returns:
A tuple containing the amount to phase around Z, then rotate around Y,
then phase around Z (all in radians). | [
"Breaks",
"down",
"a",
"2x2",
"unitary",
"into",
"more",
"useful",
"ZYZ",
"angle",
"parameters",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/linalg/decompositions.py#L47-L74 | train | Breaks down a 2x2 unitary matrix into more useful ZYZ angle parameters. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/linalg/decompositions.py | _group_similar | def _group_similar(items: List[T],
comparer: Callable[[T, T], bool]) -> List[List[T]]:
"""Combines similar items into groups.
Args:
items: The list of items to group.
comparer: Determines if two items are similar.
Returns:
A list of groups of items.
"""
groups = [] # type... | python | def _group_similar(items: List[T],
comparer: Callable[[T, T], bool]) -> List[List[T]]:
"""Combines similar items into groups.
Args:
items: The list of items to group.
comparer: Determines if two items are similar.
Returns:
A list of groups of items.
"""
groups = [] # type... | [
"def",
"_group_similar",
"(",
"items",
":",
"List",
"[",
"T",
"]",
",",
"comparer",
":",
"Callable",
"[",
"[",
"T",
",",
"T",
"]",
",",
"bool",
"]",
")",
"->",
"List",
"[",
"List",
"[",
"T",
"]",
"]",
":",
"groups",
"=",
"[",
"]",
"# type: List... | Combines similar items into groups.
Args:
items: The list of items to group.
comparer: Determines if two items are similar.
Returns:
A list of groups of items. | [
"Combines",
"similar",
"items",
"into",
"groups",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/linalg/decompositions.py#L77-L98 | train | Combines similar items into groups. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/linalg/decompositions.py | _perp_eigendecompose | def _perp_eigendecompose(matrix: np.ndarray,
rtol: float = 1e-5,
atol: float = 1e-8,
) -> Tuple[np.array, List[np.ndarray]]:
"""An eigendecomposition that ensures eigenvectors are perpendicular.
numpy.linalg.eig doesn't guarantee that e... | python | def _perp_eigendecompose(matrix: np.ndarray,
rtol: float = 1e-5,
atol: float = 1e-8,
) -> Tuple[np.array, List[np.ndarray]]:
"""An eigendecomposition that ensures eigenvectors are perpendicular.
numpy.linalg.eig doesn't guarantee that e... | [
"def",
"_perp_eigendecompose",
"(",
"matrix",
":",
"np",
".",
"ndarray",
",",
"rtol",
":",
"float",
"=",
"1e-5",
",",
"atol",
":",
"float",
"=",
"1e-8",
",",
")",
"->",
"Tuple",
"[",
"np",
".",
"array",
",",
"List",
"[",
"np",
".",
"ndarray",
"]",
... | An eigendecomposition that ensures eigenvectors are perpendicular.
numpy.linalg.eig doesn't guarantee that eigenvectors from the same
eigenspace will be perpendicular. This method uses Gram-Schmidt to recover
a perpendicular set. It further checks that all eigenvectors are
perpendicular and raises an A... | [
"An",
"eigendecomposition",
"that",
"ensures",
"eigenvectors",
"are",
"perpendicular",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/linalg/decompositions.py#L101-L145 | train | Decomposes a matrix of the ith column eigenvectors into a perpendicular set of ith eigenvalues. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/linalg/decompositions.py | map_eigenvalues | def map_eigenvalues(
matrix: np.ndarray,
func: Callable[[complex], complex],
*,
rtol: float = 1e-5,
atol: float = 1e-8) -> np.ndarray:
"""Applies a function to the eigenvalues of a matrix.
Given M = sum_k a_k |v_k><v_k|, returns f(M) = sum_k f(a_k) |v_k><v_k|.
Args:... | python | def map_eigenvalues(
matrix: np.ndarray,
func: Callable[[complex], complex],
*,
rtol: float = 1e-5,
atol: float = 1e-8) -> np.ndarray:
"""Applies a function to the eigenvalues of a matrix.
Given M = sum_k a_k |v_k><v_k|, returns f(M) = sum_k f(a_k) |v_k><v_k|.
Args:... | [
"def",
"map_eigenvalues",
"(",
"matrix",
":",
"np",
".",
"ndarray",
",",
"func",
":",
"Callable",
"[",
"[",
"complex",
"]",
",",
"complex",
"]",
",",
"*",
",",
"rtol",
":",
"float",
"=",
"1e-5",
",",
"atol",
":",
"float",
"=",
"1e-8",
")",
"->",
... | Applies a function to the eigenvalues of a matrix.
Given M = sum_k a_k |v_k><v_k|, returns f(M) = sum_k f(a_k) |v_k><v_k|.
Args:
matrix: The matrix to modify with the function.
func: The function to apply to the eigenvalues of the matrix.
rtol: Relative threshold used when separating e... | [
"Applies",
"a",
"function",
"to",
"the",
"eigenvalues",
"of",
"a",
"matrix",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/linalg/decompositions.py#L148-L176 | train | Applies a function to the eigenvalues of a matrix. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/linalg/decompositions.py | kron_factor_4x4_to_2x2s | def kron_factor_4x4_to_2x2s(
matrix: np.ndarray,
) -> Tuple[complex, np.ndarray, np.ndarray]:
"""Splits a 4x4 matrix U = kron(A, B) into A, B, and a global factor.
Requires the matrix to be the kronecker product of two 2x2 unitaries.
Requires the matrix to have a non-zero determinant.
Giving an... | python | def kron_factor_4x4_to_2x2s(
matrix: np.ndarray,
) -> Tuple[complex, np.ndarray, np.ndarray]:
"""Splits a 4x4 matrix U = kron(A, B) into A, B, and a global factor.
Requires the matrix to be the kronecker product of two 2x2 unitaries.
Requires the matrix to have a non-zero determinant.
Giving an... | [
"def",
"kron_factor_4x4_to_2x2s",
"(",
"matrix",
":",
"np",
".",
"ndarray",
",",
")",
"->",
"Tuple",
"[",
"complex",
",",
"np",
".",
"ndarray",
",",
"np",
".",
"ndarray",
"]",
":",
"# Use the entry with the largest magnitude as a reference point.",
"a",
",",
"b"... | Splits a 4x4 matrix U = kron(A, B) into A, B, and a global factor.
Requires the matrix to be the kronecker product of two 2x2 unitaries.
Requires the matrix to have a non-zero determinant.
Giving an incorrect matrix will cause garbage output.
Args:
matrix: The 4x4 unitary matrix to factor.
... | [
"Splits",
"a",
"4x4",
"matrix",
"U",
"=",
"kron",
"(",
"A",
"B",
")",
"into",
"A",
"B",
"and",
"a",
"global",
"factor",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/linalg/decompositions.py#L179-L223 | train | Splits a 4x4 matrix U into A B and a pair of 2x2 unitaries. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/linalg/decompositions.py | so4_to_magic_su2s | def so4_to_magic_su2s(
mat: np.ndarray,
*,
rtol: float = 1e-5,
atol: float = 1e-8,
check_preconditions: bool = True
) -> Tuple[np.ndarray, np.ndarray]:
"""Finds 2x2 special-unitaries A, B where mat = Mag.H @ kron(A, B) @ Mag.
Mag is the magic basis matrix:
1 0 ... | python | def so4_to_magic_su2s(
mat: np.ndarray,
*,
rtol: float = 1e-5,
atol: float = 1e-8,
check_preconditions: bool = True
) -> Tuple[np.ndarray, np.ndarray]:
"""Finds 2x2 special-unitaries A, B where mat = Mag.H @ kron(A, B) @ Mag.
Mag is the magic basis matrix:
1 0 ... | [
"def",
"so4_to_magic_su2s",
"(",
"mat",
":",
"np",
".",
"ndarray",
",",
"*",
",",
"rtol",
":",
"float",
"=",
"1e-5",
",",
"atol",
":",
"float",
"=",
"1e-8",
",",
"check_preconditions",
":",
"bool",
"=",
"True",
")",
"->",
"Tuple",
"[",
"np",
".",
"... | Finds 2x2 special-unitaries A, B where mat = Mag.H @ kron(A, B) @ Mag.
Mag is the magic basis matrix:
1 0 0 i
0 i 1 0
0 i -1 0 (times sqrt(0.5) to normalize)
1 0 0 -i
Args:
mat: A real 4x4 orthogonal matrix.
rtol: Per-matrix-entry relative toleran... | [
"Finds",
"2x2",
"special",
"-",
"unitaries",
"A",
"B",
"where",
"mat",
"=",
"Mag",
".",
"H",
"@",
"kron",
"(",
"A",
"B",
")",
"@",
"Mag",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/linalg/decompositions.py#L226-L264 | train | This function converts a 4x4 orthogonal matrix to a 2x2 special - unitaries matrix. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/linalg/decompositions.py | kak_canonicalize_vector | def kak_canonicalize_vector(x: float, y: float, z: float) -> KakDecomposition:
"""Canonicalizes an XX/YY/ZZ interaction by swap/negate/shift-ing axes.
Args:
x: The strength of the XX interaction.
y: The strength of the YY interaction.
z: The strength of the ZZ interaction.
Returns:... | python | def kak_canonicalize_vector(x: float, y: float, z: float) -> KakDecomposition:
"""Canonicalizes an XX/YY/ZZ interaction by swap/negate/shift-ing axes.
Args:
x: The strength of the XX interaction.
y: The strength of the YY interaction.
z: The strength of the ZZ interaction.
Returns:... | [
"def",
"kak_canonicalize_vector",
"(",
"x",
":",
"float",
",",
"y",
":",
"float",
",",
"z",
":",
"float",
")",
"->",
"KakDecomposition",
":",
"phase",
"=",
"[",
"complex",
"(",
"1",
")",
"]",
"# Accumulated global phase.",
"left",
"=",
"[",
"np",
".",
... | Canonicalizes an XX/YY/ZZ interaction by swap/negate/shift-ing axes.
Args:
x: The strength of the XX interaction.
y: The strength of the YY interaction.
z: The strength of the ZZ interaction.
Returns:
The canonicalized decomposition, with vector coefficients (x2, y2, z2)
... | [
"Canonicalizes",
"an",
"XX",
"/",
"YY",
"/",
"ZZ",
"interaction",
"by",
"swap",
"/",
"negate",
"/",
"shift",
"-",
"ing",
"axes",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/linalg/decompositions.py#L366-L469 | train | Canonicalizes an XX Y Z interaction by swap - negation and shift - ing axes. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/linalg/decompositions.py | kak_decomposition | def kak_decomposition(
mat: np.ndarray,
rtol: float = 1e-5,
atol: float = 1e-8) -> KakDecomposition:
"""Decomposes a 2-qubit unitary into 1-qubit ops and XX/YY/ZZ interactions.
Args:
mat: The 4x4 unitary matrix to decompose.
rtol: Per-matrix-entry relative tolerance on e... | python | def kak_decomposition(
mat: np.ndarray,
rtol: float = 1e-5,
atol: float = 1e-8) -> KakDecomposition:
"""Decomposes a 2-qubit unitary into 1-qubit ops and XX/YY/ZZ interactions.
Args:
mat: The 4x4 unitary matrix to decompose.
rtol: Per-matrix-entry relative tolerance on e... | [
"def",
"kak_decomposition",
"(",
"mat",
":",
"np",
".",
"ndarray",
",",
"rtol",
":",
"float",
"=",
"1e-5",
",",
"atol",
":",
"float",
"=",
"1e-8",
")",
"->",
"KakDecomposition",
":",
"magic",
"=",
"np",
".",
"array",
"(",
"[",
"[",
"1",
",",
"0",
... | Decomposes a 2-qubit unitary into 1-qubit ops and XX/YY/ZZ interactions.
Args:
mat: The 4x4 unitary matrix to decompose.
rtol: Per-matrix-entry relative tolerance on equality.
atol: Per-matrix-entry absolute tolerance on equality.
Returns:
A `cirq.KakDecomposition` canonicalize... | [
"Decomposes",
"a",
"2",
"-",
"qubit",
"unitary",
"into",
"1",
"-",
"qubit",
"ops",
"and",
"XX",
"/",
"YY",
"/",
"ZZ",
"interactions",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/linalg/decompositions.py#L472-L537 | train | Decomposes a 2 - qubit unitary into 1 - qubit ops and XX YZ interactions. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/contrib/acquaintance/permutation.py | update_mapping | def update_mapping(mapping: Dict[ops.Qid, LogicalIndex],
operations: ops.OP_TREE
) -> None:
"""Updates a mapping (in place) from qubits to logical indices according to
a set of permutation gates. Any gates other than permutation gates are
ignored.
Args:
map... | python | def update_mapping(mapping: Dict[ops.Qid, LogicalIndex],
operations: ops.OP_TREE
) -> None:
"""Updates a mapping (in place) from qubits to logical indices according to
a set of permutation gates. Any gates other than permutation gates are
ignored.
Args:
map... | [
"def",
"update_mapping",
"(",
"mapping",
":",
"Dict",
"[",
"ops",
".",
"Qid",
",",
"LogicalIndex",
"]",
",",
"operations",
":",
"ops",
".",
"OP_TREE",
")",
"->",
"None",
":",
"for",
"op",
"in",
"ops",
".",
"flatten_op_tree",
"(",
"operations",
")",
":"... | Updates a mapping (in place) from qubits to logical indices according to
a set of permutation gates. Any gates other than permutation gates are
ignored.
Args:
mapping: The mapping to update.
operations: The operations to update according to. | [
"Updates",
"a",
"mapping",
"(",
"in",
"place",
")",
"from",
"qubits",
"to",
"logical",
"indices",
"according",
"to",
"a",
"set",
"of",
"permutation",
"gates",
".",
"Any",
"gates",
"other",
"than",
"permutation",
"gates",
"are",
"ignored",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/contrib/acquaintance/permutation.py#L162-L176 | train | Updates a mapping from qubits to logical indices according to the given operations. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/contrib/acquaintance/permutation.py | PermutationGate.update_mapping | def update_mapping(self, mapping: Dict[ops.Qid, LogicalIndex],
keys: Sequence[ops.Qid]
) -> None:
"""Updates a mapping (in place) from qubits to logical indices.
Args:
mapping: The mapping to update.
keys: The qubits acted on by the ... | python | def update_mapping(self, mapping: Dict[ops.Qid, LogicalIndex],
keys: Sequence[ops.Qid]
) -> None:
"""Updates a mapping (in place) from qubits to logical indices.
Args:
mapping: The mapping to update.
keys: The qubits acted on by the ... | [
"def",
"update_mapping",
"(",
"self",
",",
"mapping",
":",
"Dict",
"[",
"ops",
".",
"Qid",
",",
"LogicalIndex",
"]",
",",
"keys",
":",
"Sequence",
"[",
"ops",
".",
"Qid",
"]",
")",
"->",
"None",
":",
"permutation",
"=",
"self",
".",
"permutation",
"(... | Updates a mapping (in place) from qubits to logical indices.
Args:
mapping: The mapping to update.
keys: The qubits acted on by the gate. | [
"Updates",
"a",
"mapping",
"(",
"in",
"place",
")",
"from",
"qubits",
"to",
"logical",
"indices",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/contrib/acquaintance/permutation.py#L50-L63 | train | Updates a mapping from qubits to logical indices. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/circuits/text_diagram_drawer.py | TextDiagramDrawer.write | def write(self,
x: int,
y: int,
text: str,
transposed_text: 'Optional[str]' = None):
"""Adds text to the given location.
Args:
x: The column in which to write the text.
y: The row in which to write the text.
tex... | python | def write(self,
x: int,
y: int,
text: str,
transposed_text: 'Optional[str]' = None):
"""Adds text to the given location.
Args:
x: The column in which to write the text.
y: The row in which to write the text.
tex... | [
"def",
"write",
"(",
"self",
",",
"x",
":",
"int",
",",
"y",
":",
"int",
",",
"text",
":",
"str",
",",
"transposed_text",
":",
"'Optional[str]'",
"=",
"None",
")",
":",
"entry",
"=",
"self",
".",
"entries",
".",
"get",
"(",
"(",
"x",
",",
"y",
... | Adds text to the given location.
Args:
x: The column in which to write the text.
y: The row in which to write the text.
text: The text to write at location (x, y).
transposed_text: Optional text to write instead, if the text
diagram is transposed. | [
"Adds",
"text",
"to",
"the",
"given",
"location",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/circuits/text_diagram_drawer.py#L69-L87 | train | Adds text to the given location. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/circuits/text_diagram_drawer.py | TextDiagramDrawer.content_present | def content_present(self, x: int, y: int) -> bool:
"""Determines if a line or printed text is at the given location."""
# Text?
if (x, y) in self.entries:
return True
# Vertical line?
if any(v.x == x and v.y1 < y < v.y2 for v in self.vertical_lines):
ret... | python | def content_present(self, x: int, y: int) -> bool:
"""Determines if a line or printed text is at the given location."""
# Text?
if (x, y) in self.entries:
return True
# Vertical line?
if any(v.x == x and v.y1 < y < v.y2 for v in self.vertical_lines):
ret... | [
"def",
"content_present",
"(",
"self",
",",
"x",
":",
"int",
",",
"y",
":",
"int",
")",
"->",
"bool",
":",
"# Text?",
"if",
"(",
"x",
",",
"y",
")",
"in",
"self",
".",
"entries",
":",
"return",
"True",
"# Vertical line?",
"if",
"any",
"(",
"v",
"... | Determines if a line or printed text is at the given location. | [
"Determines",
"if",
"a",
"line",
"or",
"printed",
"text",
"is",
"at",
"the",
"given",
"location",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/circuits/text_diagram_drawer.py#L89-L105 | train | Determines if a line or printed text is at the given location. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/circuits/text_diagram_drawer.py | TextDiagramDrawer.grid_line | def grid_line(self, x1: int, y1: int, x2: int, y2: int,
emphasize: bool = False):
"""Adds a vertical or horizontal line from (x1, y1) to (x2, y2).
Horizontal line is selected on equality in the second coordinate and
vertical line is selected on equality in the first coordinate... | python | def grid_line(self, x1: int, y1: int, x2: int, y2: int,
emphasize: bool = False):
"""Adds a vertical or horizontal line from (x1, y1) to (x2, y2).
Horizontal line is selected on equality in the second coordinate and
vertical line is selected on equality in the first coordinate... | [
"def",
"grid_line",
"(",
"self",
",",
"x1",
":",
"int",
",",
"y1",
":",
"int",
",",
"x2",
":",
"int",
",",
"y2",
":",
"int",
",",
"emphasize",
":",
"bool",
"=",
"False",
")",
":",
"if",
"x1",
"==",
"x2",
":",
"self",
".",
"vertical_line",
"(",
... | Adds a vertical or horizontal line from (x1, y1) to (x2, y2).
Horizontal line is selected on equality in the second coordinate and
vertical line is selected on equality in the first coordinate.
Raises:
ValueError: If line is neither horizontal nor vertical. | [
"Adds",
"a",
"vertical",
"or",
"horizontal",
"line",
"from",
"(",
"x1",
"y1",
")",
"to",
"(",
"x2",
"y2",
")",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/circuits/text_diagram_drawer.py#L107-L122 | train | Adds a horizontal or vertical line from x1 y1 to x2 y2. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/circuits/text_diagram_drawer.py | TextDiagramDrawer.vertical_line | def vertical_line(self,
x: Union[int, float],
y1: Union[int, float],
y2: Union[int, float],
emphasize: bool = False
) -> None:
"""Adds a line from (x, y1) to (x, y2)."""
y1, y2 = sorted([y1, y2]... | python | def vertical_line(self,
x: Union[int, float],
y1: Union[int, float],
y2: Union[int, float],
emphasize: bool = False
) -> None:
"""Adds a line from (x, y1) to (x, y2)."""
y1, y2 = sorted([y1, y2]... | [
"def",
"vertical_line",
"(",
"self",
",",
"x",
":",
"Union",
"[",
"int",
",",
"float",
"]",
",",
"y1",
":",
"Union",
"[",
"int",
",",
"float",
"]",
",",
"y2",
":",
"Union",
"[",
"int",
",",
"float",
"]",
",",
"emphasize",
":",
"bool",
"=",
"Fal... | Adds a line from (x, y1) to (x, y2). | [
"Adds",
"a",
"line",
"from",
"(",
"x",
"y1",
")",
"to",
"(",
"x",
"y2",
")",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/circuits/text_diagram_drawer.py#L124-L132 | train | Adds a vertical line from x y1 y2 to x y2. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/circuits/text_diagram_drawer.py | TextDiagramDrawer.horizontal_line | def horizontal_line(self,
y: Union[int, float],
x1: Union[int, float],
x2: Union[int, float],
emphasize: bool = False
) -> None:
"""Adds a line from (x1, y) to (x2, y)."""
x1, x2 = sor... | python | def horizontal_line(self,
y: Union[int, float],
x1: Union[int, float],
x2: Union[int, float],
emphasize: bool = False
) -> None:
"""Adds a line from (x1, y) to (x2, y)."""
x1, x2 = sor... | [
"def",
"horizontal_line",
"(",
"self",
",",
"y",
":",
"Union",
"[",
"int",
",",
"float",
"]",
",",
"x1",
":",
"Union",
"[",
"int",
",",
"float",
"]",
",",
"x2",
":",
"Union",
"[",
"int",
",",
"float",
"]",
",",
"emphasize",
":",
"bool",
"=",
"F... | Adds a line from (x1, y) to (x2, y). | [
"Adds",
"a",
"line",
"from",
"(",
"x1",
"y",
")",
"to",
"(",
"x2",
"y",
")",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/circuits/text_diagram_drawer.py#L134-L142 | train | Adds a horizontal line to the log. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/circuits/text_diagram_drawer.py | TextDiagramDrawer.transpose | def transpose(self) -> 'TextDiagramDrawer':
"""Returns the same diagram, but mirrored across its diagonal."""
out = TextDiagramDrawer()
out.entries = {(y, x): _DiagramText(v.transposed_text, v.text)
for (x, y), v in self.entries.items()}
out.vertical_lines = [_Vert... | python | def transpose(self) -> 'TextDiagramDrawer':
"""Returns the same diagram, but mirrored across its diagonal."""
out = TextDiagramDrawer()
out.entries = {(y, x): _DiagramText(v.transposed_text, v.text)
for (x, y), v in self.entries.items()}
out.vertical_lines = [_Vert... | [
"def",
"transpose",
"(",
"self",
")",
"->",
"'TextDiagramDrawer'",
":",
"out",
"=",
"TextDiagramDrawer",
"(",
")",
"out",
".",
"entries",
"=",
"{",
"(",
"y",
",",
"x",
")",
":",
"_DiagramText",
"(",
"v",
".",
"transposed_text",
",",
"v",
".",
"text",
... | Returns the same diagram, but mirrored across its diagonal. | [
"Returns",
"the",
"same",
"diagram",
"but",
"mirrored",
"across",
"its",
"diagonal",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/circuits/text_diagram_drawer.py#L144-L155 | train | Returns the same diagram but mirrored across its diagonal. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/circuits/text_diagram_drawer.py | TextDiagramDrawer.width | def width(self) -> int:
"""Determines how many entry columns are in the diagram."""
max_x = -1.0
for x, _ in self.entries.keys():
max_x = max(max_x, x)
for v in self.vertical_lines:
max_x = max(max_x, v.x)
for h in self.horizontal_lines:
max_x ... | python | def width(self) -> int:
"""Determines how many entry columns are in the diagram."""
max_x = -1.0
for x, _ in self.entries.keys():
max_x = max(max_x, x)
for v in self.vertical_lines:
max_x = max(max_x, v.x)
for h in self.horizontal_lines:
max_x ... | [
"def",
"width",
"(",
"self",
")",
"->",
"int",
":",
"max_x",
"=",
"-",
"1.0",
"for",
"x",
",",
"_",
"in",
"self",
".",
"entries",
".",
"keys",
"(",
")",
":",
"max_x",
"=",
"max",
"(",
"max_x",
",",
"x",
")",
"for",
"v",
"in",
"self",
".",
"... | Determines how many entry columns are in the diagram. | [
"Determines",
"how",
"many",
"entry",
"columns",
"are",
"in",
"the",
"diagram",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/circuits/text_diagram_drawer.py#L157-L166 | train | Determines how many entry columns are in the diagram. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/circuits/text_diagram_drawer.py | TextDiagramDrawer.height | def height(self) -> int:
"""Determines how many entry rows are in the diagram."""
max_y = -1.0
for _, y in self.entries.keys():
max_y = max(max_y, y)
for h in self.horizontal_lines:
max_y = max(max_y, h.y)
for v in self.vertical_lines:
max_y = ... | python | def height(self) -> int:
"""Determines how many entry rows are in the diagram."""
max_y = -1.0
for _, y in self.entries.keys():
max_y = max(max_y, y)
for h in self.horizontal_lines:
max_y = max(max_y, h.y)
for v in self.vertical_lines:
max_y = ... | [
"def",
"height",
"(",
"self",
")",
"->",
"int",
":",
"max_y",
"=",
"-",
"1.0",
"for",
"_",
",",
"y",
"in",
"self",
".",
"entries",
".",
"keys",
"(",
")",
":",
"max_y",
"=",
"max",
"(",
"max_y",
",",
"y",
")",
"for",
"h",
"in",
"self",
".",
... | Determines how many entry rows are in the diagram. | [
"Determines",
"how",
"many",
"entry",
"rows",
"are",
"in",
"the",
"diagram",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/circuits/text_diagram_drawer.py#L168-L177 | train | Determines how many entry rows are in the diagram. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/circuits/text_diagram_drawer.py | TextDiagramDrawer.force_horizontal_padding_after | def force_horizontal_padding_after(
self, index: int, padding: Union[int, float]) -> None:
"""Change the padding after the given column."""
self.horizontal_padding[index] = padding | python | def force_horizontal_padding_after(
self, index: int, padding: Union[int, float]) -> None:
"""Change the padding after the given column."""
self.horizontal_padding[index] = padding | [
"def",
"force_horizontal_padding_after",
"(",
"self",
",",
"index",
":",
"int",
",",
"padding",
":",
"Union",
"[",
"int",
",",
"float",
"]",
")",
"->",
"None",
":",
"self",
".",
"horizontal_padding",
"[",
"index",
"]",
"=",
"padding"
] | Change the padding after the given column. | [
"Change",
"the",
"padding",
"after",
"the",
"given",
"column",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/circuits/text_diagram_drawer.py#L179-L182 | train | Change the padding after the given column. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/circuits/text_diagram_drawer.py | TextDiagramDrawer.force_vertical_padding_after | def force_vertical_padding_after(
self, index: int, padding: Union[int, float]) -> None:
"""Change the padding after the given row."""
self.vertical_padding[index] = padding | python | def force_vertical_padding_after(
self, index: int, padding: Union[int, float]) -> None:
"""Change the padding after the given row."""
self.vertical_padding[index] = padding | [
"def",
"force_vertical_padding_after",
"(",
"self",
",",
"index",
":",
"int",
",",
"padding",
":",
"Union",
"[",
"int",
",",
"float",
"]",
")",
"->",
"None",
":",
"self",
".",
"vertical_padding",
"[",
"index",
"]",
"=",
"padding"
] | Change the padding after the given row. | [
"Change",
"the",
"padding",
"after",
"the",
"given",
"row",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/circuits/text_diagram_drawer.py#L184-L187 | train | Change the padding after the given row. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/circuits/text_diagram_drawer.py | TextDiagramDrawer._transform_coordinates | def _transform_coordinates(
self,
func: Callable[[Union[int, float], Union[int, float]],
Tuple[Union[int, float], Union[int, float]]]
) -> None:
"""Helper method to transformer either row or column coordinates."""
def func_x(x: Union[int, float]) -... | python | def _transform_coordinates(
self,
func: Callable[[Union[int, float], Union[int, float]],
Tuple[Union[int, float], Union[int, float]]]
) -> None:
"""Helper method to transformer either row or column coordinates."""
def func_x(x: Union[int, float]) -... | [
"def",
"_transform_coordinates",
"(",
"self",
",",
"func",
":",
"Callable",
"[",
"[",
"Union",
"[",
"int",
",",
"float",
"]",
",",
"Union",
"[",
"int",
",",
"float",
"]",
"]",
",",
"Tuple",
"[",
"Union",
"[",
"int",
",",
"float",
"]",
",",
"Union",... | Helper method to transformer either row or column coordinates. | [
"Helper",
"method",
"to",
"transformer",
"either",
"row",
"or",
"column",
"coordinates",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/circuits/text_diagram_drawer.py#L189-L219 | train | Helper method to transform row or column coordinates. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/circuits/text_diagram_drawer.py | TextDiagramDrawer.insert_empty_columns | def insert_empty_columns(self, x: int, amount: int = 1) -> None:
"""Insert a number of columns after the given column."""
def transform_columns(
column: Union[int, float],
row: Union[int, float]
) -> Tuple[Union[int, float], Union[int, float]]:
return ... | python | def insert_empty_columns(self, x: int, amount: int = 1) -> None:
"""Insert a number of columns after the given column."""
def transform_columns(
column: Union[int, float],
row: Union[int, float]
) -> Tuple[Union[int, float], Union[int, float]]:
return ... | [
"def",
"insert_empty_columns",
"(",
"self",
",",
"x",
":",
"int",
",",
"amount",
":",
"int",
"=",
"1",
")",
"->",
"None",
":",
"def",
"transform_columns",
"(",
"column",
":",
"Union",
"[",
"int",
",",
"float",
"]",
",",
"row",
":",
"Union",
"[",
"i... | Insert a number of columns after the given column. | [
"Insert",
"a",
"number",
"of",
"columns",
"after",
"the",
"given",
"column",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/circuits/text_diagram_drawer.py#L221-L228 | train | Insert a number of columns after the given column. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/circuits/text_diagram_drawer.py | TextDiagramDrawer.insert_empty_rows | def insert_empty_rows(self, y: int, amount: int = 1) -> None:
"""Insert a number of rows after the given row."""
def transform_rows(
column: Union[int, float],
row: Union[int, float]
) -> Tuple[Union[int, float], Union[int, float]]:
return column, row ... | python | def insert_empty_rows(self, y: int, amount: int = 1) -> None:
"""Insert a number of rows after the given row."""
def transform_rows(
column: Union[int, float],
row: Union[int, float]
) -> Tuple[Union[int, float], Union[int, float]]:
return column, row ... | [
"def",
"insert_empty_rows",
"(",
"self",
",",
"y",
":",
"int",
",",
"amount",
":",
"int",
"=",
"1",
")",
"->",
"None",
":",
"def",
"transform_rows",
"(",
"column",
":",
"Union",
"[",
"int",
",",
"float",
"]",
",",
"row",
":",
"Union",
"[",
"int",
... | Insert a number of rows after the given row. | [
"Insert",
"a",
"number",
"of",
"rows",
"after",
"the",
"given",
"row",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/circuits/text_diagram_drawer.py#L230-L237 | train | Insert a number of rows after the given row. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/circuits/text_diagram_drawer.py | TextDiagramDrawer.render | def render(self,
horizontal_spacing: int = 1,
vertical_spacing: int = 1,
crossing_char: str = None,
use_unicode_characters: bool = True) -> str:
"""Outputs text containing the diagram."""
block_diagram = BlockDiagramDrawer()
w = self.... | python | def render(self,
horizontal_spacing: int = 1,
vertical_spacing: int = 1,
crossing_char: str = None,
use_unicode_characters: bool = True) -> str:
"""Outputs text containing the diagram."""
block_diagram = BlockDiagramDrawer()
w = self.... | [
"def",
"render",
"(",
"self",
",",
"horizontal_spacing",
":",
"int",
"=",
"1",
",",
"vertical_spacing",
":",
"int",
"=",
"1",
",",
"crossing_char",
":",
"str",
"=",
"None",
",",
"use_unicode_characters",
":",
"bool",
"=",
"True",
")",
"->",
"str",
":",
... | Outputs text containing the diagram. | [
"Outputs",
"text",
"containing",
"the",
"diagram",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/circuits/text_diagram_drawer.py#L239-L307 | train | Outputs text containing the diagram. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/linalg/tolerance.py | all_near_zero | def all_near_zero(a: Union[float, complex, Iterable[float], np.ndarray],
*,
atol: float = 1e-8) -> bool:
"""Checks if the tensor's elements are all near zero.
Args:
a: Tensor of elements that could all be near zero.
atol: Absolute tolerance.
"""
retur... | python | def all_near_zero(a: Union[float, complex, Iterable[float], np.ndarray],
*,
atol: float = 1e-8) -> bool:
"""Checks if the tensor's elements are all near zero.
Args:
a: Tensor of elements that could all be near zero.
atol: Absolute tolerance.
"""
retur... | [
"def",
"all_near_zero",
"(",
"a",
":",
"Union",
"[",
"float",
",",
"complex",
",",
"Iterable",
"[",
"float",
"]",
",",
"np",
".",
"ndarray",
"]",
",",
"*",
",",
"atol",
":",
"float",
"=",
"1e-8",
")",
"->",
"bool",
":",
"return",
"np",
".",
"all"... | Checks if the tensor's elements are all near zero.
Args:
a: Tensor of elements that could all be near zero.
atol: Absolute tolerance. | [
"Checks",
"if",
"the",
"tensor",
"s",
"elements",
"are",
"all",
"near",
"zero",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/linalg/tolerance.py#L22-L31 | train | Checks if the tensor s elements are all near zero. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/linalg/tolerance.py | all_near_zero_mod | def all_near_zero_mod(a: Union[float, complex, Iterable[float], np.ndarray],
period: float,
*,
atol: float = 1e-8) -> bool:
"""Checks if the tensor's elements are all near multiples of the period.
Args:
a: Tensor of elements that could a... | python | def all_near_zero_mod(a: Union[float, complex, Iterable[float], np.ndarray],
period: float,
*,
atol: float = 1e-8) -> bool:
"""Checks if the tensor's elements are all near multiples of the period.
Args:
a: Tensor of elements that could a... | [
"def",
"all_near_zero_mod",
"(",
"a",
":",
"Union",
"[",
"float",
",",
"complex",
",",
"Iterable",
"[",
"float",
"]",
",",
"np",
".",
"ndarray",
"]",
",",
"period",
":",
"float",
",",
"*",
",",
"atol",
":",
"float",
"=",
"1e-8",
")",
"->",
"bool",
... | Checks if the tensor's elements are all near multiples of the period.
Args:
a: Tensor of elements that could all be near multiples of the period.
period: The period, e.g. 2 pi when working in radians.
atol: Absolute tolerance. | [
"Checks",
"if",
"the",
"tensor",
"s",
"elements",
"are",
"all",
"near",
"multiples",
"of",
"the",
"period",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/linalg/tolerance.py#L34-L46 | train | Checks if the elements of a tensor are all near zero. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | dev_tools/git_env_tools.py | _git_fetch_for_comparison | def _git_fetch_for_comparison(remote: str,
actual_branch: str,
compare_branch: str,
verbose: bool) -> prepared_env.PreparedEnv:
"""Fetches two branches including their common ancestor.
Limits the depth of the fetch to avo... | python | def _git_fetch_for_comparison(remote: str,
actual_branch: str,
compare_branch: str,
verbose: bool) -> prepared_env.PreparedEnv:
"""Fetches two branches including their common ancestor.
Limits the depth of the fetch to avo... | [
"def",
"_git_fetch_for_comparison",
"(",
"remote",
":",
"str",
",",
"actual_branch",
":",
"str",
",",
"compare_branch",
":",
"str",
",",
"verbose",
":",
"bool",
")",
"->",
"prepared_env",
".",
"PreparedEnv",
":",
"actual_id",
"=",
"''",
"base_id",
"=",
"''",... | Fetches two branches including their common ancestor.
Limits the depth of the fetch to avoid unnecessary work. Scales up the
depth exponentially and tries again when the initial guess is not deep
enough.
Args:
remote: The location of the remote repository, in a format that the
git ... | [
"Fetches",
"two",
"branches",
"including",
"their",
"common",
"ancestor",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/dev_tools/git_env_tools.py#L28-L85 | train | Fetches two branches including their common ancestor and returns the actual branch and base branch. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | dev_tools/git_env_tools.py | fetch_github_pull_request | def fetch_github_pull_request(destination_directory: str,
repository: github_repository.GithubRepository,
pull_request_number: int,
verbose: bool
) -> prepared_env.PreparedEnv:
"""Uses content fro... | python | def fetch_github_pull_request(destination_directory: str,
repository: github_repository.GithubRepository,
pull_request_number: int,
verbose: bool
) -> prepared_env.PreparedEnv:
"""Uses content fro... | [
"def",
"fetch_github_pull_request",
"(",
"destination_directory",
":",
"str",
",",
"repository",
":",
"github_repository",
".",
"GithubRepository",
",",
"pull_request_number",
":",
"int",
",",
"verbose",
":",
"bool",
")",
"->",
"prepared_env",
".",
"PreparedEnv",
":... | Uses content from github to create a dir for testing and comparisons.
Args:
destination_directory: The location to fetch the contents into.
repository: The github repository that the commit lives under.
pull_request_number: The id of the pull request to clone. If None, then
the ... | [
"Uses",
"content",
"from",
"github",
"to",
"create",
"a",
"dir",
"for",
"testing",
"and",
"comparisons",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/dev_tools/git_env_tools.py#L88-L139 | train | Uses content from github to create a dir for testing and comparison. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | dev_tools/git_env_tools.py | fetch_local_files | def fetch_local_files(destination_directory: str,
verbose: bool) -> prepared_env.PreparedEnv:
"""Uses local files to create a directory for testing and comparisons.
Args:
destination_directory: The directory where the copied files should go.
verbose: When set, more progres... | python | def fetch_local_files(destination_directory: str,
verbose: bool) -> prepared_env.PreparedEnv:
"""Uses local files to create a directory for testing and comparisons.
Args:
destination_directory: The directory where the copied files should go.
verbose: When set, more progres... | [
"def",
"fetch_local_files",
"(",
"destination_directory",
":",
"str",
",",
"verbose",
":",
"bool",
")",
"->",
"prepared_env",
".",
"PreparedEnv",
":",
"staging_dir",
"=",
"destination_directory",
"+",
"'-staging'",
"try",
":",
"shutil",
".",
"copytree",
"(",
"ge... | Uses local files to create a directory for testing and comparisons.
Args:
destination_directory: The directory where the copied files should go.
verbose: When set, more progress output is produced.
Returns:
Commit ids corresponding to content to test/compare. | [
"Uses",
"local",
"files",
"to",
"create",
"a",
"directory",
"for",
"testing",
"and",
"comparisons",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/dev_tools/git_env_tools.py#L142-L214 | train | Uses local files to create a directory for testing and comparison. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/contrib/tpu/circuit_to_tensorflow.py | circuit_to_tensorflow_runnable | def circuit_to_tensorflow_runnable(
circuit: circuits.Circuit,
initial_state: Union[int, np.ndarray] = 0,
) -> ComputeFuncAndFeedDict:
"""Returns a compute function and feed_dict for a `cirq.Circuit`'s output.
`result.compute()` will return a `tensorflow.Tensor` with
`tensorflow.pla... | python | def circuit_to_tensorflow_runnable(
circuit: circuits.Circuit,
initial_state: Union[int, np.ndarray] = 0,
) -> ComputeFuncAndFeedDict:
"""Returns a compute function and feed_dict for a `cirq.Circuit`'s output.
`result.compute()` will return a `tensorflow.Tensor` with
`tensorflow.pla... | [
"def",
"circuit_to_tensorflow_runnable",
"(",
"circuit",
":",
"circuits",
".",
"Circuit",
",",
"initial_state",
":",
"Union",
"[",
"int",
",",
"np",
".",
"ndarray",
"]",
"=",
"0",
",",
")",
"->",
"ComputeFuncAndFeedDict",
":",
"if",
"not",
"circuit",
".",
... | Returns a compute function and feed_dict for a `cirq.Circuit`'s output.
`result.compute()` will return a `tensorflow.Tensor` with
`tensorflow.placeholder` objects to be filled in by `result.feed_dict`, at
which point it will evaluate to the output state vector of the circuit.
You can apply further ope... | [
"Returns",
"a",
"compute",
"function",
"and",
"feed_dict",
"for",
"a",
"cirq",
".",
"Circuit",
"s",
"output",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/contrib/tpu/circuit_to_tensorflow.py#L41-L118 | train | Returns a compute function and feed_dict for a single circuit. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/contrib/tpu/circuit_to_tensorflow.py | _circuit_as_layers | def _circuit_as_layers(circuit: circuits.Circuit,
grouping: _QubitGrouping) -> List[_TransformsThenCzs]:
"""Transforms a circuit into a series of GroupMatrix+CZ layers.
Args:
circuit: The circuit to transform.
grouping: How the circuit's qubits are combined into groups.
... | python | def _circuit_as_layers(circuit: circuits.Circuit,
grouping: _QubitGrouping) -> List[_TransformsThenCzs]:
"""Transforms a circuit into a series of GroupMatrix+CZ layers.
Args:
circuit: The circuit to transform.
grouping: How the circuit's qubits are combined into groups.
... | [
"def",
"_circuit_as_layers",
"(",
"circuit",
":",
"circuits",
".",
"Circuit",
",",
"grouping",
":",
"_QubitGrouping",
")",
"->",
"List",
"[",
"_TransformsThenCzs",
"]",
":",
"frontier",
"=",
"{",
"q",
":",
"0",
"for",
"q",
"in",
"circuit",
".",
"all_qubits... | Transforms a circuit into a series of GroupMatrix+CZ layers.
Args:
circuit: The circuit to transform.
grouping: How the circuit's qubits are combined into groups.
Returns:
A list of layers. Each layer has a matrix to apply to each group of
qubits, and a list of CZs to apply to ... | [
"Transforms",
"a",
"circuit",
"into",
"a",
"series",
"of",
"GroupMatrix",
"+",
"CZ",
"layers",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/contrib/tpu/circuit_to_tensorflow.py#L213-L283 | train | Transforms a circuit into a series of GroupMatrix + CZs. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/contrib/tpu/circuit_to_tensorflow.py | _deref | def _deref(tensor: tf.Tensor, index: tf.Tensor) -> tf.Tensor:
"""Equivalent to `tensor[index, ...]`.
This is a workaround for XLA requiring constant tensor indices. It works
by producing a node representing hardcoded instructions like the following:
if index == 0: return tensor[0]
if index =... | python | def _deref(tensor: tf.Tensor, index: tf.Tensor) -> tf.Tensor:
"""Equivalent to `tensor[index, ...]`.
This is a workaround for XLA requiring constant tensor indices. It works
by producing a node representing hardcoded instructions like the following:
if index == 0: return tensor[0]
if index =... | [
"def",
"_deref",
"(",
"tensor",
":",
"tf",
".",
"Tensor",
",",
"index",
":",
"tf",
".",
"Tensor",
")",
"->",
"tf",
".",
"Tensor",
":",
"assert",
"tensor",
".",
"shape",
"[",
"0",
"]",
">",
"0",
"return",
"_deref_helper",
"(",
"lambda",
"i",
":",
... | Equivalent to `tensor[index, ...]`.
This is a workaround for XLA requiring constant tensor indices. It works
by producing a node representing hardcoded instructions like the following:
if index == 0: return tensor[0]
if index == 1: return tensor[1]
if index == 2: return tensor[2]
.... | [
"Equivalent",
"to",
"tensor",
"[",
"index",
"...",
"]",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/contrib/tpu/circuit_to_tensorflow.py#L286-L306 | train | Equivalent to tensor [ index... ]. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/contrib/tpu/circuit_to_tensorflow.py | _multi_deref | def _multi_deref(tensors: List[tf.Tensor], index: tf.Tensor) -> List[tf.Tensor]:
"""Equivalent to `[t[index, ...] for t in tensors]`.
See `_deref` for more details.
"""
assert tensors
assert tensors[0].shape[0] > 0
return _deref_helper(lambda i: [tensor[i, ...] for tensor in tensors],
... | python | def _multi_deref(tensors: List[tf.Tensor], index: tf.Tensor) -> List[tf.Tensor]:
"""Equivalent to `[t[index, ...] for t in tensors]`.
See `_deref` for more details.
"""
assert tensors
assert tensors[0].shape[0] > 0
return _deref_helper(lambda i: [tensor[i, ...] for tensor in tensors],
... | [
"def",
"_multi_deref",
"(",
"tensors",
":",
"List",
"[",
"tf",
".",
"Tensor",
"]",
",",
"index",
":",
"tf",
".",
"Tensor",
")",
"->",
"List",
"[",
"tf",
".",
"Tensor",
"]",
":",
"assert",
"tensors",
"assert",
"tensors",
"[",
"0",
"]",
".",
"shape",... | Equivalent to `[t[index, ...] for t in tensors]`.
See `_deref` for more details. | [
"Equivalent",
"to",
"[",
"t",
"[",
"index",
"...",
"]",
"for",
"t",
"in",
"tensors",
"]",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/contrib/tpu/circuit_to_tensorflow.py#L309-L319 | train | Equivalent to _deref for multi - tensor. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/sim/sampler.py | Sampler.run | def run(
self,
program: Union[circuits.Circuit, schedules.Schedule],
param_resolver: 'study.ParamResolverOrSimilarType' = None,
repetitions: int = 1,
) -> study.TrialResult:
"""Samples from the given Circuit or Schedule.
Args:
program: The... | python | def run(
self,
program: Union[circuits.Circuit, schedules.Schedule],
param_resolver: 'study.ParamResolverOrSimilarType' = None,
repetitions: int = 1,
) -> study.TrialResult:
"""Samples from the given Circuit or Schedule.
Args:
program: The... | [
"def",
"run",
"(",
"self",
",",
"program",
":",
"Union",
"[",
"circuits",
".",
"Circuit",
",",
"schedules",
".",
"Schedule",
"]",
",",
"param_resolver",
":",
"'study.ParamResolverOrSimilarType'",
"=",
"None",
",",
"repetitions",
":",
"int",
"=",
"1",
",",
... | Samples from the given Circuit or Schedule.
Args:
program: The circuit or schedule to simulate.
param_resolver: Parameters to run with the program.
repetitions: The number of repetitions to simulate.
Returns:
TrialResult for a run. | [
"Samples",
"from",
"the",
"given",
"Circuit",
"or",
"Schedule",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/sim/sampler.py#L25-L42 | train | Runs the given circuit or schedule and returns the first result. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/sim/sampler.py | Sampler.run_sweep | def run_sweep(
self,
program: Union[circuits.Circuit, schedules.Schedule],
params: study.Sweepable,
repetitions: int = 1,
) -> List[study.TrialResult]:
"""Samples from the given Circuit or Schedule.
In contrast to run, this allows for sweeping over di... | python | def run_sweep(
self,
program: Union[circuits.Circuit, schedules.Schedule],
params: study.Sweepable,
repetitions: int = 1,
) -> List[study.TrialResult]:
"""Samples from the given Circuit or Schedule.
In contrast to run, this allows for sweeping over di... | [
"def",
"run_sweep",
"(",
"self",
",",
"program",
":",
"Union",
"[",
"circuits",
".",
"Circuit",
",",
"schedules",
".",
"Schedule",
"]",
",",
"params",
":",
"study",
".",
"Sweepable",
",",
"repetitions",
":",
"int",
"=",
"1",
",",
")",
"->",
"List",
"... | Samples from the given Circuit or Schedule.
In contrast to run, this allows for sweeping over different parameter
values.
Args:
program: The circuit or schedule to simulate.
params: Parameters to run with the program.
repetitions: The number of repetitions t... | [
"Samples",
"from",
"the",
"given",
"Circuit",
"or",
"Schedule",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/sim/sampler.py#L45-L64 | train | Runs the sweeping procedure over the given parameter set. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/ops/common_gates.py | measure | def measure(*qubits: raw_types.Qid,
key: Optional[str] = None,
invert_mask: Tuple[bool, ...] = ()
) -> gate_operation.GateOperation:
"""Returns a single MeasurementGate applied to all the given qubits.
The qubits are measured in the computational basis.
Args:
*q... | python | def measure(*qubits: raw_types.Qid,
key: Optional[str] = None,
invert_mask: Tuple[bool, ...] = ()
) -> gate_operation.GateOperation:
"""Returns a single MeasurementGate applied to all the given qubits.
The qubits are measured in the computational basis.
Args:
*q... | [
"def",
"measure",
"(",
"*",
"qubits",
":",
"raw_types",
".",
"Qid",
",",
"key",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"invert_mask",
":",
"Tuple",
"[",
"bool",
",",
"...",
"]",
"=",
"(",
")",
")",
"->",
"gate_operation",
".",
"GateOpe... | Returns a single MeasurementGate applied to all the given qubits.
The qubits are measured in the computational basis.
Args:
*qubits: The qubits that the measurement gate should measure.
key: The string key of the measurement. If this is None, it defaults
to a comma-separated list o... | [
"Returns",
"a",
"single",
"MeasurementGate",
"applied",
"to",
"all",
"the",
"given",
"qubits",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/ops/common_gates.py#L509-L543 | train | Returns a MeasurementGate applied to all the given qubits. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/ops/common_gates.py | measure_each | def measure_each(*qubits: raw_types.Qid,
key_func: Callable[[raw_types.Qid], str] = str
) -> List[gate_operation.GateOperation]:
"""Returns a list of operations individually measuring the given qubits.
The qubits are measured in the computational basis.
Args:
*qub... | python | def measure_each(*qubits: raw_types.Qid,
key_func: Callable[[raw_types.Qid], str] = str
) -> List[gate_operation.GateOperation]:
"""Returns a list of operations individually measuring the given qubits.
The qubits are measured in the computational basis.
Args:
*qub... | [
"def",
"measure_each",
"(",
"*",
"qubits",
":",
"raw_types",
".",
"Qid",
",",
"key_func",
":",
"Callable",
"[",
"[",
"raw_types",
".",
"Qid",
"]",
",",
"str",
"]",
"=",
"str",
")",
"->",
"List",
"[",
"gate_operation",
".",
"GateOperation",
"]",
":",
... | Returns a list of operations individually measuring the given qubits.
The qubits are measured in the computational basis.
Args:
*qubits: The qubits to measure.
key_func: Determines the key of the measurements of each qubit. Takes
the qubit and returns the key for that qubit. Defaul... | [
"Returns",
"a",
"list",
"of",
"operations",
"individually",
"measuring",
"the",
"given",
"qubits",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/ops/common_gates.py#L546-L561 | train | Returns a list of operations individually measuring the given qubits. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/ops/common_gates.py | Rx | def Rx(rads: Union[float, sympy.Basic]) -> XPowGate:
"""Returns a gate with the matrix e^{-i X rads / 2}."""
pi = sympy.pi if protocols.is_parameterized(rads) else np.pi
return XPowGate(exponent=rads / pi, global_shift=-0.5) | python | def Rx(rads: Union[float, sympy.Basic]) -> XPowGate:
"""Returns a gate with the matrix e^{-i X rads / 2}."""
pi = sympy.pi if protocols.is_parameterized(rads) else np.pi
return XPowGate(exponent=rads / pi, global_shift=-0.5) | [
"def",
"Rx",
"(",
"rads",
":",
"Union",
"[",
"float",
",",
"sympy",
".",
"Basic",
"]",
")",
"->",
"XPowGate",
":",
"pi",
"=",
"sympy",
".",
"pi",
"if",
"protocols",
".",
"is_parameterized",
"(",
"rads",
")",
"else",
"np",
".",
"pi",
"return",
"XPow... | Returns a gate with the matrix e^{-i X rads / 2}. | [
"Returns",
"a",
"gate",
"with",
"the",
"matrix",
"e^",
"{",
"-",
"i",
"X",
"rads",
"/",
"2",
"}",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/ops/common_gates.py#L1132-L1135 | train | Returns a gate with the matrix e^ - i X rads / 2. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/ops/common_gates.py | Ry | def Ry(rads: Union[float, sympy.Basic]) -> YPowGate:
"""Returns a gate with the matrix e^{-i Y rads / 2}."""
pi = sympy.pi if protocols.is_parameterized(rads) else np.pi
return YPowGate(exponent=rads / pi, global_shift=-0.5) | python | def Ry(rads: Union[float, sympy.Basic]) -> YPowGate:
"""Returns a gate with the matrix e^{-i Y rads / 2}."""
pi = sympy.pi if protocols.is_parameterized(rads) else np.pi
return YPowGate(exponent=rads / pi, global_shift=-0.5) | [
"def",
"Ry",
"(",
"rads",
":",
"Union",
"[",
"float",
",",
"sympy",
".",
"Basic",
"]",
")",
"->",
"YPowGate",
":",
"pi",
"=",
"sympy",
".",
"pi",
"if",
"protocols",
".",
"is_parameterized",
"(",
"rads",
")",
"else",
"np",
".",
"pi",
"return",
"YPow... | Returns a gate with the matrix e^{-i Y rads / 2}. | [
"Returns",
"a",
"gate",
"with",
"the",
"matrix",
"e^",
"{",
"-",
"i",
"Y",
"rads",
"/",
"2",
"}",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/ops/common_gates.py#L1138-L1141 | train | Returns a gate with the matrix e^Y rads / 2. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/ops/common_gates.py | Rz | def Rz(rads: Union[float, sympy.Basic]) -> ZPowGate:
"""Returns a gate with the matrix e^{-i Z rads / 2}."""
pi = sympy.pi if protocols.is_parameterized(rads) else np.pi
return ZPowGate(exponent=rads / pi, global_shift=-0.5) | python | def Rz(rads: Union[float, sympy.Basic]) -> ZPowGate:
"""Returns a gate with the matrix e^{-i Z rads / 2}."""
pi = sympy.pi if protocols.is_parameterized(rads) else np.pi
return ZPowGate(exponent=rads / pi, global_shift=-0.5) | [
"def",
"Rz",
"(",
"rads",
":",
"Union",
"[",
"float",
",",
"sympy",
".",
"Basic",
"]",
")",
"->",
"ZPowGate",
":",
"pi",
"=",
"sympy",
".",
"pi",
"if",
"protocols",
".",
"is_parameterized",
"(",
"rads",
")",
"else",
"np",
".",
"pi",
"return",
"ZPow... | Returns a gate with the matrix e^{-i Z rads / 2}. | [
"Returns",
"a",
"gate",
"with",
"the",
"matrix",
"e^",
"{",
"-",
"i",
"Z",
"rads",
"/",
"2",
"}",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/ops/common_gates.py#L1144-L1147 | train | Returns a ZPowGate with the matrix e^ - i Z rads. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/ops/common_gates.py | SwapPowGate._decompose_ | def _decompose_(self, qubits):
"""See base class."""
a, b = qubits
yield CNOT(a, b)
yield CNOT(b, a) ** self._exponent
yield CNOT(a, b) | python | def _decompose_(self, qubits):
"""See base class."""
a, b = qubits
yield CNOT(a, b)
yield CNOT(b, a) ** self._exponent
yield CNOT(a, b) | [
"def",
"_decompose_",
"(",
"self",
",",
"qubits",
")",
":",
"a",
",",
"b",
"=",
"qubits",
"yield",
"CNOT",
"(",
"a",
",",
"b",
")",
"yield",
"CNOT",
"(",
"b",
",",
"a",
")",
"**",
"self",
".",
"_exponent",
"yield",
"CNOT",
"(",
"a",
",",
"b",
... | See base class. | [
"See",
"base",
"class",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/ops/common_gates.py#L948-L953 | train | Decomposes the set of qubits into a set of unique entries. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/ops/raw_types.py | Gate.validate_args | def validate_args(self, qubits: Sequence[Qid]) -> None:
"""Checks if this gate can be applied to the given qubits.
By default checks if input is of type Qid and qubit count.
Child classes can override.
Args:
qubits: The collection of qubits to potentially apply the gate to.... | python | def validate_args(self, qubits: Sequence[Qid]) -> None:
"""Checks if this gate can be applied to the given qubits.
By default checks if input is of type Qid and qubit count.
Child classes can override.
Args:
qubits: The collection of qubits to potentially apply the gate to.... | [
"def",
"validate_args",
"(",
"self",
",",
"qubits",
":",
"Sequence",
"[",
"Qid",
"]",
")",
"->",
"None",
":",
"if",
"len",
"(",
"qubits",
")",
"==",
"0",
":",
"raise",
"ValueError",
"(",
"\"Applied a gate to an empty set of qubits. Gate: {}\"",
".",
"format",
... | Checks if this gate can be applied to the given qubits.
By default checks if input is of type Qid and qubit count.
Child classes can override.
Args:
qubits: The collection of qubits to potentially apply the gate to.
Throws:
ValueError: The gate can't be applied... | [
"Checks",
"if",
"this",
"gate",
"can",
"be",
"applied",
"to",
"the",
"given",
"qubits",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/ops/raw_types.py#L107-L135 | train | Checks if this gate can be applied to the given qubits. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/ops/raw_types.py | Gate.on | def on(self, *qubits: Qid) -> 'gate_operation.GateOperation':
"""Returns an application of this gate to the given qubits.
Args:
*qubits: The collection of qubits to potentially apply the gate to.
"""
# Avoids circular import.
from cirq.ops import gate_operation
... | python | def on(self, *qubits: Qid) -> 'gate_operation.GateOperation':
"""Returns an application of this gate to the given qubits.
Args:
*qubits: The collection of qubits to potentially apply the gate to.
"""
# Avoids circular import.
from cirq.ops import gate_operation
... | [
"def",
"on",
"(",
"self",
",",
"*",
"qubits",
":",
"Qid",
")",
"->",
"'gate_operation.GateOperation'",
":",
"# Avoids circular import.",
"from",
"cirq",
".",
"ops",
"import",
"gate_operation",
"return",
"gate_operation",
".",
"GateOperation",
"(",
"self",
",",
"... | Returns an application of this gate to the given qubits.
Args:
*qubits: The collection of qubits to potentially apply the gate to. | [
"Returns",
"an",
"application",
"of",
"this",
"gate",
"to",
"the",
"given",
"qubits",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/ops/raw_types.py#L137-L145 | train | Returns an application of this gate to the given qubits. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/ops/raw_types.py | Gate.controlled_by | def controlled_by(self, *control_qubits: Qid) -> 'Gate':
"""Returns a controlled version of this gate.
Args:
control_qubits: Optional qubits to control the gate by.
"""
# Avoids circular import.
from cirq.ops import ControlledGate
return ControlledGate(self, ... | python | def controlled_by(self, *control_qubits: Qid) -> 'Gate':
"""Returns a controlled version of this gate.
Args:
control_qubits: Optional qubits to control the gate by.
"""
# Avoids circular import.
from cirq.ops import ControlledGate
return ControlledGate(self, ... | [
"def",
"controlled_by",
"(",
"self",
",",
"*",
"control_qubits",
":",
"Qid",
")",
"->",
"'Gate'",
":",
"# Avoids circular import.",
"from",
"cirq",
".",
"ops",
"import",
"ControlledGate",
"return",
"ControlledGate",
"(",
"self",
",",
"control_qubits",
",",
"len"... | Returns a controlled version of this gate.
Args:
control_qubits: Optional qubits to control the gate by. | [
"Returns",
"a",
"controlled",
"version",
"of",
"this",
"gate",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/ops/raw_types.py#L213-L223 | train | Returns a controlled version of this gate. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/ops/raw_types.py | Operation.transform_qubits | def transform_qubits(self: TSelf_Operation,
func: Callable[[Qid], Qid]) -> TSelf_Operation:
"""Returns the same operation, but with different qubits.
Args:
func: The function to use to turn each current qubit into a desired
new qubit.
Return... | python | def transform_qubits(self: TSelf_Operation,
func: Callable[[Qid], Qid]) -> TSelf_Operation:
"""Returns the same operation, but with different qubits.
Args:
func: The function to use to turn each current qubit into a desired
new qubit.
Return... | [
"def",
"transform_qubits",
"(",
"self",
":",
"TSelf_Operation",
",",
"func",
":",
"Callable",
"[",
"[",
"Qid",
"]",
",",
"Qid",
"]",
")",
"->",
"TSelf_Operation",
":",
"return",
"self",
".",
"with_qubits",
"(",
"*",
"(",
"func",
"(",
"q",
")",
"for",
... | Returns the same operation, but with different qubits.
Args:
func: The function to use to turn each current qubit into a desired
new qubit.
Returns:
The receiving operation but with qubits transformed by the given
function. | [
"Returns",
"the",
"same",
"operation",
"but",
"with",
"different",
"qubits",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/ops/raw_types.py#L249-L261 | train | Returns the same operation but with different qubits. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/ops/raw_types.py | Operation.controlled_by | def controlled_by(self, *control_qubits: Qid) -> 'Operation':
"""Returns a controlled version of this operation.
Args:
control_qubits: Qubits to control the operation by. Required.
"""
# Avoids circular import.
from cirq.ops import ControlledOperation
if cont... | python | def controlled_by(self, *control_qubits: Qid) -> 'Operation':
"""Returns a controlled version of this operation.
Args:
control_qubits: Qubits to control the operation by. Required.
"""
# Avoids circular import.
from cirq.ops import ControlledOperation
if cont... | [
"def",
"controlled_by",
"(",
"self",
",",
"*",
"control_qubits",
":",
"Qid",
")",
"->",
"'Operation'",
":",
"# Avoids circular import.",
"from",
"cirq",
".",
"ops",
"import",
"ControlledOperation",
"if",
"control_qubits",
"is",
"None",
"or",
"len",
"(",
"control... | Returns a controlled version of this operation.
Args:
control_qubits: Qubits to control the operation by. Required. | [
"Returns",
"a",
"controlled",
"version",
"of",
"this",
"operation",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/ops/raw_types.py#L263-L276 | train | Returns a controlled version of this operation. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/ops/display.py | WaveFunctionDisplay.value_derived_from_wavefunction | def value_derived_from_wavefunction(self,
state: np.ndarray,
qubit_map: Dict[raw_types.Qid, int]
) -> Any:
"""The value of the display, derived from the full wavefunction.
Args:
... | python | def value_derived_from_wavefunction(self,
state: np.ndarray,
qubit_map: Dict[raw_types.Qid, int]
) -> Any:
"""The value of the display, derived from the full wavefunction.
Args:
... | [
"def",
"value_derived_from_wavefunction",
"(",
"self",
",",
"state",
":",
"np",
".",
"ndarray",
",",
"qubit_map",
":",
"Dict",
"[",
"raw_types",
".",
"Qid",
",",
"int",
"]",
")",
"->",
"Any",
":"
] | The value of the display, derived from the full wavefunction.
Args:
state: The wavefunction.
qubit_map: A dictionary from qubit to qubit index in the
ordering used to define the wavefunction. | [
"The",
"value",
"of",
"the",
"display",
"derived",
"from",
"the",
"full",
"wavefunction",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/ops/display.py#L91-L101 | train | The value of the display derived from the full wavefunction. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | dev_tools/check.py | Check.perform_check | def perform_check(self,
env: env_tools.PreparedEnv,
verbose: bool) -> Tuple[bool, str]:
"""Evaluates the status check and returns a pass/fail with message.
Args:
env: Describes a prepared python 3 environment in which to run.
verbose: ... | python | def perform_check(self,
env: env_tools.PreparedEnv,
verbose: bool) -> Tuple[bool, str]:
"""Evaluates the status check and returns a pass/fail with message.
Args:
env: Describes a prepared python 3 environment in which to run.
verbose: ... | [
"def",
"perform_check",
"(",
"self",
",",
"env",
":",
"env_tools",
".",
"PreparedEnv",
",",
"verbose",
":",
"bool",
")",
"->",
"Tuple",
"[",
"bool",
",",
"str",
"]",
":"
] | Evaluates the status check and returns a pass/fail with message.
Args:
env: Describes a prepared python 3 environment in which to run.
verbose: When set, more progress output is produced.
Returns:
A tuple containing a pass/fail boolean and then a details message. | [
"Evaluates",
"the",
"status",
"check",
"and",
"returns",
"a",
"pass",
"/",
"fail",
"with",
"message",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/dev_tools/check.py#L61-L72 | train | Evaluates the status check and returns a pass or fail with a details message. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | dev_tools/check.py | Check.run | def run(self,
env: env_tools.PreparedEnv,
verbose: bool,
previous_failures: Set['Check']) -> CheckResult:
"""Evaluates this check.
Args:
env: The prepared python environment to run the check in.
verbose: When set, more progress output is produ... | python | def run(self,
env: env_tools.PreparedEnv,
verbose: bool,
previous_failures: Set['Check']) -> CheckResult:
"""Evaluates this check.
Args:
env: The prepared python environment to run the check in.
verbose: When set, more progress output is produ... | [
"def",
"run",
"(",
"self",
",",
"env",
":",
"env_tools",
".",
"PreparedEnv",
",",
"verbose",
":",
"bool",
",",
"previous_failures",
":",
"Set",
"[",
"'Check'",
"]",
")",
"->",
"CheckResult",
":",
"# Skip if a dependency failed.",
"if",
"previous_failures",
"."... | Evaluates this check.
Args:
env: The prepared python environment to run the check in.
verbose: When set, more progress output is produced.
previous_failures: Checks that have already run and failed.
Returns:
A CheckResult instance. | [
"Evaluates",
"this",
"check",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/dev_tools/check.py#L77-L115 | train | Runs the check in the given python environment. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | dev_tools/check.py | Check.pick_env_and_run_and_report | def pick_env_and_run_and_report(self,
env: env_tools.PreparedEnv,
env_py2: Optional[env_tools.PreparedEnv],
verbose: bool,
previous_failures: Set['Check']
... | python | def pick_env_and_run_and_report(self,
env: env_tools.PreparedEnv,
env_py2: Optional[env_tools.PreparedEnv],
verbose: bool,
previous_failures: Set['Check']
... | [
"def",
"pick_env_and_run_and_report",
"(",
"self",
",",
"env",
":",
"env_tools",
".",
"PreparedEnv",
",",
"env_py2",
":",
"Optional",
"[",
"env_tools",
".",
"PreparedEnv",
"]",
",",
"verbose",
":",
"bool",
",",
"previous_failures",
":",
"Set",
"[",
"'Check'",
... | Evaluates this check in python 3 or 2.7, and reports to github.
If the prepared environments are not linked to a github repository,
with a known access token, reporting to github is skipped.
Args:
env: A prepared python 3 environment.
env_py2: A prepared python 2.7 envi... | [
"Evaluates",
"this",
"check",
"in",
"python",
"3",
"or",
"2",
".",
"7",
"and",
"reports",
"to",
"github",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/dev_tools/check.py#L117-L154 | train | Selects the environment and runs it and reports the result to github. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/study/sweepable.py | to_resolvers | def to_resolvers(sweepable: Sweepable) -> List[ParamResolver]:
"""Convert a Sweepable to a list of ParamResolvers."""
if isinstance(sweepable, ParamResolver):
return [sweepable]
elif isinstance(sweepable, Sweep):
return list(sweepable)
elif isinstance(sweepable, collections.Iterable):
... | python | def to_resolvers(sweepable: Sweepable) -> List[ParamResolver]:
"""Convert a Sweepable to a list of ParamResolvers."""
if isinstance(sweepable, ParamResolver):
return [sweepable]
elif isinstance(sweepable, Sweep):
return list(sweepable)
elif isinstance(sweepable, collections.Iterable):
... | [
"def",
"to_resolvers",
"(",
"sweepable",
":",
"Sweepable",
")",
"->",
"List",
"[",
"ParamResolver",
"]",
":",
"if",
"isinstance",
"(",
"sweepable",
",",
"ParamResolver",
")",
":",
"return",
"[",
"sweepable",
"]",
"elif",
"isinstance",
"(",
"sweepable",
",",
... | Convert a Sweepable to a list of ParamResolvers. | [
"Convert",
"a",
"Sweepable",
"to",
"a",
"list",
"of",
"ParamResolvers",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/study/sweepable.py#L29-L40 | train | Convert a Sweepable to a list of ParamResolvers. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/protocols/resolve_parameters.py | is_parameterized | def is_parameterized(val: Any) -> bool:
"""Returns whether the object is parameterized with any Symbols.
A value is parameterized when it has an `_is_parameterized_` method and
that method returns a truthy value, or if the value is an instance of
sympy.Basic.
Returns:
True if the gate has ... | python | def is_parameterized(val: Any) -> bool:
"""Returns whether the object is parameterized with any Symbols.
A value is parameterized when it has an `_is_parameterized_` method and
that method returns a truthy value, or if the value is an instance of
sympy.Basic.
Returns:
True if the gate has ... | [
"def",
"is_parameterized",
"(",
"val",
":",
"Any",
")",
"->",
"bool",
":",
"if",
"isinstance",
"(",
"val",
",",
"sympy",
".",
"Basic",
")",
":",
"return",
"True",
"getter",
"=",
"getattr",
"(",
"val",
",",
"'_is_parameterized_'",
",",
"None",
")",
"res... | Returns whether the object is parameterized with any Symbols.
A value is parameterized when it has an `_is_parameterized_` method and
that method returns a truthy value, or if the value is an instance of
sympy.Basic.
Returns:
True if the gate has any unresolved Symbols
and False otherw... | [
"Returns",
"whether",
"the",
"object",
"is",
"parameterized",
"with",
"any",
"Symbols",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/protocols/resolve_parameters.py#L40-L62 | train | Returns whether the object is parameterized with any unresolved Symbols. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/protocols/resolve_parameters.py | resolve_parameters | def resolve_parameters(
val: Any,
param_resolver: 'cirq.ParamResolverOrSimilarType') -> Any:
"""Resolves symbol parameters in the effect using the param resolver.
This function will use the `_resolve_parameters_` magic method
of `val` to resolve any Symbols with concrete values from the giv... | python | def resolve_parameters(
val: Any,
param_resolver: 'cirq.ParamResolverOrSimilarType') -> Any:
"""Resolves symbol parameters in the effect using the param resolver.
This function will use the `_resolve_parameters_` magic method
of `val` to resolve any Symbols with concrete values from the giv... | [
"def",
"resolve_parameters",
"(",
"val",
":",
"Any",
",",
"param_resolver",
":",
"'cirq.ParamResolverOrSimilarType'",
")",
"->",
"Any",
":",
"if",
"not",
"param_resolver",
":",
"return",
"val",
"# Ensure its a dictionary wrapped in a ParamResolver.",
"from",
"cirq",
"im... | Resolves symbol parameters in the effect using the param resolver.
This function will use the `_resolve_parameters_` magic method
of `val` to resolve any Symbols with concrete values from the given
parameter resolver.
Args:
val: The object to resolve (e.g. the gate, operation, etc)
par... | [
"Resolves",
"symbol",
"parameters",
"in",
"the",
"effect",
"using",
"the",
"param",
"resolver",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/protocols/resolve_parameters.py#L65-L99 | train | Resolves symbol parameters in the effect using the given ParamResolver. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/contrib/qcircuit/qcircuit_diagram.py | circuit_to_latex_using_qcircuit | def circuit_to_latex_using_qcircuit(
circuit: circuits.Circuit,
qubit_order: ops.QubitOrderOrList = ops.QubitOrder.DEFAULT) -> str:
"""Returns a QCircuit-based latex diagram of the given circuit.
Args:
circuit: The circuit to represent in latex.
qubit_order: Determines the order... | python | def circuit_to_latex_using_qcircuit(
circuit: circuits.Circuit,
qubit_order: ops.QubitOrderOrList = ops.QubitOrder.DEFAULT) -> str:
"""Returns a QCircuit-based latex diagram of the given circuit.
Args:
circuit: The circuit to represent in latex.
qubit_order: Determines the order... | [
"def",
"circuit_to_latex_using_qcircuit",
"(",
"circuit",
":",
"circuits",
".",
"Circuit",
",",
"qubit_order",
":",
"ops",
".",
"QubitOrderOrList",
"=",
"ops",
".",
"QubitOrder",
".",
"DEFAULT",
")",
"->",
"str",
":",
"diagram",
"=",
"circuit",
".",
"to_text_d... | Returns a QCircuit-based latex diagram of the given circuit.
Args:
circuit: The circuit to represent in latex.
qubit_order: Determines the order of qubit wires in the diagram.
Returns:
Latex code for the diagram. | [
"Returns",
"a",
"QCircuit",
"-",
"based",
"latex",
"diagram",
"of",
"the",
"given",
"circuit",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/contrib/qcircuit/qcircuit_diagram.py#L62-L78 | train | Returns a LaTeX code for the given circuit. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/linalg/combinators.py | kron | def kron(*matrices: np.ndarray) -> np.ndarray:
"""Computes the kronecker product of a sequence of matrices.
A *args version of lambda args: functools.reduce(np.kron, args).
Args:
*matrices: The matrices and controls to combine with the kronecker
product.
Returns:
The resul... | python | def kron(*matrices: np.ndarray) -> np.ndarray:
"""Computes the kronecker product of a sequence of matrices.
A *args version of lambda args: functools.reduce(np.kron, args).
Args:
*matrices: The matrices and controls to combine with the kronecker
product.
Returns:
The resul... | [
"def",
"kron",
"(",
"*",
"matrices",
":",
"np",
".",
"ndarray",
")",
"->",
"np",
".",
"ndarray",
":",
"product",
"=",
"np",
".",
"eye",
"(",
"1",
")",
"for",
"m",
"in",
"matrices",
":",
"product",
"=",
"np",
".",
"kron",
"(",
"product",
",",
"m... | Computes the kronecker product of a sequence of matrices.
A *args version of lambda args: functools.reduce(np.kron, args).
Args:
*matrices: The matrices and controls to combine with the kronecker
product.
Returns:
The resulting matrix. | [
"Computes",
"the",
"kronecker",
"product",
"of",
"a",
"sequence",
"of",
"matrices",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/linalg/combinators.py#L23-L38 | train | Computes the kronecker product of a sequence of matrices. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/linalg/combinators.py | kron_with_controls | def kron_with_controls(*matrices: np.ndarray) -> np.ndarray:
"""Computes the kronecker product of a sequence of matrices and controls.
Use linalg.CONTROL_TAG to represent controls. Any entry of the output
matrix corresponding to a situation where the control is not satisfied will
be overwritten by iden... | python | def kron_with_controls(*matrices: np.ndarray) -> np.ndarray:
"""Computes the kronecker product of a sequence of matrices and controls.
Use linalg.CONTROL_TAG to represent controls. Any entry of the output
matrix corresponding to a situation where the control is not satisfied will
be overwritten by iden... | [
"def",
"kron_with_controls",
"(",
"*",
"matrices",
":",
"np",
".",
"ndarray",
")",
"->",
"np",
".",
"ndarray",
":",
"product",
"=",
"kron",
"(",
"*",
"matrices",
")",
"# The NaN from CONTROL_TAG spreads to everywhere identity belongs.",
"for",
"i",
"in",
"range",
... | Computes the kronecker product of a sequence of matrices and controls.
Use linalg.CONTROL_TAG to represent controls. Any entry of the output
matrix corresponding to a situation where the control is not satisfied will
be overwritten by identity matrix elements.
The control logic works by imbuing NaN wi... | [
"Computes",
"the",
"kronecker",
"product",
"of",
"a",
"sequence",
"of",
"matrices",
"and",
"controls",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/linalg/combinators.py#L44-L77 | train | Computes the kronecker product of a sequence of matrices and controls. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/linalg/combinators.py | dot | def dot(*values: Union[float, complex, np.ndarray]
) -> Union[float, complex, np.ndarray]:
"""Computes the dot/matrix product of a sequence of values.
A *args version of np.linalg.multi_dot.
Args:
*values: The values to combine with the dot/matrix product.
Returns:
The resulti... | python | def dot(*values: Union[float, complex, np.ndarray]
) -> Union[float, complex, np.ndarray]:
"""Computes the dot/matrix product of a sequence of values.
A *args version of np.linalg.multi_dot.
Args:
*values: The values to combine with the dot/matrix product.
Returns:
The resulti... | [
"def",
"dot",
"(",
"*",
"values",
":",
"Union",
"[",
"float",
",",
"complex",
",",
"np",
".",
"ndarray",
"]",
")",
"->",
"Union",
"[",
"float",
",",
"complex",
",",
"np",
".",
"ndarray",
"]",
":",
"if",
"len",
"(",
"values",
")",
"==",
"1",
":"... | Computes the dot/matrix product of a sequence of values.
A *args version of np.linalg.multi_dot.
Args:
*values: The values to combine with the dot/matrix product.
Returns:
The resulting value or matrix. | [
"Computes",
"the",
"dot",
"/",
"matrix",
"product",
"of",
"a",
"sequence",
"of",
"values",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/linalg/combinators.py#L80-L96 | train | A *args version of np. linalg. multi_dot. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/linalg/combinators.py | block_diag | def block_diag(*blocks: np.ndarray) -> np.ndarray:
"""Concatenates blocks into a block diagonal matrix.
Args:
*blocks: Square matrices to place along the diagonal of the result.
Returns:
A block diagonal matrix with the given blocks along its diagonal.
Raises:
ValueError: A bl... | python | def block_diag(*blocks: np.ndarray) -> np.ndarray:
"""Concatenates blocks into a block diagonal matrix.
Args:
*blocks: Square matrices to place along the diagonal of the result.
Returns:
A block diagonal matrix with the given blocks along its diagonal.
Raises:
ValueError: A bl... | [
"def",
"block_diag",
"(",
"*",
"blocks",
":",
"np",
".",
"ndarray",
")",
"->",
"np",
".",
"ndarray",
":",
"for",
"b",
"in",
"blocks",
":",
"if",
"b",
".",
"shape",
"[",
"0",
"]",
"!=",
"b",
".",
"shape",
"[",
"1",
"]",
":",
"raise",
"ValueError... | Concatenates blocks into a block diagonal matrix.
Args:
*blocks: Square matrices to place along the diagonal of the result.
Returns:
A block diagonal matrix with the given blocks along its diagonal.
Raises:
ValueError: A block isn't square. | [
"Concatenates",
"blocks",
"into",
"a",
"block",
"diagonal",
"matrix",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/linalg/combinators.py#L104-L133 | train | Concatenates blocks into a block diagonal matrix. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/google/line/placement/anneal.py | index_2d | def index_2d(seqs: List[List[Any]], target: Any) -> Tuple[int, int]:
"""Finds the first index of a target item within a list of lists.
Args:
seqs: The list of lists to search.
target: The item to find.
Raises:
ValueError: Item is not present.
"""
for i in range(len(seqs)):
... | python | def index_2d(seqs: List[List[Any]], target: Any) -> Tuple[int, int]:
"""Finds the first index of a target item within a list of lists.
Args:
seqs: The list of lists to search.
target: The item to find.
Raises:
ValueError: Item is not present.
"""
for i in range(len(seqs)):
... | [
"def",
"index_2d",
"(",
"seqs",
":",
"List",
"[",
"List",
"[",
"Any",
"]",
"]",
",",
"target",
":",
"Any",
")",
"->",
"Tuple",
"[",
"int",
",",
"int",
"]",
":",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"seqs",
")",
")",
":",
"for",
"j",
... | Finds the first index of a target item within a list of lists.
Args:
seqs: The list of lists to search.
target: The item to find.
Raises:
ValueError: Item is not present. | [
"Finds",
"the",
"first",
"index",
"of",
"a",
"target",
"item",
"within",
"a",
"list",
"of",
"lists",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/google/line/placement/anneal.py#L387-L401 | train | Finds the first index of a target item within a list of lists. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/google/line/placement/anneal.py | AnnealSequenceSearch.search | def search(
self,
trace_func: Callable[
[List[LineSequence], float, float, float, bool],
None] = None) -> List[LineSequence]:
"""Issues new linear sequence search.
Each call to this method starts new search.
Args:
trace_func: Op... | python | def search(
self,
trace_func: Callable[
[List[LineSequence], float, float, float, bool],
None] = None) -> List[LineSequence]:
"""Issues new linear sequence search.
Each call to this method starts new search.
Args:
trace_func: Op... | [
"def",
"search",
"(",
"self",
",",
"trace_func",
":",
"Callable",
"[",
"[",
"List",
"[",
"LineSequence",
"]",
",",
"float",
",",
"float",
",",
"float",
",",
"bool",
"]",
",",
"None",
"]",
"=",
"None",
")",
"->",
"List",
"[",
"LineSequence",
"]",
":... | Issues new linear sequence search.
Each call to this method starts new search.
Args:
trace_func: Optional callable which will be called for each simulated
annealing step with arguments: solution candidate (list of linear
sequences on the chip), current temperature (fl... | [
"Issues",
"new",
"linear",
"sequence",
"search",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/google/line/placement/anneal.py#L54-L86 | train | Issues new linear sequence search. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/google/line/placement/anneal.py | AnnealSequenceSearch._quadratic_sum_cost | def _quadratic_sum_cost(self, state: _STATE) -> float:
"""Cost function that sums squares of lengths of sequences.
Args:
state: Search state, not mutated.
Returns:
Cost which is minus the normalized quadratic sum of each linear
sequence section in the state. This ... | python | def _quadratic_sum_cost(self, state: _STATE) -> float:
"""Cost function that sums squares of lengths of sequences.
Args:
state: Search state, not mutated.
Returns:
Cost which is minus the normalized quadratic sum of each linear
sequence section in the state. This ... | [
"def",
"_quadratic_sum_cost",
"(",
"self",
",",
"state",
":",
"_STATE",
")",
"->",
"float",
":",
"cost",
"=",
"0.0",
"total_len",
"=",
"float",
"(",
"len",
"(",
"self",
".",
"_c",
")",
")",
"seqs",
",",
"_",
"=",
"state",
"for",
"seq",
"in",
"seqs"... | Cost function that sums squares of lengths of sequences.
Args:
state: Search state, not mutated.
Returns:
Cost which is minus the normalized quadratic sum of each linear
sequence section in the state. This promotes single, long linear
sequence solutions and conv... | [
"Cost",
"function",
"that",
"sums",
"squares",
"of",
"lengths",
"of",
"sequences",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/google/line/placement/anneal.py#L88-L106 | train | Function that sums squares of lengths of sequences. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/google/line/placement/anneal.py | AnnealSequenceSearch._force_edges_active_move | def _force_edges_active_move(self, state: _STATE) -> _STATE:
"""Move function which repeats _force_edge_active_move a few times.
Args:
state: Search state, not mutated.
Returns:
New search state which consists of incremental changes of the
original state.
... | python | def _force_edges_active_move(self, state: _STATE) -> _STATE:
"""Move function which repeats _force_edge_active_move a few times.
Args:
state: Search state, not mutated.
Returns:
New search state which consists of incremental changes of the
original state.
... | [
"def",
"_force_edges_active_move",
"(",
"self",
",",
"state",
":",
"_STATE",
")",
"->",
"_STATE",
":",
"for",
"_",
"in",
"range",
"(",
"self",
".",
"_rand",
".",
"randint",
"(",
"1",
",",
"4",
")",
")",
":",
"state",
"=",
"self",
".",
"_force_edge_ac... | Move function which repeats _force_edge_active_move a few times.
Args:
state: Search state, not mutated.
Returns:
New search state which consists of incremental changes of the
original state. | [
"Move",
"function",
"which",
"repeats",
"_force_edge_active_move",
"a",
"few",
"times",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/google/line/placement/anneal.py#L108-L120 | train | Move function which repeats _force_edge_active_move a few times. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/google/line/placement/anneal.py | AnnealSequenceSearch._force_edge_active_move | def _force_edge_active_move(self, state: _STATE) -> _STATE:
"""Move which forces a random edge to appear on some sequence.
This move chooses random edge from the edges which do not belong to any
sequence and modifies state in such a way, that this chosen edge
appears on some sequence of... | python | def _force_edge_active_move(self, state: _STATE) -> _STATE:
"""Move which forces a random edge to appear on some sequence.
This move chooses random edge from the edges which do not belong to any
sequence and modifies state in such a way, that this chosen edge
appears on some sequence of... | [
"def",
"_force_edge_active_move",
"(",
"self",
",",
"state",
":",
"_STATE",
")",
"->",
"_STATE",
":",
"seqs",
",",
"edges",
"=",
"state",
"unused_edges",
"=",
"edges",
".",
"copy",
"(",
")",
"# List edges which do not belong to any linear sequence.",
"for",
"seq",... | Move which forces a random edge to appear on some sequence.
This move chooses random edge from the edges which do not belong to any
sequence and modifies state in such a way, that this chosen edge
appears on some sequence of the search state.
Args:
state: Search state, not mu... | [
"Move",
"which",
"forces",
"a",
"random",
"edge",
"to",
"appear",
"on",
"some",
"sequence",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/google/line/placement/anneal.py#L122-L152 | train | Move which forces a random edge to appear on some sequence. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/google/line/placement/anneal.py | AnnealSequenceSearch._force_edge_active | def _force_edge_active(self, seqs: List[List[GridQubit]], edge: EDGE,
sample_bool: Callable[[], bool]
) -> List[List[GridQubit]]:
"""Move which forces given edge to appear on some sequence.
Args:
seqs: List of linear sequences covering chi... | python | def _force_edge_active(self, seqs: List[List[GridQubit]], edge: EDGE,
sample_bool: Callable[[], bool]
) -> List[List[GridQubit]]:
"""Move which forces given edge to appear on some sequence.
Args:
seqs: List of linear sequences covering chi... | [
"def",
"_force_edge_active",
"(",
"self",
",",
"seqs",
":",
"List",
"[",
"List",
"[",
"GridQubit",
"]",
"]",
",",
"edge",
":",
"EDGE",
",",
"sample_bool",
":",
"Callable",
"[",
"[",
"]",
",",
"bool",
"]",
")",
"->",
"List",
"[",
"List",
"[",
"GridQ... | Move which forces given edge to appear on some sequence.
Args:
seqs: List of linear sequences covering chip.
edge: Edge to be activated.
sample_bool: Callable returning random bool.
Returns:
New list of linear sequences with given edge on some of the
s... | [
"Move",
"which",
"forces",
"given",
"edge",
"to",
"appear",
"on",
"some",
"sequence",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/google/line/placement/anneal.py#L154-L245 | train | Move which forces given edge to appear on some of the linear sequences. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/google/line/placement/anneal.py | AnnealSequenceSearch._create_initial_solution | def _create_initial_solution(self) -> _STATE:
"""Creates initial solution based on the chip description.
Initial solution is constructed in a greedy way.
Returns:
Valid search state.
"""
def extract_sequences() -> List[List[GridQubit]]:
"""Creates list of... | python | def _create_initial_solution(self) -> _STATE:
"""Creates initial solution based on the chip description.
Initial solution is constructed in a greedy way.
Returns:
Valid search state.
"""
def extract_sequences() -> List[List[GridQubit]]:
"""Creates list of... | [
"def",
"_create_initial_solution",
"(",
"self",
")",
"->",
"_STATE",
":",
"def",
"extract_sequences",
"(",
")",
"->",
"List",
"[",
"List",
"[",
"GridQubit",
"]",
"]",
":",
"\"\"\"Creates list of sequcenes for initial state.\n\n Returns:\n List of lis... | Creates initial solution based on the chip description.
Initial solution is constructed in a greedy way.
Returns:
Valid search state. | [
"Creates",
"initial",
"solution",
"based",
"on",
"the",
"chip",
"description",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/google/line/placement/anneal.py#L247-L297 | train | Creates an initial solution based on the chip description. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/google/line/placement/anneal.py | AnnealSequenceSearch._normalize_edge | def _normalize_edge(self, edge: EDGE) -> EDGE:
"""Gives unique representative of the edge.
Two edges are equivalent if they form an edge between the same nodes.
This method returns representative of this edge which can be compared
using equality operator later.
Args:
... | python | def _normalize_edge(self, edge: EDGE) -> EDGE:
"""Gives unique representative of the edge.
Two edges are equivalent if they form an edge between the same nodes.
This method returns representative of this edge which can be compared
using equality operator later.
Args:
... | [
"def",
"_normalize_edge",
"(",
"self",
",",
"edge",
":",
"EDGE",
")",
"->",
"EDGE",
":",
"def",
"lower",
"(",
"n",
":",
"GridQubit",
",",
"m",
":",
"GridQubit",
")",
"->",
"bool",
":",
"return",
"n",
".",
"row",
"<",
"m",
".",
"row",
"or",
"(",
... | Gives unique representative of the edge.
Two edges are equivalent if they form an edge between the same nodes.
This method returns representative of this edge which can be compared
using equality operator later.
Args:
edge: Edge to normalize.
Returns:
Norma... | [
"Gives",
"unique",
"representative",
"of",
"the",
"edge",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/google/line/placement/anneal.py#L299-L318 | train | Normalizes an edge to be unique and return it. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
quantumlib/Cirq | cirq/google/line/placement/anneal.py | AnnealSequenceSearch._choose_random_edge | def _choose_random_edge(self, edges: Set[EDGE]) -> Optional[EDGE]:
"""Picks random edge from the set of edges.
Args:
edges: Set of edges to pick from.
Returns:
Random edge from the supplied set, or None for empty set.
"""
if edges:
index = self._... | python | def _choose_random_edge(self, edges: Set[EDGE]) -> Optional[EDGE]:
"""Picks random edge from the set of edges.
Args:
edges: Set of edges to pick from.
Returns:
Random edge from the supplied set, or None for empty set.
"""
if edges:
index = self._... | [
"def",
"_choose_random_edge",
"(",
"self",
",",
"edges",
":",
"Set",
"[",
"EDGE",
"]",
")",
"->",
"Optional",
"[",
"EDGE",
"]",
":",
"if",
"edges",
":",
"index",
"=",
"self",
".",
"_rand",
".",
"randint",
"(",
"len",
"(",
"edges",
")",
")",
"for",
... | Picks random edge from the set of edges.
Args:
edges: Set of edges to pick from.
Returns:
Random edge from the supplied set, or None for empty set. | [
"Picks",
"random",
"edge",
"from",
"the",
"set",
"of",
"edges",
"."
] | 0827da80dd7880e5b923eb69407e980ed9bc0bd2 | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/google/line/placement/anneal.py#L320-L335 | train | Picks a random edge from the set of edges. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.