From 6fa56af336d74079341f580a80c0917d5b0575f1 Mon Sep 17 00:00:00 2001 From: Purva Thakre Date: Thu, 17 Oct 2024 13:52:35 -0500 Subject: [PATCH] make private function public --- mitiq/lre/inference/multivariate_richardson.py | 6 +++--- mitiq/lre/multivariate_scaling/layerwise_folding.py | 4 ++-- mitiq/lre/tests/test_layerwise_folding.py | 12 ++++++------ 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/mitiq/lre/inference/multivariate_richardson.py b/mitiq/lre/inference/multivariate_richardson.py index 00e3f56707..0b3d47d906 100644 --- a/mitiq/lre/inference/multivariate_richardson.py +++ b/mitiq/lre/inference/multivariate_richardson.py @@ -16,7 +16,7 @@ from numpy.typing import NDArray from mitiq.lre.multivariate_scaling.layerwise_folding import ( - _get_scale_factor_vectors, + get_scale_factor_vectors, ) @@ -93,7 +93,7 @@ def sample_matrix( if fold_multiplier < 1: raise ValueError("Fold multiplier must be greater than or equal to 1.") - scale_factor_vectors = _get_scale_factor_vectors( + scale_factor_vectors = get_scale_factor_vectors( input_circuit, degree, fold_multiplier, num_chunks ) num_layers = len(scale_factor_vectors[0]) @@ -156,7 +156,7 @@ def multivariate_richardson_coefficients( input_circuit, degree, fold_multiplier, num_chunks ) num_layers = len( - _get_scale_factor_vectors( + get_scale_factor_vectors( input_circuit, degree, fold_multiplier, num_chunks ) ) diff --git a/mitiq/lre/multivariate_scaling/layerwise_folding.py b/mitiq/lre/multivariate_scaling/layerwise_folding.py index 9bd883fca2..5c5a86a278 100644 --- a/mitiq/lre/multivariate_scaling/layerwise_folding.py +++ b/mitiq/lre/multivariate_scaling/layerwise_folding.py @@ -89,7 +89,7 @@ def _get_chunks( ] -def _get_scale_factor_vectors( +def get_scale_factor_vectors( input_circuit: Circuit, degree: int, fold_multiplier: int, @@ -188,7 +188,7 @@ def multivariate_layer_scaling( circuit_copy = deepcopy(input_circuit) terminal_measurements = _pop_measurements(circuit_copy) - scaling_pattern = _get_scale_factor_vectors( + scaling_pattern = get_scale_factor_vectors( circuit_copy, degree, fold_multiplier, num_chunks ) diff --git a/mitiq/lre/tests/test_layerwise_folding.py b/mitiq/lre/tests/test_layerwise_folding.py index b1870450d8..edf5af9286 100644 --- a/mitiq/lre/tests/test_layerwise_folding.py +++ b/mitiq/lre/tests/test_layerwise_folding.py @@ -14,7 +14,7 @@ from mitiq.lre.multivariate_scaling.layerwise_folding import ( _get_chunks, _get_num_layers_without_measurements, - _get_scale_factor_vectors, + get_scale_factor_vectors, multivariate_layer_scaling, ) @@ -215,11 +215,11 @@ def test_layers_with_chunking(): ), ], ) -def test_get_scale_factor_vectors_no_chunking( +def testget_scale_factor_vectors_no_chunking( test_input, degree, test_fold_multiplier, expected_scale_factor_vectors ): """Verifies vectors of scale factors are calculated accurately.""" - calculated_scale_factor_vectors = _get_scale_factor_vectors( + calculated_scale_factor_vectors = get_scale_factor_vectors( test_input, degree, test_fold_multiplier ) @@ -234,11 +234,11 @@ def test_get_scale_factor_vectors_no_chunking( (test_circuit1, 2, 3, 2, 6), ], ) -def test_get_scale_factor_vectors_with_chunking( +def testget_scale_factor_vectors_with_chunking( test_input, degree, test_fold_multiplier, test_chunks, expected_size ): """Verifies vectors of scale factors are calculated accurately.""" - calculated_scale_factor_vectors = _get_scale_factor_vectors( + calculated_scale_factor_vectors = get_scale_factor_vectors( test_input, degree, test_fold_multiplier, test_chunks ) @@ -270,7 +270,7 @@ def test_invalid_num_chunks(test_input, num_chunks, error_msg): """Ensures that the number of intended chunks in the input circuit raises an error for an invalid value.""" with pytest.raises(ValueError, match=error_msg): - _get_scale_factor_vectors(test_input, 2, 2, num_chunks) + get_scale_factor_vectors(test_input, 2, 2, num_chunks) @pytest.mark.parametrize(