pqcprep.resource_tools
Collection of functions relating to handling resources provided as part of the pqcprep package.
1""" 2Collection of functions relating to handling resources provided as part of the *pqcprep* package. 3""" 4import numpy as np 5from importlib.resources import as_file, files 6import os 7 8def load_data_H23(name): 9 """ 10 Load data corresponding to key results from [Hayes 2023](https://arxiv.org/pdf/2306.11073). 11 12 This can be useful to compare QCNN performance to the techniques used in the paper. 13 14 Arguments: 15 --- 16 - **name** : *str* 17 18 Name of the file to be loaded. Options are: 19 20 - `'mismatch_QGAN_12'` : mismatch after each epoch when training the QGAN with 12 layers 21 22 - `'mismatch_QGAN_20'` : mismatch after each epoch when training the QGAN with 20 layers 23 24 - `'amp_state_GR'` : statevector after amplitude preparation with the Grover-Rudolph algorithm 25 26 - `'amp_state_QGAN'` : statevector after amplitdude preparation with the QGAN 27 28 - `'psi_LPF_processed'` : phase function encoded via linear piecewise functions 29 30 - `'full_state_GR'` : full waveform (amplitude and phase) encoded via the Grover-Rudolh algorithm and linear piecewise functions 31 32 - `'full_state_QGAN'` : full waveform (amplitude and phase) encoded via the QGAN and linear piecewise functions 33 34 Returns: 35 --- 36 - **arr** : *array_like* 37 38 Array corresponding to the data specified in `name`. 39 40 """ 41 package="pqcprep" 42 resource="resources" 43 name_list =["mismatch_QGAN_12","mismatch_QGAN_20", "amp_state_GR", "amp_state_QGAN", "full_state_GR","full_state_QGAN", "psi_LPF_processed"] 44 45 if name in name_list: 46 with as_file(files(package).joinpath(os.path.join(resource, name +".npy"))) as path: 47 arr = np.load(path) 48 return arr 49 else: 50 raise FileNotFoundError('No such file. Options are "mismatch_QGAN_12","mismatch_QGAN_20", "amp_state_GR", "amp_state_QGAN", "full_state_GR","full_state_QGAN", "psi_LPF_processed".')
9def load_data_H23(name): 10 """ 11 Load data corresponding to key results from [Hayes 2023](https://arxiv.org/pdf/2306.11073). 12 13 This can be useful to compare QCNN performance to the techniques used in the paper. 14 15 Arguments: 16 --- 17 - **name** : *str* 18 19 Name of the file to be loaded. Options are: 20 21 - `'mismatch_QGAN_12'` : mismatch after each epoch when training the QGAN with 12 layers 22 23 - `'mismatch_QGAN_20'` : mismatch after each epoch when training the QGAN with 20 layers 24 25 - `'amp_state_GR'` : statevector after amplitude preparation with the Grover-Rudolph algorithm 26 27 - `'amp_state_QGAN'` : statevector after amplitdude preparation with the QGAN 28 29 - `'psi_LPF_processed'` : phase function encoded via linear piecewise functions 30 31 - `'full_state_GR'` : full waveform (amplitude and phase) encoded via the Grover-Rudolh algorithm and linear piecewise functions 32 33 - `'full_state_QGAN'` : full waveform (amplitude and phase) encoded via the QGAN and linear piecewise functions 34 35 Returns: 36 --- 37 - **arr** : *array_like* 38 39 Array corresponding to the data specified in `name`. 40 41 """ 42 package="pqcprep" 43 resource="resources" 44 name_list =["mismatch_QGAN_12","mismatch_QGAN_20", "amp_state_GR", "amp_state_QGAN", "full_state_GR","full_state_QGAN", "psi_LPF_processed"] 45 46 if name in name_list: 47 with as_file(files(package).joinpath(os.path.join(resource, name +".npy"))) as path: 48 arr = np.load(path) 49 return arr 50 else: 51 raise FileNotFoundError('No such file. Options are "mismatch_QGAN_12","mismatch_QGAN_20", "amp_state_GR", "amp_state_QGAN", "full_state_GR","full_state_QGAN", "psi_LPF_processed".')
Load data corresponding to key results from Hayes 2023.
This can be useful to compare QCNN performance to the techniques used in the paper.
Arguments:
name : str
Name of the file to be loaded. Options are:
'mismatch_QGAN_12': mismatch after each epoch when training the QGAN with 12 layers'mismatch_QGAN_20': mismatch after each epoch when training the QGAN with 20 layers'amp_state_GR': statevector after amplitude preparation with the Grover-Rudolph algorithm'amp_state_QGAN': statevector after amplitdude preparation with the QGAN'psi_LPF_processed': phase function encoded via linear piecewise functions'full_state_GR': full waveform (amplitude and phase) encoded via the Grover-Rudolh algorithm and linear piecewise functions'full_state_QGAN': full waveform (amplitude and phase) encoded via the QGAN and linear piecewise functions
Returns:
arr : array_like
Array corresponding to the data specified in
name.