Skip to content

Commit

Permalink
optimization_level=0 without coupling map (#2460) (#2509)
Browse files Browse the repository at this point in the history
* optimization_level=0 without coupling map

* lean fix

* add test

* style
  • Loading branch information
ajavadia authored and kdk committed May 29, 2019
1 parent fe92cb1 commit a4bb608
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
1 change: 0 additions & 1 deletion qiskit/transpiler/preset_passmanagers/level0.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,5 @@ def _direction_condition(property_set):
# pm0.append(_direction_check) # TODO
pm0.append(_direction, condition=_direction_condition)
pm0.append(_reset)
pm0.append(_direction)

return pm0
34 changes: 34 additions & 0 deletions test/python/transpiler/test_preset_passmanagers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# -*- coding: utf-8 -*-

# This code is part of Qiskit.
#
# (C) Copyright IBM 2017, 2019.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative works of this code must retain this
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.

"""Tests preset pass manager functionalities"""

from qiskit.test import QiskitTestCase
from qiskit.compiler import transpile
from qiskit import QuantumCircuit, QuantumRegister


class TestPresetPassManager(QiskitTestCase):
"""Test preset passmanagers work as expected."""

def test_no_coupling_map(self):
"""Test that coupling_map can be None"""
q = QuantumRegister(2, name='q')
test = QuantumCircuit(q)
test.cz(q[0], q[1])
for level in [0, 1, 2, 3]:
with self.subTest(level=level):
test2 = transpile(test, basis_gates=['u1', 'u2', 'u3', 'cx'],
optimization_level=level)
self.assertIsInstance(test2, QuantumCircuit)

0 comments on commit a4bb608

Please sign in to comment.