Skip to content

Commit

Permalink
Refactor for commits that happened after initial refactor.
Browse files Browse the repository at this point in the history
  • Loading branch information
Nate Thompson committed Aug 15, 2021
1 parent 7599bf4 commit bb4f088
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cirq-aqt/cirq_aqt/aqt_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def get_op_string(op_obj: cirq.Operation) -> str:

# pylint: enable=missing-raises-doc
class AQTNoiseModel(cirq.NoiseModel):
"""A noise model for the AQT ion trap """
"""A noise model for the AQT ion trap"""

def __init__(self):
self.noise_op_dict = get_default_noise_dict()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ def estimate_single_qubit_readout_errors(
)


# TODO(#3388) Add documentation for Raises.
# pylint: disable=missing-raises-doc
def estimate_parallel_single_qubit_readout_errors(
sampler: 'cirq.Sampler',
*,
Expand Down Expand Up @@ -235,3 +237,6 @@ def estimate_parallel_single_qubit_readout_errors(
repetitions=repetitions,
timestamp=timestamp,
)


# pylint: enable=missing-raises-doc
6 changes: 4 additions & 2 deletions cirq-core/cirq/sim/act_on_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,8 @@ def swap(self, q1: 'cirq.Qid', q2: 'cirq.Qid', *, inplace=False):
otherwise.
Raises:
ValueError if the qubits are of different dimensionality."""
ValueError: If the qubits are of different dimensionality.
"""
if q1.dimension != q2.dimension:
raise ValueError(f'Cannot swap different dimensions: q1={q1}, q2={q2}')

Expand Down Expand Up @@ -189,7 +190,8 @@ def rename(self, q1: 'cirq.Qid', q2: 'cirq.Qid', *, inplace=False):
otherwise.
Raises:
ValueError if the qubits are of different dimensionality."""
ValueError: If the qubits are of different dimensionality.
"""
if q1.dimension != q2.dimension:
raise ValueError(f'Cannot rename to different dimensions: q1={q1}, q2={q2}')

Expand Down
3 changes: 3 additions & 0 deletions cirq-core/cirq/sim/simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -812,6 +812,8 @@ class SimulationTrialResult:
measurement gate.)
"""

# TODO(#3388) Add documentation for Raises.
# pylint: disable=missing-raises-doc
def __init__(
self,
params: study.ParamResolver,
Expand Down Expand Up @@ -843,6 +845,7 @@ def __init__(
self._final_step_result = final_step_result
self._final_simulator_state_cache = final_simulator_state

# pylint: enable=missing-raises-doc
@property
def _final_simulator_state(self):
if self._final_simulator_state_cache is None:
Expand Down
8 changes: 8 additions & 0 deletions cirq-core/cirq/work/observable_measurement.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,8 @@ def _to_sweep(param_tuples):
return to_sweep


# TODO(#3388) Add documentation for Raises.
# pylint: disable=missing-raises-doc
def _parse_checkpoint_options(
checkpoint: bool, checkpoint_fn: Optional[str], checkpoint_other_fn: Optional[str]
) -> Tuple[Optional[str], Optional[str]]:
Expand Down Expand Up @@ -409,6 +411,7 @@ def _parse_checkpoint_options(
return checkpoint_fn, checkpoint_other_fn


# pylint: enable=missing-raises-doc
def _needs_init_layer(grouped_settings: Dict[InitObsSetting, List[InitObsSetting]]) -> bool:
"""Helper function to go through init_states and determine if any of them need an
initialization layer of single-qubit gates."""
Expand All @@ -418,6 +421,8 @@ def _needs_init_layer(grouped_settings: Dict[InitObsSetting, List[InitObsSetting
return False


# TODO(#3388) Add documentation for Raises.
# pylint: disable=missing-raises-doc
def measure_grouped_settings(
circuit: 'cirq.Circuit',
grouped_settings: Dict[InitObsSetting, List[InitObsSetting]],
Expand Down Expand Up @@ -554,3 +559,6 @@ def measure_grouped_settings(
to_json(list(accumulators.values()), checkpoint_fn)

return list(accumulators.values())


# pylint: enable=missing-raises-doc
3 changes: 3 additions & 0 deletions cirq-google/cirq_google/calibration/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -1047,6 +1047,8 @@ def _make_zeta_chi_gamma_compensation(
return CircuitWithCalibration(compensated, compensated_moment_to_calibration)


# TODO(#3388) Add documentation for Raises.
# pylint: disable=missing-raises-doc
def _find_moment_zeta_chi_gamma_corrections(
moment: cirq.Moment,
characterization_index: Optional[int],
Expand Down Expand Up @@ -1129,6 +1131,7 @@ def _find_moment_zeta_chi_gamma_corrections(
return decompositions, decompositions_moment_to_calibration, other


# pylint: enable=missing-raises-doc
@dataclasses.dataclass(frozen=True)
class FSimPhaseCorrections:
"""Operations that compensate for zeta, chi and gamma angles of an approximate FSimGate gate.
Expand Down
3 changes: 3 additions & 0 deletions cirq-google/cirq_google/serialization/arg_func_langs.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,8 @@ def check_support(func_type: str) -> str:
raise ValueError(f'Unrecognized arg type: {type(value)}')


