Skip to content

Commit

Permalink
split test into two
Browse files Browse the repository at this point in the history
  • Loading branch information
natestemen committed Nov 5, 2024
1 parent 961e743 commit 97b02dc
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions mitiq/lre/tests/test_layerwise_folding.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,27 @@
test_circuit1_with_measurements.append(ops.measure_each(*qreg1))


@pytest.mark.parametrize("circuit_type", SUPPORTED_PROGRAM_TYPES)
def test_multivariate_layerwise_scaling(circuit_type):
"""Ensure layer scaling works with all frontends."""
def test_multivariate_layerwise_scaling_num_circuits():
"""Ensure the correct number of circuits are generated."""
degree, fold_multiplier, num_chunks = 2, 2, 3
scaled_circuits = multivariate_layer_scaling(
test_circuit1, degree, fold_multiplier, num_chunks
)

depth = len(test_circuit1)
# number of circuit is `degree` + `depth` choose `degree`
assert len(scaled_circuits) == math.comb(degree + depth, degree)


@pytest.mark.parametrize("circuit_type", SUPPORTED_PROGRAM_TYPES)
def test_multivariate_layerwise_scaling_types(circuit_type):
"""Ensure layer scaling returns circuits of the correct type."""
circuit = convert_from_mitiq(test_circuit1, circuit_type.name)
degree, fold_multiplier, num_chunks = 2, 2, 3
scaled_circuits = multivariate_layer_scaling(
circuit, degree, fold_multiplier, num_chunks
)

# number of circuit is `degree` + `depth` choose `degree`
assert len(scaled_circuits) == math.comb(degree + depth, degree)
assert all(
isinstance(circuit, circuit_type.value) for circuit in scaled_circuits
)
Expand Down

0 comments on commit 97b02dc

Please sign in to comment.