LLY-DML is part of the LILY project and is a Quantum Machine Learning model. It uses so-called L-Gates. These gates are Machine Learning gates that modify their state based on an input to map to a desired state of an input.
The extended test class includes comprehensive tests for all methods of the Circuit class. Each test function is designed to validate the functionality of the respective method under various conditions, including the verification of success codes and error codes.
1. Test Function: read_data
Description:
Executes the read_data method.
Checks if a success message is returned.
Verifies that qubits and depth are correctly set and not null.
Checks the structure and dimensions of activation_matrices and training_matrices.
Checks and Error Codes:
4111: No success message found.
4112: Qubit value is 0 or not present.
4113: Depth value is 0 or not present.
4114: Training matrix does not have the required dimensions.
4115: Activation matrix value is inconsistent or not present.
4116: Incorrect error code instead of 1060 or 1020.
Additional Steps:
Move train.json to test/var_arv and verify error code 1020.
Move data.json to test/var_arv and verify error code 1020.
2. Test Function: convert_input_data
Description:
Executes the convert_input_data method with various options ('empty' and 'named').
Checks the correct formatting of input_data.
Validates the number of elements per row and column according to depth and qubits.
Checks and Error Codes:
1044: Incorrect start of formatting.
Additional specific error codes depending on implementation (e.g., inconsistent data).
Validations:
Ensure that the first and second values in input_data are equal to 0.
Check the first three elements from the 0th column of the activation matrix and training matrix.
Validate the number of elements per row (depth).
Validate the number of columns (qubits).
Save the validated matrix in the logs.
3. Test Case: _is_matrix_consistent
Description:
Tests the private method _is_matrix_consistent, which checks the consistency of an activation matrix.
Test Cases:
Consistent Matrix:
Pass a correctly formatted matrix.
Expected return: True.
Inconsistent Matrix:
Pass a incorrectly formatted matrix (e.g., wrong number of rows, columns, or incorrect data types).
Expected return: False.
Checks and Error Messages:
4117: Consistent matrix should return True.
4118: Inconsistent matrix should return False.
4. Test Function: _is_empty_matrix
Description:
Tests the private method _is_empty_matrix, which checks if a matrix consists solely of zeros.
Test Cases:
Matrix of All Zeros:
Pass a matrix containing only zeros.
Expected return: True.
Matrix with Non-Zero Values:
Pass a matrix with at least one non-zero value.
Expected return: False.
Checks and Error Messages:
4119: Matrix of all zeros should return True.
4120: Matrix with non-zero values should return False.
5. Test Function: check_input_data
Description:
Tests the check_input_data method, which verifies the structure and consistency of input_data.
Extension of the Test Class
TestCircuit
The extended test class includes comprehensive tests for all methods of the
Circuit
class. Each test function is designed to validate the functionality of the respective method under various conditions, including the verification of success codes and error codes.1. Test Function:
read_data
Description:
read_data
method.qubits
anddepth
are correctly set and not null.activation_matrices
andtraining_matrices
.Checks and Error Codes:
1060
or1020
.Additional Steps:
train.json
totest/var_arv
and verify error code1020
.data.json
totest/var_arv
and verify error code1020
.2. Test Function:
convert_input_data
Description:
convert_input_data
method with various options ('empty'
and'named'
).input_data
.depth
andqubits
.Checks and Error Codes:
Validations:
input_data
are equal to 0.depth
).qubits
).3. Test Case:
_is_matrix_consistent
Description:
_is_matrix_consistent
, which checks the consistency of an activation matrix.Test Cases:
True
.False
.Checks and Error Messages:
True
.False
.4. Test Function:
_is_empty_matrix
Description:
_is_empty_matrix
, which checks if a matrix consists solely of zeros.Test Cases:
True
.False
.Checks and Error Messages:
True
.False
.5. Test Function:
check_input_data
Description:
check_input_data
method, which verifies the structure and consistency ofinput_data
.Test Cases:
input_data
:input_data
.True
.input_data
:input_data
(e.g., missing keys, incorrect types).False
.Checks and Error Messages:
input_data
should returnTrue
.input_data
should returnFalse
.6. Test Function:
create_L_gate
Description:
create_L_gate
method, which creates parameters for a single L-Gate.Test Cases:
entry
).2060
to2065
.1050
to1055
) and an error message.Checks and Error Messages:
7. Test Function:
create_initial_circuit
Description:
create_initial_circuit
method, which creates the initial circuit.Test Cases:
matrix_name
.2066
.matrix_name
or faulty data.1066
to1071
).Checks and Error Messages:
2066
.8. Test Function:
check_circuit
Description:
check_circuit
method, which verifies the parameters of the entire circuit.Test Cases:
True
.False
and corresponding error codes (1072
to1074
).Checks and Error Messages:
True
.9. Test Function:
measure
Description:
measure
method, which performs measurements on the circuit.Test Cases:
shots
value (positive integer).2067
.shots
value (e.g., negative number, non-integer).1075
to1076
).Checks and Error Messages:
2067
.Summary of Test Functions and Codes
Method Overview
__init__
Circuit
class.read_data
convert_input_data
_is_matrix_consistent
_is_empty_matrix
check_input_data
input_data
.create_L_gate
create_initial_circuit
check_circuit
measure
Success and Error Codes
Success Codes
Error Codes
activation_matrices
ortraining_matrices
.input_data
(end of data structure).input_data
.shots
(must be positive).1060
or1020
.True
.False
.True
.False
.input_data
should returnTrue
.input_data
should returnFalse
.2066
.True
.2067
.Additional Notes on Test Implementation
data.json
andtrain.json
) are present in the test directory (test/var
).test/var_arv
) to back up and restore original files.Circuit
class change or new error codes are introduced.