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

Refactor ghz_Circuits Error Handling and Update Random Generator in mirror_circuits #2529

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ANUKOOL324
Copy link

@ANUKOOL324 ANUKOOL324 commented Oct 5, 2024

Update GHZ Circuit Preparation and Mirror Circuit Random Generator

Changes:

  1. Modified GHZ Circuits (mitiq/benchmarks/ghz_circuits.py)

    • Old Code:
      raise ValueError("Cannot prepare a GHZ circuit with {} qubits" , n_qubits)
    • New Code:
      raise ValueError(f"Cannot prepare a GHZ circuit with {n_qubits} qubits")
    • Description: Updated the error message to use f-string formatting for better clarity and consistency.
  2. Modified Mirror Circuits (mitiq/benchmarks/mirror_circuits.py)

    • Old Code:
      random_state = random.RandomState(seed)
    • New Code:
      random_state = random.default_rng(seed)
    • Description: Replaced RandomState with default_rng() to utilize the modern NumPy random number generator, improving randomness quality and performance.

Summary:

  • Enhanced error messaging in GHZ circuit preparation.
  • Updated the random generator method in mirror circuits for better randomness and performance.

1. **Modified GHZ Circuits** (`mitiq/benchmarks/ghz_circuits.py`)
   - **Old Code**:
     ```python
     raise ValueError("Cannot prepare a GHZ circuit with {} qubits", n_qubits)
     ```
   - **New Code**:
     ```python
     raise ValueError(f"Cannot prepare a GHZ circuit with {n_qubits} qubits")
     ```
   - **Description**: Updated the error message to use f-string formatting for better clarity and consistency.

2. **Modified Mirror Circuits** (`mitiq/benchmarks/mirror_circuits.py`)
   - **Old Code**:
     ```python
     random_state = random.RandomState(seed)
     ```
   - **New Code**:
     ```python
     random_state = random.default_rng(seed)
     ```
   - **Description**: Replaced `RandomState` with `default_rng()` to utilize the modern NumPy random number generator, improving randomness quality and performance.

- Enhanced error messaging in GHZ circuit preparation.
- Updated the random generator method in mirror circuits for better randomness and performance.
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @ANUKOOL324, thank you for submitting a PR to Mitiq! We will respond as soon as possible, and if you have any questions in the meantime, you can ask us on the Unitary Fund Discord.

@ANUKOOL324
Copy link
Author

Hey @cosenal @natestemen ...assist me here ! i am failing test here ! help me ! i am interested in this project ! i doing this under the Hactoberfest 2024 !! please read my PR !
suggest me some changes here !!

- Updated random number generation to use `numpy.random.default_rng()` for improved performance and reproducibility.
- Fixed typos in comments and variable names for better readability and clarity.
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.

1 participant