Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update black[jupyter] requirement from ~=23.1 to ~=24.1 #472

Merged
merged 3 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions circuit_knitting/cutting/cutqc/dynamic_definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,11 +350,11 @@ def _merge_state_into_bins_parallel(
subcircuit_entry_id = subcircuit_instances[subcircuit_idx][
subcircuit_entry_init_meas
]
merged_subcircuit_entry_probs[subcircuit_idx][
subcircuit_entry_id
] = _merge_prob_vector(
subcircuit_entry_probs[subcircuit_idx][subcircuit_entry_id],
dd_schedule["subcircuit_state"][subcircuit_idx],
merged_subcircuit_entry_probs[subcircuit_idx][subcircuit_entry_id] = (
_merge_prob_vector(
subcircuit_entry_probs[subcircuit_idx][subcircuit_entry_id],
dd_schedule["subcircuit_state"][subcircuit_idx],
)
)
return merged_subcircuit_entry_probs

Expand Down Expand Up @@ -404,9 +404,9 @@ def _merge_states_into_bins(
rank_merged_subcircuit_entry_probs = workers_merge_subcircuit_entry_probs[rank]
for subcircuit_idx in rank_merged_subcircuit_entry_probs:
if subcircuit_idx not in merged_subcircuit_entry_probs:
merged_subcircuit_entry_probs[
subcircuit_idx
] = rank_merged_subcircuit_entry_probs[subcircuit_idx]
merged_subcircuit_entry_probs[subcircuit_idx] = (
rank_merged_subcircuit_entry_probs[subcircuit_idx]
)
else:
merged_subcircuit_entry_probs[subcircuit_idx].update(
rank_merged_subcircuit_entry_probs[subcircuit_idx]
Expand Down Expand Up @@ -474,9 +474,9 @@ def read_dd_bins(
["0", "1"], repeat=num_merged
):
for merged_qubit_ctr in range(num_merged):
binary_full_state[
merged_qubit_indices[merged_qubit_ctr]
] = binary_merged_state[merged_qubit_ctr]
binary_full_state[merged_qubit_indices[merged_qubit_ctr]] = (
binary_merged_state[merged_qubit_ctr]
)
full_state = "".join(binary_full_state)[::-1]
full_state_idx = int(full_state, 2)
reconstructed_prob[full_state_idx] = average_state_prob
Expand Down
30 changes: 16 additions & 14 deletions circuit_knitting/cutting/cutqc/mip_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,12 @@ def _add_variables(self) -> None:
for subcircuit in range(self.num_subcircuit):
self.subcircuit_counter[subcircuit] = {}

self.subcircuit_counter[subcircuit][
"original_input"
] = self.model.integer_var(
lb=0,
ub=self.max_subcircuit_width,
name="original_input_%d" % subcircuit,
self.subcircuit_counter[subcircuit]["original_input"] = (
self.model.integer_var(
lb=0,
ub=self.max_subcircuit_width,
name="original_input_%d" % subcircuit,
)
)
self.subcircuit_counter[subcircuit]["rho"] = self.model.integer_var(
lb=0, ub=self.max_subcircuit_width, name="rho_%d" % subcircuit
Expand All @@ -162,10 +162,12 @@ def _add_variables(self) -> None:
lb=0.1, ub=self.max_subcircuit_size, name="size_%d" % subcircuit
)
if self.max_subcircuit_cuts is not None:
self.subcircuit_counter[subcircuit][
"num_cuts"
] = self.model.integer_var(
lb=0.1, ub=self.max_subcircuit_cuts, name="num_cuts_%d" % subcircuit
self.subcircuit_counter[subcircuit]["num_cuts"] = (
self.model.integer_var(
lb=0.1,
ub=self.max_subcircuit_cuts,
name="num_cuts_%d" % subcircuit,
)
)

self.subcircuit_counter[subcircuit]["rho_qubit_product"] = []
Expand All @@ -189,10 +191,10 @@ def _add_variables(self) -> None:
if subcircuit > 0:
lb = 0
ub = self.num_qubits + 2 * self.max_cuts + 1
self.subcircuit_counter[subcircuit][
"build_cost_exponent"
] = self.model.integer_var(
lb=lb, ub=ub, name="build_cost_exponent_%d" % subcircuit
self.subcircuit_counter[subcircuit]["build_cost_exponent"] = (
self.model.integer_var(
lb=lb, ub=ub, name="build_cost_exponent_%d" % subcircuit
)
)

def _add_constraints(self) -> None:
Expand Down
4 changes: 1 addition & 3 deletions circuit_knitting/cutting/cutqc/wire_cutting.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,7 @@ def reconstruct_dd_full_distribution(
return reconstructed_prob


def _generate_metadata(
cuts: dict[str, Any]
) -> tuple[
def _generate_metadata(cuts: dict[str, Any]) -> tuple[
list[dict[int, int]],
dict[int, dict[tuple[str, str], tuple[int, Sequence[tuple[int, int]]]]],
dict[int, dict[tuple[tuple[str, ...], tuple[Any, ...]], int]],
Expand Down
6 changes: 3 additions & 3 deletions circuit_knitting/cutting/cutqc/wire_cutting_evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,9 +389,9 @@ def _run_subcircuit_batch(
mutated_subcircuit_instance_idx = subcircuit_instance[
(init_meas[0], meas)
]
subcircuit_instance_probs[
mutated_subcircuit_instance_idx
] = measured_prob
subcircuit_instance_probs[mutated_subcircuit_instance_idx] = (
measured_prob
)
unique_subcircuit_check[mutated_subcircuit_instance_idx] = True

return subcircuit_instance_probs
6 changes: 3 additions & 3 deletions circuit_knitting/cutting/cutting_experiments.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,9 @@ def generate_cutting_experiments(
subexperiments_dict[label] = pass_manager.run(subexperiments)

# If the input was a single quantum circuit, return the subexperiments as a list
subexperiments_out: list[QuantumCircuit] | dict[
Hashable, list[QuantumCircuit]
] = dict(subexperiments_dict)
subexperiments_out: list[QuantumCircuit] | dict[Hashable, list[QuantumCircuit]] = (
dict(subexperiments_dict)
)
assert isinstance(subexperiments_out, dict)
if isinstance(circuits, QuantumCircuit):
assert len(subexperiments_out.keys()) == 1
Expand Down
2 changes: 1 addition & 1 deletion circuit_knitting/forging/cholesky_decomposition.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ def _get_fermionic_ops_with_cholesky(
occupied_orbitals_to_reduce: np.ndarray | None = None,
virtual_orbitals_to_reduce: np.ndarray | None = None,
epsilon_cholesky: float = 1e-10,
) -> tuple[SparsePauliOp, list[SparsePauliOp], float, np.ndarray, np.ndarray,]:
) -> tuple[SparsePauliOp, list[SparsePauliOp], float, np.ndarray, np.ndarray]:
r"""
Decompose the Hamiltonian operators into a form appropriate for entanglement forging.

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ nbtest = [
]
style = [
"autoflake==2.2.1",
"black[jupyter]~=23.1",
"black[jupyter]~=24.1",
"ruff>=0.0.246",
"nbqa>=1.6.0",
]
Expand Down