Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data class update #32

Merged
merged 1 commit into from
Nov 6, 2024
Merged

Data class update #32

merged 1 commit into from
Nov 6, 2024

Conversation

clausia
Copy link
Contributor

@clausia clausia commented Nov 6, 2024

Update Data Class as specified in Issue #27

This PR refactors the Data class to align with the specifications outlined in the corresponded issue. The following modifications have been made:

Main Changes:

  • Attributes:

    • qubits, depth, and activation_matrices now store and manage the circuit's parameters and activation matrices as described.
    • The class now loads and processes matrices directly from data.json and supports the storage of converted matrices.
  • Methods:

    • get_data(): Loads qubits, depth, and activation_matrices from data.json. Returns error codes if data.json or train.json are missing.
    • return_matrices(): Validates and returns activation matrices with the expected properties; returns an error code if validation fails.
    • convert_matrices(): Converts each activation matrix by combining values from three pages into a flattened format, following the required structure.
    • check_final_matrix(): Checks matrix dimensions to ensure they match the required (qubits, depth * 3) format.
    • create_training_matrix(): Generates a training matrix with randomized values, validates dimensions, and saves it to train.json.

Additional Changes:

  • Created comprehensive unit tests for each method using pytest to ensure functionality and handle edge cases:
    • Tests verify error handling, matrix conversion, dimension validation, and file operations.
    • Includes checks for missing files, correct and incorrect dimensions, and successful data loading and storage.

Fixes #27

@xleonplayz xleonplayz merged commit 437a619 into LILY-QML:main Nov 6, 2024
0 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Class Description: Data
2 participants