diff --git a/.ado/ci.yml b/.ado/ci.yml index b8c9cc7..5da327a 100644 --- a/.ado/ci.yml +++ b/.ado/ci.yml @@ -12,6 +12,10 @@ strategy: python.version: '3.8' Python39: python.version: '3.9' + Python310: + python.version: '3.10' + Python311: + python.version: '3.11' steps: - task: UsePythonVersion@0 @@ -20,10 +24,20 @@ steps: displayName: 'Use Python $(python.version)' - script: | - python -m pip install wheel --upgrade pip + python -m pip install --upgrade pip + python -m pip install -r requirements_dev.txt make dist - python -m pip install dist/*.whl displayName: 'Build package' +- script: | + python -m pip install dist/*.whl + displayName: 'Install package' +- script: | + pytest + displayName: 'Test package' +- publish: dist + artifact: Wheels + displayName: Upload Python Artifacts + condition: eq(variables['python.version'], '3.8') - task: ms.vss-governance-buildtask.governance-build-task-component-detection.ComponentGovernanceComponentDetection@0 displayName: 'Component Detection' diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index de78836..63a6471 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ['3.7', '3.8', '3.9'] + python-version: ['3.8', '3.9', '3.10', '3.11'] steps: - uses: actions/checkout@v1 @@ -21,12 +21,11 @@ jobs: python-version: ${{ matrix.python-version }} - name: Build package run: | + python -m pip install --upgrade pip python -m pip install -r requirements_dev.txt make dist - name: Install dependencies run: | - python -m pip install --upgrade pip python -m pip install dist/*.whl - python -m pip install pytest - name: Run tests run: pytest diff --git a/requirements_dev.txt b/requirements_dev.txt index 213315f..27b20ac 100644 --- a/requirements_dev.txt +++ b/requirements_dev.txt @@ -1,10 +1,11 @@ -wheel>=0.38.1 -watchdog==0.9.0 -flake8==3.7.8 -tox==3.14.0 -coverage==4.5.4 +wheel>=0.41 +watchdog==3.0.0 +flake8==6.1.0 +tox==4.11.3 +coverage==7.3.2 Sphinx==1.8.5 -twine==1.14.0 -pytest==6.2.4 -black==21.7b0 -pyqir==0.8.0 +twine==4.0.2 +pytest==7.4.3 +black==23.11.0 +pyqir==0.10.0 +qiskit-terra>=0.19.2,<1.0 \ No newline at end of file diff --git a/setup.cfg b/setup.cfg index d91de58..32a3592 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = qiskit-qir -version = 0.3.2 +version = 0.4.0 author = Microsoft author_email = que-contacts@microsoft.com description = Qiskit to QIR translator @@ -15,11 +15,11 @@ classifiers = License :: OSI Approved :: MIT License Natural Language :: English Programming Language :: Python :: 3 - Programming Language :: Python :: 3.7 Programming Language :: Python :: 3.8 Programming Language :: Python :: 3.9 Programming Language :: Python :: 3.10 Programming Language :: Python :: 3.11 + Programming Language :: Python :: 3.12 Operating System :: Microsoft Operating System :: MacOS Operating System :: Unix @@ -28,11 +28,11 @@ classifiers = package_dir = = src packages = find: -python_requires = >=3.7 +python_requires = >=3.8 install_requires = - qiskit >= 0.34.2 - qiskit-terra >= 0.19.2 - pyqir == 0.8.0 + qiskit>=0.34.2,<1.0 + qiskit-terra>=0.19.2,<1.0 + pyqir>=0.10.0,<0.11.0 [options.extras_require] test = pytest diff --git a/src/qiskit_qir/__init__.py b/src/qiskit_qir/__init__.py index 1582402..f30143d 100644 --- a/src/qiskit_qir/__init__.py +++ b/src/qiskit_qir/__init__.py @@ -4,6 +4,6 @@ ## __author__ = """Microsoft Corporation""" __email__ = "que-contacts@microsoft.com" -__version__ = "0.3.2" +__version__ = "0.4.0" from qiskit_qir.translate import to_qir_module diff --git a/src/qiskit_qir/visitor.py b/src/qiskit_qir/visitor.py index cfcabbb..796f9bf 100644 --- a/src/qiskit_qir/visitor.py +++ b/src/qiskit_qir/visitor.py @@ -197,7 +197,7 @@ def process_composite_instruction( f"Composite instruction {instruction.name} called with the wrong number of classical bits; \ {subcircuit.num_clbits} expected, {len(cargs)} provided" ) - for (inst, i_qargs, i_cargs) in subcircuit.data: + for inst, i_qargs, i_cargs in subcircuit.data: mapped_qbits = [qargs[subcircuit.qubits.index(i)] for i in i_qargs] mapped_clbits = [cargs[subcircuit.clbits.index(i)] for i in i_cargs] _log.debug( diff --git a/tests/resources/test_single_clbit_variations_falsy.ll b/tests/resources/test_single_clbit_variations_falsy.ll index 61e217a..7800a8a 100644 --- a/tests/resources/test_single_clbit_variations_falsy.ll +++ b/tests/resources/test_single_clbit_variations_falsy.ll @@ -28,7 +28,7 @@ declare void @__quantum__qis__mz__body(%Qubit*, %Result* writeonly) #1 declare i1 @__quantum__qis__read_result__body(%Result*) -attributes #0 = { "entry_point" "num_required_qubits"="2" "num_required_results"="2" "output_labeling_schema" "qir_profiles"="custom" } +attributes #0 = { "entry_point" "output_labeling_schema" "qir_profiles"="custom" "required_num_qubits"="2" "required_num_results"="2" } attributes #1 = { "irreversible" } !llvm.module.flags = !{!0, !1, !2, !3} diff --git a/tests/resources/test_single_clbit_variations_truthy.ll b/tests/resources/test_single_clbit_variations_truthy.ll index 31649a7..4dd0cd6 100644 --- a/tests/resources/test_single_clbit_variations_truthy.ll +++ b/tests/resources/test_single_clbit_variations_truthy.ll @@ -28,7 +28,7 @@ declare void @__quantum__qis__mz__body(%Qubit*, %Result* writeonly) #1 declare i1 @__quantum__qis__read_result__body(%Result*) -attributes #0 = { "entry_point" "num_required_qubits"="2" "num_required_results"="2" "output_labeling_schema" "qir_profiles"="custom" } +attributes #0 = { "entry_point" "output_labeling_schema" "qir_profiles"="custom" "required_num_qubits"="2" "required_num_results"="2" } attributes #1 = { "irreversible" } !llvm.module.flags = !{!0, !1, !2, !3} diff --git a/tests/resources/test_single_register_index_variations_falsy.ll b/tests/resources/test_single_register_index_variations_falsy.ll index 71c9547..a99993d 100644 --- a/tests/resources/test_single_register_index_variations_falsy.ll +++ b/tests/resources/test_single_register_index_variations_falsy.ll @@ -28,7 +28,7 @@ declare void @__quantum__qis__mz__body(%Qubit*, %Result* writeonly) #1 declare i1 @__quantum__qis__read_result__body(%Result*) -attributes #0 = { "entry_point" "num_required_qubits"="2" "num_required_results"="2" "output_labeling_schema" "qir_profiles"="custom" } +attributes #0 = { "entry_point" "output_labeling_schema" "qir_profiles"="custom" "required_num_qubits"="2" "required_num_results"="2" } attributes #1 = { "irreversible" } !llvm.module.flags = !{!0, !1, !2, !3} diff --git a/tests/resources/test_single_register_index_variations_truthy.ll b/tests/resources/test_single_register_index_variations_truthy.ll index b147df8..2c2a28e 100644 --- a/tests/resources/test_single_register_index_variations_truthy.ll +++ b/tests/resources/test_single_register_index_variations_truthy.ll @@ -28,7 +28,7 @@ declare void @__quantum__qis__mz__body(%Qubit*, %Result* writeonly) #1 declare i1 @__quantum__qis__read_result__body(%Result*) -attributes #0 = { "entry_point" "num_required_qubits"="2" "num_required_results"="2" "output_labeling_schema" "qir_profiles"="custom" } +attributes #0 = { "entry_point" "output_labeling_schema" "qir_profiles"="custom" "required_num_qubits"="2" "required_num_results"="2" } attributes #1 = { "irreversible" } !llvm.module.flags = !{!0, !1, !2, !3} diff --git a/tests/resources/test_single_register_variations_falsy.ll b/tests/resources/test_single_register_variations_falsy.ll index f8d3173..0f2f4fc 100644 --- a/tests/resources/test_single_register_variations_falsy.ll +++ b/tests/resources/test_single_register_variations_falsy.ll @@ -38,7 +38,7 @@ declare void @__quantum__qis__mz__body(%Qubit*, %Result* writeonly) #1 declare i1 @__quantum__qis__read_result__body(%Result*) -attributes #0 = { "entry_point" "num_required_qubits"="2" "num_required_results"="2" "output_labeling_schema" "qir_profiles"="custom" } +attributes #0 = { "entry_point" "output_labeling_schema" "qir_profiles"="custom" "required_num_qubits"="2" "required_num_results"="2" } attributes #1 = { "irreversible" } !llvm.module.flags = !{!0, !1, !2, !3} diff --git a/tests/resources/test_single_register_variations_truthy.ll b/tests/resources/test_single_register_variations_truthy.ll index e803079..4f0d37b 100644 --- a/tests/resources/test_single_register_variations_truthy.ll +++ b/tests/resources/test_single_register_variations_truthy.ll @@ -38,7 +38,7 @@ declare void @__quantum__qis__mz__body(%Qubit*, %Result* writeonly) #1 declare i1 @__quantum__qis__read_result__body(%Result*) -attributes #0 = { "entry_point" "num_required_qubits"="2" "num_required_results"="2" "output_labeling_schema" "qir_profiles"="custom" } +attributes #0 = { "entry_point" "output_labeling_schema" "qir_profiles"="custom" "required_num_qubits"="2" "required_num_results"="2" } attributes #1 = { "irreversible" } !llvm.module.flags = !{!0, !1, !2, !3} diff --git a/tests/resources/test_two_bit_register_variations_falsy.ll b/tests/resources/test_two_bit_register_variations_falsy.ll index 7c9aefe..e4f7ad3 100644 --- a/tests/resources/test_two_bit_register_variations_falsy.ll +++ b/tests/resources/test_two_bit_register_variations_falsy.ll @@ -39,7 +39,7 @@ declare void @__quantum__qis__mz__body(%Qubit*, %Result* writeonly) #1 declare i1 @__quantum__qis__read_result__body(%Result*) -attributes #0 = { "entry_point" "num_required_qubits"="3" "num_required_results"="3" "output_labeling_schema" "qir_profiles"="custom" } +attributes #0 = { "entry_point" "output_labeling_schema" "qir_profiles"="custom" "required_num_qubits"="3" "required_num_results"="3" } attributes #1 = { "irreversible" } !llvm.module.flags = !{!0, !1, !2, !3} diff --git a/tests/resources/test_two_bit_register_variations_three.ll b/tests/resources/test_two_bit_register_variations_three.ll index 62043b0..7addc29 100644 --- a/tests/resources/test_two_bit_register_variations_three.ll +++ b/tests/resources/test_two_bit_register_variations_three.ll @@ -39,7 +39,7 @@ declare void @__quantum__qis__mz__body(%Qubit*, %Result* writeonly) #1 declare i1 @__quantum__qis__read_result__body(%Result*) -attributes #0 = { "entry_point" "num_required_qubits"="3" "num_required_results"="3" "output_labeling_schema" "qir_profiles"="custom" } +attributes #0 = { "entry_point" "output_labeling_schema" "qir_profiles"="custom" "required_num_qubits"="3" "required_num_results"="3" } attributes #1 = { "irreversible" } !llvm.module.flags = !{!0, !1, !2, !3} diff --git a/tests/resources/test_two_bit_register_variations_truthy.ll b/tests/resources/test_two_bit_register_variations_truthy.ll index 93d879a..ac6a76a 100644 --- a/tests/resources/test_two_bit_register_variations_truthy.ll +++ b/tests/resources/test_two_bit_register_variations_truthy.ll @@ -39,7 +39,7 @@ declare void @__quantum__qis__mz__body(%Qubit*, %Result* writeonly) #1 declare i1 @__quantum__qis__read_result__body(%Result*) -attributes #0 = { "entry_point" "num_required_qubits"="3" "num_required_results"="3" "output_labeling_schema" "qir_profiles"="custom" } +attributes #0 = { "entry_point" "output_labeling_schema" "qir_profiles"="custom" "required_num_qubits"="3" "required_num_results"="3" } attributes #1 = { "irreversible" } !llvm.module.flags = !{!0, !1, !2, !3} diff --git a/tests/resources/test_two_bit_register_variations_two.ll b/tests/resources/test_two_bit_register_variations_two.ll index 262fa79..4f61ad8 100644 --- a/tests/resources/test_two_bit_register_variations_two.ll +++ b/tests/resources/test_two_bit_register_variations_two.ll @@ -39,7 +39,7 @@ declare void @__quantum__qis__mz__body(%Qubit*, %Result* writeonly) #1 declare i1 @__quantum__qis__read_result__body(%Result*) -attributes #0 = { "entry_point" "num_required_qubits"="3" "num_required_results"="3" "output_labeling_schema" "qir_profiles"="custom" } +attributes #0 = { "entry_point" "output_labeling_schema" "qir_profiles"="custom" "required_num_qubits"="3" "required_num_results"="3" } attributes #1 = { "irreversible" } !llvm.module.flags = !{!0, !1, !2, !3} diff --git a/tests/test_batching.py b/tests/test_batching.py index d2462da..247f0c9 100644 --- a/tests/test_batching.py +++ b/tests/test_batching.py @@ -32,7 +32,8 @@ def get_parameterized_circuit(num_qubits: int, num_params: int) -> List[QuantumC circuit.measure(0, 0) circuits = [ - circuit.bind_parameters({theta: theta_val}) for theta_val in theta_range + circuit.assign_parameters({theta: theta_val}, inplace=False) + for theta_val in theta_range ] return circuits diff --git a/tests/test_circuits/__init__.py b/tests/test_circuits/__init__.py index e9c91f8..1f29f32 100644 --- a/tests/test_circuits/__init__.py +++ b/tests/test_circuits/__init__.py @@ -12,7 +12,7 @@ "teleport", "unroll", "teleport_with_subroutine", - "measure_x_as_subroutine" + "measure_x_as_subroutine", ] + random_fixtures noop_tests = ["bernstein_vazirani_with_delay", "ghz_with_delay"] diff --git a/tests/test_circuits/basic_circuits.py b/tests/test_circuits/basic_circuits.py index 1ec0107..da1a447 100644 --- a/tests/test_circuits/basic_circuits.py +++ b/tests/test_circuits/basic_circuits.py @@ -86,7 +86,7 @@ def bernstein_vazirani_with_delay(): oracle = oracle[::-1] for index in range(num_qubits): if oracle[index] == "0": - circuit.i(index) + circuit.id(index) else: circuit.cx(index, num_qubits) @@ -118,9 +118,10 @@ def ghz_with_delay(): return circuit + @pytest.fixture() def measure_x_as_subroutine(): - measure_x_circuit = QuantumCircuit(1, 1, name='measure_x') + measure_x_circuit = QuantumCircuit(1, 1, name="measure_x") measure_x_circuit.h(0) measure_x_circuit.measure(0, 0) measure_x_circuit.h(0) diff --git a/tests/test_circuits/control_flow_circuits.py b/tests/test_circuits/control_flow_circuits.py index 91f8f37..17c796a 100644 --- a/tests/test_circuits/control_flow_circuits.py +++ b/tests/test_circuits/control_flow_circuits.py @@ -22,9 +22,9 @@ def for_loop(): circuit = QuantumCircuit(4, 0) circuit.name = "Simple for-loop circuit" circuit.h(3) - with circuit.for_loop(range(3)) as q: + with circuit.for_loop(range(3)): # Qiskit doesn't (yet) support cnot(3, i) - circuit.cnot(3, 0) + circuit.cx(3, 0) return circuit diff --git a/tox.ini b/tox.ini index 71e8252..3c3ac0c 100644 --- a/tox.ini +++ b/tox.ini @@ -1,16 +1,18 @@ [tox] -envlist = py37, py38, py39, flake8 +envlist = py38, py39, py310, py311, py312, black [travis] python = + 3.12: py312 + 3.11: py311 + 3.10: py310 3.9: py39 3.8: py38 - 3.7: py37 -[testenv:flake8] +[testenv:black] basepython = python -deps = flake8 -commands = flake8 src tests +deps = black +commands = black --check src tests [testenv] setenv =