Skip to content

Commit

Permalink
formatting updates
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanhill1 committed Sep 27, 2024
1 parent b4f7118 commit d661a71
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 15 deletions.
10 changes: 7 additions & 3 deletions qbraid_qir/qasm3/analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@
#
# THERE IS NO WARRANTY for the qBraid-SDK, as per Section 15 of the GPL v3.

# pylint: disable=import-outside-toplevel,cyclic-import

"""
Module with analysis functions for QASM3 visitor
"""
# pylint: disable=cyclic-import, import-outside-toplevel
from __future__ import annotations

from typing import Any, Optional, Union
from typing import TYPE_CHECKING, Any, Optional, Union

import numpy as np
from openqasm3.ast import (
Expand All @@ -29,9 +31,11 @@
UnaryExpression,
)

from .elements import Variable
from .exceptions import Qasm3ConversionError, raise_qasm3_error

if TYPE_CHECKING:
from qbraid_qir.qasm3.elements import Variable


class Qasm3Analyzer:
"""Class with utility functions for analyzing QASM3 elements"""
Expand Down
11 changes: 7 additions & 4 deletions qbraid_qir/qasm3/elements.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#
# THERE IS NO WARRANTY for the qBraid-SDK, as per Section 15 of the GPL v3.

# pylint: disable=too-many-arguments,too-many-positional-arguments

"""
Module defining Qasm3 Converter elements.
Expand All @@ -16,7 +18,7 @@
import uuid
from abc import ABCMeta, abstractmethod
from enum import Enum
from typing import Optional, Union
from typing import Any, Optional, Union

import numpy as np
from openqasm3.ast import BitType, ClassicalDeclaration, Program, QubitDeclaration, Statement
Expand Down Expand Up @@ -65,11 +67,10 @@ class Variable:
"""

# pylint: disable-next=too-many-arguments
def __init__(
self,
name: str,
base_type,
base_type: Any,
base_size: int,
dims: Optional[list[int]] = None,
value: Optional[Union[int, float, np.ndarray]] = None,
Expand All @@ -86,6 +87,7 @@ def __init__(


class _ProgramElement(metaclass=ABCMeta):

@classmethod
def from_element_list(cls, elements):
return [cls(elem) for elem in elements]
Expand All @@ -96,6 +98,7 @@ def accept(self, visitor):


class _Register(_ProgramElement):

def __init__(self, register: Union[QubitDeclaration, ClassicalDeclaration]):
self._register: Union[QubitDeclaration, ClassicalDeclaration] = register

Expand All @@ -107,6 +110,7 @@ def __str__(self) -> str:


class _Statement(_ProgramElement):

def __init__(self, statement: Statement):
self._statement = statement

Expand All @@ -129,7 +133,6 @@ class Qasm3Module:
elements (list[Statement]): list of openqasm3 Statements.
"""

# pylint: disable-next=too-many-arguments
def __init__(
self,
name: str,
Expand Down
5 changes: 2 additions & 3 deletions qbraid_qir/qasm3/maps.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
Module mapping supported QASM gates/operations to pyqir functions.
"""


from typing import Callable, Union

import numpy as np
Expand Down Expand Up @@ -389,7 +387,8 @@ def gpi2_gate(builder, phi, qubit):
u3_gate(builder, theta_0, phi_0, lambda_0, qubit)


def ms_gate(builder, phi0, phi1, theta, qubit0, qubit1): # pylint: disable=too-many-arguments
# pylint: disable-next=too-many-arguments,too-many-positional-arguments
def ms_gate(builder, phi0, phi1, theta, qubit0, qubit1):
"""
Implements the Molmer Sorenson gate as a decomposition of other gates.
"""
Expand Down
4 changes: 2 additions & 2 deletions qbraid_qir/qasm3/subroutines.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#
# THERE IS NO WARRANTY for the qBraid-SDK, as per Section 15 of the GPL v3.

# pylint: disable=too-many-arguments,too-many-positional-arguments,too-many-locals,too-many-branches

"""
Module containing the class for validating QASM3 subroutines.
Expand All @@ -30,8 +32,6 @@
from .transformer import Qasm3Transformer
from .validator import Qasm3Validator

# pylint: disable=too-many-arguments, too-many-locals, too-many-branches


class Qasm3SubroutineProcessor:
"""Class for processing QASM3 subroutines."""
Expand Down
4 changes: 2 additions & 2 deletions qbraid_qir/qasm3/visitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
#
# THERE IS NO WARRANTY for the qBraid-SDK, as per Section 15 of the GPL v3.

# pylint: disable=too-many-instance-attributes,too-many-lines,too-many-branches

"""
Module defining Qasm3 Visitor.
"""
import copy
import logging
from abc import ABCMeta, abstractmethod

# pylint: disable=too-many-instance-attributes,too-many-lines,too-many-branches
from collections import deque
from typing import Any, Optional, Union

Expand Down
2 changes: 1 addition & 1 deletion tests/qasm3_qir/test_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

import pytest

from qbraid_qir.qasm3.checker import validate_qasm, QasmValidationError
from qbraid_qir.qasm3.checker import QasmValidationError, validate_qasm


def test_correct_check():
Expand Down

0 comments on commit d661a71

Please sign in to comment.