Skip to content

Commit

Permalink
Fixing a bunch of typos (#3252)
Browse files Browse the repository at this point in the history
  • Loading branch information
balopat authored Aug 20, 2020
1 parent 826db47 commit ac21df5
Show file tree
Hide file tree
Showing 47 changed files with 110 additions and 108 deletions.
2 changes: 1 addition & 1 deletion cirq/contrib/noise_models/noise_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ def simple_noise_from_calibration_metrics(calibration: engine.Calibration,
Args:
calibration: a Calibration object (cirq/google/engine/calibration.py).
This object can be retrived from the engine by calling
This object can be retrieved from the engine by calling
'get_latest_calibration()' or 'get_calibration()' using the ID of
the target processor.
depol_noise: Enables per-gate depolarization if True.
Expand Down
2 changes: 1 addition & 1 deletion cirq/contrib/qasm_import/_lexer_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def test_qelib_inc():
assert token.value == 'include "qelib1.inc";'


def test_measurment():
def test_measurement():
lexer = QasmLexer()
lexer.input("measure q -> c;")
token = lexer.token()
Expand Down
2 changes: 1 addition & 1 deletion cirq/contrib/quantum_volume/quantum_volume_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def test_sample_heavy_set_with_parity():
# Construct a result that returns [1, 0, 1, 0] for the physical qubit
# measurement, and [0, 1, 1, 0] for the ancilla qubit measurement. The first
# bitstring "10" is valid and heavy. The second "01" is valid and not
# heavy. The third and fourth bitstraings "11" and "00" are not valid and
# heavy. The third and fourth bitstrings "11" and "00" are not valid and
# dropped.
result = cirq.TrialResult.from_single_parameter_set(
params=cirq.ParamResolver({}),
Expand Down
2 changes: 1 addition & 1 deletion cirq/contrib/svg/svg.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def _fit_vertical(tdd: 'cirq.TextDiagramDrawer',
well-spaced SVG coordinates.
The eagle eyed coder may notice that this function is very
similar to _fit_horizonal. That function was written first
similar to _fit_horizontal. That function was written first
because horizontal spacing is very important for being able
to see all the gates but vertical spacing is just for aesthetics.
It wasn't until this function was written that I (mpharrigan)
Expand Down
2 changes: 1 addition & 1 deletion cirq/experiments/single_qubit_readout_calibration.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def estimate_single_qubit_readout_errors(
Returns:
A SingleQubitReadoutCalibrationResult storing the readout error
probabilities as well as the number of repetitions used to estimate
the probabilties. Also stores a timestamp indicating the time when
the probabilities. Also stores a timestamp indicating the time when
data was finished being collected from the sampler.
"""
qubits = list(qubits)
Expand Down
8 changes: 4 additions & 4 deletions cirq/google/api/v2/results.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,10 @@ def _trial_sweep_from_proto(
Args:
msg: v2 Result message to convert.
measure_map: A mapping of measurement keys to a mesurement configuration
containing qubit ordering. If no measurement config is provided,
then all results will be returned in the order specified within the
result.
measure_map: A mapping of measurement keys to a measurement
configuration containing qubit ordering. If no measurement config is
provided, then all results will be returned in the order specified
within the result.
Returns:
A list containing a list of trial results for the sweep.
Expand Down
4 changes: 2 additions & 2 deletions cirq/google/devices/serializable_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def __init__(
def with_can_serialize_predicate(
self, can_serialize_predicate: Callable[['cirq.Operation'], bool]
) -> '_GateDefinition':
"""Creates a new _GateDefintion as a copy of the existing definition
"""Creates a new _GateDefinition as a copy of the existing definition
but with a new with_can_serialize_predicate. This is useful if multiple
definitions exist for the same gate, but with different conditions.
Expand Down Expand Up @@ -120,7 +120,7 @@ def from_proto(
into cirq Gates.
"""

# Store target sets, since they are refered to by name later
# Store target sets, since they are referred to by name later
allowed_targets: Dict[str, Set[Tuple['cirq.Qid', ...]]] = {}
permutation_ids: Set[str] = set()
for ts in proto.valid_targets:
Expand Down
2 changes: 1 addition & 1 deletion cirq/google/devices/serializable_device_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def test_duration_of():
assert foxtail.duration_of(cirq.H(valid_qubit1))


def test_assymetric_gate():
def test_asymmetric_gate():
spec = device_pb2.DeviceSpecification()
for row in range(5):
for col in range(2):
Expand Down
4 changes: 2 additions & 2 deletions cirq/google/line/placement/anneal.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ def _force_edge_active(self, seqs: List[List[GridQubit]], edge: EDGE,
seqs.append(part[0][other[c0]])
seqs.append(part[1][other[c1]])
else:
# Swap nodes so that n0 always preceeds n1 on sequence.
# Swap nodes so that n0 always precedes n1 on sequence.
if j0 > j1:
j0, j1 = j1, j0
n0, n1 = n1, n0
Expand Down Expand Up @@ -252,7 +252,7 @@ def _create_initial_solution(self) -> _STATE:
"""

def extract_sequences() -> List[List[GridQubit]]:
"""Creates list of sequcenes for initial state.
"""Creates list of sequences for initial state.
Returns:
List of lists of sequences constructed on the chip.
Expand Down
4 changes: 2 additions & 2 deletions cirq/google/line/placement/greedy.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
class GreedySequenceSearch:
"""Base class for greedy search heuristics.
Specialized greedy heuristics should implement abstrace _sequence_search
Specialized greedy heuristics should implement abstract _sequence_search
method.
"""

Expand Down Expand Up @@ -108,7 +108,7 @@ def _sequence_search(self, start: GridQubit,
sequences that begin and end on this qubit are searched for.
Args:
start: The first qubit, where search should be trigerred from.
start: The first qubit, where search should be triggered from.
current: Previously found linear sequence, which qubits are
forbidden to use during the search.
Expand Down
4 changes: 2 additions & 2 deletions cirq/google/optimizers/convert_to_sycamore_gates.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ def decompose_phased_iswap_into_syc_precomputed(theta: float, a: ops.Qid,
This should only be called if the Gate has a phase_exponent of .25. If the
gate has an exponent of 1, decompose_phased_iswap_into_syc should be used
instead. Converting PhasedISwap gates to Sycamore is not supported if
neither of these constraints are satsified.
neither of these constraints are satisfied.
This synthesize a PhasedISwap in terms of four sycamore gates. This
compilation converts the gate into a circuit involving two CZ gates, which
Expand Down Expand Up @@ -510,7 +510,7 @@ def cphase(theta: float, q0: ops.Qid, q1: ops.Qid) -> ops.OP_TREE:
q0: First qubit id to operate on
q1: Second qubit id to operate on
returns:
a cirq program implementating cphase
a cirq program implementing cphase
"""
yield rzz(-theta / 4, q0, q1)
yield ops.rz(theta / 2).on(q0)
Expand Down
2 changes: 1 addition & 1 deletion cirq/google/optimizers/optimize_for_sycamore.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def optimized_for_sycamore(
Uses a set of optimizers that will compile to the proper gateset for the
device (xmon, sqrt_iswap, or sycamore gates) and then use optimizers to
compresss the gate depth down as much as is easily algorithmically possible
compress the gate depth down as much as is easily algorithmically possible
by merging rotations, ejecting Z gates, etc.
Args:
Expand Down
2 changes: 1 addition & 1 deletion cirq/google/serializable_gate_set_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ def test_serialize_deserialize_op_subclass():
'id': '1_1'
}]
})
# cirq.X is a sublcass of XPowGate.
# cirq.X is a subclass of XPowGate.
assert proto == MY_GATE_SET.serialize_op(cirq.X(q0))
assert MY_GATE_SET.deserialize_op(proto) == cirq.X(q0)

Expand Down
2 changes: 1 addition & 1 deletion cirq/linalg/transformations_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ def test_sub_state_vector_non_kron():

def test_sub_state_vector_invalid_inputs():

# State cannot be expressed as a seperable pure state.
# State cannot be expressed as a separable pure state.
with pytest.raises(ValueError, match='7'):
cirq.sub_state_vector(np.arange(7), [1, 2], atol=1e-8)

Expand Down
2 changes: 1 addition & 1 deletion cirq/ops/clifford_gate_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ def _test(clifford_gate):
_test(cirq.SingleQubitCliffordGate.X_nsqrt)


def test_from_untary_with_phase_shift():
def test_from_unitary_with_phase_shift():
u = np.exp(0.42j) * cirq.unitary(cirq.SingleQubitCliffordGate.Y_sqrt)
gate = cirq.SingleQubitCliffordGate.from_unitary(u)

Expand Down
2 changes: 1 addition & 1 deletion cirq/ops/gate_operation_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def test_gate_operation_eq():

@cirq.value_equality
class PairGate(cirq.Gate, cirq.InterchangeableQubitsGate):
"""Interchangeable substes."""
"""Interchangeable subsets."""

def __init__(self, num_qubits):
self._num_qubits = num_qubits
Expand Down
2 changes: 1 addition & 1 deletion cirq/ops/pauli_string.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
Each Pauli operation can be specified as a cirq object (e.g. `cirq.X`) or as
a string (e.g. `"X"`) or as an integer where 0=I, 1=X, 2=Y, 3=Z.
Collections of Pauli operations are recrusively multiplied into a single
Collections of Pauli operations are recursively multiplied into a single
Pauli string.
""")

Expand Down
2 changes: 1 addition & 1 deletion cirq/ops/two_qubit_diagonal_gate.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Creates the gate instrance for a two qubit diagonal gate.
"""Creates the gate instance for a two qubit diagonal gate.
The gate is used to create a 4x4 matrix with the diagonal elements
passed as a list.
Expand Down
2 changes: 1 addition & 1 deletion cirq/optimizers/cphase_to_fsim.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def decompose_cphase_into_two_fsim(
φ = fsim_gate.phi,
δ = -π * cphase_gate.exponent.
Note that the gate parametrizations are non-injective. For the
Note that the gate parameterizations are non-injective. For the
decomposition to be feasible it is sufficient that one of the
parameter values which correspond to the provided gate satisfies
the constraints. This function will find and use the appropriate
Expand Down
2 changes: 1 addition & 1 deletion cirq/optimizers/expand_composite_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def generator(depth):
assert_equal_mod_empty(expected, circuit)


def test_nonrecursive_expansion():
def test_non_recursive_expansion():
qubits = [cirq.NamedQubit(s) for s in 'xy']
no_decomp = lambda op: (isinstance(op, cirq.GateOperation) and
op.gate == cirq.ISWAP)
Expand Down
2 changes: 1 addition & 1 deletion cirq/optimizers/synchronize_terminal_measurements.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
class SynchronizeTerminalMeasurements():
"""Move measurements to the end of the circuit.
Move all measurements in a circuit to the final moment if it can accomodate
Move all measurements in a circuit to the final moment if it can accommodate
them (without overlapping with other operations). If
self._after_other_operations is true then a new moment will be added to the
end of the circuit containing all the measurements that should be brought
Expand Down
40 changes: 20 additions & 20 deletions cirq/protocols/apply_channel_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,9 @@ def err_str(buf_num_str):
return result

# Fallback to using the object's `_channel_` matrices.
krauss = channel(val, None)
if krauss is not None:
return _apply_krauss(krauss, args)
kraus = channel(val, None)
if kraus is not None:
return _apply_kraus(kraus, args)

# Don't know how to apply channel. Fallback to specified default behavior.
if default is not RaiseTypeErrorIfNotProvided:
Expand Down Expand Up @@ -279,58 +279,58 @@ def _apply_unitary(val: Any, args: 'ApplyChannelArgs') -> Optional[np.ndarray]:
return right_result


def _apply_krauss(krauss: Union[Tuple[np.ndarray], Sequence[Any]],
args: 'ApplyChannelArgs') -> np.ndarray:
def _apply_kraus(kraus: Union[Tuple[np.ndarray], Sequence[Any]],
args: 'ApplyChannelArgs') -> np.ndarray:
"""Directly apply the kraus operators to the target tensor."""
# Initialize output.
args.out_buffer[:] = 0
# Stash initial state into buffer0.
np.copyto(dst=args.auxiliary_buffer0, src=args.target_tensor)

# Special case for single-qubit operations.
if len(args.left_axes) == 1 and krauss[0].shape == (2, 2):
return _apply_krauss_single_qubit(krauss, args)
if len(args.left_axes) == 1 and kraus[0].shape == (2, 2):
return _apply_kraus_single_qubit(kraus, args)
# Fallback to np.einsum for the general case.
return _apply_krauss_multi_qubit(krauss, args)
return _apply_kraus_multi_qubit(kraus, args)


def _apply_krauss_single_qubit(krauss: Union[Tuple[Any], Sequence[Any]],
args: 'ApplyChannelArgs') -> np.ndarray:
def _apply_kraus_single_qubit(kraus: Union[Tuple[Any], Sequence[Any]],
args: 'ApplyChannelArgs') -> np.ndarray:
"""Use slicing to apply single qubit channel. Only for two-level qubits."""
zero_left = linalg.slice_for_qubits_equal_to(args.left_axes, 0)
one_left = linalg.slice_for_qubits_equal_to(args.left_axes, 1)
zero_right = linalg.slice_for_qubits_equal_to(args.right_axes, 0)
one_right = linalg.slice_for_qubits_equal_to(args.right_axes, 1)
for krauss_op in krauss:
for kraus_op in kraus:
np.copyto(dst=args.target_tensor, src=args.auxiliary_buffer0)
linalg.apply_matrix_to_slices(args.target_tensor,
krauss_op, [zero_left, one_left],
kraus_op, [zero_left, one_left],
out=args.auxiliary_buffer1)
# No need to transpose as we are acting on the tensor
# representation of matrix, so transpose is done for us.
linalg.apply_matrix_to_slices(args.auxiliary_buffer1,
np.conjugate(krauss_op),
np.conjugate(kraus_op),
[zero_right, one_right],
out=args.target_tensor)
args.out_buffer += args.target_tensor
return args.out_buffer


def _apply_krauss_multi_qubit(krauss: Union[Tuple[Any], Sequence[Any]],
args: 'ApplyChannelArgs') -> np.ndarray:
def _apply_kraus_multi_qubit(kraus: Union[Tuple[Any], Sequence[Any]],
args: 'ApplyChannelArgs') -> np.ndarray:
"""Use numpy's einsum to apply a multi-qubit channel."""
qid_shape = tuple(args.target_tensor.shape[i] for i in args.left_axes)
for krauss_op in krauss:
for kraus_op in kraus:
np.copyto(dst=args.target_tensor, src=args.auxiliary_buffer0)
krauss_tensor = np.reshape(krauss_op.astype(args.target_tensor.dtype),
qid_shape * 2)
linalg.targeted_left_multiply(krauss_tensor,
kraus_tensor = np.reshape(kraus_op.astype(args.target_tensor.dtype),
qid_shape * 2)
linalg.targeted_left_multiply(kraus_tensor,
args.target_tensor,
args.left_axes,
out=args.auxiliary_buffer1)
# No need to transpose as we are acting on the tensor
# representation of matrix, so transpose is done for us.
linalg.targeted_left_multiply(np.conjugate(krauss_tensor),
linalg.targeted_left_multiply(np.conjugate(kraus_tensor),
args.auxiliary_buffer1,
args.right_axes,
out=args.target_tensor)
Expand Down
10 changes: 5 additions & 5 deletions cirq/protocols/apply_channel_protocol_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,17 @@ def _apply_channel_(self, args: cirq.ApplyChannelArgs):
one_right = cirq.slice_for_qubits_equal_to(args.right_axes, 1)
args.out_buffer[:] = 0
np.copyto(dst=args.auxiliary_buffer0, src=args.target_tensor)
for krauss_op in [
for kraus_op in [
np.sqrt(0.5) * np.eye(2, dtype=np.complex128),
np.sqrt(0.5) * x
]:
np.copyto(dst=args.target_tensor, src=args.auxiliary_buffer0)
cirq.apply_matrix_to_slices(args.target_tensor,
krauss_op, [zero_left, one_left],
kraus_op, [zero_left, one_left],
out=args.auxiliary_buffer1)

cirq.apply_matrix_to_slices(args.auxiliary_buffer1,
np.conjugate(krauss_op),
np.conjugate(kraus_op),
[zero_right, one_right],
out=args.target_tensor)
args.out_buffer += args.target_tensor
Expand Down Expand Up @@ -311,7 +311,7 @@ def _apply_unitary_(self, args: cirq.ApplyUnitaryArgs) -> np.ndarray:

def test_apply_channel_apply_unitary_not_implemented():

class ApplyUnitaryNotImplemeneted:
class ApplyUnitaryNotImplemented:

def _apply_unitary_(self, args: cirq.ApplyUnitaryArgs):
return NotImplemented
Expand All @@ -320,7 +320,7 @@ def _apply_unitary_(self, args: cirq.ApplyUnitaryArgs):
out_buf, aux_buf0, aux_buf1 = make_buffers((2, 2, 2, 2), dtype=rho.dtype)

with pytest.raises(TypeError):
cirq.apply_channel(ApplyUnitaryNotImplemeneted(),
cirq.apply_channel(ApplyUnitaryNotImplemented(),
args=cirq.ApplyChannelArgs(
target_tensor=rho,
left_axes=[1],
Expand Down
2 changes: 1 addition & 1 deletion cirq/protocols/apply_mixture_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def __init__(self,
upon.
right_axes: Which axes to multiply the right action of the mixture
upon. If provided we will assume `target_tensor` is a density
matrix, otherwise it will be assuemd `target_tensor` is a
matrix, otherwise it will be assumed `target_tensor` is a
state vector.
"""
self.target_tensor = target_tensor
Expand Down
Loading

0 comments on commit ac21df5

Please sign in to comment.