From 7bb5014685f70e68321499739c400da7d19b2a40 Mon Sep 17 00:00:00 2001 From: Coull Date: Tue, 26 Nov 2024 11:16:38 -0800 Subject: [PATCH] reformat code --- benchmark/benchmark.py | 22 +++++--------------- src/braket/simulator_v2/base_simulator_v2.py | 2 +- 2 files changed, 6 insertions(+), 18 deletions(-) diff --git a/benchmark/benchmark.py b/benchmark/benchmark.py index d8894ed..9d1dcec 100644 --- a/benchmark/benchmark.py +++ b/benchmark/benchmark.py @@ -69,11 +69,7 @@ def test_exact_shots(benchmark, device_id, nq, exact_results, circuit): exact_results in ("state_vector",) or nq > 10 ): pytest.skip() - if ( - device_id in ("braket_sv",) - and exact_results in ("density_matrix q[0], q[1]",) - and nq >= 17 - ): + if device_id in ("braket_sv",) and exact_results in ("density_matrix q[0], q[1]",) and nq >= 17: pytest.skip() result_type = exact_results oq3_prog = Program(source=circuit(nq, result_type)) @@ -86,9 +82,7 @@ def test_exact_shots(benchmark, device_id, nq, exact_results, circuit): @pytest.mark.parametrize("batch_size", batch_size) @pytest.mark.parametrize("exact_results", exact_shots_results) @pytest.mark.parametrize("circuit", generators) -def test_exact_shots_batched( - benchmark, device_id, nq, batch_size, exact_results, circuit -): +def test_exact_shots_batched(benchmark, device_id, nq, batch_size, exact_results, circuit): if device_id in ("braket_dm_v2", "braket_dm") and ( exact_results in ("state_vector,") or nq >= 5 ): @@ -100,9 +94,7 @@ def test_exact_shots_batched( result_type = exact_results oq3_prog = [Program(source=circuit(nq, result_type)) for _ in range(batch_size)] sim = LocalSimulator(device_id) - benchmark.pedantic( - run_sim_batch, args=(oq3_prog, sim, 0), iterations=5, warmup_rounds=1 - ) + benchmark.pedantic(run_sim_batch, args=(oq3_prog, sim, 0), iterations=5, warmup_rounds=1) shots = (100,) @@ -119,9 +111,7 @@ def test_nonzero_shots(benchmark, device_id, nq, shots, nonzero_shots_results, c result_type = nonzero_shots_results oq3_prog = Program(source=circuit(nq, result_type)) sim = LocalSimulator(device_id) - benchmark.pedantic( - run_sim, args=(oq3_prog, sim, shots), iterations=5, warmup_rounds=1 - ) + benchmark.pedantic(run_sim, args=(oq3_prog, sim, shots), iterations=5, warmup_rounds=1) del sim @@ -145,7 +135,5 @@ def test_nonzero_shots_batched( result_type = nonzero_shots_results oq3_prog = [Program(source=circuit(nq, result_type)) for _ in range(batch_size)] sim = LocalSimulator(device_id) - benchmark.pedantic( - run_sim_batch, args=(oq3_prog, sim, shots), iterations=5, warmup_rounds=1 - ) + benchmark.pedantic(run_sim_batch, args=(oq3_prog, sim, shots), iterations=5, warmup_rounds=1) del sim diff --git a/src/braket/simulator_v2/base_simulator_v2.py b/src/braket/simulator_v2/base_simulator_v2.py index e57c33c..0171604 100644 --- a/src/braket/simulator_v2/base_simulator_v2.py +++ b/src/braket/simulator_v2/base_simulator_v2.py @@ -42,7 +42,7 @@ def setup_julia() -> None: os.environ[k] = os.environ.get(k, default) import juliacall # noqa: PLC0415 - + jl = juliacall.Main jl.seval("using BraketSimulator, JSON3") stock_oq3 = """