# TODO(#3388) Add documentation for Raises.
# pylint: disable=missing-raises-doc
def float_arg_from_proto(
arg_proto: v2.program_pb2.FloatArg,
*,
Expand Down Expand Up @@ -307,6 +309,7 @@ def arg_from_proto(
return None


# TODO(#3388) Add documentation for Raises.
def _arg_func_from_proto(
func: v2.program_pb2.ArgFunction,
*,
Expand Down
11 changes: 11 additions & 0 deletions cirq-google/cirq_google/serialization/circuit_serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ def __init__(
"""
self.gate_set_name = gate_set_name

# TODO(#3388) Add documentation for Raises.
# pylint: disable=missing-raises-doc
def serialize(
self,
program: cirq.Circuit,
Expand Down Expand Up @@ -82,6 +84,7 @@ def serialize(
)
return msg

# pylint: enable=missing-raises-doc
def _serialize_circuit(
self,
circuit: cirq.AbstractCircuit,
Expand Down Expand Up @@ -114,6 +117,8 @@ def _serialize_circuit(
raw_constants=raw_constants,
)

# TODO(#3388) Add documentation for Raises.
# pylint: disable=missing-raises-doc
def _serialize_gate_op(
self,
op: cirq.Operation,
Expand Down Expand Up @@ -254,6 +259,7 @@ def _serialize_gate_op(
raw_constants[tag.token] = msg.token_constant_index
return msg

# TODO(#3388) Add documentation for Raises.
def _serialize_circuit_op(
self,
op: cirq.CircuitOperation,
Expand Down Expand Up @@ -304,6 +310,7 @@ def _serialize_circuit_op(
raw_constants=raw_constants,
)

# TODO(#3388) Add documentation for Raises.
def deserialize(
self, proto: v2.program_pb2.Program, device: Optional[cirq.Device] = None
) -> cirq.Circuit:
Expand Down Expand Up @@ -359,6 +366,7 @@ def deserialize(

raise NotImplementedError('Program proto does not contain a circuit.')

# pylint: enable=missing-raises-doc
def _deserialize_circuit(
self,
circuit_proto: v2.program_pb2.Circuit,
Expand Down Expand Up @@ -391,6 +399,8 @@ def _deserialize_circuit(
moments.append(cirq.Moment(moment_ops))
return cirq.Circuit(moments)

# TODO(#3388) Add documentation for Raises.
# pylint: disable=missing-raises-doc
def _deserialize_gate_op(
self,
operation_proto: v2.program_pb2.Operation,
Expand Down Expand Up @@ -562,6 +572,7 @@ def _deserialize_gate_op(

return op

# pylint: enable=missing-raises-doc
def _deserialize_circuit_op(
self,
operation_proto: v2.program_pb2.CircuitOperation,
Expand Down
2 changes: 1 addition & 1 deletion cirq-pasqal/cirq_pasqal/pasqal_noise_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@


class PasqalNoiseModel(cirq.devices.NoiseModel):
"""A noise model for Pasqal neutral atom device """
"""A noise model for Pasqal neutral atom device"""

def __init__(self, device: cirq.devices.Device):
self.noise_op_dict = self.get_default_noise_dict()
Expand Down
6 changes: 6 additions & 0 deletions cirq-rigetti/cirq_rigetti/aspen_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,8 @@ def get_rigetti_qcs_aspen_device(
class OctagonalQubit(cirq.ops.Qid):
"""A cirq.Qid supporting Octagonal indexing."""

# TODO(#3388) Add documentation for Raises.
# pylint: disable=missing-raises-doc
def __init__(self, octagon_position: int):
r"""Initializes an `OctagonalQubit` using indices 0-7.
4 - 3
Expand All @@ -297,6 +299,7 @@ def __init__(self, octagon_position: int):
self._octagon_position = octagon_position
self.index = octagon_position

# pylint: enable=missing-raises-doc
@property
def octagon_position(self):
return self._octagon_position
Expand Down Expand Up @@ -476,6 +479,8 @@ def from_grid_qubit(grid_qubit: cirq.GridQubit) -> 'AspenQubit':
return AspenQubit.from_aspen_index(_grid_qubit_mapping[grid_qubit])
raise ValueError(f'{grid_qubit} is not convertible to Aspen qubit')

# TODO(#3388) Add documentation for Raises.
# pylint: disable=missing-raises-doc
@staticmethod
def from_named_qubit(qubit: cirq.NamedQubit) -> 'AspenQubit':
"""Converts `cirq.NamedQubit` to `AspenQubit`.
Expand All @@ -492,6 +497,7 @@ def from_named_qubit(qubit: cirq.NamedQubit) -> 'AspenQubit':
except ValueError:
raise UnsupportedQubit(f'Aspen devices only support named qubits by octagonal index')

# pylint: enable=missing-raises-doc
@staticmethod
def from_aspen_index(index: int) -> 'AspenQubit':
"""Initializes an `AspenQubit` at the given index. See `OctagonalQubit` to understand
Expand Down

0 comments on commit bb4f088

Please sign in to comment.