3 Created on Fri Jun 26 14:42:56 2020 4 Copyright 2020 Peter Rakyta, Ph.D. 6 Licensed under the Apache License, Version 2.0 (the "License"); 7 you may not use this file except in compliance with the License. 8 You may obtain a copy of the License at 10 http://www.apache.org/licenses/LICENSE-2.0 12 Unless required by applicable law or agreed to in writing, software 13 distributed under the License is distributed on an "AS IS" BASIS, 14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 See the License for the specific language governing permissions and 16 limitations under the License. 18 You should have received a copy of the GNU General Public License 19 along with this program. If not, see http://www.gnu.org/licenses/. 21 @author: Peter Rakyta, Ph.D. 29 from scipy.stats
import unitary_group
34 from mpi4py
import MPI
36 except ModuleNotFoundError:
46 parameters = np.zeros(num_of_parameters)
50 num_of_adaptive_layers =
int(qbit_num*(qbit_num-1)/2 * levels)
52 parameters[0:qbit_num*3] = np.random.rand(qbit_num*3)*2*np.pi
58 nontrivial_adaptive_layers = np.zeros( (num_of_adaptive_layers ))
60 for layer_idx
in range(num_of_adaptive_layers) :
62 nontrivial_adaptive_layer = random.randint(0,1)
63 nontrivial_adaptive_layers[layer_idx] = nontrivial_adaptive_layer
65 if (nontrivial_adaptive_layer) :
68 start_idx = qbit_num*3 + layer_idx*7
70 end_idx = start_idx + 7
71 parameters[start_idx:end_idx] = np.random.rand(7)*2*np.pi
76 return parameters, nontrivial_adaptive_layers
80 """This is a test class of the python iterface to the decompsition classes of the QGD package""" 84 This method is called by pytest. 85 Test to create an instance of class N_Qubit_Decomposition. 96 matrix_size = pow(2, qbit_num )
105 chanels, nontrivial_adaptive_layers = nn_class.get_NN_Chanels( qbit_num=qbit_num, levels=levels, samples_num=4 )
def create_randomized_parameters(num_of_parameters, qbit_num, levels)
Call to construct random parameter, with limited number of non-trivial adaptive layers.
def test_get_nn_chanels(self)