Skip to content

Commit

Permalink
black formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
MarquessV committed Feb 21, 2023
1 parent 4bc4fa1 commit 1e75d92
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 19 deletions.
21 changes: 5 additions & 16 deletions pennylane_rigetti/qc.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,7 @@ def __init__(
raise ValueError("Number of shots must be a positive integer or None.")

if parallel and max_threads <= 0:
raise ValueError(
"max_threads must be set to a positive integer greater than 0"
)
raise ValueError("max_threads must be set to a positive integer greater than 0")

self._parallel = parallel
self._max_threads = max_threads
Expand Down Expand Up @@ -222,9 +220,7 @@ def apply(self, operations, **kwargs):
qubits = sorted(self.wiring.values())
ro = self.prog.declare("ro", "BIT", len(qubits))
used_qubits = self.prog.get_qubits(indices=True)
normalized_qubit_indices = {
wire: i for i, wire in enumerate(list(self.wiring.values()))
}
normalized_qubit_indices = {wire: i for i, wire in enumerate(list(self.wiring.values()))}
for qubit in used_qubits:
self.prog += MEASURE(qubit, ro[normalized_qubit_indices[qubit]])

Expand Down Expand Up @@ -266,10 +262,7 @@ def apply_parametric_operations(self, operations):
par.append(self._parameter_reference_map[parameter_string])
else:
for param in operation.data:
if (
getattr(param, "requires_grad", False)
and operation.name != "BasisState"
):
if getattr(param, "requires_grad", False) and operation.name != "BasisState":
# Using the idx for trainable parameter objects to specify the
# corresponding symbolic parameter
parameter_string = "theta" + str(id(param))
Expand All @@ -278,9 +271,7 @@ def apply_parametric_operations(self, operations):
# Create a new PyQuil memory reference and store it in the
# parameter reference map if it was not done so already
current_ref = self.prog.declare(parameter_string, "REAL")
self._parameter_reference_map[
parameter_string
] = current_ref
self._parameter_reference_map[parameter_string] = current_ref

# Store the numeric value bound to the symbolic parameter
self._parameter_map[parameter_string] = [param.unwrap()]
Expand Down Expand Up @@ -403,9 +394,7 @@ def generate_samples(self):
if self._batch_size is not None:
for i in range(self._batch_size):
for region, values in self._batched_parameter_map.items():
self._compiled_program.write_memory(
region_name=region, value=values[i]
)
self._compiled_program.write_memory(region_name=region, value=values[i])
samples = self.qc.run(self._compiled_program)
samples = self.extract_samples(samples)
results.append(samples)
Expand Down
4 changes: 1 addition & 3 deletions pennylane_rigetti/qpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,7 @@ def __init__(
self.calibrate_readout = calibrate_readout
self._skip_generate_samples = False

super().__init__(
device, wires=wires, shots=shots, active_reset=active_reset, **kwargs
)
super().__init__(device, wires=wires, shots=shots, active_reset=active_reset, **kwargs)

def compile(self) -> QuantumExecutable:
return self.qc.compile(self.prog, protoquil=True)
Expand Down

0 comments on commit 1e75d92

Please sign in to comment.